diff --git a/Makefile b/Makefile index 38467ce5..0a944f3b 100644 --- a/Makefile +++ b/Makefile @@ -189,7 +189,12 @@ integration-test-all: init-test-framework \ devnet-up: init-devnet @echo "Fairyring Devnet is now running in the background, run 'make devnet-down' to stop devnet." -devnet-down: clean-devnet-data +devnet-down: + @echo "Killing fairyringd, fairyport, fairyringclient, ShareGenerationClient and removing previous data" + -@killall fairyringd 2>/dev/null + -@killall fairyport 2>/dev/null + -@killall fairyringclient 2>/dev/null + -@killall ShareGenerationClient 2>/dev/null test-tx-limit: @echo "Testing Block tx limit..." diff --git a/app/ante.go b/app/ante.go index 0c2a96fc..8593fc8d 100644 --- a/app/ante.go +++ b/app/ante.go @@ -1,8 +1,6 @@ package app import ( - "errors" - corestoretypes "cosmossdk.io/core/store" circuitante "cosmossdk.io/x/circuit/ante" wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" @@ -13,17 +11,20 @@ import ( "github.com/cosmos/cosmos-sdk/x/auth/ante" ibcante "github.com/cosmos/ibc-go/v8/modules/core/ante" ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper" - "github.com/skip-mev/block-sdk/v2/block" ) type FairyringHandlerOptions struct { - BaseOptions ante.HandlerOptions - wasmConfig wasmtypes.WasmConfig - KeyShareLane pepante.KeyShareLane - FreeLane block.Lane - TxDecoder sdk.TxDecoder - TxEncoder sdk.TxEncoder - PepKeeper pepkeeper.Keeper + // FreeLane block.Lane + BaseOptions ante.HandlerOptions + KeyShareLane pepante.KeyShareLane + TxDecoder sdk.TxDecoder + TxEncoder sdk.TxEncoder + PepKeeper pepkeeper.Keeper + IBCKeeper *ibckeeper.Keeper + WasmConfig *wasmtypes.WasmConfig + WasmKeeper *wasmkeeper.Keeper + TXCounterStoreService corestoretypes.KVStoreService + CircuitKeeper circuitante.CircuitBreaker } // NewFairyringAnteHandler wraps all of the default Cosmos SDK AnteDecorators with the Fairyring AnteHandler. @@ -44,85 +45,96 @@ func NewFairyringAnteHandler(options FairyringHandlerOptions) sdk.AnteHandler { panic("fee grant keeper is required for ante builder") } + if options.WasmConfig == nil { + panic("wasm config is required for ante builder") + } + if options.TXCounterStoreService == nil { + panic("wasm store service is required for ante builder") + } + if options.CircuitKeeper == nil { + panic("circuit keeper is required for ante builder") + } + anteDecorators := []sdk.AnteDecorator{ ante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first - wasmkeeper.NewLimitSimulationGasDecorator(options.wasmConfig.SimulationGasLimit), + wasmkeeper.NewLimitSimulationGasDecorator(options.WasmConfig.SimulationGasLimit), + wasmkeeper.NewCountTXDecorator(options.TXCounterStoreService), + wasmkeeper.NewGasRegisterDecorator(options.WasmKeeper.GetGasRegister()), + circuitante.NewCircuitBreakerDecorator(options.CircuitKeeper), ante.NewExtensionOptionsDecorator(options.BaseOptions.ExtensionOptionChecker), ante.NewValidateBasicDecorator(), ante.NewTxTimeoutHeightDecorator(), ante.NewValidateMemoDecorator(options.BaseOptions.AccountKeeper), ante.NewConsumeGasForTxSizeDecorator(options.BaseOptions.AccountKeeper), - block.NewIgnoreDecorator( - ante.NewDeductFeeDecorator( - options.BaseOptions.AccountKeeper, - options.BaseOptions.BankKeeper, - options.BaseOptions.FeegrantKeeper, - options.BaseOptions.TxFeeChecker, - ), - options.FreeLane, + ante.NewDeductFeeDecorator( + options.BaseOptions.AccountKeeper, + options.BaseOptions.BankKeeper, + options.BaseOptions.FeegrantKeeper, + options.BaseOptions.TxFeeChecker, ), ante.NewSetPubKeyDecorator(options.BaseOptions.AccountKeeper), // SetPubKeyDecorator must be called before all signature verification decorators ante.NewValidateSigCountDecorator(options.BaseOptions.AccountKeeper), ante.NewSigGasConsumeDecorator(options.BaseOptions.AccountKeeper, options.BaseOptions.SigGasConsumer), ante.NewSigVerificationDecorator(options.BaseOptions.AccountKeeper, options.BaseOptions.SignModeHandler), ante.NewIncrementSequenceDecorator(options.BaseOptions.AccountKeeper), - pepante.NewPepDecorator(options.PepKeeper, options.TxEncoder, options.KeyShareLane), + ibcante.NewRedundantRelayDecorator(options.IBCKeeper), + // pepante.NewPepDecorator(options.PepKeeper, options.TxEncoder, options.KeyShareLane), } return sdk.ChainAnteDecorators(anteDecorators...) } -// HandlerOptions extend the SDK's AnteHandler options by requiring the IBC -// channel keeper. -type HandlerOptions struct { - ante.HandlerOptions +// // HandlerOptions extend the SDK's AnteHandler options by requiring the IBC +// // channel keeper. +// type HandlerOptions struct { +// ante.HandlerOptions - IBCKeeper *ibckeeper.Keeper - WasmConfig *wasmtypes.WasmConfig - WasmKeeper *wasmkeeper.Keeper - TXCounterStoreService corestoretypes.KVStoreService - CircuitKeeper circuitante.CircuitBreaker -} +// IBCKeeper *ibckeeper.Keeper +// WasmConfig *wasmtypes.WasmConfig +// WasmKeeper *wasmkeeper.Keeper +// TXCounterStoreService corestoretypes.KVStoreService +// CircuitKeeper circuitante.CircuitBreaker +// } -func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) { - if options.AccountKeeper == nil { - return nil, errors.New("account keeper is required for ante builder") - } - if options.BankKeeper == nil { - return nil, errors.New("bank keeper is required for ante builder") - } - if options.SignModeHandler == nil { - return nil, errors.New("sign mode handler is required for ante builder") - } - if options.WasmConfig == nil { - return nil, errors.New("wasm config is required for ante builder") - } - if options.TXCounterStoreService == nil { - return nil, errors.New("wasm store service is required for ante builder") - } - if options.CircuitKeeper == nil { - return nil, errors.New("circuit keeper is required for ante builder") - } +// func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) { +// if options.AccountKeeper == nil { +// return nil, errors.New("account keeper is required for ante builder") +// } +// if options.BankKeeper == nil { +// return nil, errors.New("bank keeper is required for ante builder") +// } +// if options.SignModeHandler == nil { +// return nil, errors.New("sign mode handler is required for ante builder") +// } +// if options.WasmConfig == nil { +// return nil, errors.New("wasm config is required for ante builder") +// } +// if options.TXCounterStoreService == nil { +// return nil, errors.New("wasm store service is required for ante builder") +// } +// if options.CircuitKeeper == nil { +// return nil, errors.New("circuit keeper is required for ante builder") +// } - anteDecorators := []sdk.AnteDecorator{ - ante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first - wasmkeeper.NewLimitSimulationGasDecorator(options.WasmConfig.SimulationGasLimit), // after setup context to enforce limits early - wasmkeeper.NewCountTXDecorator(options.TXCounterStoreService), - wasmkeeper.NewGasRegisterDecorator(options.WasmKeeper.GetGasRegister()), - circuitante.NewCircuitBreakerDecorator(options.CircuitKeeper), - ante.NewExtensionOptionsDecorator(options.ExtensionOptionChecker), - ante.NewValidateBasicDecorator(), - ante.NewTxTimeoutHeightDecorator(), - ante.NewValidateMemoDecorator(options.AccountKeeper), - ante.NewConsumeGasForTxSizeDecorator(options.AccountKeeper), - ante.NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, options.TxFeeChecker), - ante.NewSetPubKeyDecorator(options.AccountKeeper), // SetPubKeyDecorator must be called before all signature verification decorators - ante.NewValidateSigCountDecorator(options.AccountKeeper), - ante.NewSigGasConsumeDecorator(options.AccountKeeper, options.SigGasConsumer), - ante.NewSigVerificationDecorator(options.AccountKeeper, options.SignModeHandler), - ante.NewIncrementSequenceDecorator(options.AccountKeeper), - ibcante.NewRedundantRelayDecorator(options.IBCKeeper), - } +// anteDecorators := []sdk.AnteDecorator{ +// ante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first +// wasmkeeper.NewLimitSimulationGasDecorator(options.WasmConfig.SimulationGasLimit), // after setup context to enforce limits early +// wasmkeeper.NewCountTXDecorator(options.TXCounterStoreService), +// wasmkeeper.NewGasRegisterDecorator(options.WasmKeeper.GetGasRegister()), +// circuitante.NewCircuitBreakerDecorator(options.CircuitKeeper), +// ante.NewExtensionOptionsDecorator(options.ExtensionOptionChecker), +// ante.NewValidateBasicDecorator(), +// ante.NewTxTimeoutHeightDecorator(), +// ante.NewValidateMemoDecorator(options.AccountKeeper), +// ante.NewConsumeGasForTxSizeDecorator(options.AccountKeeper), +// ante.NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, options.TxFeeChecker), +// ante.NewSetPubKeyDecorator(options.AccountKeeper), // SetPubKeyDecorator must be called before all signature verification decorators +// ante.NewValidateSigCountDecorator(options.AccountKeeper), +// ante.NewSigGasConsumeDecorator(options.AccountKeeper, options.SigGasConsumer), +// ante.NewSigVerificationDecorator(options.AccountKeeper, options.SignModeHandler), +// ante.NewIncrementSequenceDecorator(options.AccountKeeper), +// ibcante.NewRedundantRelayDecorator(options.IBCKeeper), +// } - return sdk.ChainAnteDecorators(anteDecorators...), nil -} +// return sdk.ChainAnteDecorators(anteDecorators...), nil +// } diff --git a/app/app.go b/app/app.go index c8291266..0f96a576 100644 --- a/app/app.go +++ b/app/app.go @@ -2,15 +2,16 @@ package app import ( "context" - circuittypes "cosmossdk.io/x/circuit/types" - "cosmossdk.io/x/nft" - upgradetypes "cosmossdk.io/x/upgrade/types" "fmt" - feetypes "github.com/cosmos/ibc-go/v8/modules/apps/29-fee/types" "io" "os" "path/filepath" + circuittypes "cosmossdk.io/x/circuit/types" + "cosmossdk.io/x/nft" + upgradetypes "cosmossdk.io/x/upgrade/types" + feetypes "github.com/cosmos/ibc-go/v8/modules/apps/29-fee/types" + _ "cosmossdk.io/api/cosmos/tx/config/v1" // import for side-effects "cosmossdk.io/depinject" "cosmossdk.io/log" @@ -27,6 +28,7 @@ import ( upgradekeeper "cosmossdk.io/x/upgrade/keeper" "github.com/CosmWasm/wasmd/x/wasm" wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" + wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" "github.com/Fairblock/fairyring/abci/checktx" tmproto "github.com/cometbft/cometbft/proto/tendermint/types" dbm "github.com/cosmos/cosmos-db" @@ -349,18 +351,23 @@ func New( app.App = appBuilder.Build(db, traceStore, baseAppOptions...) + // Register legacy modules + if err := app.registerIBCModules(appOpts); err != nil { + return nil, err + } + // ---------------------------------------------------------------------------- // // ------------------------- Begin Custom Code -------------------------------- // // ---------------------------------------------------------------------------- // // STEP 1-3: Create the Block SDK lanes. - keyshareLane, freeLane, defaultLane := CreateLanes(app) + keyshareLane, defaultLane := CreateLanes(app) // STEP 4: Construct a mempool based off the lanes. Note that the order of the lanes // matters. Blocks are constructed from the top lane to the bottom lane. The top lane // is the first lane in the array and the bottom lane is the last lane in the array. mempool, err := block.NewLanedMempool( app.Logger(), - []block.Lane{keyshareLane, freeLane, defaultLane}, + []block.Lane{keyshareLane, defaultLane}, ) if err != nil { panic(err) @@ -385,13 +392,16 @@ func New( SignModeHandler: app.txConfig.SignModeHandler(), } options := FairyringHandlerOptions{ - BaseOptions: handlerOptions, - wasmConfig: wasmConfig, - TxDecoder: app.txConfig.TxDecoder(), - TxEncoder: app.txConfig.TxEncoder(), - KeyShareLane: keyshareLane, - PepKeeper: app.PepKeeper, - FreeLane: freeLane, + BaseOptions: handlerOptions, + IBCKeeper: app.IBCKeeper, + WasmConfig: &wasmConfig, + WasmKeeper: &app.WasmKeeper, + TXCounterStoreService: runtime.NewKVStoreService(app.GetKey(wasmtypes.StoreKey)), + CircuitKeeper: &app.CircuitBreakerKeeper, + TxDecoder: app.txConfig.TxDecoder(), + TxEncoder: app.txConfig.TxEncoder(), + KeyShareLane: keyshareLane, + PepKeeper: app.PepKeeper, } anteHandler := NewFairyringAnteHandler(options) app.App.SetAnteHandler(anteHandler) @@ -403,12 +413,12 @@ func New( keyshareLane.WithOptions( opt..., ) - freeLane.WithOptions( - opt..., - ) - // defaultLane.WithOptions( + // freeLane.WithOptions( // opt..., // ) + defaultLane.WithOptions( + opt..., + ) // Step 6: Create the proposal handler and set it on the app. Now the application // will build and verify proposals using the Block SDK! @@ -441,11 +451,6 @@ func New( // ------------------------- End Custom Code ---------------------------------- // // ---------------------------------------------------------------------------- // - // Register legacy modules - if err := app.registerIBCModules(appOpts); err != nil { - return nil, err - } - // register streaming services if err := app.RegisterStreamingServices(appOpts, app.kvStoreKeys()); err != nil { return nil, err diff --git a/app/lanes.go b/app/lanes.go index f819a9fc..28b80ff3 100644 --- a/app/lanes.go +++ b/app/lanes.go @@ -7,14 +7,13 @@ import ( signerextraction "github.com/skip-mev/block-sdk/v2/adapters/signer_extraction_adapter" "github.com/skip-mev/block-sdk/v2/block/base" defaultlane "github.com/skip-mev/block-sdk/v2/lanes/base" - freelane "github.com/skip-mev/block-sdk/v2/lanes/free" ) // CreateLanes walks through the process of creating the lanes for the block sdk. In this function // we create three separate lanes - Keyshare, Free, and Default - and then return them. // // NOTE: Application Developers should closely replicate this function in their own application. -func CreateLanes(app *App) (*keysharelane.KeyShareLane, *base.BaseLane, *base.BaseLane) { +func CreateLanes(app *App) (*keysharelane.KeyShareLane, *base.BaseLane) { // 1. Create the signer extractor. This is used to extract the expected signers from // a transaction. Each lane can have a different signer extractor if needed. signerAdapter := signerextraction.NewDefaultAdapter() @@ -32,21 +31,21 @@ func CreateLanes(app *App) (*keysharelane.KeyShareLane, *base.BaseLane, *base.Ba Logger: app.Logger(), TxEncoder: app.txConfig.TxEncoder(), TxDecoder: app.txConfig.TxDecoder(), - MaxBlockSpace: math.LegacyMustNewDecFromStr("0.2"), + MaxBlockSpace: math.LegacyMustNewDecFromStr("0.3"), SignerExtractor: signerAdapter, - MaxTxs: 1000, + MaxTxs: 10000, } // Create a free configuration that accepts 1000 transactions and consumes 20% of the // block space. - freeConfig := base.LaneConfig{ - Logger: app.Logger(), - TxEncoder: app.txConfig.TxEncoder(), - TxDecoder: app.txConfig.TxDecoder(), - MaxBlockSpace: math.LegacyMustNewDecFromStr("0.2"), - SignerExtractor: signerAdapter, - MaxTxs: 1000, - } + // freeConfig := base.LaneConfig{ + // Logger: app.Logger(), + // TxEncoder: app.txConfig.TxEncoder(), + // TxDecoder: app.txConfig.TxDecoder(), + // MaxBlockSpace: math.LegacyMustNewDecFromStr("0.2"), + // SignerExtractor: signerAdapter, + // MaxTxs: 1000, + // } // Create a default configuration that accepts 1000 transactions and consumes 60% of the // block space. @@ -54,9 +53,9 @@ func CreateLanes(app *App) (*keysharelane.KeyShareLane, *base.BaseLane, *base.Ba Logger: app.Logger(), TxEncoder: app.txConfig.TxEncoder(), TxDecoder: app.txConfig.TxDecoder(), - MaxBlockSpace: math.LegacyMustNewDecFromStr("0.6"), + MaxBlockSpace: math.LegacyMustNewDecFromStr("0.7"), SignerExtractor: signerAdapter, - MaxTxs: 1000, + MaxTxs: 10000, } // 3. Create the match handlers for each lane. These match handlers determine whether or not @@ -67,7 +66,7 @@ func CreateLanes(app *App) (*keysharelane.KeyShareLane, *base.BaseLane, *base.Ba keyshareMatchHandler := factory.MatchHandler() // Create the final match handler for the free lane. - freeMatchHandler := freelane.DefaultMatchHandler() + // freeMatchHandler := freelane.DefaultMatchHandler() // Create the final match handler for the default lane. defaultMatchHandler := base.DefaultMatchHandler() @@ -79,16 +78,16 @@ func CreateLanes(app *App) (*keysharelane.KeyShareLane, *base.BaseLane, *base.Ba keyshareMatchHandler, ) - freeLane := freelane.NewFreeLane( - freeConfig, - base.DefaultTxPriority(), - freeMatchHandler, - ) + // freeLane := freelane.NewFreeLane( + // freeConfig, + // base.DefaultTxPriority(), + // freeMatchHandler, + // ) defaultLane := defaultlane.NewDefaultLane( defaultConfig, defaultMatchHandler, ) - return keyshareLane, freeLane, defaultLane + return keyshareLane, defaultLane } diff --git a/app/wasm.go b/app/wasm.go index 9f366a7b..cbc2620c 100644 --- a/app/wasm.go +++ b/app/wasm.go @@ -1,17 +1,17 @@ package app import ( - storetypes "cosmossdk.io/store/types" "fmt" + "path/filepath" + + storetypes "cosmossdk.io/store/types" "github.com/CosmWasm/wasmd/x/wasm" wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" - "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/runtime" servertypes "github.com/cosmos/cosmos-sdk/server/types" "github.com/cosmos/cosmos-sdk/types/msgservice" - "github.com/cosmos/cosmos-sdk/x/auth/ante" "github.com/cosmos/cosmos-sdk/x/auth/posthandler" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper" @@ -20,7 +20,6 @@ import ( ibcfee "github.com/cosmos/ibc-go/v8/modules/apps/29-fee" porttypes "github.com/cosmos/ibc-go/v8/modules/core/05-port/types" "github.com/spf13/cast" - "path/filepath" ) // AllCapabilities returns all capabilities available with the current wasmvm @@ -98,9 +97,9 @@ func (app *App) registerWasmModules( return nil, err } - if err := app.setAnteHandler(app.txConfig, wasmConfig, app.GetKey(wasmtypes.StoreKey)); err != nil { - return nil, err - } + // if err := app.setAnteHandler(app.txConfig, wasmConfig, app.GetKey(wasmtypes.StoreKey)); err != nil { + // return nil, err + // } if manager := app.SnapshotManager(); manager != nil { err := manager.RegisterExtensions( @@ -146,28 +145,28 @@ func (app *App) setPostHandler() error { return nil } -func (app *App) setAnteHandler(txConfig client.TxConfig, wasmConfig wasmtypes.WasmConfig, txCounterStoreKey *storetypes.KVStoreKey) error { - anteHandler, err := NewAnteHandler( - HandlerOptions{ - HandlerOptions: ante.HandlerOptions{ - AccountKeeper: app.AccountKeeper, - BankKeeper: app.BankKeeper, - SignModeHandler: txConfig.SignModeHandler(), - FeegrantKeeper: app.FeeGrantKeeper, - SigGasConsumer: ante.DefaultSigVerificationGasConsumer, - }, - IBCKeeper: app.IBCKeeper, - WasmConfig: &wasmConfig, - WasmKeeper: &app.WasmKeeper, - TXCounterStoreService: runtime.NewKVStoreService(txCounterStoreKey), - CircuitKeeper: &app.CircuitBreakerKeeper, - }, - ) - if err != nil { - return fmt.Errorf("failed to create AnteHandler: %s", err) - } - - // Set the AnteHandler for the app - app.SetAnteHandler(anteHandler) - return nil -} +// func (app *App) setAnteHandler(txConfig client.TxConfig, wasmConfig wasmtypes.WasmConfig, txCounterStoreKey *storetypes.KVStoreKey) error { +// anteHandler, err := NewAnteHandler( +// HandlerOptions{ +// HandlerOptions: ante.HandlerOptions{ +// AccountKeeper: app.AccountKeeper, +// BankKeeper: app.BankKeeper, +// SignModeHandler: txConfig.SignModeHandler(), +// FeegrantKeeper: app.FeeGrantKeeper, +// SigGasConsumer: ante.DefaultSigVerificationGasConsumer, +// }, +// IBCKeeper: app.IBCKeeper, +// WasmConfig: &wasmConfig, +// WasmKeeper: &app.WasmKeeper, +// TXCounterStoreService: runtime.NewKVStoreService(txCounterStoreKey), +// CircuitKeeper: &app.CircuitBreakerKeeper, +// }, +// ) +// if err != nil { +// return fmt.Errorf("failed to create AnteHandler: %s", err) +// } + +// // Set the AnteHandler for the app +// app.SetAnteHandler(anteHandler) +// return nil +// } diff --git a/go.mod b/go.mod index b630a646..24477033 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/Fairblock/fairyring -go 1.22 +go 1.22.4 replace ( cosmossdk.io/api => github.com/Fairblock/cosmossdk-api v0.7.5 @@ -47,15 +47,15 @@ require ( github.com/grpc-ecosystem/grpc-gateway v1.16.0 github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 github.com/hashicorp/go-metrics v0.5.3 - github.com/skip-mev/block-sdk/v2 v2.1.3 + github.com/skip-mev/block-sdk/v2 v2.1.5 github.com/spf13/cast v1.6.0 github.com/spf13/cobra v1.8.0 github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.18.2 github.com/stretchr/testify v1.9.0 - golang.org/x/tools v0.20.0 - google.golang.org/genproto/googleapis/api v0.0.0-20240304212257-790db918fca8 - google.golang.org/grpc v1.63.2 + golang.org/x/tools v0.22.0 + google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 + google.golang.org/grpc v1.65.0 google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.3.0 google.golang.org/protobuf v1.34.1 ) @@ -63,8 +63,7 @@ require ( require ( buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.33.0-20240221180331-f05a6f4403ce.1 // indirect cloud.google.com/go v0.112.0 // indirect - cloud.google.com/go/compute v1.24.0 // indirect - cloud.google.com/go/compute/metadata v0.2.3 // indirect + cloud.google.com/go/compute/metadata v0.3.0 // indirect cloud.google.com/go/iam v1.1.6 // indirect cloud.google.com/go/storage v1.36.0 // indirect connectrpc.com/connect v1.15.0 // indirect @@ -127,7 +126,7 @@ require ( github.com/dustin/go-humanize v1.0.1 // indirect github.com/dvsekhvalnov/jose2go v1.6.0 // indirect github.com/emicklei/dot v1.6.1 // indirect - github.com/fatih/color v1.16.0 // indirect + github.com/fatih/color v1.17.0 // indirect github.com/felixge/fgprof v0.9.4 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect @@ -143,7 +142,7 @@ require ( github.com/gofrs/uuid/v5 v5.0.0 // indirect github.com/gogo/googleapis v1.4.1 // indirect github.com/gogo/protobuf v1.3.3 // indirect - github.com/golang/glog v1.2.0 // indirect + github.com/golang/glog v1.2.1 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/mock v1.6.0 // indirect github.com/golang/snappy v0.0.4 // indirect @@ -168,7 +167,7 @@ require ( github.com/hashicorp/go-immutable-radix v1.3.1 // indirect github.com/hashicorp/go-plugin v1.5.2 // indirect github.com/hashicorp/go-safetemp v1.0.0 // indirect - github.com/hashicorp/go-version v1.6.0 // indirect + github.com/hashicorp/go-version v1.7.0 // indirect github.com/hashicorp/golang-lru v1.0.2 // indirect github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect github.com/hashicorp/hcl v1.0.0 // indirect @@ -204,7 +203,7 @@ require ( github.com/oklog/run v1.1.0 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.1.0 // indirect - github.com/pelletier/go-toml/v2 v2.1.0 // indirect + github.com/pelletier/go-toml/v2 v2.2.2 // indirect github.com/petermattis/goid v0.0.0-20231207134359-e60b3f734c67 // indirect github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect github.com/pkg/errors v0.9.1 // indirect @@ -248,20 +247,19 @@ require ( go.uber.org/atomic v1.11.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.27.0 // indirect - golang.org/x/crypto v0.22.0 // indirect + golang.org/x/crypto v0.24.0 // indirect golang.org/x/exp v0.0.0-20240404231335-c0f41cb1a7a0 // indirect - golang.org/x/mod v0.17.0 // indirect - golang.org/x/net v0.24.0 // indirect - golang.org/x/oauth2 v0.18.0 // indirect + golang.org/x/mod v0.18.0 // indirect + golang.org/x/net v0.26.0 // indirect + golang.org/x/oauth2 v0.20.0 // indirect golang.org/x/sync v0.7.0 // indirect - golang.org/x/sys v0.20.0 // indirect - golang.org/x/term v0.19.0 // indirect - golang.org/x/text v0.14.0 // indirect + golang.org/x/sys v0.21.0 // indirect + golang.org/x/term v0.21.0 // indirect + golang.org/x/text v0.16.0 // indirect golang.org/x/time v0.5.0 // indirect google.golang.org/api v0.162.0 // indirect - google.golang.org/appengine v1.6.8 // indirect google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/go.sum b/go.sum index 98493801..adcb708d 100644 --- a/go.sum +++ b/go.sum @@ -70,10 +70,8 @@ cloud.google.com/go/compute v1.6.0/go.mod h1:T29tfhtVbq1wvAPo0E3+7vhgmkOYeXjhFvz cloud.google.com/go/compute v1.6.1/go.mod h1:g85FgpzFvNULZ+S8AYq87axRKuf2Kh7deLqV/jJ3thU= cloud.google.com/go/compute v1.7.0/go.mod h1:435lt8av5oL9P3fv1OEzSbSUe+ybHXGMPQHHZWZxy9U= cloud.google.com/go/compute v1.10.0/go.mod h1:ER5CLbMxl90o2jtNbGSbtfOpQKR0t15FOtRsugnLrlU= -cloud.google.com/go/compute v1.24.0 h1:phWcR2eWzRJaL/kOiJwfFsPs4BaKq1j6vnpZrc1YlVg= -cloud.google.com/go/compute v1.24.0/go.mod h1:kw1/T+h/+tK2LJK0wiPPx1intgdAM3j/g3hFDlscY40= -cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGBW5aJ7UnBMY= -cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA= +cloud.google.com/go/compute/metadata v0.3.0 h1:Tz+eQXMEqDIKRsmY3cHTL6FVaynIjX2QxYC4trgAKZc= +cloud.google.com/go/compute/metadata v0.3.0/go.mod h1:zFmK7XCadkQkj6TtorcaGlCW1hT1fIilQDwofLpJ20k= cloud.google.com/go/containeranalysis v0.5.1/go.mod h1:1D92jd8gRR/c0fGMlymRgxWD3Qw9C1ff6/T7mLgVL8I= cloud.google.com/go/containeranalysis v0.6.0/go.mod h1:HEJoiEIu+lEXM+k7+qLCci0h33lX3ZqoYFdmPcoO7s4= cloud.google.com/go/datacatalog v1.3.0/go.mod h1:g9svFY6tuR+j+hrTw3J2dNcmI0dzmSiyOzm8kpLq0a0= @@ -346,8 +344,8 @@ github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWH github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20231128003011-0fa0005c9caa h1:jQCWAUqqlij9Pgj2i/PB79y4KOPYVyFYdROxgaCwdTQ= -github.com/cncf/xds/go v0.0.0-20231128003011-0fa0005c9caa/go.mod h1:x/1Gn8zydmfq8dk6e9PdstVsDgu9RuyIIJqAaF//0IM= +github.com/cncf/xds/go v0.0.0-20240423153145-555b57ec207b h1:ga8SEFjZ60pxLcmhnThWgvH2wg8376yUJmPhEH4H3kw= +github.com/cncf/xds/go v0.0.0-20240423153145-555b57ec207b/go.mod h1:W+zGtBO5Y1IgJhy4+A9GOqVhqLpfZi+vwmdNXUehLA8= github.com/cockroachdb/apd/v2 v2.0.2 h1:weh8u7Cneje73dDh+2tEVLUvyBc89iwepWCD8b8034E= github.com/cockroachdb/apd/v2 v2.0.2/go.mod h1:DDxRlzC2lo3/vSlmSoS7JkqbbrARPuFOGr0B9pvN3Gw= github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= @@ -483,8 +481,8 @@ github.com/envoyproxy/protoc-gen-validate v1.0.4 h1:gVPz/FMfvh57HdSJQyvBtF00j8JU github.com/envoyproxy/protoc-gen-validate v1.0.4/go.mod h1:qys6tmnRsYrQqIhm2bvKZH4Blx/1gTIZ2UKVY1M+Yew= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= -github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM= -github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE= +github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4= +github.com/fatih/color v1.17.0/go.mod h1:YZ7TlrGPkiz6ku9fK3TLD/pl3CpsiFyu8N92HLgmosI= github.com/felixge/fgprof v0.9.3/go.mod h1:RdbpDgzqYVh/T9fPELJyV7EYJuHB55UTEULNun8eiPw= github.com/felixge/fgprof v0.9.4 h1:ocDNwMFlnA0NU0zSB3I52xkO4sFXk80VK9lXjLClu88= github.com/felixge/fgprof v0.9.4/go.mod h1:yKl+ERSa++RYOs32d8K6WEXCB4uXdLls4ZaZPpayhMM= @@ -566,8 +564,8 @@ github.com/gogo/googleapis v1.4.1-0.20201022092350-68b0159b7869/go.mod h1:5YRNX2 github.com/gogo/googleapis v1.4.1 h1:1Yx4Myt7BxzvUr5ldGSbwYiZG6t9wGBZ+8/fX3Wvtq0= github.com/gogo/googleapis v1.4.1/go.mod h1:2lpHqI5OcWCtVElxXnPt+s8oJvMpySlOyM6xDCrzib4= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/glog v1.2.0 h1:uCdmnmatrKCgMBlM4rMuJZWOkPDqdbZPnrMXDY4gI68= -github.com/golang/glog v1.2.0/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w= +github.com/golang/glog v1.2.1 h1:OptwRhECazUx5ix5TTWC3EZhsZEHWcYWY4FQHTIubm4= +github.com/golang/glog v1.2.1/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w= github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -743,8 +741,9 @@ github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/b github.com/hashicorp/go-uuid v1.0.2 h1:cfejS+Tpcp13yd5nYHWDI6qVCny6wyX2Mt5SGur2IGE= github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek= github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= +github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKeRZfjY= +github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= @@ -930,8 +929,8 @@ github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8 github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/image-spec v1.1.0 h1:8SG7/vwALn54lVB/0yZ/MMwhFrPYtpEHQb2IpWsCzug= github.com/opencontainers/image-spec v1.1.0/go.mod h1:W4s4sFTMaBeK1BQLXbG4AdM2szdn85PY75RI83NrTrM= -github.com/opencontainers/runc v1.1.12 h1:BOIssBaW1La0/qbNZHXOOa71dZfZEQOzW7dqQf3phss= -github.com/opencontainers/runc v1.1.12/go.mod h1:S+lQwSfncpBha7XTy/5lBwWgm5+y5Ma/O44Ekby9FK8= +github.com/opencontainers/runc v1.1.3 h1:vIXrkId+0/J2Ymu2m7VjGvbSlAId9XNRPhn2p4b+d8w= +github.com/opencontainers/runc v1.1.3/go.mod h1:1J5XiS+vdZ3wCyZybsuxXZWGrgSr8fFJHLXuG2PsnNg= github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492/go.mod h1:Ngi6UdF0k5OKD5t5wlmGhe/EDKPoUM3BXZSSfIuJbis= github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74= github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= @@ -951,8 +950,8 @@ github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0Mw github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= -github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6/MHO4= -github.com/pelletier/go-toml/v2 v2.1.0/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc= +github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM= +github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs= github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac= github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5/go.mod h1:jvVRKCrJTQWu0XVbaOlby/2lO20uSCHEMzzplHXte1o= github.com/petermattis/goid v0.0.0-20231207134359-e60b3f734c67 h1:jik8PHtAIsPlCRJjJzl4udgEf7hawInF9texMeO2jrU= @@ -1044,8 +1043,8 @@ github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrf github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= -github.com/skip-mev/block-sdk/v2 v2.1.3 h1:iuqqa2KzoCq/ujX+5T2sOV2nowMx0oI7qrqCKFRwt6Y= -github.com/skip-mev/block-sdk/v2 v2.1.3/go.mod h1:kIq7SMva0/eHKTCiG/oI5XGxD4HNVK0t71TrUZqHcvA= +github.com/skip-mev/block-sdk/v2 v2.1.5 h1:3uoYG2ayP253wiohBPKdD3LrkJGd1Kgw914mmI1ZyOI= +github.com/skip-mev/block-sdk/v2 v2.1.5/go.mod h1:E8SvITZUdxkes3gI3+kgESZL+NLffkcLKnowUgYTOf4= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= @@ -1201,8 +1200,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30= -golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= +golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI= +golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -1242,8 +1241,8 @@ golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= -golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.18.0 h1:5+9lSbEzPSdWkH32vYPBwEpX8KwDbM52Ud9xBUvNlb0= +golang.org/x/mod v0.18.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -1303,8 +1302,8 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug golang.org/x/net v0.0.0-20220909164309-bea034e7d591/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/net v0.0.0-20221014081412-f15817d10f9b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= -golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w= -golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8= +golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ= +golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1330,8 +1329,8 @@ golang.org/x/oauth2 v0.0.0-20220822191816-0ebed06d0094/go.mod h1:h4gKUeWbJ4rQPri golang.org/x/oauth2 v0.0.0-20220909003341-f21342109be1/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= golang.org/x/oauth2 v0.1.0/go.mod h1:G9FE4dLTsbXUu90h/Pf85g4w1D+SSAgR+q46nJZ8M4A= -golang.org/x/oauth2 v0.18.0 h1:09qnuIAgzdx1XplqJvW6CQqMCtGZykZWcXzPMPUusvI= -golang.org/x/oauth2 v0.18.0/go.mod h1:Wf7knwG0MPoWIMMBgFlEaSUDaKskp0dCfrlJRJXbBi8= +golang.org/x/oauth2 v0.20.0 h1:4mQdhULixXKP1rwYBW0vAijoXnkTG0BLCDRzfe1idMo= +golang.org/x/oauth2 v0.20.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -1447,13 +1446,13 @@ golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y= -golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= +golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.19.0 h1:+ThwsDv+tYfnJFhF4L8jITxu1tdTWRTZpdsWgEgjL6Q= -golang.org/x/term v0.19.0/go.mod h1:2CuTdWZ7KHSQwUzKva0cbMg6q2DMI3Mmxp+gKJbskEk= +golang.org/x/term v0.21.0 h1:WVXCp+/EBEHOj53Rvu+7KiT/iElMrO8ACK16SMZ3jaA= +golang.org/x/term v0.21.0/go.mod h1:ooXLefLobQVslOqselCNF4SxFAaoS6KujMbsGzSDmX0= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1463,10 +1462,9 @@ golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= +golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -1533,8 +1531,8 @@ golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.20.0 h1:hz/CVckiOxybQvFw6h7b/q80NTr9IUQb4s1IIzW7KNY= -golang.org/x/tools v0.20.0/go.mod h1:WvitBU7JJf6A4jOdg4S1tviW9bhUxkgeCui/0JHctQg= +golang.org/x/tools v0.22.0 h1:gqSGLZqv+AI9lIQzniJ0nZDRG5GBPsSi+DRNHWNz6yA= +golang.org/x/tools v0.22.0/go.mod h1:aCwcsjqvq7Yqt6TNyX7QMU2enbQ/Gt0bo6krSeEri+c= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -1603,8 +1601,6 @@ google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM= -google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= @@ -1714,10 +1710,10 @@ google.golang.org/genproto v0.0.0-20221014213838-99cd37c6964a/go.mod h1:1vXfmgAz google.golang.org/genproto v0.0.0-20221025140454-527a21cfbd71/go.mod h1:9qHF0xnpdSfF6knlcsnpzUu5y+rpwgbvsyGAZPBMg4s= google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de h1:F6qOa9AZTYJXOUEr4jDysRDLrm4PHePlge4v4TGAlxY= google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:VUhTRKeHn9wwcdrk73nvdC9gF178Tzhmt/qyaFcPLSo= -google.golang.org/genproto/googleapis/api v0.0.0-20240304212257-790db918fca8 h1:8eadJkXbwDEMNwcB5O0s5Y5eCfyuCLdvaiOIaGTrWmQ= -google.golang.org/genproto/googleapis/api v0.0.0-20240304212257-790db918fca8/go.mod h1:O1cOfN1Cy6QEYr7VxtjOyP5AdAuR0aJ/MYZaaof623Y= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda h1:LI5DOvAxUPMv/50agcLLoo+AdWc1irS9Rzz4vPuD1V4= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY= +google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 h1:7whR9kGa5LUwFtpLm2ArCEejtnxlGeLbAyjFY8sGNFw= +google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157/go.mod h1:99sLkeliLXfdj2J75X3Ho+rrVCaJze0uwN7zDDkjPVU= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 h1:Zy9XzmMEflZ/MAaA7vNcoebnRAld7FsPW1EeBB7V0m8= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157/go.mod h1:EfXuqaE1J41VCDicxHzUDm+8rk+7ZdXzHV0IhO/I6s0= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.0/go.mod h1:chYK+tFQF0nDUGJgXMSgLCQk3phJEuONr2DCgLDdAQM= @@ -1759,8 +1755,8 @@ google.golang.org/grpc v1.48.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACu google.golang.org/grpc v1.49.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.50.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.50.1/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= -google.golang.org/grpc v1.63.2 h1:MUeiw1B2maTVZthpU5xvASfTh3LDbxHd6IJ6QQVU+xM= -google.golang.org/grpc v1.63.2/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA= +google.golang.org/grpc v1.65.0 h1:bs/cUb4lp1G5iImFFd3u5ixQzweKizoZJAwBNLR42lc= +google.golang.org/grpc v1.65.0/go.mod h1:WgYC2ypjlB0EiQi6wdKixMqukr6lBc0Vo+oOgjrM5ZQ= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.3.0 h1:rNBFJjBCOgVr9pWD7rs/knKL4FRTKgpZmsRfV214zcA= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.3.0/go.mod h1:Dk1tviKTvMCz5tvh7t+fh94dhmQVHuCt2OzJB3CTW9Y= diff --git a/lanes/base/README.md b/lanes/base/README.md deleted file mode 100644 index 4f0b52c3..00000000 --- a/lanes/base/README.md +++ /dev/null @@ -1,112 +0,0 @@ -# 🏗️ Default Lane Setup - -## 📦 Dependencies - -The Block SDK is built on top of the Cosmos SDK. The Block SDK is currently -compatible with Cosmos SDK versions greater than or equal to `v0.47.0`. - -## 📥 Installation - -To install the Block SDK, run the following command: - -```bash -$ go install github.com/skip-mev/block-sdk -``` - -## 📚 Usage - -> Note: Please visit [app.go](../../tests/app/lanes.go) to see a sample base app set up. - -1. First determine the set of lanes that you want to use in your application. The -available lanes can be found in our -[Lane App Store](https://docs.skip.money/chains/lanes/existing-lanes/default). -This guide only sets up the `default lane` -2. In your base application, you will need to create a `LanedMempool` composed -of the `lanes` you want to use. -3. Next, order the lanes by priority. The first lane is the highest priority lane -and the last lane is the lowest priority lane. **It is recommended that the last -lane is the default lane.** -4. You will also need to create a `PrepareProposalHandler` and a -`ProcessProposalHandler` that will be responsible for preparing and processing -proposals respectively. Configure the order of the lanes in the -`PrepareProposalHandler` and `ProcessProposalHandler` to match the order of the -lanes in the `LanedMempool`. -5. Configure your `app.go` to include the following: - -```golang -import ( - "github.com/skip-mev/block-sdk/abci" - "github.com/skip-mev/block-sdk/block/base" - defaultlane "github.com/skip-mev/block-sdk/lanes/base" -) - -... - -func NewApp() { - ... - // 1. Create the lanes. - // - // NOTE: The lanes are ordered by priority. The first lane is the highest priority - // lane and the last lane is the lowest priority lane. - // - // For more information on how to utilize the LaneConfig please - // visit the README in docs.skip.money/chains/lanes/build-your-own-lane#-lane-config. - // - // Default lane accepts all transactions. - defaultConfig := base.LaneConfig{ - Logger: app.Logger(), - TxEncoder: app.txConfig.TxEncoder(), - TxDecoder: app.txConfig.TxDecoder(), - MaxBlockSpace: math.LegacyZeroDec(), - MaxTxs: 5000, - } - defaultLane := defaultlane.NewDefaultLane(defaultConfig, base.DefaultMatchHandler()) - - // 2. Set up the relative priority of lanes - lanes := []block.Lane{ - defaultLane, - } - mempool := block.NewLanedMempool(app.Logger(), lanes) - app.App.SetMempool(mempool) - - ... - - // 3. Set up the ante handler. - anteDecorators := []sdk.AnteDecorator{ - ante.NewSetUpContextDecorator(), - ... - utils.NewIgnoreDecorator( - ante.NewDeductFeeDecorator( - options.BaseOptions.AccountKeeper, - options.BaseOptions.BankKeeper, - options.BaseOptions.FeegrantKeeper, - options.BaseOptions.TxFeeChecker, - ), - options.FreeLane, - ), - ... - } - - anteHandler := sdk.ChainAnteDecorators(anteDecorators...) - - // Set the lane ante handlers on the lanes. - // - // NOTE: This step is very important. Without the antehandlers, lanes will not - // be able to verify transactions. - for _, lane := range lanes { - lane.SetAnteHandler(anteHandler) - } - app.App.SetAnteHandler(anteHandler) - - // 4. Set the abci handlers on base app - proposalHandler := abci.NewProposalHandler( - app.Logger(), - app.TxConfig().TxDecoder(), - mempool, - ) - app.App.SetPrepareProposal(proposalHandler.PrepareProposalHandler()) - app.App.SetProcessProposal(proposalHandler.ProcessProposalHandler()) - - ... -} -``` diff --git a/lanes/base/abci_test.go b/lanes/base/abci_test.go deleted file mode 100644 index d94ae1a8..00000000 --- a/lanes/base/abci_test.go +++ /dev/null @@ -1,1703 +0,0 @@ -package base_test - -import ( - "context" - "crypto/sha256" - "encoding/hex" - "fmt" - "math/rand" - - "cosmossdk.io/log" - "cosmossdk.io/math" - sdk "github.com/cosmos/cosmos-sdk/types" - - signer_extraction "github.com/skip-mev/block-sdk/v2/adapters/signer_extraction_adapter" - "github.com/skip-mev/block-sdk/v2/block" - "github.com/skip-mev/block-sdk/v2/block/base" - "github.com/skip-mev/block-sdk/v2/block/mocks" - "github.com/skip-mev/block-sdk/v2/block/proposals" - "github.com/skip-mev/block-sdk/v2/block/utils" - defaultlane "github.com/skip-mev/block-sdk/v2/lanes/base" - testutils "github.com/skip-mev/block-sdk/v2/testutils" -) - -func (s *BaseTestSuite) TestPrepareLane() { - s.Run("should not build a proposal when amount configured to lane is too small", func() { - // Create a basic transaction that should not in the proposal - tx, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[0], - 0, - 1, - 0, - 1, - sdk.NewCoin(s.gasTokenDenom, math.NewInt(1)), - ) - s.Require().NoError(err) - - expectedExecution := map[sdk.Tx]bool{ - tx: true, - } - lane := s.initLane(math.LegacyMustNewDecFromStr("0.5"), expectedExecution) - s.Require().NoError(lane.Insert(s.ctx, tx)) - - txBz, err := s.encodingConfig.TxConfig.TxEncoder()(tx) - s.Require().NoError(err) - - emptyProposal := proposals.NewProposal( - log.NewNopLogger(), - int64(len(txBz)), - 1, - ) - - finalProposal, err := lane.PrepareLane(s.ctx, emptyProposal, block.NoOpPrepareLanesHandler()) - s.Require().NoError(err) - - // Ensure the proposal is empty - s.Require().Equal(0, len(finalProposal.Txs)) - s.Require().Equal(int64(0), finalProposal.Info.BlockSize) - s.Require().Equal(uint64(0), finalProposal.Info.GasLimit) - }) - - s.Run("should not build a proposal when gas configured to lane is too small", func() { - // Create a basic transaction that should not in the proposal - tx, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[0], - 0, - 1, - 0, - 10, - sdk.NewCoin(s.gasTokenDenom, math.NewInt(1)), - ) - s.Require().NoError(err) - - expectedExecution := map[sdk.Tx]bool{ - tx: true, - } - lane := s.initLane(math.LegacyMustNewDecFromStr("0.5"), expectedExecution) - - // Insert the transaction into the lane - s.Require().NoError(lane.Insert(s.ctx, tx)) - - txBz, err := s.encodingConfig.TxConfig.TxEncoder()(tx) - s.Require().NoError(err) - - limit := proposals.LaneLimits{ - MaxTxBytes: int64(len(txBz)) * 10, - MaxGasLimit: 10, - } - emptyProposal := proposals.NewProposal( - log.NewNopLogger(), - limit.MaxTxBytes, - limit.MaxGasLimit, - ) - - finalProposal, err := lane.PrepareLane(s.ctx, emptyProposal, block.NoOpPrepareLanesHandler()) - s.Require().NoError(err) - - // Ensure the proposal is empty - s.Require().Equal(0, len(finalProposal.Txs)) - s.Require().Equal(int64(0), finalProposal.Info.BlockSize) - s.Require().Equal(uint64(0), finalProposal.Info.GasLimit) - }) - - s.Run("should not build a proposal when gas configured to lane is too small p2", func() { - // Create a basic transaction that should not in the proposal - tx, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[0], - 0, - 1, - 0, - 10, - sdk.NewCoin(s.gasTokenDenom, math.NewInt(1)), - ) - s.Require().NoError(err) - - expectedExecution := map[sdk.Tx]bool{ - tx: true, - } - lane := s.initLane(math.LegacyMustNewDecFromStr("0.5"), expectedExecution) - - // Insert the transaction into the lane - s.Require().NoError(lane.Insert(s.ctx, tx)) - - txBz, err := s.encodingConfig.TxConfig.TxEncoder()(tx) - s.Require().NoError(err) - - // Create a proposal - limit := proposals.LaneLimits{ - MaxTxBytes: int64(len(txBz)) * 10, // have enough space for 10 of these txs - MaxGasLimit: 10, - } - emptyProposal := proposals.NewProposal( - log.NewNopLogger(), - limit.MaxTxBytes, - limit.MaxGasLimit, - ) - - finalProposal, err := lane.PrepareLane(s.ctx, emptyProposal, block.NoOpPrepareLanesHandler()) - s.Require().NoError(err) - - // Ensure the proposal is empty - s.Require().Equal(0, len(finalProposal.Txs)) - s.Require().Equal(int64(0), finalProposal.Info.BlockSize) - s.Require().Equal(uint64(0), finalProposal.Info.GasLimit) - }) - - s.Run("should be able to build a proposal with a tx that just fits in", func() { - // Create a basic transaction that should just fit in with the gas limit - // and max size - tx, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[0], - 0, - 1, - 0, - 10, - sdk.NewCoin(s.gasTokenDenom, math.NewInt(1)), - ) - s.Require().NoError(err) - - expectedExecution := map[sdk.Tx]bool{ - tx: true, - } - lane := s.initLane(math.LegacyOneDec(), expectedExecution) - - s.Require().NoError(lane.Insert(s.ctx, tx)) - - txBz, err := s.encodingConfig.TxConfig.TxEncoder()(tx) - s.Require().NoError(err) - - limit := proposals.LaneLimits{ - MaxTxBytes: int64(len(txBz)), - MaxGasLimit: 10, - } - emptyProposal := proposals.NewProposal( - log.NewNopLogger(), - limit.MaxTxBytes, - limit.MaxGasLimit, - ) - - finalProposal, err := lane.PrepareLane(s.ctx, emptyProposal, block.NoOpPrepareLanesHandler()) - s.Require().NoError(err) - - // Ensure the proposal is not empty and contains the transaction - s.Require().Equal(1, len(finalProposal.Txs)) - s.Require().Equal(limit.MaxTxBytes, finalProposal.Info.BlockSize) - s.Require().Equal(uint64(10), finalProposal.Info.GasLimit) - s.Require().Equal(txBz, finalProposal.Txs[0]) - }) - - s.Run("should not build a proposal with a that fails verify tx", func() { - // Create a basic transaction that should not in the proposal - tx, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[0], - 0, - 1, - 0, - 10, - sdk.NewCoin(s.gasTokenDenom, math.NewInt(1)), - ) - s.Require().NoError(err) - - // We expect the transaction to fail verify tx - expectedExecution := map[sdk.Tx]bool{ - tx: false, - } - lane := s.initLane(math.LegacyOneDec(), expectedExecution) - - s.Require().NoError(lane.Insert(s.ctx, tx)) - - txBz, err := s.encodingConfig.TxConfig.TxEncoder()(tx) - s.Require().NoError(err) - - emptyProposal := proposals.NewProposal( - log.NewNopLogger(), - int64(len(txBz)), - 10, - ) - - finalProposal, err := lane.PrepareLane(s.ctx, emptyProposal, block.NoOpPrepareLanesHandler()) - s.Require().NoError(err) - - // Ensure the proposal is empty - s.Require().Equal(0, len(finalProposal.Txs)) - s.Require().Equal(int64(0), finalProposal.Info.BlockSize) - s.Require().Equal(uint64(0), finalProposal.Info.GasLimit) - - // Ensure the transaction is removed from the lane - s.Require().False(lane.Contains(tx)) - s.Require().Equal(0, lane.CountTx()) - }) - - s.Run("should order transactions correctly in the proposal", func() { - tx1, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[0], - 0, - 1, - 0, - 10, - sdk.NewCoin(s.gasTokenDenom, math.NewInt(2)), - ) - s.Require().NoError(err) - - tx2, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[1], - 0, - 1, - 0, - 10, - sdk.NewCoin(s.gasTokenDenom, math.NewInt(1)), - ) - s.Require().NoError(err) - - expectedExecution := map[sdk.Tx]bool{ - tx1: true, - tx2: true, - } - lane := s.initLane(math.LegacyOneDec(), expectedExecution) - - s.Require().NoError(lane.Insert(s.ctx, tx1)) - s.Require().NoError(lane.Insert(s.ctx, tx2)) - - txBz1, err := s.encodingConfig.TxConfig.TxEncoder()(tx1) - s.Require().NoError(err) - - txBz2, err := s.encodingConfig.TxConfig.TxEncoder()(tx2) - s.Require().NoError(err) - - size := int64(len(txBz1)) + int64(len(txBz2)) - gasLimit := uint64(20) - emptyProposal := proposals.NewProposal( - log.NewNopLogger(), - size, - gasLimit, - ) - - finalProposal, err := lane.PrepareLane(s.ctx, emptyProposal, block.NoOpPrepareLanesHandler()) - s.Require().NoError(err) - - // Ensure the proposal is ordered correctly - s.Require().Equal(2, len(finalProposal.Txs)) - s.Require().Equal(size, finalProposal.Info.BlockSize) - s.Require().Equal(gasLimit, finalProposal.Info.GasLimit) - s.Require().Equal([][]byte{txBz1, txBz2}, finalProposal.Txs) - }) - - s.Run("should order transactions correctly in the proposal (with different insertion)", func() { - tx1, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[1], - 1, - 1, - 0, - 1, - sdk.NewCoin(s.gasTokenDenom, math.NewInt(1)), - ) - s.Require().NoError(err) - - tx2, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[1], - 0, - 1, - 0, - 1, - sdk.NewCoin(s.gasTokenDenom, math.NewInt(2)), - ) - s.Require().NoError(err) - - expectedExecution := map[sdk.Tx]bool{ - tx1: true, - tx2: true, - } - lane := s.initLane(math.LegacyOneDec(), expectedExecution) - - s.Require().NoError(lane.Insert(s.ctx, tx1)) - s.Require().NoError(lane.Insert(s.ctx, tx2)) - - txBz1, err := s.encodingConfig.TxConfig.TxEncoder()(tx1) - s.Require().NoError(err) - - txBz2, err := s.encodingConfig.TxConfig.TxEncoder()(tx2) - s.Require().NoError(err) - - size := int64(len(txBz1)) + int64(len(txBz2)) - gasLimit := uint64(2) - emptyProposal := proposals.NewProposal( - log.NewNopLogger(), - size, - gasLimit, - ) - - finalProposal, err := lane.PrepareLane(s.ctx, emptyProposal, block.NoOpPrepareLanesHandler()) - s.Require().NoError(err) - - // Ensure the proposal is ordered correctly - s.Require().Equal(2, len(finalProposal.Txs)) - s.Require().Equal(size, finalProposal.Info.BlockSize) - s.Require().Equal(gasLimit, finalProposal.Info.GasLimit) - s.Require().Equal([][]byte{txBz2, txBz1}, finalProposal.Txs) - }) - - s.Run("should include tx that fits in proposal when other does not", func() { - // Create a basic transaction that should not in the proposal - tx1, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[0], - 0, - 1, - 0, - 2, - sdk.NewCoin(s.gasTokenDenom, math.NewInt(1)), - ) - s.Require().NoError(err) - - tx2, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[1], - 0, - 10, // This tx is too large to fit in the proposal - 0, - 1, - sdk.NewCoin(s.gasTokenDenom, math.NewInt(1)), - ) - s.Require().NoError(err) - - // Create a lane with a max block space of 1 but a proposal that is smaller than the tx - expectedExecution := map[sdk.Tx]bool{ - tx1: true, - tx2: true, - } - lane := s.initLane(math.LegacyOneDec(), expectedExecution) - - // Insert the transaction into the lane - s.Require().NoError(lane.Insert(s.ctx.WithPriority(10), tx1)) - s.Require().NoError(lane.Insert(s.ctx.WithPriority(5), tx2)) - - txBz1, err := s.encodingConfig.TxConfig.TxEncoder()(tx1) - s.Require().NoError(err) - - txBz2, err := s.encodingConfig.TxConfig.TxEncoder()(tx2) - s.Require().NoError(err) - - size := int64(len(txBz1)) + int64(len(txBz2)) - 1 - gasLimit := uint64(3) - emptyProposal := proposals.NewProposal( - log.NewNopLogger(), - size, - gasLimit, - ) - - finalProposal, err := lane.PrepareLane(s.ctx, emptyProposal, block.NoOpPrepareLanesHandler()) - s.Require().NoError(err) - - // Ensure the proposal is ordered correctly - s.Require().Equal(1, len(finalProposal.Txs)) - s.Require().Equal(int64(len(txBz1)), finalProposal.Info.BlockSize) - s.Require().Equal(uint64(2), finalProposal.Info.GasLimit) - s.Require().Equal([][]byte{txBz1}, finalProposal.Txs) - }) - - s.Run("should include tx that consumes all gas in proposal while other cannot", func() { - // Create a basic transaction that should not in the proposal - tx1, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[0], - 0, - 1, - 0, - 2, - sdk.NewCoin(s.gasTokenDenom, math.NewInt(1)), - ) - s.Require().NoError(err) - - tx2, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[1], - 0, - 10, // This tx is too large to fit in the proposal - 0, - 1, - sdk.NewCoin(s.gasTokenDenom, math.NewInt(1)), - ) - s.Require().NoError(err) - - // Create a lane with a max block space of 1 but a proposal that is smaller than the tx - expectedExecution := map[sdk.Tx]bool{ - tx1: true, - tx2: true, - } - lane := s.initLane(math.LegacyOneDec(), expectedExecution) - - // Insert the transaction into the lane - s.Require().NoError(lane.Insert(s.ctx, tx1)) - s.Require().NoError(lane.Insert(s.ctx, tx2)) - - txBz1, err := s.encodingConfig.TxConfig.TxEncoder()(tx1) - s.Require().NoError(err) - - txBz2, err := s.encodingConfig.TxConfig.TxEncoder()(tx2) - s.Require().NoError(err) - - size := int64(len(txBz1)) + int64(len(txBz2)) - 1 - gasLimit := uint64(1) - emptyProposal := proposals.NewProposal( - log.NewNopLogger(), - size, - gasLimit, - ) - - finalProposal, err := lane.PrepareLane(s.ctx, emptyProposal, block.NoOpPrepareLanesHandler()) - s.Require().NoError(err) - - // Ensure the proposal is ordered correctly - s.Require().Equal(1, len(finalProposal.Txs)) - s.Require().Equal(int64(len(txBz2)), finalProposal.Info.BlockSize) - s.Require().Equal(uint64(1), finalProposal.Info.GasLimit) - s.Require().Equal([][]byte{txBz2}, finalProposal.Txs) - }) - - s.Run("should not attempt to include transaction already included in the proposal", func() { - // Create a basic transaction that should not in the proposal - tx, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[0], - 0, - 1, - 0, - 2, - sdk.NewCoin(s.gasTokenDenom, math.NewInt(1)), - ) - s.Require().NoError(err) - - // Create a lane with a max block space of 1 but a proposal that is smaller than the tx - expectedExecution := map[sdk.Tx]bool{ - tx: true, - } - lane := s.initLane(math.LegacyOneDec(), expectedExecution) - - // Insert the transaction into the lane - s.Require().NoError(lane.Insert(s.ctx, tx)) - - txBz, err := s.encodingConfig.TxConfig.TxEncoder()(tx) - s.Require().NoError(err) - - emptyProposal := proposals.NewProposal( - log.NewNopLogger(), - int64(len(txBz))*10, - 1000000, - ) - - mockLane := mocks.NewLane(s.T()) - - mockLane.On("Name").Return("test") - mockLane.On("GetMaxBlockSpace").Return(math.LegacyOneDec()) - - txWithInfo, err := lane.GetTxInfo(s.ctx, tx) - s.Require().NoError(err) - - err = emptyProposal.UpdateProposal(mockLane, []utils.TxWithInfo{txWithInfo}) - s.Require().NoError(err) - - finalProposal, err := lane.PrepareLane(s.ctx, emptyProposal, block.NoOpPrepareLanesHandler()) - s.Require().NoError(err) - - // Ensure the proposal is ordered correctly - s.Require().Equal(1, len(finalProposal.Txs)) - s.Require().Equal(int64(len(txBz)), finalProposal.Info.BlockSize) - s.Require().Equal(uint64(2), finalProposal.Info.GasLimit) - s.Require().Equal([][]byte{txBz}, finalProposal.Txs) - }) - - s.Run("should not attempt to include transaction that matches to a different lane", func() { - // Create a basic transaction that should not in the proposal - tx, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[0], - 0, - 1, - 0, - 2, - sdk.NewCoin(s.gasTokenDenom, math.NewInt(1)), - ) - s.Require().NoError(err) - - mh := func(ctx sdk.Context, tx sdk.Tx) bool { - return true - } - - // Create a lane with a max block space of 1 but a proposal that is smaller than the tx - expectedExecution := map[sdk.Tx]bool{ - tx: true, - } - lane := s.initLaneWithMatchHandlers(math.LegacyOneDec(), expectedExecution, []base.MatchHandler{mh}) - - // Insert the transaction into the lane - s.Require().NoError(lane.Insert(s.ctx, tx)) - - txBz, err := s.encodingConfig.TxConfig.TxEncoder()(tx) - s.Require().NoError(err) - - emptyProposal := proposals.NewProposal( - log.NewNopLogger(), - int64(len(txBz))*10, - 1000000, - ) - - finalProposal, err := lane.PrepareLane(s.ctx, emptyProposal, block.NoOpPrepareLanesHandler()) - s.Require().NoError(err) - s.Require().Len(finalProposal.Txs, 0) - }) -} - -func (s *BaseTestSuite) TestProcessLane() { - s.Run("should accept a proposal where transaction fees are not in order bc of sequence numbers", func() { - tx1, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[0], - 0, - 1, - 0, - 1, - sdk.NewCoin(s.gasTokenDenom, math.NewInt(1)), - ) - s.Require().NoError(err) - - tx2, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[0], - 1, - 0, - 0, - 0, - sdk.NewCoin(s.gasTokenDenom, math.NewInt(2)), - ) - s.Require().NoError(err) - - proposal := []sdk.Tx{ - tx1, - tx2, // This transaction has a higher sequence number and higher fees - } - - lane := s.initLane( - math.LegacyOneDec(), - map[sdk.Tx]bool{ - tx1: true, - tx2: true, - }, - ) - - txsFromLane, remainingTxs, err := base.NewDefaultProposalHandler(lane).ProcessLaneHandler()(s.ctx, proposal) - s.Require().NoError(err) - s.Require().Len(txsFromLane, 2) - s.Require().Len(remainingTxs, 0) - - emptyProposal := proposals.NewProposal( - log.NewNopLogger(), - 100000, - 100000, - ) - - finalProposal, err := lane.ProcessLane(s.ctx, emptyProposal, proposal, block.NoOpProcessLanesHandler()) - s.Require().Len(finalProposal.Txs, 2) - s.Require().NoError(err) - - encodedTxs, err := utils.GetEncodedTxs(s.encodingConfig.TxConfig.TxEncoder(), proposal) - s.Require().NoError(err) - s.Require().Equal(encodedTxs, finalProposal.Txs) - }) - - s.Run("should accept a proposal where transaction fees are not in order bc of sequence numbers with other txs", func() { - tx1, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[0], - 0, - 1, - 0, - 1, - sdk.NewCoin(s.gasTokenDenom, math.NewInt(10)), - ) - s.Require().NoError(err) - - tx2, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[0], - 1, - 0, - 0, - 0, - sdk.NewCoin(s.gasTokenDenom, math.NewInt(20)), - ) - s.Require().NoError(err) - - tx3, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[1], - 0, - 1, - 0, - 1, - sdk.NewCoin(s.gasTokenDenom, math.NewInt(3)), - ) - s.Require().NoError(err) - - proposal := []sdk.Tx{ - tx1, - tx2, // This transaction has a higher sequence number and higher fees - tx3, - } - - lane := s.initLane( - math.LegacyOneDec(), - map[sdk.Tx]bool{ - tx1: true, - tx2: true, - tx3: true, - }, - ) - - // - txsFromLane, remainingTxs, err := base.NewDefaultProposalHandler(lane).ProcessLaneHandler()(s.ctx, proposal) - s.Require().NoError(err) - s.Require().Len(txsFromLane, 3) - s.Require().Len(remainingTxs, 0) - - emptyProposal := proposals.NewProposal( - log.NewNopLogger(), - 100000, - 100000, - ) - - finalProposal, err := lane.ProcessLane(s.ctx, emptyProposal, proposal, block.NoOpProcessLanesHandler()) - s.Require().Len(finalProposal.Txs, 3) - s.Require().NoError(err) - - encodedTxs, err := utils.GetEncodedTxs(s.encodingConfig.TxConfig.TxEncoder(), proposal) - s.Require().NoError(err) - s.Require().Equal(encodedTxs, finalProposal.Txs) - }) - - s.Run("accepts proposal with multiple senders and seq nums", func() { - tx1, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[0], - 0, - 1, - 0, - 1, - sdk.NewCoin(s.gasTokenDenom, math.NewInt(10)), - ) - s.Require().NoError(err) - - tx2, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[0], - 1, - 0, - 0, - 0, - sdk.NewCoin(s.gasTokenDenom, math.NewInt(20)), - ) - s.Require().NoError(err) - - tx3, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[1], - 0, - 1, - 0, - 1, - sdk.NewCoin(s.gasTokenDenom, math.NewInt(9)), - ) - s.Require().NoError(err) - - tx4, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[1], - 1, - 1, - 0, - 1, - sdk.NewCoin(s.gasTokenDenom, math.NewInt(11)), - ) - s.Require().NoError(err) - - proposal := []sdk.Tx{ - tx1, - tx2, - tx3, - tx4, - } - - lane := s.initLane( - math.LegacyOneDec(), - map[sdk.Tx]bool{ - tx1: true, - tx2: true, - tx3: true, - tx4: true, - }, - ) - - txsFromLane, remainingTxs, err := base.NewDefaultProposalHandler(lane).ProcessLaneHandler()(s.ctx, proposal) - s.Require().NoError(err) - s.Require().Len(txsFromLane, 4) - s.Require().Len(remainingTxs, 0) - - emptyProposal := proposals.NewProposal( - log.NewNopLogger(), - 100000, - 100000, - ) - - finalProposal, err := lane.ProcessLane(s.ctx, emptyProposal, proposal, block.NoOpProcessLanesHandler()) - s.Require().Len(finalProposal.Txs, 4) - s.Require().NoError(err) - - encodedTxs, err := utils.GetEncodedTxs(s.encodingConfig.TxConfig.TxEncoder(), proposal) - s.Require().NoError(err) - s.Require().Equal(encodedTxs, finalProposal.Txs) - }) - - s.Run("should accept a proposal with a single valid transaction", func() { - tx1, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[0], - 0, - 1, - 0, - 1, - ) - s.Require().NoError(err) - - proposal := []sdk.Tx{ - tx1, - } - - lane := s.initLane( - math.LegacyOneDec(), - map[sdk.Tx]bool{ - tx1: true, - }, - ) - - txsFromLane, remainingTxs, err := base.NewDefaultProposalHandler(lane).ProcessLaneHandler()(s.ctx, proposal) - s.Require().NoError(err) - s.Require().Len(txsFromLane, 1) - s.Require().Len(remainingTxs, 0) - - emptyProposal := proposals.NewProposal( - log.NewNopLogger(), - 100000, - 100000, - ) - - finalProposal, err := lane.ProcessLane(s.ctx, emptyProposal, proposal, block.NoOpProcessLanesHandler()) - s.Require().Len(finalProposal.Txs, 1) - s.Require().NoError(err) - - encodedTxs, err := utils.GetEncodedTxs(s.encodingConfig.TxConfig.TxEncoder(), proposal) - s.Require().NoError(err) - s.Require().Equal(encodedTxs, finalProposal.Txs) - }) - - s.Run("should not accept a proposal with invalid transactions", func() { - tx1, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[0], - 0, - 1, - 0, - 1, - ) - s.Require().NoError(err) - - proposal := []sdk.Tx{ - tx1, - } - - lane := s.initLane( - math.LegacyOneDec(), - map[sdk.Tx]bool{ - tx1: false, - }, - ) - - txsFromLane, remainingTxs, err := base.NewDefaultProposalHandler(lane).ProcessLaneHandler()(s.ctx, proposal) - s.Require().Error(err) - s.Require().Len(txsFromLane, 0) - s.Require().Len(remainingTxs, 0) - - emptyProposal := proposals.NewProposal( - log.NewNopLogger(), - 100000, - 100000, - ) - - _, err = lane.ProcessLane(s.ctx, emptyProposal, proposal, block.NoOpProcessLanesHandler()) - s.Require().Error(err) - }) - - s.Run("should not accept a proposal with some invalid transactions", func() { - tx1, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[0], - 0, - 1, - 0, - 1, - ) - s.Require().NoError(err) - - tx2, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[1], - 0, - 1, - 0, - 1, - ) - s.Require().NoError(err) - - tx3, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[2], - 0, - 1, - 0, - 1, - ) - s.Require().NoError(err) - - proposal := []sdk.Tx{ - tx1, - tx2, - tx3, - } - - lane := s.initLane( - math.LegacyOneDec(), - map[sdk.Tx]bool{ - tx1: true, - tx2: false, - tx3: true, - }, - ) - - txsFromLane, remainingTxs, err := base.NewDefaultProposalHandler(lane).ProcessLaneHandler()(s.ctx, proposal) - s.Require().Error(err) - s.Require().Len(txsFromLane, 0) - s.Require().Len(remainingTxs, 0) - - emptyProposal := proposals.NewProposal( - log.NewNopLogger(), - 100000, - 100000, - ) - - _, err = lane.ProcessLane(s.ctx, emptyProposal, proposal, block.NoOpProcessLanesHandler()) - s.Require().Error(err) - }) - - s.Run("should accept proposal with transactions in correct order with same fees", func() { - tx1, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[0], - 0, - 1, - 0, - 1, - sdk.NewCoin(s.gasTokenDenom, math.NewInt(2)), - ) - s.Require().NoError(err) - - tx2, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[1], - 0, - 1, - 0, - 1, - sdk.NewCoin(s.gasTokenDenom, math.NewInt(2)), - ) - s.Require().NoError(err) - - proposal := []sdk.Tx{ - tx1, - tx2, - } - - lane := s.initLane( - math.LegacyOneDec(), - map[sdk.Tx]bool{ - tx1: true, - tx2: true, - }, - ) - - txsFromLane, remainingTxs, err := base.NewDefaultProposalHandler(lane).ProcessLaneHandler()(s.ctx, proposal) - s.Require().NoError(err) - s.Require().Len(txsFromLane, 2) - s.Require().Len(remainingTxs, 0) - - emptyProposal := proposals.NewProposal( - log.NewNopLogger(), - 100000, - 100000, - ) - - finalProposal, err := lane.ProcessLane(s.ctx, emptyProposal, proposal, block.NoOpProcessLanesHandler()) - s.Require().Len(finalProposal.Txs, 2) - s.Require().NoError(err) - - encodedTxs, err := utils.GetEncodedTxs(s.encodingConfig.TxConfig.TxEncoder(), proposal) - s.Require().NoError(err) - s.Require().Equal(encodedTxs, finalProposal.Txs) - }) - - s.Run("should accept a proposal with transactions that are in any order fee wise", func() { - tx1, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[0], - 0, - 1, - 0, - 1, - sdk.NewCoin(s.gasTokenDenom, math.NewInt(1)), - ) - s.Require().NoError(err) - - tx2, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[1], - 0, - 1, - 0, - 1, - sdk.NewCoin(s.gasTokenDenom, math.NewInt(2)), - ) - s.Require().NoError(err) - - proposal := []sdk.Tx{ - tx1, - tx2, - } - - lane := s.initLane( - math.LegacyOneDec(), - map[sdk.Tx]bool{ - tx1: true, - tx2: true, - }, - ) - - txsFromLane, remainingTxs, err := base.NewDefaultProposalHandler(lane).ProcessLaneHandler()(s.ctx, proposal) - s.Require().NoError(err) - s.Require().Len(txsFromLane, 2) - s.Require().Len(remainingTxs, 0) - - emptyProposal := proposals.NewProposal( - log.NewNopLogger(), - 100000, - 100000, - ) - - _, err = lane.ProcessLane(s.ctx, emptyProposal, proposal, block.NoOpProcessLanesHandler()) - s.Require().NoError(err) - }) - - s.Run("should not accept proposal where transactions from lane are not contiguous from the start", func() { - tx1, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[0], - 0, - 2, - 0, - 1, - sdk.NewCoin(s.gasTokenDenom, math.NewInt(1)), - ) - s.Require().NoError(err) - - tx2, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[1], - 0, - 1, - 0, - 1, - sdk.NewCoin(s.gasTokenDenom, math.NewInt(2)), - ) - s.Require().NoError(err) - - // First lane matches this lane the other does not. - mh := func(ctx sdk.Context, tx sdk.Tx) bool { - return tx == tx1 - } - - lane := s.initLaneWithMatchHandlers( - math.LegacyOneDec(), - map[sdk.Tx]bool{ - tx1: true, - tx2: true, - }, - []base.MatchHandler{mh}, - ) - - proposal := []sdk.Tx{ - tx1, - tx2, - } - - txsFromLane, remainingTxs, err := base.NewDefaultProposalHandler(lane).ProcessLaneHandler()(s.ctx, proposal) - s.Require().Error(err) - s.Require().Len(txsFromLane, 0) - s.Require().Len(remainingTxs, 0) - - emptyProposal := proposals.NewProposal( - log.NewNopLogger(), - 100000, - 100000, - ) - - _, err = lane.ProcessLane(s.ctx, emptyProposal, proposal, block.NoOpProcessLanesHandler()) - s.Require().Error(err) - }) - - s.Run("should not accept a proposal that builds too large of a partial block", func() { - tx1, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[0], - 0, - 1, - 0, - 1, - ) - s.Require().NoError(err) - - proposal := []sdk.Tx{ - tx1, - } - - lane := s.initLane( - math.LegacyOneDec(), - map[sdk.Tx]bool{ - tx1: true, - }, - ) - - txsFromLane, remainingTxs, err := base.NewDefaultProposalHandler(lane).ProcessLaneHandler()(s.ctx, proposal) - s.Require().NoError(err) - s.Require().Len(txsFromLane, 1) - s.Require().Len(remainingTxs, 0) - - // Set the size to be 1 less than the size of the transaction - maxSize := s.getTxSize(tx1) - 1 - emptyProposal := proposals.NewProposal( - log.NewNopLogger(), - maxSize, - 1000000, - ) - - _, err = lane.ProcessLane(s.ctx, emptyProposal, proposal, block.NoOpProcessLanesHandler()) - s.Require().Error(err) - }) - - s.Run("should not accept a proposal that builds a partial block that is too gas consumptive", func() { - tx1, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[0], - 0, - 1, - 0, - 10, - ) - s.Require().NoError(err) - - proposal := []sdk.Tx{ - tx1, - } - - lane := s.initLane( - math.LegacyOneDec(), - map[sdk.Tx]bool{ - tx1: true, - }, - ) - - txsFromLane, remainingTxs, err := base.NewDefaultProposalHandler(lane).ProcessLaneHandler()(s.ctx, proposal) - s.Require().NoError(err) - s.Require().Len(txsFromLane, 1) - s.Require().Len(remainingTxs, 0) - - maxSize := s.getTxSize(tx1) - emptyProposal := proposals.NewProposal( - log.NewNopLogger(), - maxSize, - 9, - ) - - _, err = lane.ProcessLane(s.ctx, emptyProposal, proposal, block.NoOpProcessLanesHandler()) - s.Require().Error(err) - }) - - s.Run("should not accept a proposal that builds a partial block that is too gas consumptive p2", func() { - tx1, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[0], - 0, - 1, - 0, - 10, - ) - s.Require().NoError(err) - - tx2, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[1], - 0, - 1, - 0, - 10, - ) - s.Require().NoError(err) - - proposal := []sdk.Tx{ - tx1, - tx2, - } - - lane := s.initLane( - math.LegacyOneDec(), - map[sdk.Tx]bool{ - tx1: true, - tx2: true, - }, - ) - - txsFromLane, remainingTxs, err := base.NewDefaultProposalHandler(lane).ProcessLaneHandler()(s.ctx, proposal) - s.Require().NoError(err) - s.Require().Len(txsFromLane, 2) - s.Require().Len(remainingTxs, 0) - - maxSize := s.getTxSize(tx1) + s.getTxSize(tx2) - emptyProposal := proposals.NewProposal( - log.NewNopLogger(), - maxSize, - 19, - ) - - _, err = lane.ProcessLane(s.ctx, emptyProposal, proposal, block.NoOpProcessLanesHandler()) - s.Require().Error(err) - }) - - s.Run("should not accept a proposal that builds a partial block that is too large p2", func() { - tx1, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[0], - 0, - 1, - 0, - 10, - ) - s.Require().NoError(err) - - tx2, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[1], - 0, - 1, - 0, - 10, - ) - s.Require().NoError(err) - - proposal := []sdk.Tx{ - tx1, - tx2, - } - - lane := s.initLane( - math.LegacyOneDec(), - map[sdk.Tx]bool{ - tx1: true, - tx2: true, - }, - ) - - txsFromLane, remainingTxs, err := base.NewDefaultProposalHandler(lane).ProcessLaneHandler()(s.ctx, proposal) - s.Require().NoError(err) - s.Require().Len(txsFromLane, 2) - s.Require().Len(remainingTxs, 0) - - maxSize := s.getTxSize(tx1) + s.getTxSize(tx2) - 1 - emptyProposal := proposals.NewProposal( - log.NewNopLogger(), - maxSize, - 20, - ) - - _, err = lane.ProcessLane(s.ctx, emptyProposal, proposal, block.NoOpProcessLanesHandler()) - s.Require().Error(err) - }) - - s.Run("contiguous set of transactions should be accepted with other transactions that do not match", func() { - tx1, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[0], - 1, - 1, - 0, - 1, - ) - s.Require().NoError(err) - - tx2, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[1], - 2, - 1, - 0, - 1, - ) - s.Require().NoError(err) - - tx3, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[2], - 3, - 1, - 0, - 1, - ) - s.Require().NoError(err) - - tx4, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[3], - 4, - 1, - 0, - 1, - ) - s.Require().NoError(err) - - proposal := []sdk.Tx{ - tx1, - tx2, - tx3, - tx4, - } - - mh := func(ctx sdk.Context, tx sdk.Tx) bool { - if tx == tx1 || tx == tx2 { - return false - } - - return true - } - - lane := s.initLaneWithMatchHandlers( - math.LegacyOneDec(), - map[sdk.Tx]bool{ - tx1: true, - tx2: true, - }, - []base.MatchHandler{mh}, - ) - - txsFromLane, remainingTxs, err := base.NewDefaultProposalHandler(lane).ProcessLaneHandler()(s.ctx, proposal) - s.Require().NoError(err) - s.Require().Len(txsFromLane, 2) - s.Require().Len(remainingTxs, 2) - s.Require().Equal([]sdk.Tx{tx3, tx4}, remainingTxs) - - emptyProposal := proposals.NewProposal( - log.NewNopLogger(), - 1000, - 1000, - ) - - finalProposal, err := lane.ProcessLane(s.ctx, emptyProposal, proposal, block.NoOpProcessLanesHandler()) - s.Require().NoError(err) - s.Require().Len(finalProposal.Txs, 2) - - encodedTxs, err := utils.GetEncodedTxs(s.encodingConfig.TxConfig.TxEncoder(), []sdk.Tx{tx1, tx2}) - s.Require().NoError(err) - s.Require().Equal(encodedTxs, finalProposal.Txs) - }) - - s.Run("returns no error if transactions belong to a different lane", func() { - tx1, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[0], - 1, - 1, - 0, - 1, - ) - s.Require().NoError(err) - - tx2, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[1], - 2, - 1, - 0, - 1, - ) - s.Require().NoError(err) - - tx3, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[2], - 3, - 1, - 0, - 1, - ) - s.Require().NoError(err) - - tx4, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[3], - 4, - 1, - 0, - 1, - ) - s.Require().NoError(err) - - proposal := []sdk.Tx{ - tx1, - tx2, - tx3, - tx4, - } - - mh := func(ctx sdk.Context, tx sdk.Tx) bool { - return true - } - - lane := s.initLaneWithMatchHandlers( - math.LegacyOneDec(), - map[sdk.Tx]bool{}, - []base.MatchHandler{mh}, - ) - - txsFromLane, remainingTxs, err := base.NewDefaultProposalHandler(lane).ProcessLaneHandler()(s.ctx, proposal) - s.Require().NoError(err) - s.Require().Len(txsFromLane, 0) - s.Require().Len(remainingTxs, 4) - s.Require().Equal(proposal, remainingTxs) - - emptyProposal := proposals.NewProposal( - log.NewNopLogger(), - 1000, - 1000, - ) - - finalProposal, err := lane.ProcessLane(s.ctx, emptyProposal, proposal, block.NoOpProcessLanesHandler()) - s.Require().NoError(err) - s.Require().Len(finalProposal.Txs, 0) - }) - - s.Run("returns an error if transactions are interleaved with other lanes", func() { - tx1, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[0], - 1, - 1, - 0, - 1, - ) - s.Require().NoError(err) - - tx2, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[1], - 2, - 1, - 0, - 1, - ) - s.Require().NoError(err) - - tx3, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[2], - 3, - 1, - 0, - 1, - ) - s.Require().NoError(err) - - tx4, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[3], - 4, - 1, - 0, - 1, - ) - s.Require().NoError(err) - - proposal := []sdk.Tx{ - tx1, - tx2, - tx3, - tx4, - } - - mh := func(ctx sdk.Context, tx sdk.Tx) bool { - if tx == tx1 || tx == tx3 { - return false - } - - return true - } - - lane := s.initLaneWithMatchHandlers( - math.LegacyOneDec(), - map[sdk.Tx]bool{ - tx1: true, - tx2: true, - tx3: true, - tx4: true, - }, - []base.MatchHandler{mh}, - ) - - txsFromLane, remainingTxs, err := base.NewDefaultProposalHandler(lane).ProcessLaneHandler()(s.ctx, proposal) - s.Require().Error(err) - s.Require().Len(txsFromLane, 0) - s.Require().Len(remainingTxs, 0) - - emptyProposal := proposals.NewProposal( - log.NewNopLogger(), - 1000, - 1000, - ) - - _, err = lane.ProcessLane(s.ctx, emptyProposal, proposal, block.NoOpProcessLanesHandler()) - s.Require().Error(err) - }) -} - -func (s *BaseTestSuite) TestPrepareProcessParity() { - txsToInsert := []sdk.Tx{} - validationMap := make(map[sdk.Tx]bool) - numTxsPerAccount := uint64(50) - accounts := testutils.RandomAccounts(s.random, 50) - - for _, account := range accounts { - for nonce := uint64(0); nonce < numTxsPerAccount; nonce++ { - // create a random fee amount - feeAmount := math.NewInt(int64(rand.Intn(100000))) - tx, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - account, - nonce, - 1, - 0, - 1, - sdk.NewCoin(s.gasTokenDenom, feeAmount), - ) - s.Require().NoError(err) - - txsToInsert = append(txsToInsert, tx) - validationMap[tx] = true - } - } - - // Add the transactions to the lane - lane := s.initLane(math.LegacyOneDec(), validationMap) - for _, tx := range txsToInsert { - s.Require().NoError(lane.Insert(s.ctx, tx)) - } - - // Retrieve the transactions from the lane in the same way the prepare function would. - retrievedTxs := []sdk.Tx{} - for iterator := lane.Select(context.Background(), nil); iterator != nil; iterator = iterator.Next() { - retrievedTxs = append(retrievedTxs, iterator.Tx()) - } - s.Require().Equal(len(txsToInsert), len(retrievedTxs)) - - // Construct a block proposal with the transactions in the mempool - emptyProposal := proposals.NewProposal( - log.NewNopLogger(), - 1000000000000000, - 1000000000000000, - ) - proposal, err := lane.PrepareLane(s.ctx, emptyProposal, block.NoOpPrepareLanesHandler()) - s.Require().NoError(err) - s.Require().Equal(len(retrievedTxs), len(proposal.Txs)) - - // Ensure that the transactions are in the same order - for i := 0; i < len(retrievedTxs); i++ { - bz, err := s.encodingConfig.TxConfig.TxEncoder()(retrievedTxs[i]) - s.Require().NoError(err) - s.Require().Equal(bz, proposal.Txs[i]) - } - - decodedTxs, err := utils.GetDecodedTxs(s.encodingConfig.TxConfig.TxDecoder(), proposal.Txs) - s.Require().NoError(err) - - // Verify the same proposal with the process lanes handler - emptyProposal = proposals.NewProposal( - log.NewNopLogger(), - 1000000000000000, - 1000000000000000, - ) - proposal, err = lane.ProcessLane(s.ctx, emptyProposal, decodedTxs, block.NoOpProcessLanesHandler()) - s.Require().NoError(err) - s.Require().Equal(len(txsToInsert), len(proposal.Txs)) - s.T().Logf("proposal num txs: %d", len(proposal.Txs)) - - // Ensure that the transactions are in the same order - for i := 0; i < len(retrievedTxs); i++ { - bz, err := s.encodingConfig.TxConfig.TxEncoder()(retrievedTxs[i]) - s.Require().NoError(err) - s.Require().Equal(bz, proposal.Txs[i]) - } -} - -func (s *BaseTestSuite) TestIterateMempoolAndProcessProposalParity() { - txsToInsert := []sdk.Tx{} - validationMap := make(map[sdk.Tx]bool) - numTxsPerAccount := uint64(200) - accounts := testutils.RandomAccounts(s.random, 50) - - for _, account := range accounts { - for nonce := uint64(0); nonce < numTxsPerAccount; nonce++ { - // create a random fee amount - feeAmount := math.NewInt(int64(rand.Intn(100000))) - tx, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - account, - nonce, - 1, - 0, - 1, - sdk.NewCoin(s.gasTokenDenom, feeAmount), - ) - s.Require().NoError(err) - - txsToInsert = append(txsToInsert, tx) - validationMap[tx] = true - } - } - - // Add the transactions to the lane - lane := s.initLane(math.LegacyOneDec(), validationMap) - for _, tx := range txsToInsert { - s.Require().NoError(lane.Insert(s.ctx, tx)) - } - - // Retrieve the transactions from the lane in the same way the prepare function would. - retrievedTxs := []sdk.Tx{} - for iterator := lane.Select(context.Background(), nil); iterator != nil; iterator = iterator.Next() { - retrievedTxs = append(retrievedTxs, iterator.Tx()) - } - - s.Require().Equal(len(txsToInsert), len(retrievedTxs)) - - emptyProposal := proposals.NewProposal( - log.NewNopLogger(), - 1000000000000000, - 1000000000000000, - ) - - proposal, err := lane.ProcessLane(s.ctx, emptyProposal, retrievedTxs, block.NoOpProcessLanesHandler()) - s.Require().NoError(err) - s.Require().Equal(len(retrievedTxs), len(proposal.Txs)) - s.T().Logf("proposal num txs: %d", len(proposal.Txs)) - - // Ensure that the transactions are in the same order - for i := 0; i < len(retrievedTxs); i++ { - bz, err := s.encodingConfig.TxConfig.TxEncoder()(retrievedTxs[i]) - s.Require().NoError(err) - s.Require().Equal(bz, proposal.Txs[i]) - } -} - -func (s *BaseTestSuite) initLane( - maxBlockSpace math.LegacyDec, - expectedExecution map[sdk.Tx]bool, -) *base.BaseLane { - config := base.NewLaneConfig( - log.NewNopLogger(), - s.encodingConfig.TxConfig.TxEncoder(), - s.encodingConfig.TxConfig.TxDecoder(), - s.setUpAnteHandler(expectedExecution), - signer_extraction.NewDefaultAdapter(), - maxBlockSpace, - ) - - return defaultlane.NewDefaultLane(config, base.DefaultMatchHandler()) -} - -func (s *BaseTestSuite) initLaneWithMatchHandlers( - maxBlockSpace math.LegacyDec, - expectedExecution map[sdk.Tx]bool, - matchHandlers []base.MatchHandler, -) *base.BaseLane { - config := base.NewLaneConfig( - log.NewNopLogger(), - s.encodingConfig.TxConfig.TxEncoder(), - s.encodingConfig.TxConfig.TxDecoder(), - s.setUpAnteHandler(expectedExecution), - signer_extraction.NewDefaultAdapter(), - maxBlockSpace, - ) - - mh := base.NewMatchHandler(base.DefaultMatchHandler(), matchHandlers...) - - return defaultlane.NewDefaultLane(config, mh) -} - -func (s *BaseTestSuite) setUpAnteHandler(expectedExecution map[sdk.Tx]bool) sdk.AnteHandler { - txCache := make(map[string]bool) - for tx, pass := range expectedExecution { - bz, err := s.encodingConfig.TxConfig.TxEncoder()(tx) - s.Require().NoError(err) - - hash := sha256.Sum256(bz) - hashStr := hex.EncodeToString(hash[:]) - txCache[hashStr] = pass - } - - anteHandler := func(ctx sdk.Context, tx sdk.Tx, simulate bool) (newCtx sdk.Context, err error) { - bz, err := s.encodingConfig.TxConfig.TxEncoder()(tx) - s.Require().NoError(err) - - hash := sha256.Sum256(bz) - hashStr := hex.EncodeToString(hash[:]) - - pass, found := txCache[hashStr] - if !found { - return ctx, fmt.Errorf("tx not found") - } - - if pass { - return ctx, nil - } - - return ctx, fmt.Errorf("tx failed") - } - - return anteHandler -} - -func (s *BaseTestSuite) getTxSize(tx sdk.Tx) int64 { - txBz, err := s.encodingConfig.TxConfig.TxEncoder()(tx) - s.Require().NoError(err) - - return int64(len(txBz)) -} diff --git a/lanes/base/base_test.go b/lanes/base/base_test.go deleted file mode 100644 index 1c91547f..00000000 --- a/lanes/base/base_test.go +++ /dev/null @@ -1,41 +0,0 @@ -package base_test - -import ( - "math/rand" - "testing" - - storetypes "cosmossdk.io/store/types" - "github.com/cosmos/cosmos-sdk/testutil" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/suite" - - testutils "github.com/skip-mev/block-sdk/v2/testutils" - "github.com/skip-mev/block-sdk/v2/x/auction/types" -) - -type BaseTestSuite struct { - suite.Suite - - ctx sdk.Context - encodingConfig testutils.EncodingConfig - random *rand.Rand - accounts []testutils.Account - gasTokenDenom string -} - -func TestBaseTestSuite(t *testing.T) { - suite.Run(t, new(BaseTestSuite)) -} - -func (s *BaseTestSuite) SetupTest() { - // Set up basic TX encoding config. - s.encodingConfig = testutils.CreateTestEncodingConfig() - - // Create a few random accounts - s.random = rand.New(rand.NewSource(1)) - s.accounts = testutils.RandomAccounts(s.random, 5) - s.gasTokenDenom = "stake" - - key := storetypes.NewKVStoreKey(types.StoreKey) - s.ctx = testutil.DefaultContext(key, storetypes.NewTransientStoreKey("transient_key")) -} diff --git a/lanes/base/lane.go b/lanes/base/lane.go deleted file mode 100644 index 85fbc4a3..00000000 --- a/lanes/base/lane.go +++ /dev/null @@ -1,32 +0,0 @@ -package base - -import ( - "github.com/skip-mev/block-sdk/v2/block/base" -) - -const ( - // LaneName defines the name of the default lane. - LaneName = "default" -) - -// NewDefaultLane returns a new default lane. The DefaultLane defines a default -// lane implementation. The default lane orders transactions by the transaction fees. -// The default lane accepts any transaction. The default lane builds and verifies blocks -// in a similar fashion to how the CometBFT/Tendermint consensus engine builds and verifies -// blocks pre SDK version 0.47.0. -func NewDefaultLane(cfg base.LaneConfig, matchHandler base.MatchHandler) *base.BaseLane { - options := []base.LaneOption{ - base.WithMatchHandler(matchHandler), - } - - lane, err := base.NewBaseLane( - cfg, - LaneName, - options..., - ) - if err != nil { - panic(err) - } - - return lane -} diff --git a/lanes/base/mempool_test.go b/lanes/base/mempool_test.go deleted file mode 100644 index 8521c1a7..00000000 --- a/lanes/base/mempool_test.go +++ /dev/null @@ -1,289 +0,0 @@ -package base_test - -import ( - "cosmossdk.io/math" - sdk "github.com/cosmos/cosmos-sdk/types" - - signer_extraction "github.com/skip-mev/block-sdk/v2/adapters/signer_extraction_adapter" - "github.com/skip-mev/block-sdk/v2/block/base" - testutils "github.com/skip-mev/block-sdk/v2/testutils" -) - -func (s *BaseTestSuite) TestCompareTxPriority() { - lane := s.initLane(math.LegacyOneDec(), nil) - - s.Run("should return -1 when signers are the same but the first tx has a higher sequence", func() { - tx1, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[0], - 1, - 0, - 0, - 0, - sdk.NewCoin(s.gasTokenDenom, math.NewInt(100)), - ) - s.Require().NoError(err) - - tx2, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[0], - 0, - 0, - 0, - 0, - sdk.NewCoin(s.gasTokenDenom, math.NewInt(100)), - ) - s.Require().NoError(err) - - cmp, err := lane.Compare(sdk.Context{}, tx1, tx2) - s.Require().NoError(err) - s.Require().Equal(-1, cmp) - }) - - s.Run("should return 1 when signers are the same but the second tx has a higher sequence", func() { - tx1, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[0], - 0, - 0, - 0, - 0, - sdk.NewCoin(s.gasTokenDenom, math.NewInt(100)), - ) - s.Require().NoError(err) - - tx2, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[0], - 1, - 0, - 0, - 0, - sdk.NewCoin(s.gasTokenDenom, math.NewInt(100)), - ) - s.Require().NoError(err) - - cmp, err := lane.Compare(sdk.Context{}, tx1, tx2) - s.Require().NoError(err) - s.Require().Equal(1, cmp) - }) - - s.Run("should return 0 when signers are the same and the sequence is the same", func() { - tx1, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[0], - 1, - 0, - 0, - 0, - sdk.NewCoin(s.gasTokenDenom, math.NewInt(100)), - ) - s.Require().NoError(err) - - tx2, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[0], - 1, - 0, - 0, - 0, - sdk.NewCoin(s.gasTokenDenom, math.NewInt(100)), - ) - s.Require().NoError(err) - - _, err = lane.Compare(sdk.Context{}, tx1, tx2) - s.Require().Error(err) - }) - - s.Run("should return 0 when the first tx has a higher fee", func() { - tx1, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[0], - 0, - 0, - 0, - 0, - sdk.NewCoin(s.gasTokenDenom, math.NewInt(200)), - ) - s.Require().NoError(err) - - tx2, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[1], - 0, - 0, - 0, - 0, - sdk.NewCoin(s.gasTokenDenom, math.NewInt(100)), - ) - s.Require().NoError(err) - - cmp, err := lane.Compare(sdk.Context{}, tx1, tx2) - s.Require().NoError(err) - s.Require().Equal(0, cmp) - }) -} - -func (s *BaseTestSuite) TestInsert() { - mempool := base.NewMempool(base.DefaultTxPriority(), s.encodingConfig.TxConfig.TxEncoder(), signer_extraction.NewDefaultAdapter(), 3) - - s.Run("should be able to insert a transaction", func() { - tx, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[0], - 0, - 0, - 0, - 0, - sdk.NewCoin(s.gasTokenDenom, math.NewInt(100)), - ) - s.Require().NoError(err) - - err = mempool.Insert(sdk.Context{}, tx) - s.Require().NoError(err) - s.Require().True(mempool.Contains(tx)) - }) - - s.Run("cannot insert more transactions than the max", func() { - for i := 0; i < 3; i++ { - tx, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[0], - uint64(i), - 0, - 0, - 0, - sdk.NewCoin(s.gasTokenDenom, math.NewInt(int64(100*i))), - ) - s.Require().NoError(err) - - err = mempool.Insert(sdk.Context{}, tx) - s.Require().NoError(err) - s.Require().True(mempool.Contains(tx)) - } - - tx, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[0], - 10, - 0, - 0, - 0, - sdk.NewCoin(s.gasTokenDenom, math.NewInt(100)), - ) - s.Require().NoError(err) - - err = mempool.Insert(sdk.Context{}, tx) - s.Require().Error(err) - s.Require().False(mempool.Contains(tx)) - }) -} - -func (s *BaseTestSuite) TestRemove() { - mempool := base.NewMempool(base.DefaultTxPriority(), s.encodingConfig.TxConfig.TxEncoder(), signer_extraction.NewDefaultAdapter(), 3) - - s.Run("should be able to remove a transaction", func() { - tx, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[0], - 0, - 0, - 0, - 0, - sdk.NewCoin(s.gasTokenDenom, math.NewInt(100)), - ) - s.Require().NoError(err) - - err = mempool.Insert(sdk.Context{}, tx) - s.Require().NoError(err) - s.Require().True(mempool.Contains(tx)) - - mempool.Remove(tx) - s.Require().False(mempool.Contains(tx)) - }) - - s.Run("should not error when removing a transaction that does not exist", func() { - tx, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[0], - 0, - 0, - 0, - 0, - sdk.NewCoin(s.gasTokenDenom, math.NewInt(100)), - ) - s.Require().NoError(err) - - mempool.Remove(tx) - }) -} - -func (s *BaseTestSuite) TestSelect() { - s.Run("should be able to select transactions in the correct order", func() { - mempool := base.NewMempool(base.DefaultTxPriority(), s.encodingConfig.TxConfig.TxEncoder(), signer_extraction.NewDefaultAdapter(), 3) - - tx1, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[1], - 0, - 0, - 0, - 0, - sdk.NewCoin(s.gasTokenDenom, math.NewInt(100)), - ) - s.Require().NoError(err) - - tx2, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[1], - 1, - 0, - 0, - 0, - sdk.NewCoin(s.gasTokenDenom, math.NewInt(200)), - ) - s.Require().NoError(err) - - // Insert the transactions into the mempool - s.Require().NoError(mempool.Insert(sdk.Context{}, tx1)) - s.Require().NoError(mempool.Insert(sdk.Context{}, tx2)) - s.Require().Equal(2, mempool.CountTx()) - - // Check that the transactions are in the correct order - iterator := mempool.Select(sdk.Context{}, nil) - s.Require().NotNil(iterator) - s.Require().Equal(tx1, iterator.Tx()) - - // Check the second transaction - iterator = iterator.Next() - s.Require().NotNil(iterator) - s.Require().Equal(tx2, iterator.Tx()) - }) - - s.Run("should be able to select a single transaction", func() { - mempool := base.NewMempool(base.DefaultTxPriority(), s.encodingConfig.TxConfig.TxEncoder(), signer_extraction.NewDefaultAdapter(), 3) - - tx1, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - s.accounts[0], - 0, - 0, - 0, - 0, - sdk.NewCoin(s.gasTokenDenom, math.NewInt(100)), - ) - s.Require().NoError(err) - - // Insert the transactions into the mempool - s.Require().NoError(mempool.Insert(sdk.Context{}, tx1)) - s.Require().Equal(1, mempool.CountTx()) - - // Check that the transactions are in the correct order - iterator := mempool.Select(sdk.Context{}, nil) - s.Require().NotNil(iterator) - s.Require().Equal(tx1, iterator.Tx()) - - iterator = iterator.Next() - s.Require().Nil(iterator) - }) -} diff --git a/lanes/base/tx_info_test.go b/lanes/base/tx_info_test.go deleted file mode 100644 index 78b992c5..00000000 --- a/lanes/base/tx_info_test.go +++ /dev/null @@ -1,85 +0,0 @@ -package base_test - -import ( - "math/rand" - - "cosmossdk.io/math" - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/skip-mev/block-sdk/v2/testutils" -) - -func (s *BaseTestSuite) TestGetTxInfo() { - accounts := testutils.RandomAccounts(rand.New(rand.NewSource(1)), 3) - lane := s.initLane(math.LegacyOneDec(), nil) - - s.Run("can retrieve information for a default tx", func() { - signer := accounts[0] - nonce := uint64(1) - fee := sdk.NewCoins(sdk.NewCoin(s.gasTokenDenom, math.NewInt(100))) - gasLimit := uint64(100) - - tx, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - signer, - nonce, - 1, - 0, - gasLimit, - fee..., - ) - s.Require().NoError(err) - - txInfo, err := lane.GetTxInfo(s.ctx, tx) - s.Require().NoError(err) - s.Require().NotEmpty(txInfo.Hash) - - // Verify the signers - s.Require().Len(txInfo.Signers, 1) - s.Require().Equal(signer.Address.String(), txInfo.Signers[0].Signer.String()) - s.Require().Equal(nonce, txInfo.Signers[0].Sequence) - - // Verify the gas limit - s.Require().Equal(gasLimit, txInfo.GasLimit) - - // Verify the bytes - txBz, err := s.encodingConfig.TxConfig.TxEncoder()(tx) - s.Require().NoError(err) - s.Require().Equal(txBz, txInfo.TxBytes) - - // Verify the size - s.Require().Equal(int64(len(txBz)), txInfo.Size) - }) - - s.Run("can retrieve information with different fees", func() { - signer := accounts[1] - nonce := uint64(10) - fee := sdk.NewCoins(sdk.NewCoin(s.gasTokenDenom, math.NewInt(20000))) - gasLimit := uint64(10000000) - - tx, err := testutils.CreateRandomTx( - s.encodingConfig.TxConfig, - signer, - nonce, - 10, - 0, - gasLimit, - fee..., - ) - s.Require().NoError(err) - - txInfo, err := lane.GetTxInfo(s.ctx, tx) - s.Require().NoError(err) - s.Require().NotEmpty(txInfo.Hash) - - // Verify the signers - s.Require().Len(txInfo.Signers, 1) - s.Require().Equal(signer.Address.String(), txInfo.Signers[0].Signer.String()) - s.Require().Equal(nonce, txInfo.Signers[0].Sequence) - - // Verify the bytes - txBz, err := s.encodingConfig.TxConfig.TxEncoder()(tx) - s.Require().NoError(err) - s.Require().Equal(txBz, txInfo.TxBytes) - }) -} diff --git a/lanes/free/README.md b/lanes/free/README.md deleted file mode 100644 index 3b5dbcd0..00000000 --- a/lanes/free/README.md +++ /dev/null @@ -1,130 +0,0 @@ -# 🏗️ Free Lane Setup - -## 📦 Dependencies - -The Block SDK is built on top of the Cosmos SDK. The Block SDK is currently -compatible with Cosmos SDK versions greater than or equal to `v0.47.0`. - -## 📥 Installation - -To install the Block SDK, run the following command: - -```bash -$ go install github.com/skip-mev/block-sdk -``` - -## 📚 Usage - -> Note: Please visit [app.go](../../tests/app/lanes.go) to see a sample base app set up. - -1. First determine the set of lanes that you want to use in your application. The -available lanes can be found in our -[Lane App Store](https://docs.skip.money/chains/lanes/existing-lanes/default). -In your base application, you will need to create a `LanedMempool` composed of the -lanes you want to use. *The free lane should not exist on its own. At minimum, it -is recommended that the free lane is paired with the default lane.* -2. Next, order the lanes by priority. The first lane is the highest priority lane -and the last lane is the lowest priority lane. -3. Set up your `FeeDeductorDecorator` to ignore the free lane where ever you -initialize your `AnteHandler`. This will ensure that the free lane is not -subject to deducting transaction fees. -4. You will also need to create a `PrepareProposalHandler` and a -`ProcessProposalHandler` that will be responsible for preparing and processing -proposals respectively. Configure the order of the lanes in the -`PrepareProposalHandler` and `ProcessProposalHandler` to match the order of the -lanes in the `LanedMempool`. - -NOTE: This example walks through setting up the Free and Default lanes. - -```golang -import ( - "github.com/skip-mev/block-sdk/abci" - "github.com/skip-mev/block-sdk/block/base" - defaultlane "github.com/skip-mev/block-sdk/lanes/base" - freelane "github.com/skip-mev/block-sdk/lanes/free" -) - -... - -func NewApp() { - ... - // 1. Create the lanes. - // - // NOTE: The lanes are ordered by priority. The first lane is the highest priority - // lane and the last lane is the lowest priority lane. - // - // For more information on how to utilize the LaneConfig please - // visit the README in docs.skip.money/chains/lanes/build-your-own-lane#-lane-config. - // - // Set up the configuration of the free lane and instantiate it. - freeConfig := base.LaneConfig{ - Logger: app.Logger(), - TxEncoder: app.txConfig.TxEncoder(), - TxDecoder: app.txConfig.TxDecoder(), - MaxBlockSpace: math.LegacyZeroDec(), - MaxTxs: 0, - } - freeLane := freelane.NewFreeLane(freeConfig, base.DefaultTxPriority(), freelane.DefaultMatchHandler()) - - // Default lane accepts all transactions. - defaultConfig := base.LaneConfig{ - Logger: app.Logger(), - TxEncoder: app.txConfig.TxEncoder(), - TxDecoder: app.txConfig.TxDecoder(), - MaxBlockSpace: math.LegacyZeroDec(), - MaxTxs: 0, - } - defaultLane := defaultlane.NewDefaultLane(defaultConfig, base.DefaultMatchHandler()) - - // 2. Set up the relative priority of lanes - lanes := []block.Lane{ - freeLane, - defaultLane, - } - mempool := block.NewLanedMempool(app.Logger(), lanes) - app.App.SetMempool(mempool) - - ... - - // 3. Set up the ante handler. - // - // This will allow any transaction that matches the to the free lane to - // be processed without paying any fees. - anteDecorators := []sdk.AnteDecorator{ - ante.NewSetUpContextDecorator(), - ... - utils.NewIgnoreDecorator( - ante.NewDeductFeeDecorator( - options.BaseOptions.AccountKeeper, - options.BaseOptions.BankKeeper, - options.BaseOptions.FeegrantKeeper, - options.BaseOptions.TxFeeChecker, - ), - options.FreeLane, - ), - ... - } - - anteHandler := sdk.ChainAnteDecorators(anteDecorators...) - - // Set the lane ante handlers on the lanes. - // - // NOTE: This step is very important. Without the antehandlers, lanes will not - // be able to verify transactions. - for _, lane := range lanes { - lane.SetAnteHandler(anteHandler) - } - app.App.SetAnteHandler(anteHandler) - - // 4. Set the abci handlers on base app - proposalHandler := abci.NewProposalHandler( - app.Logger(), - app.TxConfig().TxDecoder(), - mempool, - ) - app.App.SetPrepareProposal(proposalHandler.PrepareProposalHandler()) - app.App.SetProcessProposal(proposalHandler.ProcessProposalHandler()) - - ... -} -``` diff --git a/lanes/free/lane.go b/lanes/free/lane.go deleted file mode 100644 index 99e031d9..00000000 --- a/lanes/free/lane.go +++ /dev/null @@ -1,56 +0,0 @@ -package free - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/staking/types" - - "github.com/skip-mev/block-sdk/v2/block/base" -) - -const ( - // LaneName defines the name of the free lane. - LaneName = "free" -) - -// NewFreeLane returns a new free lane. -func NewFreeLane[C comparable]( - cfg base.LaneConfig, - txPriority base.TxPriority[C], - matchFn base.MatchHandler, -) *base.BaseLane { - options := []base.LaneOption{ - base.WithMatchHandler(matchFn), - base.WithMempoolConfigs[C](cfg, txPriority), - } - - lane, err := base.NewBaseLane( - cfg, - LaneName, - options..., - ) - if err != nil { - panic(err) - } - - return lane -} - -// DefaultMatchHandler returns the default match handler for the free lane. The -// default implementation matches transactions that are staking related. In particular, -// any transaction that is a MsgDelegate, MsgBeginRedelegate, or MsgCancelUnbondingDelegation. -func DefaultMatchHandler() base.MatchHandler { - return func(ctx sdk.Context, tx sdk.Tx) bool { - for _, msg := range tx.GetMsgs() { - switch msg.(type) { - case *types.MsgDelegate: - return true - case *types.MsgBeginRedelegate: - return true - case *types.MsgCancelUnbondingDelegation: - return true - } - } - - return false - } -} diff --git a/scripts/devnet/start.sh b/scripts/devnet/start.sh index d808657b..22a52609 100755 --- a/scripts/devnet/start.sh +++ b/scripts/devnet/start.sh @@ -126,7 +126,7 @@ sed -i -e 's/"is_source_chain": false/"is_source_chain": true/g' $CHAIN_DIR/$CHA echo "Starting $CHAINID in $CHAIN_DIR..." echo "Creating log file at $CHAIN_DIR/$CHAINID.log" -$BINARY start --log_level trace --log_format json --home $CHAIN_DIR/$CHAINID --pruning=nothing --grpc.address="0.0.0.0:$GRPCPORT" > $CHAIN_DIR/$CHAINID.log 2>&1 & +$BINARY start --log_level info --log_format json --home $CHAIN_DIR/$CHAINID --pruning=nothing --grpc.address="0.0.0.0:$GRPCPORT" > $CHAIN_DIR/$CHAINID.log 2>&1 & rm rly1.json &> /dev/null