-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Lane's with custom tx adapters (#239)
* greedy approach to lane verification * docs * base lane testing * mev lane testing nits * abci top level testing done * network spamming in E2E * string rep of escrow address * nit * nit * nit v1.0.1 * removing logs from testing * query test * logging with tx info * nits * nit * nit * testing nit --------- Co-authored-by: Alex Johnson <[email protected]>
- Loading branch information
1 parent
01a84b1
commit be4465a
Showing
19 changed files
with
444 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package base | ||
|
||
import ( | ||
"encoding/hex" | ||
"fmt" | ||
"strings" | ||
|
||
comettypes "github.com/cometbft/cometbft/types" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/skip-mev/block-sdk/block/utils" | ||
) | ||
|
||
// GetTxInfo returns various information about the transaction that | ||
// belongs to the lane including its priority, signer's, sequence number, | ||
// size and more. | ||
func (l *BaseLane) GetTxInfo(ctx sdk.Context, tx sdk.Tx) (utils.TxWithInfo, error) { | ||
txBytes, err := l.cfg.TxEncoder(tx) | ||
if err != nil { | ||
return utils.TxWithInfo{}, fmt.Errorf("failed to encode transaction: %w", err) | ||
} | ||
|
||
// TODO: Add an adapter to lanes so that this can be flexible to support EVM, etc. | ||
gasTx, ok := tx.(sdk.FeeTx) | ||
if !ok { | ||
return utils.TxWithInfo{}, fmt.Errorf("failed to cast transaction to gas tx") | ||
} | ||
|
||
signers, err := l.cfg.SignerExtractor.GetSigners(tx) | ||
if err != nil { | ||
return utils.TxWithInfo{}, err | ||
} | ||
|
||
return utils.TxWithInfo{ | ||
Hash: strings.ToUpper(hex.EncodeToString(comettypes.Tx(txBytes).Hash())), | ||
Size: int64(len(txBytes)), | ||
GasLimit: gasTx.GetGas(), | ||
TxBytes: txBytes, | ||
Priority: l.LaneMempool.Priority(ctx, tx), | ||
Signers: signers, | ||
}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.