From 02644bfc008257bca803c8746230758780e13670 Mon Sep 17 00:00:00 2001 From: Nikhil Vasan Date: Wed, 20 Sep 2023 14:24:43 -0700 Subject: [PATCH 1/3] add a signer-extraction-adapter --- abci/abci_test.go | 7 ++- .../signer_extraction_adapter.go | 50 +++++++++++++++++ .../signer_extraction_adapter_test.go | 54 +++++++++++++++++++ block/base/config.go | 11 ++++ block/base/mempool.go | 4 +- block/base/priority_nonce.go | 28 +++++----- block/mempool_test.go | 4 ++ go.sum | 40 ++++++++++++++ lanes/base/abci_test.go | 2 + lanes/base/lane.go | 1 + lanes/base/mempool_test.go | 9 ++-- lanes/free/lane.go | 1 + lanes/mev/lane.go | 1 + tests/app/app.go | 4 ++ x/auction/ante/ante_test.go | 3 ++ 15 files changed, 200 insertions(+), 19 deletions(-) create mode 100644 adapters/signer_extraction_adapter/signer_extraction_adapter.go create mode 100644 adapters/signer_extraction_adapter/signer_extraction_adapter_test.go diff --git a/abci/abci_test.go b/abci/abci_test.go index b12a9f9b..29da22af 100644 --- a/abci/abci_test.go +++ b/abci/abci_test.go @@ -16,6 +16,7 @@ import ( "github.com/stretchr/testify/suite" "github.com/skip-mev/block-sdk/abci" + signer_extraction "github.com/skip-mev/block-sdk/adapters/signer_extraction_adapter" "github.com/skip-mev/block-sdk/block" "github.com/skip-mev/block-sdk/block/base" defaultlane "github.com/skip-mev/block-sdk/lanes/base" @@ -738,6 +739,7 @@ func (s *ProposalsTestSuite) setUpStandardLane(maxBlockSpace math.LegacyDec, exp Logger: log.NewTestLogger(s.T()), TxEncoder: s.encodingConfig.TxConfig.TxEncoder(), TxDecoder: s.encodingConfig.TxConfig.TxDecoder(), + SignerExtractor: signer_extraction.NewDefaultSignerExtractionAdapter(), AnteHandler: s.setUpAnteHandler(expectedExecution), MaxBlockSpace: maxBlockSpace, } @@ -751,6 +753,7 @@ func (s *ProposalsTestSuite) setUpTOBLane(maxBlockSpace math.LegacyDec, expected TxEncoder: s.encodingConfig.TxConfig.TxEncoder(), TxDecoder: s.encodingConfig.TxConfig.TxDecoder(), AnteHandler: s.setUpAnteHandler(expectedExecution), + SignerExtractor: signer_extraction.NewDefaultSignerExtractionAdapter(), MaxBlockSpace: maxBlockSpace, } @@ -763,6 +766,7 @@ func (s *ProposalsTestSuite) setUpFreeLane(maxBlockSpace math.LegacyDec, expecte TxEncoder: s.encodingConfig.TxConfig.TxEncoder(), TxDecoder: s.encodingConfig.TxConfig.TxDecoder(), AnteHandler: s.setUpAnteHandler(expectedExecution), + SignerExtractor: signer_extraction.NewDefaultSignerExtractionAdapter(), MaxBlockSpace: maxBlockSpace, } @@ -774,13 +778,14 @@ func (s *ProposalsTestSuite) setUpPanicLane(maxBlockSpace math.LegacyDec) *base. Logger: log.NewTestLogger(s.T()), TxEncoder: s.encodingConfig.TxConfig.TxEncoder(), TxDecoder: s.encodingConfig.TxConfig.TxDecoder(), + SignerExtractor: signer_extraction.NewDefaultSignerExtractionAdapter(), MaxBlockSpace: maxBlockSpace, } lane := base.NewBaseLane( cfg, "panic", - base.NewMempool[string](base.DefaultTxPriority(), cfg.TxEncoder, 0), + base.NewMempool[string](base.DefaultTxPriority(), cfg.TxEncoder, signer_extraction.NewDefaultSignerExtractionAdapter(), 0), base.DefaultMatchHandler(), ) diff --git a/adapters/signer_extraction_adapter/signer_extraction_adapter.go b/adapters/signer_extraction_adapter/signer_extraction_adapter.go new file mode 100644 index 00000000..9f2af312 --- /dev/null +++ b/adapters/signer_extraction_adapter/signer_extraction_adapter.go @@ -0,0 +1,50 @@ +package signer_extraction + +import ( + "fmt" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/auth/signing" +) + +type SignerData struct { + Signer sdk.AccAddress + Sequence uint64 +} + +// SignerExtractionAdapter is an interface used to determine how the signers of a transaction should be extracted +// from the transaction. +type SignerExtractionAdapter interface { + GetSigners(sdk.Tx) ([]SignerData, error) +} + +var _ SignerExtractionAdapter = DefaultSignerExtractionAdapter{} + +// DefaultSignerExtractionAdapter is the default implementation of SignerExtractionAdapter. It extracts the signers +// from a cosmos-sdk tx via GetSignaturesV2. +type DefaultSignerExtractionAdapter struct {} + +func NewDefaultSignerExtractionAdapter() DefaultSignerExtractionAdapter { + return DefaultSignerExtractionAdapter{} +} + +func (DefaultSignerExtractionAdapter) GetSigners(tx sdk.Tx) ([]SignerData, error) { + sigTx, ok := tx.(signing.SigVerifiableTx) + if !ok { + return nil, fmt.Errorf("tx of type %T does not implement SigVerifiableTx", tx) + } + + sigs, err := sigTx.GetSignaturesV2() + if err != nil { + return nil, err + } + + signers := make([]SignerData, len(sigs)) + for i, sig := range sigs { + signers[i] = SignerData{ + Signer: sig.PubKey.Address().Bytes(), + Sequence: sig.Sequence, + } + } + + return signers, nil +} diff --git a/adapters/signer_extraction_adapter/signer_extraction_adapter_test.go b/adapters/signer_extraction_adapter/signer_extraction_adapter_test.go new file mode 100644 index 00000000..b3aca902 --- /dev/null +++ b/adapters/signer_extraction_adapter/signer_extraction_adapter_test.go @@ -0,0 +1,54 @@ +package signer_extraction_test + +import ( + "math/rand" + "testing" + + "cosmossdk.io/math" + "github.com/cosmos/cosmos-sdk/client" + sdk "github.com/cosmos/cosmos-sdk/types" + testutils "github.com/skip-mev/block-sdk/testutils" + "github.com/stretchr/testify/suite" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + signer_extraction "github.com/skip-mev/block-sdk/adapters/signer_extraction_adapter" +) + + +type SignerExtractionAdapterTestSuite struct { + suite.Suite + txConfig client.TxConfig + accts []testutils.Account + adapter signer_extraction.DefaultSignerExtractionAdapter +} + +func TestSignerExtractionAdapterTestSuite(t *testing.T) { + suite.Run(t, new(SignerExtractionAdapterTestSuite)) +} + +func (suite *SignerExtractionAdapterTestSuite) SetupTest() { + encodingConfig := testutils.CreateTestEncodingConfig() + suite.txConfig = encodingConfig.TxConfig + + accts := testutils.RandomAccounts(rand.New(rand.NewSource(1)), 2) + + suite.accts = accts +} + +func (s *SignerExtractionAdapterTestSuite) TestGetSigners() { + acct := s.accts[0] + tx, err := testutils.CreateTx(s.txConfig, acct, 1, 1, []sdk.Msg{ + &banktypes.MsgSend{ + FromAddress: acct.Address.String(), + ToAddress: acct.Address.String(), + Amount: sdk.NewCoins(sdk.NewInt64Coin("test", 1)), + }, + }, sdk.NewCoins(sdk.NewCoin("test", math.NewInt(1)))...) + s.Require().NoError(err) + + signers, err := s.adapter.GetSigners(tx) + s.Require().NoError(err) + + s.Require().Len(signers, 1) + s.Require().Equal(acct.Address.String(), signers[0].Signer.String()) + s.Require().Equal(uint64(1), signers[0].Sequence) +} diff --git a/block/base/config.go b/block/base/config.go index c2736604..d16e7a3d 100644 --- a/block/base/config.go +++ b/block/base/config.go @@ -7,6 +7,7 @@ import ( "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" + signer_extraction "github.com/skip-mev/block-sdk/adapters/signer_extraction_adapter" "github.com/skip-mev/block-sdk/block" ) @@ -17,6 +18,10 @@ type LaneConfig struct { TxDecoder sdk.TxDecoder AnteHandler sdk.AnteHandler + // SignerExtractor defines the interface used for extracting the expected signers of a transaction + // from the transaction. + SignerExtractor signer_extraction.SignerExtractionAdapter + // MaxBlockSpace defines the relative percentage of block space that can be // used by this lane. NOTE: If this is set to zero, then there is no limit // on the number of transactions that can be included in the block for this @@ -47,6 +52,7 @@ func NewLaneConfig( txEncoder sdk.TxEncoder, txDecoder sdk.TxDecoder, anteHandler sdk.AnteHandler, + signerExtractor signer_extraction.SignerExtractionAdapter, maxBlockSpace math.LegacyDec, ) LaneConfig { return LaneConfig{ @@ -55,6 +61,7 @@ func NewLaneConfig( TxDecoder: txDecoder, AnteHandler: anteHandler, MaxBlockSpace: maxBlockSpace, + SignerExtractor: signerExtractor, } } @@ -72,6 +79,10 @@ func (c *LaneConfig) ValidateBasic() error { return fmt.Errorf("tx decoder cannot be nil") } + if c.SignerExtractor == nil { + return fmt.Errorf("signer extractor cannot be nil") + } + if c.MaxBlockSpace.IsNil() || c.MaxBlockSpace.IsNegative() || c.MaxBlockSpace.GT(math.LegacyOneDec()) { return fmt.Errorf("max block space must be set to a value between 0 and 1") } diff --git a/block/base/mempool.go b/block/base/mempool.go index a0d5d2fa..acfdb575 100644 --- a/block/base/mempool.go +++ b/block/base/mempool.go @@ -8,6 +8,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkmempool "github.com/cosmos/cosmos-sdk/types/mempool" + signer_extraction "github.com/skip-mev/block-sdk/adapters/signer_extraction_adapter" "github.com/skip-mev/block-sdk/block/utils" ) @@ -81,13 +82,14 @@ func DefaultTxPriority() TxPriority[string] { } // NewMempool returns a new Mempool. -func NewMempool[C comparable](txPriority TxPriority[C], txEncoder sdk.TxEncoder, maxTx int) *Mempool[C] { +func NewMempool[C comparable](txPriority TxPriority[C], txEncoder sdk.TxEncoder, extractor signer_extraction.SignerExtractionAdapter, maxTx int) *Mempool[C] { return &Mempool[C]{ index: NewPriorityMempool( PriorityNonceMempoolConfig[C]{ TxPriority: txPriority, MaxTx: maxTx, }, + extractor, ), txPriority: txPriority, txEncoder: txEncoder, diff --git a/block/base/priority_nonce.go b/block/base/priority_nonce.go index 1b32019e..74fa3995 100644 --- a/block/base/priority_nonce.go +++ b/block/base/priority_nonce.go @@ -21,7 +21,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkmempool "github.com/cosmos/cosmos-sdk/types/mempool" - "github.com/cosmos/cosmos-sdk/x/auth/signing" + signer_extraction "github.com/skip-mev/block-sdk/adapters/signer_extraction_adapter" ) var ( @@ -67,6 +67,7 @@ type ( senderIndices map[string]*skiplist.SkipList scores map[txMeta[C]]txMeta[C] cfg PriorityNonceMempoolConfig[C] + signerExtractor signer_extraction.SignerExtractionAdapter } // PriorityNonceIterator defines an iterator that is used for mempool iteration @@ -167,21 +168,22 @@ func skiplistComparable[C comparable](txPriority TxPriority[C]) skiplist.Compara // NewPriorityMempool returns the SDK's default mempool implementation which // returns txs in a partial order by 2 dimensions; priority, and sender-nonce. -func NewPriorityMempool[C comparable](cfg PriorityNonceMempoolConfig[C]) *PriorityNonceMempool[C] { +func NewPriorityMempool[C comparable](cfg PriorityNonceMempoolConfig[C], extractor signer_extraction.SignerExtractionAdapter) *PriorityNonceMempool[C] { mp := &PriorityNonceMempool[C]{ priorityIndex: skiplist.New(skiplistComparable(cfg.TxPriority)), priorityCounts: make(map[C]int), senderIndices: make(map[string]*skiplist.SkipList), scores: make(map[txMeta[C]]txMeta[C]), cfg: cfg, + signerExtractor: extractor, } return mp } // DefaultPriorityMempool returns a priorityNonceMempool with no options. -func DefaultPriorityMempool() *PriorityNonceMempool[int64] { - return NewPriorityMempool(DefaultPriorityNonceMempoolConfig()) +func DefaultPriorityMempool(extractor signer_extraction.DefaultSignerExtractionAdapter) *PriorityNonceMempool[int64] { + return NewPriorityMempool(DefaultPriorityNonceMempoolConfig(), extractor) } // NextSenderTx returns the next transaction for a given sender by nonce order, @@ -213,18 +215,18 @@ func (mp *PriorityNonceMempool[C]) Insert(ctx context.Context, tx sdk.Tx) error return nil } - sigs, err := tx.(signing.SigVerifiableTx).GetSignaturesV2() + signers, err := mp.signerExtractor.GetSigners(tx) if err != nil { return err } - if len(sigs) == 0 { + if len(signers) == 0 { return fmt.Errorf("tx must have at least one signer") } - sig := sigs[0] - sender := sdk.AccAddress(sig.PubKey.Address()).String() + signer := signers[0] + sender := signer.Signer.String() priority := mp.cfg.TxPriority.GetTxPriority(ctx, tx) - nonce := sig.Sequence + nonce := signer.Sequence key := txMeta[C]{nonce: nonce, priority: priority, sender: sender} senderIndex, ok := mp.senderIndices[sender] @@ -427,16 +429,16 @@ func (mp *PriorityNonceMempool[C]) CountTx() int { // Remove removes a transaction from the mempool in O(log n) time, returning an // error if unsuccessful. func (mp *PriorityNonceMempool[C]) Remove(tx sdk.Tx) error { - sigs, err := tx.(signing.SigVerifiableTx).GetSignaturesV2() + signers, err := mp.signerExtractor.GetSigners(tx) if err != nil { return err } - if len(sigs) == 0 { + if len(signers) == 0 { return fmt.Errorf("attempted to remove a tx with no signatures") } - sig := sigs[0] - sender := sdk.AccAddress(sig.PubKey.Address()).String() + sig := signers[0] + sender := sig.Signer.String() nonce := sig.Sequence scoreKey := txMeta[C]{nonce: nonce, sender: sender} diff --git a/block/mempool_test.go b/block/mempool_test.go index 753379ad..72429638 100644 --- a/block/mempool_test.go +++ b/block/mempool_test.go @@ -12,6 +12,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/suite" + signer_extraction "github.com/skip-mev/block-sdk/adapters/signer_extraction_adapter" "github.com/skip-mev/block-sdk/block" "github.com/skip-mev/block-sdk/block/base" defaultlane "github.com/skip-mev/block-sdk/lanes/base" @@ -63,6 +64,7 @@ func (suite *BlockBusterTestSuite) SetupTest() { Logger: log.NewNopLogger(), TxEncoder: suite.encodingConfig.TxConfig.TxEncoder(), TxDecoder: suite.encodingConfig.TxConfig.TxDecoder(), + SignerExtractor: signer_extraction.NewDefaultSignerExtractionAdapter(), AnteHandler: nil, MaxBlockSpace: math.LegacyZeroDec(), } @@ -76,6 +78,7 @@ func (suite *BlockBusterTestSuite) SetupTest() { Logger: log.NewNopLogger(), TxEncoder: suite.encodingConfig.TxConfig.TxEncoder(), TxDecoder: suite.encodingConfig.TxConfig.TxDecoder(), + SignerExtractor: signer_extraction.NewDefaultSignerExtractionAdapter(), AnteHandler: nil, MaxBlockSpace: math.LegacyZeroDec(), } @@ -90,6 +93,7 @@ func (suite *BlockBusterTestSuite) SetupTest() { Logger: log.NewNopLogger(), TxEncoder: suite.encodingConfig.TxConfig.TxEncoder(), TxDecoder: suite.encodingConfig.TxConfig.TxDecoder(), + SignerExtractor: signer_extraction.NewDefaultSignerExtractionAdapter(), AnteHandler: nil, MaxBlockSpace: math.LegacyZeroDec(), } diff --git a/go.sum b/go.sum index 35ae02af..dea772f7 100644 --- a/go.sum +++ b/go.sum @@ -233,6 +233,7 @@ github.com/Antonboom/errname v0.1.12/go.mod h1:bK7todrzvlaZoQagP1orKzWXv59X/x0W0 github.com/Antonboom/nilnil v0.1.7 h1:ofgL+BA7vlA1K2wNQOsHzLJ2Pw5B5DpWRLdDAVvvTow= github.com/Antonboom/nilnil v0.1.7/go.mod h1:TP+ScQWVEq0eSIxqU8CbdT5DFWoHp0MbP+KMUO1BKYQ= github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25UVaW/CKtUDjefjrs0SPonmDGUVOYP0= +github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8= github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= @@ -248,7 +249,9 @@ github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww= github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y= github.com/Microsoft/go-winio v0.6.0 h1:slsWYD/zyx7lCXoZVlvQrj0hPTM1HI4+v1sIda2yDvg= +github.com/Microsoft/go-winio v0.6.0/go.mod h1:cTAf44im0RAYeL23bpB+fzCyDH2MJiz2BO69KH/soAE= github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 h1:TngWCqHvy9oXAN6lEVMRuU21PR1EtLVZJmdB18Gu3Rw= +github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8D7ML55dXQrVaamCz2vxCfdQBasLZfHKk= github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/OpenPeeDeeP/depguard/v2 v2.1.0 h1:aQl70G173h/GZYhWf36aE5H0KaujXfVMnn/f1kSDVYY= @@ -258,6 +261,7 @@ github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMx github.com/VividCortex/gohistogram v1.0.0 h1:6+hBz+qvs0JOrrNhhmR7lFxo5sINxBCGXrdtl/UvroE= github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g= github.com/adlio/schema v1.3.3 h1:oBJn8I02PyTB466pZO1UZEn1TV5XLlifBSyMrmHl/1I= +github.com/adlio/schema v1.3.3/go.mod h1:1EsRssiv9/Ce2CMzq5DoL7RiMshhuigQxrR4DMV9fHg= github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= @@ -314,8 +318,11 @@ github.com/breml/errchkjson v0.3.1/go.mod h1:XroxrzKjdiutFyW3nWhw34VGg7kiMsDQox7 github.com/btcsuite/btcd/btcec/v2 v2.3.2 h1:5n0X6hX0Zk+6omWcihdYvdAlGf2DfasC0GMf7DClJ3U= github.com/btcsuite/btcd/btcec/v2 v2.3.2/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04= github.com/btcsuite/btcd/btcutil v1.1.3 h1:xfbtw8lwpp0G6NwSHb+UE67ryTFHJAiNuipusjXSohQ= +github.com/btcsuite/btcd/btcutil v1.1.3/go.mod h1:UR7dsSJzJUfMmFiiLlIrMq1lS9jh9EdCV7FStZSnpi0= github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U= +github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= github.com/bufbuild/protocompile v0.5.1 h1:mixz5lJX4Hiz4FpqFREJHIXLfaLBntfaJv1h+/jS+Qg= +github.com/bufbuild/protocompile v0.5.1/go.mod h1:G5iLmavmF4NsYtpZFvE3B/zFch2GIY8+wjsYLR/lc40= github.com/butuzov/ireturn v0.2.0 h1:kCHi+YzC150GE98WFuZQu9yrTn6GEydO2AuPLbTgnO4= github.com/butuzov/ireturn v0.2.0/go.mod h1:Wh6Zl3IMtTpaIKbmwzqi6olnM9ptYQxxVacMsOEFPoc= github.com/butuzov/mirror v1.1.0 h1:ZqX54gBVMXu78QLoiqdwpl2mgmoOJTk7s4p4o+0avZI= @@ -369,6 +376,7 @@ github.com/cockroachdb/apd/v2 v2.0.2 h1:weh8u7Cneje73dDh+2tEVLUvyBc89iwepWCD8b80 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= github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f h1:otljaYPt5hWxV3MUfO5dFPFiOXg9CyG5/kCfayTqsJ4= +github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f/go.mod h1:a9RdTaap04u637JoCzcUoIcDmvwSUtcUFtT/C3kJlTU= github.com/cockroachdb/errors v1.11.1 h1:xSEW75zKaKCWzR3OfxXUxgrk/NtT4G1MiOv5lWZazG8= github.com/cockroachdb/errors v1.11.1/go.mod h1:8MUxA3Gi6b25tYlFEBGLf+D8aISL+M4MIpiWMSNRfxw= github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE= @@ -386,6 +394,7 @@ github.com/cometbft/cometbft-db v0.8.0 h1:vUMDaH3ApkX8m0KZvOFFy9b5DZHBAjsnEuo9AK github.com/cometbft/cometbft-db v0.8.0/go.mod h1:6ASCP4pfhmrCBpfk01/9E1SI29nD3HfVHrY4PG8x5c0= github.com/containerd/console v1.0.3/go.mod h1:7LqA/THxQ86k76b8c/EMSiaJ3h1eZkMkXar0TQ1gf3U= github.com/containerd/continuity v0.3.0 h1:nisirsYROK15TAMVukJOUyGJjz4BNQJBVsNvAXZJ/eg= +github.com/containerd/continuity v0.3.0/go.mod h1:wJEAIwKOm/pBZuBd0JmeTvnLquTB1Ag8espWhkykbPM= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= @@ -436,6 +445,7 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5ilcvdfma9wOH6Y= +github.com/decred/dcrd/crypto/blake256 v1.0.1/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= github.com/denis-tingaikin/go-header v0.4.3 h1:tEaZKAlqql6SKCY++utLmkPLd6K8IBM20Ha7UVm+mtU= @@ -452,8 +462,10 @@ github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUn github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 h1:fAjc9m62+UWV/WAFKLNi6ZS0675eEUC9y3AlwSbQu1Y= github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= +github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= +github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= @@ -493,10 +505,12 @@ github.com/felixge/httpsnoop v1.0.2/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSw github.com/firefart/nonamedreturns v1.0.4 h1:abzI1p7mAEPYuR4A+VLKn4eNDOycjYo2phmY9sfv40Y= github.com/firefart/nonamedreturns v1.0.4/go.mod h1:TDhe/tjI1BXo48CmYbUduTV7BdIga8MAO/xbKdcVsGI= github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw= +github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4= github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20= github.com/frankban/quicktest v1.11.3/go.mod h1:wRf/ReqHper53s+kmmSZizM8NamnL3IM0I9ntUbOk+k= github.com/frankban/quicktest v1.14.4 h1:g2rn0vABPOOXmZUj+vbmUp0lPoXEMuhTpIluN0XL9UY= +github.com/frankban/quicktest v1.14.4/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= @@ -510,9 +524,11 @@ github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M= github.com/gin-gonic/gin v1.8.1 h1:4+fr/el88TOO3ewCmQr8cx/CtZ/umlIRIs5M4NTNjf8= +github.com/gin-gonic/gin v1.8.1/go.mod h1:ji8BvRH1azfM+SYow9zQ6SZMvR8qOMZHmsCuWR9tTTk= github.com/go-critic/go-critic v0.9.0 h1:Pmys9qvU3pSML/3GEQ2Xd9RZ/ip+aXHKILuxczKGV/U= github.com/go-critic/go-critic v0.9.0/go.mod h1:5P8tdXL7m/6qnyG6oRAlYLORvoXH0WDypYgAEmagT40= github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA= +github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= @@ -530,16 +546,21 @@ github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG github.com/go-logfmt/logfmt v0.6.0 h1:wGYYu3uicYdqXVgoYbvnkrPVXkuLM1p1ifugDMEdRi4= github.com/go-logfmt/logfmt v0.6.0/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= +github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= github.com/go-playground/locales v0.14.0 h1:u50s323jtVGugKlcYeyzC0etD1HifMjqmJqb8WugfUU= +github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs= github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= github.com/go-playground/universal-translator v0.18.0 h1:82dyy6p4OuJq4/CByFNOn/jYrnRPArHwAcmLoJZxyho= +github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA= github.com/go-playground/validator/v10 v10.2.0/go.mod h1:uOYAAleCW8F/7oMFd6aG0GOhaH6EGOAJShg8Id5JGkI= github.com/go-playground/validator/v10 v10.11.1 h1:prmOlTVv+YjZjmRmNSF3VmspqJIxJWXmqUsHwfTRRkQ= +github.com/go-playground/validator/v10 v10.11.1/go.mod h1:i+3WkQ1FvaUjjxh1kSvIA4dMGDBiPU55YFDl0WbKdWU= github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= +github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= github.com/go-toolsmith/astcast v1.1.0 h1:+JN9xZV1A+Re+95pgnMgDboWNVnIMMQXwfBwLRPgSC8= github.com/go-toolsmith/astcast v1.1.0/go.mod h1:qdcuFWeGGS2xX5bLM/c3U9lewg7+Zu4mr+xPwZIB4ZU= github.com/go-toolsmith/astcopy v1.1.0 h1:YGwBN0WM+ekI/6SS6+52zLDEf8Yvp3n2seZITCUBt5s= @@ -552,6 +573,7 @@ github.com/go-toolsmith/astfmt v1.1.0/go.mod h1:OrcLlRwu0CuiIBp/8b5PYF9ktGVZUjlN github.com/go-toolsmith/astp v1.1.0 h1:dXPuCl6u2llURjdPLLDxJeZInAeZ0/eZwFJmqZMnpQA= github.com/go-toolsmith/astp v1.1.0/go.mod h1:0T1xFGz9hicKs8Z5MfAqSUitoUYS30pDMsRVIDHs8CA= github.com/go-toolsmith/pkgload v1.2.2 h1:0CtmHq/02QhxcF7E9N5LIFcYFsMR5rdovfqTtRKkgIk= +github.com/go-toolsmith/pkgload v1.2.2/go.mod h1:R2hxLNRKuAsiXCo2i5J6ZQPhnPMOVtU+f0arbFPWCus= github.com/go-toolsmith/strparse v1.0.0/go.mod h1:YI2nUKP9YGZnL/L1/DLFBfixrcjslWct4wyljWhSRy8= github.com/go-toolsmith/strparse v1.1.0 h1:GAioeZUK9TGxnLS+qfdqNbA4z0SSm5zVNtCQiyP2Bvw= github.com/go-toolsmith/strparse v1.1.0/go.mod h1:7ksGy58fsaQkGQlY8WVoBFNyEPMGuJin1rfoPS4lBSQ= @@ -568,6 +590,7 @@ github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6Wezm github.com/gobwas/ws v1.0.2 h1:CoAavW/wd/kulfZmSIBt6p24n4j7tHgNVCjsfHVNUbo= github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM= github.com/goccy/go-json v0.9.11 h1:/pAaQDLHEoCq/5FFmSKBswWmK6H0e8g4159Kc/X/nqk= +github.com/goccy/go-json v0.9.11/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 h1:ZpnhV/YsD2/4cESfV5+Hoeu/iUR3ruzNvZ+yQfO03a0= github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2/go.mod h1:bBOAhwG1umN6/6ZUMtDFBMQR8jRg9O75tm9K00oMsK4= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= @@ -670,12 +693,14 @@ github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= +github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible h1:/CP5g8u/VJHijgedC/Legn3BAbAaWPgecwXBIDzw5no= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/martian/v3 v3.2.1/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk= github.com/google/martian/v3 v3.3.2 h1:IqNFLAmvJOgVlpdEBiQbDc2EwKW77amAycfTuWKdfvw= +github.com/google/martian/v3 v3.3.2/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk= github.com/google/orderedcode v0.0.1 h1:UzfcAexk9Vhv8+9pNOgRu41f16lHq725vPwnSeiG/Us= github.com/google/orderedcode v0.0.1/go.mod h1:iVyU4/qPKHY5h/wSd6rZZCDcLJNxiWO6dvsYES2Sb20= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= @@ -694,6 +719,7 @@ github.com/google/pprof v0.0.0-20210601050228-01bbb1931b22/go.mod h1:kpwsk12EmLe github.com/google/pprof v0.0.0-20210609004039-a478d1d731e9/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20230228050547-1710fef4ab10 h1:CqYfpuYIjnlNxM3msdyPRKabhXZWbKjf3Q8BWROFBso= +github.com/google/pprof v0.0.0-20230228050547-1710fef4ab10/go.mod h1:79YE0hCXdHag9sBkw2o+N/YnZtTkXi0UT9Nnixa5eYk= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/s2a-go v0.1.4 h1:1kZ/sQM3srePvKs3tXAvQzo66XfcReoqFpIpIccE7Oc= github.com/google/s2a-go v0.1.4/go.mod h1:Ej+mSEMGRnqRzjc7VtF+jdBwYG5fuJfiZ8ELkjEwM0A= @@ -744,6 +770,7 @@ github.com/gostaticanalysis/nilerr v0.1.1 h1:ThE+hJP0fEp4zWLkWHWcRyI2Od0p7DlgYG3 github.com/gostaticanalysis/nilerr v0.1.1/go.mod h1:wZYb6YI5YAxxq0i1+VJbY0s2YONW0HU0GPE3+5PWN4A= github.com/gostaticanalysis/testutil v0.3.1-0.20210208050101-bfb5c8eec0e4/go.mod h1:D+FIZ+7OahH3ePw/izIEeH5I06eKs1IKI4Xr64/Am3M= github.com/gostaticanalysis/testutil v0.4.0 h1:nhdCmubdmDF6VEatUNjgUZBJKWRqugoISdUv3PPQgHY= +github.com/gostaticanalysis/testutil v0.4.0/go.mod h1:bLIoPefWXrRi/ssLFWX1dx7Repi5x3CuviD3dgAZaBU= github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= github.com/grpc-ecosystem/go-grpc-middleware v1.2.2/go.mod h1:EaizFBKfUKtMIF5iaDEhniwNedqGo9FuLFzppDr3uwI= github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 h1:UH//fgunKIs4JdUbpDl1VZCDaL56wXCB/5+wF6uHfaI= @@ -827,6 +854,7 @@ github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod github.com/jgautheron/goconst v1.5.1 h1:HxVbL1MhydKs8R8n/HE5NPvzfaYmQJA3o879lE4+WcM= github.com/jgautheron/goconst v1.5.1/go.mod h1:aAosetZ5zaeC/2EfMeRswtxUFBpe2Hr7HzkgX4fanO4= github.com/jhump/protoreflect v1.15.2 h1:7YppbATX94jEt9KLAc5hICx4h6Yt3SaavhQRsIUEHP0= +github.com/jhump/protoreflect v1.15.2/go.mod h1:4ORHmSBmlCW8fh3xHmJMGyul1zNqZK4Elxc8qKP+p1k= github.com/jingyugao/rowserrcheck v1.1.1 h1:zibz55j/MJtLsjP1OF4bSdgXxwL1b+Vn7Tjzq7gFzUs= github.com/jingyugao/rowserrcheck v1.1.1/go.mod h1:4yvlZSDb3IyDTUZJUmpZfm2Hwok+Dtp+nu2qOq+er9c= github.com/jirfag/go-printf-func-name v0.0.0-20200119135958-7558a9eaa5af h1:KA9BjwUk7KlCh6S9EAGWBt1oExIUv9WyNCiRz5amv48= @@ -894,6 +922,7 @@ github.com/ldez/tagliatelle v0.5.0 h1:epgfuYt9v0CG3fms0pEgIMNPuFf/LpPIfjk4kyqSio github.com/ldez/tagliatelle v0.5.0/go.mod h1:rj1HmWiL1MiKQuOONhd09iySTEkUuE/8+5jtPYz9xa4= github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w= +github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY= github.com/leonklingele/grouper v1.1.1 h1:suWXRU57D4/Enn6pXR0QVqqWWrnJ9Osrz+5rjt8ivzU= github.com/leonklingele/grouper v1.1.1/go.mod h1:uk3I3uDfi9B6PeUjsCKi6ndcf63Uy7snXgR4yDYQVDY= github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= @@ -994,6 +1023,7 @@ github.com/nunnatsa/ginkgolinter v0.13.5 h1:fOsPB4CEZOPkyMqF4B9hoqOpooFWU7vWSVkC github.com/nunnatsa/ginkgolinter v0.13.5/go.mod h1:OBHy4536xtuX3102NM63XRtOyxqZOO02chsaeDWXVO8= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= +github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= github.com/oasisprotocol/curve25519-voi v0.0.0-20230110094441-db37f07504ce h1:/pEpMk55wH0X+E5zedGEMOdLuWmV8P4+4W3+LZaM6kg= github.com/oasisprotocol/curve25519-voi v0.0.0-20230110094441-db37f07504ce/go.mod h1:hVoHR2EVESiICEMbg137etN/Lx+lSrHPTD39Z/uE+2s= github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs= @@ -1009,13 +1039,17 @@ github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108 github.com/onsi/ginkgo v1.14.0 h1:2mOpI4JVVPBN+WQRa0WKH2eXR+Ey+uK4n7Zj0aYpIQA= github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= github.com/onsi/ginkgo/v2 v2.11.0 h1:WgqUCUt/lT6yXoQ8Wef0fsNn5cAuMK7+KT9UFRz2tcU= +github.com/onsi/ginkgo/v2 v2.11.0/go.mod h1:ZhrRA5XmEE3x3rhlzamx/JJvujdZoJ2uvgI7kR0iZvM= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI= +github.com/onsi/gomega v1.27.10/go.mod h1:RsS8tutOdbdgzbPtzzATp12yT7kM5I5aElG3evPbQ0M= github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= +github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/image-spec v1.1.0-rc2 h1:2zx/Stx4Wc5pIPDvIxHXvXtQFW/7XWJGmnM7r3wg034= +github.com/opencontainers/image-spec v1.1.0-rc2/go.mod h1:3OVijpioIKYWTqjiG0zfF6wvoJ4fAXGbjdZuI2NgsRQ= github.com/opencontainers/runc v1.1.5 h1:L44KXEpKmfWDcS02aeGm8QNTFXTo2D+8MYGDIJ/GDEs= github.com/opencontainers/runc v1.1.5/go.mod h1:1J5XiS+vdZ3wCyZybsuxXZWGrgSr8fFJHLXuG2PsnNg= github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= @@ -1029,6 +1063,7 @@ github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJ github.com/openzipkin/zipkin-go v0.2.1/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= github.com/ory/dockertest v3.3.5+incompatible h1:iLLK6SQwIhcbrG783Dghaaa3WPzGc+4Emza6EbVUUGA= +github.com/ory/dockertest v3.3.5+incompatible/go.mod h1:1vX4m9wsvi00u5bseYwXaSnhNrne+V0E6LAcBILJdPs= github.com/otiai10/copy v1.2.0 h1:HvG945u96iNadPoG2/Ja2+AUJeW5YuFQMixq9yirC+k= github.com/otiai10/copy v1.2.0/go.mod h1:rrF5dJ5F0t/EWSYODDu4j9/vEeYHMkc8jt0zJChqQWw= github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJG+0mI8eUu6xqkFDYS2kb2saOteoSB3cE= @@ -1050,6 +1085,7 @@ github.com/petermattis/goid v0.0.0-20230518223814-80aa455d8761/go.mod h1:pxMtw7c github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= +github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -1252,6 +1288,7 @@ github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVM github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= github.com/ugorji/go/codec v1.2.7 h1:YPXUKf7fYbp/y8xloBqZOw2qaVggbfwMlI8WM3wZUJ0= +github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY= github.com/ulikunitz/xz v0.5.10/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/ulikunitz/xz v0.5.11 h1:kpFauv27b6ynzBNT/Xy+1k+fK4WswhN/6PN5WhFAGw8= github.com/ulikunitz/xz v0.5.11/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= @@ -1289,6 +1326,7 @@ github.com/zondax/ledger-go v0.14.1/go.mod h1:fZ3Dqg6qcdXWSOJFKMG8GCTnD7slO/RL2f gitlab.com/bosi/decorder v0.4.0 h1:HWuxAhSxIvsITcXeP+iIRg9d1cVfvVkmlF7M68GaoDY= gitlab.com/bosi/decorder v0.4.0/go.mod h1:xarnteyUoJiOTEldDysquWKTVDCKo2TOIOIibSuWqOg= go-simpler.org/assert v0.6.0 h1:QxSrXa4oRuo/1eHMXSBFHKvJIpWABayzKldqZyugG7E= +go-simpler.org/assert v0.6.0/go.mod h1:74Eqh5eI6vCK6Y5l3PI8ZYFXG4Sa+tkr70OIPJAUr28= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/bbolt v1.3.7 h1:j+zJOnnEjF/kyHlDDgGnVL/AIqIJPq8UoB2GSNfkUfQ= go.etcd.io/bbolt v1.3.7/go.mod h1:N9Mkw9X8x5fupy0IKsmuqVtoGDyxsaDlbk4Rd05IAQw= @@ -1315,6 +1353,7 @@ go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI= +go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= @@ -1979,6 +2018,7 @@ gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= gopkg.in/cheggaaa/pb.v1 v1.0.27/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= diff --git a/lanes/base/abci_test.go b/lanes/base/abci_test.go index 242e3d5f..11ce5aff 100644 --- a/lanes/base/abci_test.go +++ b/lanes/base/abci_test.go @@ -9,6 +9,7 @@ import ( "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" + signer_extraction "github.com/skip-mev/block-sdk/adapters/signer_extraction_adapter" "github.com/skip-mev/block-sdk/block" "github.com/skip-mev/block-sdk/block/base" "github.com/skip-mev/block-sdk/block/utils/mocks" @@ -509,6 +510,7 @@ func (s *BaseTestSuite) initLane( s.encodingConfig.TxConfig.TxEncoder(), s.encodingConfig.TxConfig.TxDecoder(), s.setUpAnteHandler(expectedExecution), + signer_extraction.NewDefaultSignerExtractionAdapter(), maxBlockSpace, ) diff --git a/lanes/base/lane.go b/lanes/base/lane.go index 8f2a1f99..eb8f38d2 100644 --- a/lanes/base/lane.go +++ b/lanes/base/lane.go @@ -30,6 +30,7 @@ func NewDefaultLane(cfg base.LaneConfig) *DefaultLane { base.NewMempool[string]( base.DefaultTxPriority(), cfg.TxEncoder, + cfg.SignerExtractor, cfg.MaxTxs, ), base.DefaultMatchHandler(), diff --git a/lanes/base/mempool_test.go b/lanes/base/mempool_test.go index e66a8a30..92b11cb3 100644 --- a/lanes/base/mempool_test.go +++ b/lanes/base/mempool_test.go @@ -6,6 +6,7 @@ import ( "github.com/skip-mev/block-sdk/block/base" testutils "github.com/skip-mev/block-sdk/testutils" + signer_extraction "github.com/skip-mev/block-sdk/adapters/signer_extraction_adapter" ) func (s *BaseTestSuite) TestGetTxPriority() { @@ -85,7 +86,7 @@ func (s *BaseTestSuite) TestCompareTxPriority() { } func (s *BaseTestSuite) TestInsert() { - mempool := base.NewMempool[string](base.DefaultTxPriority(), s.encodingConfig.TxConfig.TxEncoder(), 3) + mempool := base.NewMempool[string](base.DefaultTxPriority(), s.encodingConfig.TxConfig.TxEncoder(), signer_extraction.NewDefaultSignerExtractionAdapter(), 3) s.Run("should be able to insert a transaction", func() { tx, err := testutils.CreateRandomTx( @@ -137,7 +138,7 @@ func (s *BaseTestSuite) TestInsert() { } func (s *BaseTestSuite) TestRemove() { - mempool := base.NewMempool[string](base.DefaultTxPriority(), s.encodingConfig.TxConfig.TxEncoder(), 3) + mempool := base.NewMempool[string](base.DefaultTxPriority(), s.encodingConfig.TxConfig.TxEncoder(), signer_extraction.NewDefaultSignerExtractionAdapter(), 3) s.Run("should be able to remove a transaction", func() { tx, err := testutils.CreateRandomTx( @@ -175,7 +176,7 @@ func (s *BaseTestSuite) TestRemove() { func (s *BaseTestSuite) TestSelect() { s.Run("should be able to select transactions in the correct order", func() { - mempool := base.NewMempool[string](base.DefaultTxPriority(), s.encodingConfig.TxConfig.TxEncoder(), 3) + mempool := base.NewMempool[string](base.DefaultTxPriority(), s.encodingConfig.TxConfig.TxEncoder(), signer_extraction.NewDefaultSignerExtractionAdapter(), 3) tx1, err := testutils.CreateRandomTx( s.encodingConfig.TxConfig, @@ -214,7 +215,7 @@ func (s *BaseTestSuite) TestSelect() { }) s.Run("should be able to select a single transaction", func() { - mempool := base.NewMempool[string](base.DefaultTxPriority(), s.encodingConfig.TxConfig.TxEncoder(), 3) + mempool := base.NewMempool[string](base.DefaultTxPriority(), s.encodingConfig.TxConfig.TxEncoder(), signer_extraction.NewDefaultSignerExtractionAdapter(), 3) tx1, err := testutils.CreateRandomTx( s.encodingConfig.TxConfig, diff --git a/lanes/free/lane.go b/lanes/free/lane.go index a6e2b5d2..ceabef76 100644 --- a/lanes/free/lane.go +++ b/lanes/free/lane.go @@ -33,6 +33,7 @@ func NewFreeLane( base.NewMempool[string]( txPriority, cfg.TxEncoder, + cfg.SignerExtractor, cfg.MaxTxs, ), matchFn, diff --git a/lanes/mev/lane.go b/lanes/mev/lane.go index 55617d18..7b6d6da3 100644 --- a/lanes/mev/lane.go +++ b/lanes/mev/lane.go @@ -53,6 +53,7 @@ func NewMEVLane( base.NewMempool[string]( TxPriority(factory), cfg.TxEncoder, + cfg.SignerExtractor, cfg.MaxTxs, ), factory.MatchHandler(), diff --git a/tests/app/app.go b/tests/app/app.go index 4b2de6b5..3fa9580b 100644 --- a/tests/app/app.go +++ b/tests/app/app.go @@ -62,6 +62,7 @@ import ( stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" "github.com/skip-mev/block-sdk/abci" + signer_extraction "github.com/skip-mev/block-sdk/adapters/signer_extraction_adapter" "github.com/skip-mev/block-sdk/block" "github.com/skip-mev/block-sdk/block/base" defaultlane "github.com/skip-mev/block-sdk/lanes/base" @@ -268,6 +269,7 @@ func New( TxEncoder: app.txConfig.TxEncoder(), TxDecoder: app.txConfig.TxDecoder(), MaxBlockSpace: math.LegacyZeroDec(), // This means the lane has no limit on block space. + SignerExtractor: signer_extraction.NewDefaultSignerExtractionAdapter(), MaxTxs: 0, // This means the lane has no limit on the number of transactions it can store. } mevLane := mev.NewMEVLane( @@ -281,6 +283,7 @@ func New( TxEncoder: app.txConfig.TxEncoder(), TxDecoder: app.txConfig.TxDecoder(), MaxBlockSpace: math.LegacyZeroDec(), + SignerExtractor: signer_extraction.NewDefaultSignerExtractionAdapter(), MaxTxs: 0, } freeLane := free.NewFreeLane( @@ -295,6 +298,7 @@ func New( TxEncoder: app.txConfig.TxEncoder(), TxDecoder: app.txConfig.TxDecoder(), MaxBlockSpace: math.LegacyZeroDec(), + SignerExtractor: signer_extraction.NewDefaultSignerExtractionAdapter(), MaxTxs: 0, } defaultLane := defaultlane.NewDefaultLane(defaultConfig) diff --git a/x/auction/ante/ante_test.go b/x/auction/ante/ante_test.go index a35a868a..4def685a 100644 --- a/x/auction/ante/ante_test.go +++ b/x/auction/ante/ante_test.go @@ -13,6 +13,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/suite" + signer_extraction "github.com/skip-mev/block-sdk/adapters/signer_extraction_adapter" "github.com/skip-mev/block-sdk/block" "github.com/skip-mev/block-sdk/block/base" defaultlane "github.com/skip-mev/block-sdk/lanes/base" @@ -89,6 +90,7 @@ func (suite *AnteTestSuite) SetupTest() { Logger: suite.ctx.Logger(), TxEncoder: suite.encodingConfig.TxConfig.TxEncoder(), TxDecoder: suite.encodingConfig.TxConfig.TxDecoder(), + SignerExtractor: signer_extraction.NewDefaultSignerExtractionAdapter(), AnteHandler: suite.anteHandler, MaxBlockSpace: math.LegacyZeroDec(), } @@ -103,6 +105,7 @@ func (suite *AnteTestSuite) SetupTest() { TxEncoder: suite.encodingConfig.TxConfig.TxEncoder(), TxDecoder: suite.encodingConfig.TxConfig.TxDecoder(), AnteHandler: suite.anteHandler, + SignerExtractor: signer_extraction.NewDefaultSignerExtractionAdapter(), MaxBlockSpace: math.LegacyZeroDec(), IgnoreList: []block.Lane{suite.mevLane}, } From c56259b866f43f8bd19801828ded6ddc71f56189 Mon Sep 17 00:00:00 2001 From: Nikhil Vasan Date: Wed, 20 Sep 2023 14:36:11 -0700 Subject: [PATCH 2/3] linting --- abci/abci_test.go | 48 +++++++++---------- .../signer_extraction_adapter.go | 19 ++++---- .../signer_extraction_adapter_test.go | 17 ++++--- block/base/config.go | 18 +++---- block/base/mempool.go | 2 +- block/base/priority_nonce.go | 26 +++++----- block/mempool_test.go | 36 +++++++------- lanes/base/abci_test.go | 2 +- lanes/base/mempool_test.go | 10 ++-- tests/app/app.go | 36 +++++++------- x/auction/ante/ante_test.go | 26 +++++----- 11 files changed, 120 insertions(+), 120 deletions(-) diff --git a/abci/abci_test.go b/abci/abci_test.go index 29da22af..cb02f2d1 100644 --- a/abci/abci_test.go +++ b/abci/abci_test.go @@ -736,12 +736,12 @@ func (s *ProposalsTestSuite) setUpAnteHandler(expectedExecution map[sdk.Tx]bool) func (s *ProposalsTestSuite) setUpStandardLane(maxBlockSpace math.LegacyDec, expectedExecution map[sdk.Tx]bool) *defaultlane.DefaultLane { cfg := base.LaneConfig{ - Logger: log.NewTestLogger(s.T()), - TxEncoder: s.encodingConfig.TxConfig.TxEncoder(), - TxDecoder: s.encodingConfig.TxConfig.TxDecoder(), - SignerExtractor: signer_extraction.NewDefaultSignerExtractionAdapter(), - AnteHandler: s.setUpAnteHandler(expectedExecution), - MaxBlockSpace: maxBlockSpace, + Logger: log.NewTestLogger(s.T()), + TxEncoder: s.encodingConfig.TxConfig.TxEncoder(), + TxDecoder: s.encodingConfig.TxConfig.TxDecoder(), + SignerExtractor: signer_extraction.NewDefaultAdapter(), + AnteHandler: s.setUpAnteHandler(expectedExecution), + MaxBlockSpace: maxBlockSpace, } return defaultlane.NewDefaultLane(cfg) @@ -749,12 +749,12 @@ func (s *ProposalsTestSuite) setUpStandardLane(maxBlockSpace math.LegacyDec, exp func (s *ProposalsTestSuite) setUpTOBLane(maxBlockSpace math.LegacyDec, expectedExecution map[sdk.Tx]bool) *mev.MEVLane { cfg := base.LaneConfig{ - Logger: log.NewTestLogger(s.T()), - TxEncoder: s.encodingConfig.TxConfig.TxEncoder(), - TxDecoder: s.encodingConfig.TxConfig.TxDecoder(), - AnteHandler: s.setUpAnteHandler(expectedExecution), - SignerExtractor: signer_extraction.NewDefaultSignerExtractionAdapter(), - MaxBlockSpace: maxBlockSpace, + Logger: log.NewTestLogger(s.T()), + TxEncoder: s.encodingConfig.TxConfig.TxEncoder(), + TxDecoder: s.encodingConfig.TxConfig.TxDecoder(), + AnteHandler: s.setUpAnteHandler(expectedExecution), + SignerExtractor: signer_extraction.NewDefaultAdapter(), + MaxBlockSpace: maxBlockSpace, } return mev.NewMEVLane(cfg, mev.NewDefaultAuctionFactory(cfg.TxDecoder)) @@ -762,12 +762,12 @@ func (s *ProposalsTestSuite) setUpTOBLane(maxBlockSpace math.LegacyDec, expected func (s *ProposalsTestSuite) setUpFreeLane(maxBlockSpace math.LegacyDec, expectedExecution map[sdk.Tx]bool) *free.FreeLane { cfg := base.LaneConfig{ - Logger: log.NewTestLogger(s.T()), - TxEncoder: s.encodingConfig.TxConfig.TxEncoder(), - TxDecoder: s.encodingConfig.TxConfig.TxDecoder(), - AnteHandler: s.setUpAnteHandler(expectedExecution), - SignerExtractor: signer_extraction.NewDefaultSignerExtractionAdapter(), - MaxBlockSpace: maxBlockSpace, + Logger: log.NewTestLogger(s.T()), + TxEncoder: s.encodingConfig.TxConfig.TxEncoder(), + TxDecoder: s.encodingConfig.TxConfig.TxDecoder(), + AnteHandler: s.setUpAnteHandler(expectedExecution), + SignerExtractor: signer_extraction.NewDefaultAdapter(), + MaxBlockSpace: maxBlockSpace, } return free.NewFreeLane(cfg, base.DefaultTxPriority(), free.DefaultMatchHandler()) @@ -775,17 +775,17 @@ func (s *ProposalsTestSuite) setUpFreeLane(maxBlockSpace math.LegacyDec, expecte func (s *ProposalsTestSuite) setUpPanicLane(maxBlockSpace math.LegacyDec) *base.BaseLane { cfg := base.LaneConfig{ - Logger: log.NewTestLogger(s.T()), - TxEncoder: s.encodingConfig.TxConfig.TxEncoder(), - TxDecoder: s.encodingConfig.TxConfig.TxDecoder(), - SignerExtractor: signer_extraction.NewDefaultSignerExtractionAdapter(), - MaxBlockSpace: maxBlockSpace, + Logger: log.NewTestLogger(s.T()), + TxEncoder: s.encodingConfig.TxConfig.TxEncoder(), + TxDecoder: s.encodingConfig.TxConfig.TxDecoder(), + SignerExtractor: signer_extraction.NewDefaultAdapter(), + MaxBlockSpace: maxBlockSpace, } lane := base.NewBaseLane( cfg, "panic", - base.NewMempool[string](base.DefaultTxPriority(), cfg.TxEncoder, signer_extraction.NewDefaultSignerExtractionAdapter(), 0), + base.NewMempool[string](base.DefaultTxPriority(), cfg.TxEncoder, signer_extraction.NewDefaultAdapter(), 0), base.DefaultMatchHandler(), ) diff --git a/adapters/signer_extraction_adapter/signer_extraction_adapter.go b/adapters/signer_extraction_adapter/signer_extraction_adapter.go index 9f2af312..e905c5b3 100644 --- a/adapters/signer_extraction_adapter/signer_extraction_adapter.go +++ b/adapters/signer_extraction_adapter/signer_extraction_adapter.go @@ -1,33 +1,34 @@ -package signer_extraction +package signerextraction import ( "fmt" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth/signing" ) type SignerData struct { - Signer sdk.AccAddress + Signer sdk.AccAddress Sequence uint64 } // SignerExtractionAdapter is an interface used to determine how the signers of a transaction should be extracted // from the transaction. -type SignerExtractionAdapter interface { +type Adapter interface { GetSigners(sdk.Tx) ([]SignerData, error) } -var _ SignerExtractionAdapter = DefaultSignerExtractionAdapter{} +var _ Adapter = DefaultAdapter{} // DefaultSignerExtractionAdapter is the default implementation of SignerExtractionAdapter. It extracts the signers // from a cosmos-sdk tx via GetSignaturesV2. -type DefaultSignerExtractionAdapter struct {} +type DefaultAdapter struct{} -func NewDefaultSignerExtractionAdapter() DefaultSignerExtractionAdapter { - return DefaultSignerExtractionAdapter{} +func NewDefaultAdapter() DefaultAdapter { + return DefaultAdapter{} } -func (DefaultSignerExtractionAdapter) GetSigners(tx sdk.Tx) ([]SignerData, error) { +func (DefaultAdapter) GetSigners(tx sdk.Tx) ([]SignerData, error) { sigTx, ok := tx.(signing.SigVerifiableTx) if !ok { return nil, fmt.Errorf("tx of type %T does not implement SigVerifiableTx", tx) @@ -41,7 +42,7 @@ func (DefaultSignerExtractionAdapter) GetSigners(tx sdk.Tx) ([]SignerData, error signers := make([]SignerData, len(sigs)) for i, sig := range sigs { signers[i] = SignerData{ - Signer: sig.PubKey.Address().Bytes(), + Signer: sig.PubKey.Address().Bytes(), Sequence: sig.Sequence, } } diff --git a/adapters/signer_extraction_adapter/signer_extraction_adapter_test.go b/adapters/signer_extraction_adapter/signer_extraction_adapter_test.go index b3aca902..220db0bb 100644 --- a/adapters/signer_extraction_adapter/signer_extraction_adapter_test.go +++ b/adapters/signer_extraction_adapter/signer_extraction_adapter_test.go @@ -1,4 +1,4 @@ -package signer_extraction_test +package signerextraction_test import ( "math/rand" @@ -7,31 +7,30 @@ import ( "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/client" sdk "github.com/cosmos/cosmos-sdk/types" - testutils "github.com/skip-mev/block-sdk/testutils" - "github.com/stretchr/testify/suite" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" signer_extraction "github.com/skip-mev/block-sdk/adapters/signer_extraction_adapter" + testutils "github.com/skip-mev/block-sdk/testutils" + "github.com/stretchr/testify/suite" ) - type SignerExtractionAdapterTestSuite struct { suite.Suite txConfig client.TxConfig - accts []testutils.Account - adapter signer_extraction.DefaultSignerExtractionAdapter + accts []testutils.Account + adapter signer_extraction.DefaultAdapter } func TestSignerExtractionAdapterTestSuite(t *testing.T) { suite.Run(t, new(SignerExtractionAdapterTestSuite)) } -func (suite *SignerExtractionAdapterTestSuite) SetupTest() { +func (s *SignerExtractionAdapterTestSuite) SetupTest() { encodingConfig := testutils.CreateTestEncodingConfig() - suite.txConfig = encodingConfig.TxConfig + s.txConfig = encodingConfig.TxConfig accts := testutils.RandomAccounts(rand.New(rand.NewSource(1)), 2) - suite.accts = accts + s.accts = accts } func (s *SignerExtractionAdapterTestSuite) TestGetSigners() { diff --git a/block/base/config.go b/block/base/config.go index d16e7a3d..9275efee 100644 --- a/block/base/config.go +++ b/block/base/config.go @@ -18,9 +18,9 @@ type LaneConfig struct { TxDecoder sdk.TxDecoder AnteHandler sdk.AnteHandler - // SignerExtractor defines the interface used for extracting the expected signers of a transaction + // SignerExtractor defines the interface used for extracting the expected signers of a transaction // from the transaction. - SignerExtractor signer_extraction.SignerExtractionAdapter + SignerExtractor signer_extraction.Adapter // MaxBlockSpace defines the relative percentage of block space that can be // used by this lane. NOTE: If this is set to zero, then there is no limit @@ -52,15 +52,15 @@ func NewLaneConfig( txEncoder sdk.TxEncoder, txDecoder sdk.TxDecoder, anteHandler sdk.AnteHandler, - signerExtractor signer_extraction.SignerExtractionAdapter, + signerExtractor signer_extraction.Adapter, maxBlockSpace math.LegacyDec, ) LaneConfig { return LaneConfig{ - Logger: logger, - TxEncoder: txEncoder, - TxDecoder: txDecoder, - AnteHandler: anteHandler, - MaxBlockSpace: maxBlockSpace, + Logger: logger, + TxEncoder: txEncoder, + TxDecoder: txDecoder, + AnteHandler: anteHandler, + MaxBlockSpace: maxBlockSpace, SignerExtractor: signerExtractor, } } @@ -82,7 +82,7 @@ func (c *LaneConfig) ValidateBasic() error { if c.SignerExtractor == nil { return fmt.Errorf("signer extractor cannot be nil") } - + if c.MaxBlockSpace.IsNil() || c.MaxBlockSpace.IsNegative() || c.MaxBlockSpace.GT(math.LegacyOneDec()) { return fmt.Errorf("max block space must be set to a value between 0 and 1") } diff --git a/block/base/mempool.go b/block/base/mempool.go index acfdb575..2c39ac64 100644 --- a/block/base/mempool.go +++ b/block/base/mempool.go @@ -82,7 +82,7 @@ func DefaultTxPriority() TxPriority[string] { } // NewMempool returns a new Mempool. -func NewMempool[C comparable](txPriority TxPriority[C], txEncoder sdk.TxEncoder, extractor signer_extraction.SignerExtractionAdapter, maxTx int) *Mempool[C] { +func NewMempool[C comparable](txPriority TxPriority[C], txEncoder sdk.TxEncoder, extractor signer_extraction.Adapter, maxTx int) *Mempool[C] { return &Mempool[C]{ index: NewPriorityMempool( PriorityNonceMempoolConfig[C]{ diff --git a/block/base/priority_nonce.go b/block/base/priority_nonce.go index 74fa3995..21913fa7 100644 --- a/block/base/priority_nonce.go +++ b/block/base/priority_nonce.go @@ -62,12 +62,12 @@ type ( // priority to other sender txs and must be partially ordered by both sender-nonce // and priority. PriorityNonceMempool[C comparable] struct { - priorityIndex *skiplist.SkipList - priorityCounts map[C]int - senderIndices map[string]*skiplist.SkipList - scores map[txMeta[C]]txMeta[C] - cfg PriorityNonceMempoolConfig[C] - signerExtractor signer_extraction.SignerExtractionAdapter + priorityIndex *skiplist.SkipList + priorityCounts map[C]int + senderIndices map[string]*skiplist.SkipList + scores map[txMeta[C]]txMeta[C] + cfg PriorityNonceMempoolConfig[C] + signerExtractor signer_extraction.Adapter } // PriorityNonceIterator defines an iterator that is used for mempool iteration @@ -168,13 +168,13 @@ func skiplistComparable[C comparable](txPriority TxPriority[C]) skiplist.Compara // NewPriorityMempool returns the SDK's default mempool implementation which // returns txs in a partial order by 2 dimensions; priority, and sender-nonce. -func NewPriorityMempool[C comparable](cfg PriorityNonceMempoolConfig[C], extractor signer_extraction.SignerExtractionAdapter) *PriorityNonceMempool[C] { +func NewPriorityMempool[C comparable](cfg PriorityNonceMempoolConfig[C], extractor signer_extraction.Adapter) *PriorityNonceMempool[C] { mp := &PriorityNonceMempool[C]{ - priorityIndex: skiplist.New(skiplistComparable(cfg.TxPriority)), - priorityCounts: make(map[C]int), - senderIndices: make(map[string]*skiplist.SkipList), - scores: make(map[txMeta[C]]txMeta[C]), - cfg: cfg, + priorityIndex: skiplist.New(skiplistComparable(cfg.TxPriority)), + priorityCounts: make(map[C]int), + senderIndices: make(map[string]*skiplist.SkipList), + scores: make(map[txMeta[C]]txMeta[C]), + cfg: cfg, signerExtractor: extractor, } @@ -182,7 +182,7 @@ func NewPriorityMempool[C comparable](cfg PriorityNonceMempoolConfig[C], extract } // DefaultPriorityMempool returns a priorityNonceMempool with no options. -func DefaultPriorityMempool(extractor signer_extraction.DefaultSignerExtractionAdapter) *PriorityNonceMempool[int64] { +func DefaultPriorityMempool(extractor signer_extraction.DefaultAdapter) *PriorityNonceMempool[int64] { return NewPriorityMempool(DefaultPriorityNonceMempoolConfig(), extractor) } diff --git a/block/mempool_test.go b/block/mempool_test.go index 72429638..4625fa5c 100644 --- a/block/mempool_test.go +++ b/block/mempool_test.go @@ -61,12 +61,12 @@ func (suite *BlockBusterTestSuite) SetupTest() { // TOB lane set up suite.gasTokenDenom = "stake" mevConfig := base.LaneConfig{ - Logger: log.NewNopLogger(), - TxEncoder: suite.encodingConfig.TxConfig.TxEncoder(), - TxDecoder: suite.encodingConfig.TxConfig.TxDecoder(), - SignerExtractor: signer_extraction.NewDefaultSignerExtractionAdapter(), - AnteHandler: nil, - MaxBlockSpace: math.LegacyZeroDec(), + Logger: log.NewNopLogger(), + TxEncoder: suite.encodingConfig.TxConfig.TxEncoder(), + TxDecoder: suite.encodingConfig.TxConfig.TxDecoder(), + SignerExtractor: signer_extraction.NewDefaultAdapter(), + AnteHandler: nil, + MaxBlockSpace: math.LegacyZeroDec(), } suite.mevLane = mev.NewMEVLane( mevConfig, @@ -75,12 +75,12 @@ func (suite *BlockBusterTestSuite) SetupTest() { // Free lane set up freeConfig := base.LaneConfig{ - Logger: log.NewNopLogger(), - TxEncoder: suite.encodingConfig.TxConfig.TxEncoder(), - TxDecoder: suite.encodingConfig.TxConfig.TxDecoder(), - SignerExtractor: signer_extraction.NewDefaultSignerExtractionAdapter(), - AnteHandler: nil, - MaxBlockSpace: math.LegacyZeroDec(), + Logger: log.NewNopLogger(), + TxEncoder: suite.encodingConfig.TxConfig.TxEncoder(), + TxDecoder: suite.encodingConfig.TxConfig.TxDecoder(), + SignerExtractor: signer_extraction.NewDefaultAdapter(), + AnteHandler: nil, + MaxBlockSpace: math.LegacyZeroDec(), } suite.freeLane = free.NewFreeLane( freeConfig, @@ -90,12 +90,12 @@ func (suite *BlockBusterTestSuite) SetupTest() { // Base lane set up baseConfig := base.LaneConfig{ - Logger: log.NewNopLogger(), - TxEncoder: suite.encodingConfig.TxConfig.TxEncoder(), - TxDecoder: suite.encodingConfig.TxConfig.TxDecoder(), - SignerExtractor: signer_extraction.NewDefaultSignerExtractionAdapter(), - AnteHandler: nil, - MaxBlockSpace: math.LegacyZeroDec(), + Logger: log.NewNopLogger(), + TxEncoder: suite.encodingConfig.TxConfig.TxEncoder(), + TxDecoder: suite.encodingConfig.TxConfig.TxDecoder(), + SignerExtractor: signer_extraction.NewDefaultAdapter(), + AnteHandler: nil, + MaxBlockSpace: math.LegacyZeroDec(), } suite.baseLane = defaultlane.NewDefaultLane( baseConfig, diff --git a/lanes/base/abci_test.go b/lanes/base/abci_test.go index 11ce5aff..c577fb6d 100644 --- a/lanes/base/abci_test.go +++ b/lanes/base/abci_test.go @@ -510,7 +510,7 @@ func (s *BaseTestSuite) initLane( s.encodingConfig.TxConfig.TxEncoder(), s.encodingConfig.TxConfig.TxDecoder(), s.setUpAnteHandler(expectedExecution), - signer_extraction.NewDefaultSignerExtractionAdapter(), + signer_extraction.NewDefaultAdapter(), maxBlockSpace, ) diff --git a/lanes/base/mempool_test.go b/lanes/base/mempool_test.go index 92b11cb3..c21120c5 100644 --- a/lanes/base/mempool_test.go +++ b/lanes/base/mempool_test.go @@ -4,9 +4,9 @@ import ( "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" + signer_extraction "github.com/skip-mev/block-sdk/adapters/signer_extraction_adapter" "github.com/skip-mev/block-sdk/block/base" testutils "github.com/skip-mev/block-sdk/testutils" - signer_extraction "github.com/skip-mev/block-sdk/adapters/signer_extraction_adapter" ) func (s *BaseTestSuite) TestGetTxPriority() { @@ -86,7 +86,7 @@ func (s *BaseTestSuite) TestCompareTxPriority() { } func (s *BaseTestSuite) TestInsert() { - mempool := base.NewMempool[string](base.DefaultTxPriority(), s.encodingConfig.TxConfig.TxEncoder(), signer_extraction.NewDefaultSignerExtractionAdapter(), 3) + mempool := base.NewMempool[string](base.DefaultTxPriority(), s.encodingConfig.TxConfig.TxEncoder(), signer_extraction.NewDefaultAdapter(), 3) s.Run("should be able to insert a transaction", func() { tx, err := testutils.CreateRandomTx( @@ -138,7 +138,7 @@ func (s *BaseTestSuite) TestInsert() { } func (s *BaseTestSuite) TestRemove() { - mempool := base.NewMempool[string](base.DefaultTxPriority(), s.encodingConfig.TxConfig.TxEncoder(), signer_extraction.NewDefaultSignerExtractionAdapter(), 3) + mempool := base.NewMempool[string](base.DefaultTxPriority(), s.encodingConfig.TxConfig.TxEncoder(), signer_extraction.NewDefaultAdapter(), 3) s.Run("should be able to remove a transaction", func() { tx, err := testutils.CreateRandomTx( @@ -176,7 +176,7 @@ func (s *BaseTestSuite) TestRemove() { func (s *BaseTestSuite) TestSelect() { s.Run("should be able to select transactions in the correct order", func() { - mempool := base.NewMempool[string](base.DefaultTxPriority(), s.encodingConfig.TxConfig.TxEncoder(), signer_extraction.NewDefaultSignerExtractionAdapter(), 3) + mempool := base.NewMempool[string](base.DefaultTxPriority(), s.encodingConfig.TxConfig.TxEncoder(), signer_extraction.NewDefaultAdapter(), 3) tx1, err := testutils.CreateRandomTx( s.encodingConfig.TxConfig, @@ -215,7 +215,7 @@ func (s *BaseTestSuite) TestSelect() { }) s.Run("should be able to select a single transaction", func() { - mempool := base.NewMempool[string](base.DefaultTxPriority(), s.encodingConfig.TxConfig.TxEncoder(), signer_extraction.NewDefaultSignerExtractionAdapter(), 3) + mempool := base.NewMempool[string](base.DefaultTxPriority(), s.encodingConfig.TxConfig.TxEncoder(), signer_extraction.NewDefaultAdapter(), 3) tx1, err := testutils.CreateRandomTx( s.encodingConfig.TxConfig, diff --git a/tests/app/app.go b/tests/app/app.go index 3fa9580b..96108a44 100644 --- a/tests/app/app.go +++ b/tests/app/app.go @@ -265,12 +265,12 @@ func New( // lane and the last lane is the lowest priority lane. // MEV lane allows transactions to bid for inclusion at the top of the next block. mevConfig := base.LaneConfig{ - Logger: app.Logger(), - TxEncoder: app.txConfig.TxEncoder(), - TxDecoder: app.txConfig.TxDecoder(), - MaxBlockSpace: math.LegacyZeroDec(), // This means the lane has no limit on block space. - SignerExtractor: signer_extraction.NewDefaultSignerExtractionAdapter(), - MaxTxs: 0, // This means the lane has no limit on the number of transactions it can store. + Logger: app.Logger(), + TxEncoder: app.txConfig.TxEncoder(), + TxDecoder: app.txConfig.TxDecoder(), + MaxBlockSpace: math.LegacyZeroDec(), // This means the lane has no limit on block space. + SignerExtractor: signer_extraction.NewDefaultAdapter(), + MaxTxs: 0, // This means the lane has no limit on the number of transactions it can store. } mevLane := mev.NewMEVLane( mevConfig, @@ -279,12 +279,12 @@ func New( // Free lane allows transactions to be included in the next block for free. freeConfig := base.LaneConfig{ - Logger: app.Logger(), - TxEncoder: app.txConfig.TxEncoder(), - TxDecoder: app.txConfig.TxDecoder(), - MaxBlockSpace: math.LegacyZeroDec(), - SignerExtractor: signer_extraction.NewDefaultSignerExtractionAdapter(), - MaxTxs: 0, + Logger: app.Logger(), + TxEncoder: app.txConfig.TxEncoder(), + TxDecoder: app.txConfig.TxDecoder(), + MaxBlockSpace: math.LegacyZeroDec(), + SignerExtractor: signer_extraction.NewDefaultAdapter(), + MaxTxs: 0, } freeLane := free.NewFreeLane( freeConfig, @@ -294,12 +294,12 @@ func New( // Default lane accepts all other transactions. defaultConfig := base.LaneConfig{ - Logger: app.Logger(), - TxEncoder: app.txConfig.TxEncoder(), - TxDecoder: app.txConfig.TxDecoder(), - MaxBlockSpace: math.LegacyZeroDec(), - SignerExtractor: signer_extraction.NewDefaultSignerExtractionAdapter(), - MaxTxs: 0, + Logger: app.Logger(), + TxEncoder: app.txConfig.TxEncoder(), + TxDecoder: app.txConfig.TxDecoder(), + MaxBlockSpace: math.LegacyZeroDec(), + SignerExtractor: signer_extraction.NewDefaultAdapter(), + MaxTxs: 0, } defaultLane := defaultlane.NewDefaultLane(defaultConfig) diff --git a/x/auction/ante/ante_test.go b/x/auction/ante/ante_test.go index 4def685a..3822db45 100644 --- a/x/auction/ante/ante_test.go +++ b/x/auction/ante/ante_test.go @@ -87,12 +87,12 @@ func (suite *AnteTestSuite) SetupTest() { // // TOB lane set up mevConfig := base.LaneConfig{ - Logger: suite.ctx.Logger(), - TxEncoder: suite.encodingConfig.TxConfig.TxEncoder(), - TxDecoder: suite.encodingConfig.TxConfig.TxDecoder(), - SignerExtractor: signer_extraction.NewDefaultSignerExtractionAdapter(), - AnteHandler: suite.anteHandler, - MaxBlockSpace: math.LegacyZeroDec(), + Logger: suite.ctx.Logger(), + TxEncoder: suite.encodingConfig.TxConfig.TxEncoder(), + TxDecoder: suite.encodingConfig.TxConfig.TxDecoder(), + SignerExtractor: signer_extraction.NewDefaultAdapter(), + AnteHandler: suite.anteHandler, + MaxBlockSpace: math.LegacyZeroDec(), } suite.mevLane = mev.NewMEVLane( mevConfig, @@ -101,13 +101,13 @@ func (suite *AnteTestSuite) SetupTest() { // Base lane set up baseConfig := base.LaneConfig{ - Logger: suite.ctx.Logger(), - TxEncoder: suite.encodingConfig.TxConfig.TxEncoder(), - TxDecoder: suite.encodingConfig.TxConfig.TxDecoder(), - AnteHandler: suite.anteHandler, - SignerExtractor: signer_extraction.NewDefaultSignerExtractionAdapter(), - MaxBlockSpace: math.LegacyZeroDec(), - IgnoreList: []block.Lane{suite.mevLane}, + Logger: suite.ctx.Logger(), + TxEncoder: suite.encodingConfig.TxConfig.TxEncoder(), + TxDecoder: suite.encodingConfig.TxConfig.TxDecoder(), + AnteHandler: suite.anteHandler, + SignerExtractor: signer_extraction.NewDefaultAdapter(), + MaxBlockSpace: math.LegacyZeroDec(), + IgnoreList: []block.Lane{suite.mevLane}, } suite.baseLane = defaultlane.NewDefaultLane(baseConfig) From 7306e3e289eaae6f5244b25dc40cf92213645294 Mon Sep 17 00:00:00 2001 From: Nikhil Vasan <97126437+nivasan1@users.noreply.github.com> Date: Wed, 27 Sep 2023 07:35:09 -0700 Subject: [PATCH 3/3] feat(adapters/mev-lane): Use the SignerExtractionAdapter in the Mev-Lane [ENG-1917] (#115) * use SignerExtractionAdapter in the Factory * feat(e2e): block sdk integration updates (#122) * cherry-pick from injective * remove transactions from app-side mempool on failed re-checktx --- Makefile | 2 +- abci/abci_test.go | 2 +- block/mempool_test.go | 2 +- lanes/mev/check_tx.go | 26 +- lanes/mev/factory.go | 19 +- lanes/mev/mev_test.go | 3 +- tests/app/app.go | 2 +- tests/integration/block_sdk_suite.go | 379 ++++++++++++++++++--------- tests/integration/chain_setup.go | 174 +++++++++--- tests/integration/go.mod | 7 +- tests/integration/go.sum | 13 +- x/auction/ante/ante.go | 15 +- x/auction/ante/ante_test.go | 2 +- 13 files changed, 440 insertions(+), 206 deletions(-) diff --git a/Makefile b/Makefile index 220b5d01..42f0b997 100644 --- a/Makefile +++ b/Makefile @@ -119,7 +119,7 @@ TEST_INTEGRATION_TAGS = integration test-integration: $(TEST_INTEGRATION_DEPS) @ echo "Running integration tests..." - @go test ./tests/integration/block_sdk_integration_test.go -timeout 30m -race -v -tags='$(TEST_INTEGRATION_TAGS)' + @go test ./tests/integration/block_sdk_integration_test.go -timeout 30m -p 1 -race -v -tags='$(TEST_INTEGRATION_TAGS)' test: use-main @go test -v -race $(shell go list ./... | grep -v tests/) diff --git a/abci/abci_test.go b/abci/abci_test.go index cb02f2d1..1c26c009 100644 --- a/abci/abci_test.go +++ b/abci/abci_test.go @@ -757,7 +757,7 @@ func (s *ProposalsTestSuite) setUpTOBLane(maxBlockSpace math.LegacyDec, expected MaxBlockSpace: maxBlockSpace, } - return mev.NewMEVLane(cfg, mev.NewDefaultAuctionFactory(cfg.TxDecoder)) + return mev.NewMEVLane(cfg, mev.NewDefaultAuctionFactory(cfg.TxDecoder, signer_extraction.NewDefaultAdapter())) } func (s *ProposalsTestSuite) setUpFreeLane(maxBlockSpace math.LegacyDec, expectedExecution map[sdk.Tx]bool) *free.FreeLane { diff --git a/block/mempool_test.go b/block/mempool_test.go index 4625fa5c..714bc27a 100644 --- a/block/mempool_test.go +++ b/block/mempool_test.go @@ -70,7 +70,7 @@ func (suite *BlockBusterTestSuite) SetupTest() { } suite.mevLane = mev.NewMEVLane( mevConfig, - mev.NewDefaultAuctionFactory(suite.encodingConfig.TxConfig.TxDecoder()), + mev.NewDefaultAuctionFactory(suite.encodingConfig.TxConfig.TxDecoder(), signer_extraction.NewDefaultAdapter()), ) // Free lane set up diff --git a/lanes/mev/check_tx.go b/lanes/mev/check_tx.go index 48c9a4a1..e5807f4d 100644 --- a/lanes/mev/check_tx.go +++ b/lanes/mev/check_tx.go @@ -118,7 +118,7 @@ func (handler *CheckTxHandler) CheckTx() CheckTx { 0, nil, false, - ), err + ), nil } // Attempt to get the bid info of the transaction. @@ -135,7 +135,7 @@ func (handler *CheckTxHandler) CheckTx() CheckTx { 0, nil, false, - ), err + ), nil } // If this is not a bid transaction, we just execute it normally. @@ -162,17 +162,35 @@ func (handler *CheckTxHandler) CheckTx() CheckTx { handler.baseApp.Logger().Info( "invalid bid tx", "err", err, + "tx", req.Tx, + "removing tx from mempool", true, ) + // attempt to remove the bid from the MEVLane (if it exists) + if handler.mevLane.Contains(tx) { + if err := handler.mevLane.Remove(tx); err != nil { + handler.baseApp.Logger().Error( + "failed to remove bid transaction from mev-lane", + "err", err, + ) + } + } + return sdkerrors.ResponseCheckTxWithEvents( fmt.Errorf("invalid bid tx: %w", err), gasInfo.GasWanted, gasInfo.GasUsed, nil, false, - ), err + ), nil } + handler.baseApp.Logger().Info( + "valid bid tx", + "tx", req.Tx, + "inserting tx into mempool", true, + ) + // If the bid transaction is valid, we know we can insert it into the mempool for consideration in the next block. if err := handler.mevLane.Insert(ctx, tx); err != nil { handler.baseApp.Logger().Info( @@ -186,7 +204,7 @@ func (handler *CheckTxHandler) CheckTx() CheckTx { gasInfo.GasUsed, nil, false, - ), err + ), nil } return &cometabci.ResponseCheckTx{ diff --git a/lanes/mev/factory.go b/lanes/mev/factory.go index 20094537..41cf6f17 100644 --- a/lanes/mev/factory.go +++ b/lanes/mev/factory.go @@ -4,8 +4,8 @@ import ( "fmt" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/auth/signing" + signer_extraction "github.com/skip-mev/block-sdk/adapters/signer_extraction_adapter" "github.com/skip-mev/block-sdk/block/base" "github.com/skip-mev/block-sdk/x/auction/types" ) @@ -30,7 +30,8 @@ type ( // DefaultAuctionFactory defines a default implmentation for the auction factory interface for processing auction transactions. DefaultAuctionFactory struct { - txDecoder sdk.TxDecoder + txDecoder sdk.TxDecoder + signerExtractor signer_extraction.Adapter } // TxWithTimeoutHeight is used to extract timeouts from sdk.Tx transactions. In the case where, @@ -45,9 +46,10 @@ type ( var _ Factory = (*DefaultAuctionFactory)(nil) // NewDefaultAuctionFactory returns a default auction factory interface implementation. -func NewDefaultAuctionFactory(txDecoder sdk.TxDecoder) Factory { +func NewDefaultAuctionFactory(txDecoder sdk.TxDecoder, extractor signer_extraction.Adapter) Factory { return &DefaultAuctionFactory{ - txDecoder: txDecoder, + txDecoder: txDecoder, + signerExtractor: extractor, } } @@ -115,20 +117,15 @@ func (config *DefaultAuctionFactory) getBundleSigners(bundle [][]byte) ([]map[st return nil, err } - sigTx, ok := sdkTx.(signing.SigVerifiableTx) - if !ok { - return nil, fmt.Errorf("transaction is not valid") - } - txSigners := make(map[string]struct{}) - signers, err := sigTx.GetSigners() + signers, err := config.signerExtractor.GetSigners(sdkTx) if err != nil { return nil, err } for _, signer := range signers { - txSigners[sdk.AccAddress(signer).String()] = struct{}{} + txSigners[signer.Signer.String()] = struct{}{} } bundleSigners = append(bundleSigners, txSigners) diff --git a/lanes/mev/mev_test.go b/lanes/mev/mev_test.go index 8485a639..4f6a2c51 100644 --- a/lanes/mev/mev_test.go +++ b/lanes/mev/mev_test.go @@ -10,6 +10,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/suite" + signer_extraction "github.com/skip-mev/block-sdk/adapters/signer_extraction_adapter" "github.com/skip-mev/block-sdk/lanes/mev" testutils "github.com/skip-mev/block-sdk/testutils" ) @@ -32,7 +33,7 @@ func TestMempoolTestSuite(t *testing.T) { func (suite *MEVTestSuite) SetupTest() { // Mempool setup suite.encCfg = testutils.CreateTestEncodingConfig() - suite.config = mev.NewDefaultAuctionFactory(suite.encCfg.TxConfig.TxDecoder()) + suite.config = mev.NewDefaultAuctionFactory(suite.encCfg.TxConfig.TxDecoder(), signer_extraction.NewDefaultAdapter()) suite.ctx = sdk.NewContext(nil, cmtproto.Header{}, false, log.NewTestLogger(suite.T())) // Init accounts diff --git a/tests/app/app.go b/tests/app/app.go index 96108a44..29a8039b 100644 --- a/tests/app/app.go +++ b/tests/app/app.go @@ -274,7 +274,7 @@ func New( } mevLane := mev.NewMEVLane( mevConfig, - mev.NewDefaultAuctionFactory(app.txConfig.TxDecoder()), + mev.NewDefaultAuctionFactory(app.txConfig.TxDecoder(), signer_extraction.NewDefaultAdapter()), ) // Free lane allows transactions to be included in the next block for free. diff --git a/tests/integration/block_sdk_suite.go b/tests/integration/block_sdk_suite.go index 6bae76d9..88c278c0 100644 --- a/tests/integration/block_sdk_suite.go +++ b/tests/integration/block_sdk_suite.go @@ -12,6 +12,10 @@ import ( "github.com/strangelove-ventures/interchaintest/v7/ibc" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/crypto/keyring" + rpctypes "github.com/cometbft/cometbft/rpc/core/types" + "bytes" ) const ( @@ -31,6 +35,12 @@ type IntegrationTestSuite struct { user1, user2, user3 ibc.Wallet // denom denom string + + // overrides for key-ring configuration of the broadcaster + broadcasterOverrides *KeyringOverride + + // broadcaster is the RPC interface to the ITS network + bc *cosmos.Broadcaster } func NewIntegrationTestSuiteFromSpec(spec *interchaintest.ChainSpec) *IntegrationTestSuite { @@ -50,6 +60,13 @@ func (s *IntegrationTestSuite) WithDenom(denom string) *IntegrationTestSuite { return s } +func (s *IntegrationTestSuite) WithKeyringOptions(cdc codec.Codec, opts keyring.Option) { + s.broadcasterOverrides = &KeyringOverride{ + cdc: cdc, + keyringOptions: opts, + } +} + func (s *IntegrationTestSuite) SetupSuite() { // build the chain s.T().Log("building chain with spec", s.spec) @@ -64,6 +81,10 @@ func (s *IntegrationTestSuite) SetupSuite() { s.user1 = interchaintest.GetAndFundTestUsers(s.T(), ctx, s.T().Name(), initBalance, s.chain)[0] s.user2 = interchaintest.GetAndFundTestUsers(s.T(), ctx, s.T().Name(), initBalance, s.chain)[0] s.user3 = interchaintest.GetAndFundTestUsers(s.T(), ctx, s.T().Name(), initBalance, s.chain)[0] + + // create the broadcaster + s.T().Log("creating broadcaster") + s.setupBroadcaster() } func (s *IntegrationTestSuite) TearDownSuite() { @@ -108,7 +129,7 @@ func (s *IntegrationTestSuite) TestValidBids() { // create the MsgAuctioBid bidAmt := params.ReserveFee - bid, bundledTxs := CreateAuctionBidMsg(s.T(), context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{ + bid, bundledTxs := s.CreateAuctionBidMsg(context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{ { User: s.user1, Msgs: []sdk.Msg{ @@ -122,7 +143,7 @@ func (s *IntegrationTestSuite) TestValidBids() { require.NoError(s.T(), err) // broadcast + wait for the tx to be included in a block - res := BroadcastTxs(s.T(), context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{ + res := s.BroadcastTxs( context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{ { User: s.user1, Msgs: []sdk.Msg{bid}, @@ -156,7 +177,7 @@ func (s *IntegrationTestSuite) TestValidBids() { // create the MsgAuctionBid bidAmt := params.ReserveFee - bid, bundledTxs := CreateAuctionBidMsg(s.T(), context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{ + bid, bundledTxs := s.CreateAuctionBidMsg( context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{ { User: s.user1, Msgs: msgs[0:1], @@ -172,24 +193,52 @@ func (s *IntegrationTestSuite) TestValidBids() { msgsToBcast = append(msgsToBcast, Tx{ User: s.user1, Msgs: []sdk.Msg{bid}, - Height: height + 1, + Height: height + 3, }) msgsToBcast = append(msgsToBcast, Tx{ User: s.user2, Msgs: msgs[1:2], - Height: height + 1, + Height: height + 3, }) - regular_txs := BroadcastTxs(s.T(), context.Background(), s.chain.(*cosmos.CosmosChain), msgsToBcast) + expTxs := make(chan committedTx, 2) + + regular_txs := s.BroadcastTxsWithCallback( + context.Background(), + s.chain.(*cosmos.CosmosChain), + msgsToBcast, + func(tx []byte, resp *rpctypes.ResultTx) { + expTxs <- committedTx{tx, resp} + }, + ) + close(expTxs) + s.Require().Len(expTxs, 2) + + // get the height of the block that the bid was included in + var commitHeight int64 + + tx1 := <-expTxs + tx2 := <-expTxs + + // determine which tx is the bid + if bytes.Equal(tx1.tx, regular_txs[0]) { + commitHeight = tx1.res.Height + } else { + commitHeight = tx2.res.Height + } + + // if they were committed in the same height + if tx1.res.Height == tx2.res.Height { + bundledTxs = append(bundledTxs, regular_txs[1:]...) + } // get the block at the next height - WaitForHeight(s.T(), s.chain.(*cosmos.CosmosChain), height+1) - block := Block(s.T(), s.chain.(*cosmos.CosmosChain), int64(height+1)) + block := Block(s.T(), s.chain.(*cosmos.CosmosChain), commitHeight) // verify the block bidTxHash := TxHash(regular_txs[0]) - VerifyBlock(s.T(), block, 0, bidTxHash, append(bundledTxs, regular_txs[1:]...)) + VerifyBlock(s.T(), block, 0, bidTxHash, bundledTxs) // ensure that escrow account has the correct balance escrowAcctBalanceAfterBid := QueryAccountBalance(s.T(), s.chain, escrowAddr, params.ReserveFee.Denom) @@ -216,10 +265,10 @@ func (s *IntegrationTestSuite) TestValidBids() { } // create bundle bidAmt := params.ReserveFee - bid, bundledTxs := CreateAuctionBidMsg(s.T(), context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, txs) + bid, bundledTxs := s.CreateAuctionBidMsg( context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, txs) // create 2 more bundle w same txs from same user - bid2, _ := CreateAuctionBidMsg(s.T(), context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt.Add(params.MinBidIncrement), txs) - bid3, _ := CreateAuctionBidMsg(s.T(), context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt.Add(params.MinBidIncrement).Add(params.MinBidIncrement), txs) + bid2, _ := s.CreateAuctionBidMsg( context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt.Add(params.MinBidIncrement), txs) + bid3, _ := s.CreateAuctionBidMsg( context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt.Add(params.MinBidIncrement).Add(params.MinBidIncrement), txs) // query height height, err := s.chain.(*cosmos.CosmosChain).Height(context.Background()) @@ -230,7 +279,7 @@ func (s *IntegrationTestSuite) TestValidBids() { height++ // broadcast all bids - broadcastedTxs := BroadcastTxs(s.T(), context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{ + broadcastedTxs := s.BroadcastTxs( context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{ { User: s.user1, Msgs: []sdk.Msg{bid}, @@ -286,28 +335,41 @@ func (s *IntegrationTestSuite) TestValidBids() { // create bundle bidAmt := params.ReserveFee - bid, bundledTxs := CreateAuctionBidMsg(s.T(), context.Background(), s.user2, s.chain.(*cosmos.CosmosChain), bidAmt, txs) + bid, bundledTxs := s.CreateAuctionBidMsg(context.Background(), s.user2, s.chain.(*cosmos.CosmosChain), bidAmt, txs) // get chain height height, err = s.chain.(*cosmos.CosmosChain).Height(context.Background()) require.NoError(s.T(), err) + expTxs := make(chan committedTx, 4) + // broadcast txs in the bundle to network + bundle + extra - broadcastedTxs := BroadcastTxs(s.T(), context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{txs[0], txs[1], { + broadcastedTxs := s.BroadcastTxsWithCallback(context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{ + { User: s.user2, Msgs: []sdk.Msg{bid}, - Height: height + 1, + Height: height + 3, }, { User: s.user3, Msgs: []sdk.Msg{banktypes.NewMsgSend(s.user3.Address(), s.user1.Address(), sdk.NewCoins(sdk.NewCoin(s.denom, math.NewInt(100))))}, - }}) + Height: height + 3, + }}, + func(tx []byte, resp *rpctypes.ResultTx) { + expTxs <- committedTx{tx, resp} + }) + close(expTxs) - // query next block - WaitForHeight(s.T(), s.chain.(*cosmos.CosmosChain), height+1) - block := Block(s.T(), s.chain.(*cosmos.CosmosChain), int64(height+1)) + var bidTxHeight int64 + for tx := range expTxs { + if bytes.Equal(tx.tx, broadcastedTxs[0]) { + bidTxHeight = tx.res.Height + } + } + + block := Block(s.T(), s.chain.(*cosmos.CosmosChain), bidTxHeight) // check block - VerifyBlock(s.T(), block, 0, TxHash(broadcastedTxs[2]), append(bundledTxs, broadcastedTxs[3])) + VerifyBlock(s.T(), block, 0, TxHash(broadcastedTxs[0]), bundledTxs) // check escrow account balance escrowAcctBalanceAfterBid := QueryAccountBalance(s.T(), s.chain, escrowAddr, params.ReserveFee.Denom) @@ -316,6 +378,11 @@ func (s *IntegrationTestSuite) TestValidBids() { }) } +type committedTx struct { + tx []byte + res *rpctypes.ResultTx +} + // TestMultipleBids tests the execution of various valid auction bids in the same block. There are a few // invariants that are tested: // @@ -343,7 +410,7 @@ func (s *IntegrationTestSuite) TestMultipleBids() { } // create bid1 bidAmt := params.ReserveFee - bid1, bundledTxs := CreateAuctionBidMsg(s.T(), context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{msg}) + bid1, bundledTxs := s.CreateAuctionBidMsg( context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{msg}) // create bid 2 msg2 := Tx{ @@ -352,36 +419,45 @@ func (s *IntegrationTestSuite) TestMultipleBids() { SequenceIncrement: 1, } // create bid2 w/ higher bid than bid1 - bid2, bundledTxs2 := CreateAuctionBidMsg(s.T(), context.Background(), s.user2, s.chain.(*cosmos.CosmosChain), bidAmt.Add(params.MinBidIncrement), []Tx{msg2}) + bid2, bundledTxs2 := s.CreateAuctionBidMsg( context.Background(), s.user2, s.chain.(*cosmos.CosmosChain), bidAmt.Add(params.MinBidIncrement), []Tx{msg2}) // get chain height height, err := s.chain.(*cosmos.CosmosChain).Height(context.Background()) require.NoError(s.T(), err) - // broadcast both bids - txs := BroadcastTxs(s.T(), context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{ + // create channel to receive txs + txsCh := make(chan committedTx, 2) + + // broadcast both bids (with ample time to be committed (instead of timing out)) + txs := s.BroadcastTxsWithCallback(context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{ { User: s.user1, Msgs: []sdk.Msg{bid1}, - Height: height + 2, - SkipInclusionCheck: true, + Height: height + 4, }, { User: s.user2, Msgs: []sdk.Msg{bid2}, - Height: height + 1, + Height: height + 3, }, + }, func(tx []byte, resp *rpctypes.ResultTx) { + txsCh <- committedTx{tx, resp} }) + + // check txs were committed + require.Len(s.T(), txsCh, 2) + close(txsCh) - // query next block - WaitForHeight(s.T(), s.chain.(*cosmos.CosmosChain), height+1) - block := Block(s.T(), s.chain.(*cosmos.CosmosChain), int64(height+1)) + tx1 := <-txsCh + tx2 := <-txsCh + + // query next block + block := Block(s.T(), s.chain.(*cosmos.CosmosChain), tx1.res.Height) // check bid2 was included first VerifyBlock(s.T(), block, 0, TxHash(txs[1]), bundledTxs2) // check next block - WaitForHeight(s.T(), s.chain.(*cosmos.CosmosChain), height+2) - block = Block(s.T(), s.chain.(*cosmos.CosmosChain), int64(height+2)) + block = Block(s.T(), s.chain.(*cosmos.CosmosChain), tx2.res.Height) // check bid1 was included second VerifyBlock(s.T(), block, 0, TxHash(txs[0]), bundledTxs) @@ -405,7 +481,7 @@ func (s *IntegrationTestSuite) TestMultipleBids() { } // create bid1 bidAmt := params.ReserveFee - bid1, bundledTxs := CreateAuctionBidMsg(s.T(), context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{tx}) + bid1, bundledTxs := s.CreateAuctionBidMsg( context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{tx}) // create bid 2 tx2 := Tx{ @@ -414,30 +490,36 @@ func (s *IntegrationTestSuite) TestMultipleBids() { SequenceIncrement: 1, } // create bid2 w/ higher bid than bid1 - bid2, _ := CreateAuctionBidMsg(s.T(), context.Background(), s.user2, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{tx2}) + bid2, _ := s.CreateAuctionBidMsg( context.Background(), s.user2, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{tx2}) // get chain height height, err := s.chain.(*cosmos.CosmosChain).Height(context.Background()) require.NoError(s.T(), err) - // broadcast both bids - txs := BroadcastTxs(s.T(), context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{ + expTx := make(chan committedTx, 1) + + // broadcast both bids (wait for the first to be committed) + txs := s.BroadcastTxsWithCallback(context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{ { User: s.user1, Msgs: []sdk.Msg{bid1}, - Height: height + 1, + Height: height + 4, }, { User: s.user2, Msgs: []sdk.Msg{bid2}, - Height: height + 1, + Height: height + 3, ExpectFail: true, }, + }, func(tx []byte, resp *rpctypes.ResultTx) { + expTx <- committedTx{tx, resp} }) + close(expTx) + commitTx := <-expTx + // query next block - WaitForHeight(s.T(), s.chain.(*cosmos.CosmosChain), height+1) - block := Block(s.T(), s.chain.(*cosmos.CosmosChain), int64(height+1)) + block := Block(s.T(), s.chain.(*cosmos.CosmosChain), commitTx.res.Height) // check bid2 was included first VerifyBlock(s.T(), block, 0, TxHash(txs[0]), bundledTxs) @@ -461,7 +543,7 @@ func (s *IntegrationTestSuite) TestMultipleBids() { } // create bid1 bidAmt := params.ReserveFee - bid1, bundledTxs := CreateAuctionBidMsg(s.T(), context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{msg}) + bid1, bundledTxs := s.CreateAuctionBidMsg( context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{msg}) // create bid 2 msg2 := Tx{ @@ -469,33 +551,39 @@ func (s *IntegrationTestSuite) TestMultipleBids() { Msgs: []sdk.Msg{banktypes.NewMsgSend(s.user2.Address(), s.user3.Address(), sdk.NewCoins(sdk.NewCoin(s.denom, math.NewInt(100))))}, SequenceIncrement: 1, } + // create bid2 w/ higher bid than bid1 - bid2, _ := CreateAuctionBidMsg(s.T(), context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{msg2}) + bid2, _ := s.CreateAuctionBidMsg( context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{msg2}) // get chain height height, err := s.chain.(*cosmos.CosmosChain).Height(context.Background()) require.NoError(s.T(), err) + expTx := make(chan committedTx, 1) + // broadcast both bids - txs := BroadcastTxs(s.T(), context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{ + txs := s.BroadcastTxsWithCallback(context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{ { User: s.user1, Msgs: []sdk.Msg{bid1}, - Height: height + 1, + Height: height + 4, }, { User: s.user1, Msgs: []sdk.Msg{bid2}, - SequenceIncrement: 1, - Height: height + 1, + Height: height + 4, ExpectFail: true, }, + }, func(tx []byte, resp *rpctypes.ResultTx) { + expTx <- committedTx{tx, resp} }) + close(expTx) + + commitTx := <-expTx // query next block - WaitForHeight(s.T(), s.chain.(*cosmos.CosmosChain), height+1) - block := Block(s.T(), s.chain.(*cosmos.CosmosChain), int64(height+1)) + block := Block(s.T(), s.chain.(*cosmos.CosmosChain), commitTx.res.Height) - // check bid2 was included first + // check bid1 was included first VerifyBlock(s.T(), block, 0, TxHash(txs[0]), bundledTxs) // check escrow balance @@ -517,41 +605,49 @@ func (s *IntegrationTestSuite) TestMultipleBids() { } // create bid1 bidAmt := params.ReserveFee - bid1, bundledTxs := CreateAuctionBidMsg(s.T(), context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{msg}) + bid1, bundledTxs := s.CreateAuctionBidMsg( context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{msg}) // create bid2 w/ higher bid than bid1 - bid2, _ := CreateAuctionBidMsg(s.T(), context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt.Add(params.MinBidIncrement), []Tx{msg}) + bid2, _ := s.CreateAuctionBidMsg( context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt.Add(params.MinBidIncrement), []Tx{msg}) // get chain height height, err := s.chain.(*cosmos.CosmosChain).Height(context.Background()) require.NoError(s.T(), err) + commitTx := make(chan committedTx, 1) + // broadcast both bids - txs := BroadcastTxs(s.T(), context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{ - { - User: s.user1, - Msgs: []sdk.Msg{bid2}, - Height: height + 1, - }, + txs := s.BroadcastTxsWithCallback(context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{ { User: s.user1, Msgs: []sdk.Msg{bid1}, - Height: height + 2, - SequenceIncrement: 1, - ExpectFail: true, + Height: height + 4, + SkipInclusionCheck: true, + }, + { + User: s.user1, + Msgs: []sdk.Msg{bid2}, + Height: height + 3, }, + }, func(tx []byte, resp *rpctypes.ResultTx) { + commitTx <- committedTx{tx, resp} }) + close(commitTx) + + expTx := <-commitTx // query next block - WaitForHeight(s.T(), s.chain.(*cosmos.CosmosChain), height+1) - block := Block(s.T(), s.chain.(*cosmos.CosmosChain), int64(height+1)) + block := Block(s.T(), s.chain.(*cosmos.CosmosChain), expTx.res.Height) // check bid2 was included first - VerifyBlock(s.T(), block, 0, TxHash(txs[0]), bundledTxs) + VerifyBlock(s.T(), block, 0, TxHash(txs[1]), bundledTxs) // check escrow balance escrowAcctBalanceAfterBid := QueryAccountBalance(s.T(), s.chain, escrowAddr, params.ReserveFee.Denom) expectedIncrement := escrowAddressIncrement(bidAmt.Add(params.MinBidIncrement).Amount, params.ProposerFee) require.Equal(s.T(), escrowAcctBalanceBeforeBid+expectedIncrement, escrowAcctBalanceAfterBid) + + // wait for next block for mempool to clear + WaitForHeight(s.T(), s.chain.(*cosmos.CosmosChain), height+3) }) s.Run("Multiple transactions from diff. account with increasing bids but first bid has same bundle so it should fail in later block", func() { @@ -567,40 +663,49 @@ func (s *IntegrationTestSuite) TestMultipleBids() { // create bid1 bidAmt := params.ReserveFee - bid1, bundledTxs := CreateAuctionBidMsg(s.T(), context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{msg}) + bid1, bundledTxs := s.CreateAuctionBidMsg( context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{msg}) // create bid2 w/ higher bid than bid1 - bid2, _ := CreateAuctionBidMsg(s.T(), context.Background(), s.user2, s.chain.(*cosmos.CosmosChain), bidAmt.Add(params.MinBidIncrement), []Tx{msg}) + bid2, _ := s.CreateAuctionBidMsg( context.Background(), s.user2, s.chain.(*cosmos.CosmosChain), bidAmt.Add(params.MinBidIncrement), []Tx{msg}) // get chain height height, err := s.chain.(*cosmos.CosmosChain).Height(context.Background()) require.NoError(s.T(), err) + commitTx := make(chan committedTx, 1) + // broadcast both bids - txs := BroadcastTxs(s.T(), context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{ - { - User: s.user2, - Msgs: []sdk.Msg{bid2}, - Height: height + 1, - }, + txs := s.BroadcastTxsWithCallback(context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{ { User: s.user1, Msgs: []sdk.Msg{bid1}, - Height: height + 1, - ExpectFail: true, + Height: height + 4, + SkipInclusionCheck: true, }, + { + User: s.user2, + Msgs: []sdk.Msg{bid2}, + Height: height + 3, + }, + }, func(tx []byte, resp *rpctypes.ResultTx) { + commitTx <- committedTx{tx, resp} }) + close(commitTx) + + expTx := <-commitTx // query next block - WaitForHeight(s.T(), s.chain.(*cosmos.CosmosChain), height+1) - block := Block(s.T(), s.chain.(*cosmos.CosmosChain), int64(height+1)) + block := Block(s.T(), s.chain.(*cosmos.CosmosChain), expTx.res.Height) // check bid2 was included first - VerifyBlock(s.T(), block, 0, TxHash(txs[0]), bundledTxs) + VerifyBlock(s.T(), block, 0, TxHash(txs[1]), bundledTxs) // check escrow balance escrowAcctBalanceAfterBid := QueryAccountBalance(s.T(), s.chain, escrowAddr, params.ReserveFee.Denom) expectedIncrement := escrowAddressIncrement(bidAmt.Add(params.MinBidIncrement).Amount, params.ProposerFee) require.Equal(s.T(), escrowAcctBalanceBeforeBid+expectedIncrement, escrowAcctBalanceAfterBid) + + // wait for next block for mempool to clear + WaitForHeight(s.T(), s.chain.(*cosmos.CosmosChain), height+3) }) s.Run("Multiple transactions with increasing bids and different bundles", func() { @@ -616,7 +721,7 @@ func (s *IntegrationTestSuite) TestMultipleBids() { } // create bid1 bidAmt := params.ReserveFee - bid1, bundledTxs := CreateAuctionBidMsg(s.T(), context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{msg}) + bid1, bundledTxs := s.CreateAuctionBidMsg( context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{msg}) // create bid2 // create a second message @@ -627,36 +732,48 @@ func (s *IntegrationTestSuite) TestMultipleBids() { } // create bid2 w/ higher bid than bid1 - bid2, bundledTxs2 := CreateAuctionBidMsg(s.T(), context.Background(), s.user2, s.chain.(*cosmos.CosmosChain), bidAmt.Add(params.MinBidIncrement), []Tx{msg2}) + bid2, bundledTxs2 := s.CreateAuctionBidMsg(context.Background(), s.user2, s.chain.(*cosmos.CosmosChain), bidAmt.Add(params.MinBidIncrement), []Tx{msg2}) // get chain height height, err := s.chain.(*cosmos.CosmosChain).Height(context.Background()) require.NoError(s.T(), err) + // make channel for committedTxs (expect 2 txs to be committed) + committedTxs := make(chan committedTx, 2) + // broadcast both bids - txs := BroadcastTxs(s.T(), context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{ + txs := s.BroadcastTxsWithCallback(context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{ { User: s.user1, Msgs: []sdk.Msg{bid1}, - Height: height + 2, - SkipInclusionCheck: true, + Height: height + 4, }, { User: s.user2, Msgs: []sdk.Msg{bid2}, - Height: height + 1, + Height: height + 3, }, + }, func(tx []byte, resp *rpctypes.ResultTx) { + committedTxs <- committedTx{ + tx: tx, + res: resp, + } }) + // close the channel when finished + close(committedTxs) + + // expect 2 txs + tx1 := <-committedTxs + tx2 := <-committedTxs + // query next block - WaitForHeight(s.T(), s.chain.(*cosmos.CosmosChain), height+1) - block := Block(s.T(), s.chain.(*cosmos.CosmosChain), int64(height+1)) + block := Block(s.T(), s.chain.(*cosmos.CosmosChain), tx1.res.Height) // check bid2 was included first VerifyBlock(s.T(), block, 0, TxHash(txs[1]), bundledTxs2) // query next block and check tx inclusion - WaitForHeight(s.T(), s.chain.(*cosmos.CosmosChain), height+2) - block = Block(s.T(), s.chain.(*cosmos.CosmosChain), int64(height+2)) + block = Block(s.T(), s.chain.(*cosmos.CosmosChain), tx2.res.Height) // check bid1 was included second VerifyBlock(s.T(), block, 0, TxHash(txs[0]), bundledTxs) @@ -680,11 +797,11 @@ func (s *IntegrationTestSuite) TestInvalidBids() { SequenceIncrement: 2, } bidAmt := params.ReserveFee - bid, _ := CreateAuctionBidMsg(s.T(), context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{msg}) + bid, _ := s.CreateAuctionBidMsg( context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{msg}) height, err := s.chain.(*cosmos.CosmosChain).Height(context.Background()) // wrap bidTx in another tx - wrappedBid, _ := CreateAuctionBidMsg(s.T(), context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{ + wrappedBid, _ := s.CreateAuctionBidMsg( context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{ { User: s.user1, Msgs: []sdk.Msg{bid}, @@ -696,7 +813,7 @@ func (s *IntegrationTestSuite) TestInvalidBids() { require.NoError(s.T(), err) // broadcast wrapped bid, and expect a failure - BroadcastTxs(s.T(), context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{ + s.BroadcastTxs( context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{ { User: s.user1, Msgs: []sdk.Msg{wrappedBid}, @@ -714,13 +831,13 @@ func (s *IntegrationTestSuite) TestInvalidBids() { SequenceIncrement: 2, } bidAmt := sdk.NewCoin(s.denom, math.NewInt(1000000000000000000)) - bid, _ := CreateAuctionBidMsg(s.T(), context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{msg}) + bid, _ := s.CreateAuctionBidMsg( context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{msg}) height, err := s.chain.(*cosmos.CosmosChain).Height(context.Background()) require.NoError(s.T(), err) // broadcast wrapped bid, and expect a failure - SimulateTx(s.T(), context.Background(), s.chain.(*cosmos.CosmosChain), s.user1, height+1, true, []sdk.Msg{bid}...) + s.SimulateTx(context.Background(), s.chain.(*cosmos.CosmosChain), s.user1, height+1, true, []sdk.Msg{bid}...) }) s.Run("Invalid bid that is attempting to front-run/sandwich", func() { @@ -741,13 +858,13 @@ func (s *IntegrationTestSuite) TestInvalidBids() { } bidAmt := params.ReserveFee - bid, _ := CreateAuctionBidMsg(s.T(), context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{msg, msg2, msg3}) + bid, _ := s.CreateAuctionBidMsg( context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{msg, msg2, msg3}) height, err := s.chain.(*cosmos.CosmosChain).Height(context.Background()) require.NoError(s.T(), err) // broadcast wrapped bid, and expect a failure - SimulateTx(s.T(), context.Background(), s.chain.(*cosmos.CosmosChain), s.user1, height+1, true, []sdk.Msg{bid}...) + s.SimulateTx(context.Background(), s.chain.(*cosmos.CosmosChain), s.user1, height+1, true, []sdk.Msg{bid}...) }) s.Run("Invalid bid that includes an invalid bundle tx", func() { @@ -758,13 +875,13 @@ func (s *IntegrationTestSuite) TestInvalidBids() { SequenceIncrement: 2, } bidAmt := params.ReserveFee - bid, _ := CreateAuctionBidMsg(s.T(), context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{msg}) + bid, _ := s.CreateAuctionBidMsg( context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{msg}) height, err := s.chain.(*cosmos.CosmosChain).Height(context.Background()) require.NoError(s.T(), err) // broadcast wrapped bid, and expect a failure - BroadcastTxs(s.T(), context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{ + s.BroadcastTxs( context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{ { User: s.user1, Msgs: []sdk.Msg{bid}, @@ -784,13 +901,13 @@ func (s *IntegrationTestSuite) TestInvalidBids() { // create bid smaller than reserve bidAmt := sdk.NewCoin(s.denom, math.NewInt(0)) - bid, _ := CreateAuctionBidMsg(s.T(), context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{msg}) + bid, _ := s.CreateAuctionBidMsg( context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{msg}) height, err := s.chain.(*cosmos.CosmosChain).Height(context.Background()) require.NoError(s.T(), err) // broadcast wrapped bid, and expect a failure - SimulateTx(s.T(), context.Background(), s.chain.(*cosmos.CosmosChain), s.user1, height+1, true, []sdk.Msg{bid}...) + s.SimulateTx(context.Background(), s.chain.(*cosmos.CosmosChain), s.user1, height+1, true, []sdk.Msg{bid}...) }) s.Run("Invalid auction bid with too many transactions in the bundle", func() { @@ -807,13 +924,13 @@ func (s *IntegrationTestSuite) TestInvalidBids() { // create bid smaller than reserve bidAmt := sdk.NewCoin(s.denom, math.NewInt(0)) - bid, _ := CreateAuctionBidMsg(s.T(), context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, msgs) + bid, _ := s.CreateAuctionBidMsg( context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, msgs) height, err := s.chain.(*cosmos.CosmosChain).Height(context.Background()) require.NoError(s.T(), err) // broadcast wrapped bid, and expect a failure - SimulateTx(s.T(), context.Background(), s.chain.(*cosmos.CosmosChain), s.user1, height+1, true, []sdk.Msg{bid}...) + s.SimulateTx(context.Background(), s.chain.(*cosmos.CosmosChain), s.user1, height+1, true, []sdk.Msg{bid}...) }) s.Run("invalid auction bid that has an invalid timeout", func() { @@ -826,10 +943,10 @@ func (s *IntegrationTestSuite) TestInvalidBids() { // create bid smaller than reserve bidAmt := sdk.NewCoin(s.denom, math.NewInt(0)) - bid, _ := CreateAuctionBidMsg(s.T(), context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{msg}) + bid, _ := s.CreateAuctionBidMsg( context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{msg}) // broadcast wrapped bid, and expect a failure - SimulateTx(s.T(), context.Background(), s.chain.(*cosmos.CosmosChain), s.user1, 0, true, []sdk.Msg{bid}...) + s.SimulateTx(context.Background(), s.chain.(*cosmos.CosmosChain), s.user1, 0, true, []sdk.Msg{bid}...) }) s.Run("Invalid bid that includes valid transactions that are in the mempool", func() { @@ -842,7 +959,7 @@ func (s *IntegrationTestSuite) TestInvalidBids() { // create the MsgAuctioBid (this should fail b.c same tx is repeated twice) bidAmt := params.ReserveFee - bid, _ := CreateAuctionBidMsg(s.T(), context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{ + bid, _ := s.CreateAuctionBidMsg( context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{ { User: s.user2, Msgs: []sdk.Msg{ @@ -859,7 +976,7 @@ func (s *IntegrationTestSuite) TestInvalidBids() { require.NoError(s.T(), err) // broadcast + wait for the tx to be included in a block - txs := BroadcastTxs(s.T(), context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{ + txs := s.BroadcastTxs( context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{ { User: s.user1, Msgs: []sdk.Msg{bid}, @@ -905,7 +1022,7 @@ func (s *IntegrationTestSuite) TestFreeLane() { balanceBefore := QueryAccountBalance(s.T(), s.chain.(*cosmos.CosmosChain), s.user1.FormattedAddress(), s.denom) // create a free tx (MsgDelegate), broadcast and wait for commit - BroadcastTxs(s.T(), context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{ + s.BroadcastTxs( context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{ { User: s.user1, Msgs: []sdk.Msg{ @@ -929,7 +1046,7 @@ func (s *IntegrationTestSuite) TestFreeLane() { user2BalanceBefore := QueryAccountBalance(s.T(), s.chain.(*cosmos.CosmosChain), s.user2.FormattedAddress(), s.denom) // user1 submits a free-tx, user2 submits a normal tx - BroadcastTxs(s.T(), context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{ + s.BroadcastTxs(context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{ { User: s.user1, Msgs: []sdk.Msg{ @@ -968,7 +1085,7 @@ func (s *IntegrationTestSuite) TestFreeLane() { user2BalanceBefore := QueryAccountBalance(s.T(), s.chain.(*cosmos.CosmosChain), s.user2.FormattedAddress(), s.denom) // user1 submits a free-tx, user2 submits a free tx - BroadcastTxs(s.T(), context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{ + s.BroadcastTxs( context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{ { User: s.user1, Msgs: []sdk.Msg{ @@ -1012,8 +1129,7 @@ func (s *IntegrationTestSuite) TestLanes() { user2BalanceBefore := QueryAccountBalance(s.T(), s.chain.(*cosmos.CosmosChain), s.user2.FormattedAddress(), s.denom) // create free-tx, bid-tx, and normal-tx\ - bid, bundledTx := CreateAuctionBidMsg( - s.T(), + bid, bundledTx := s.CreateAuctionBidMsg( context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), @@ -1036,11 +1152,13 @@ func (s *IntegrationTestSuite) TestLanes() { height, err := s.chain.(*cosmos.CosmosChain).Height(context.Background()) require.NoError(s.T(), err) - txs := BroadcastTxs(s.T(), context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{ + committedTxs := make(chan committedTx, 3) + + txs := s.BroadcastTxsWithCallback(context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{ { User: s.user1, Msgs: []sdk.Msg{bid}, - Height: height + 1, + Height: height + 3, }, { User: s.user2, @@ -1063,13 +1181,23 @@ func (s *IntegrationTestSuite) TestLanes() { }, }, }, + }, func(tx []byte, resp *rpctypes.ResultTx) { + committedTxs <- committedTx{tx: tx, res: resp} }) + close(committedTxs) + + // find height of committed tx + var committedHeight int64 + for tx := range committedTxs { + if bytes.Equal(tx.tx, txs[0]) { + committedHeight = tx.res.Height + break + } + } - // check block - WaitForHeight(s.T(), s.chain.(*cosmos.CosmosChain), height+1) - block := Block(s.T(), s.chain.(*cosmos.CosmosChain), int64(height+1)) + block := Block(s.T(), s.chain.(*cosmos.CosmosChain), committedHeight) - VerifyBlock(s.T(), block, 0, TxHash(txs[0]), append(bundledTx, txs[1:]...)) + VerifyBlock(s.T(), block, 0, TxHash(txs[0]), bundledTx) // check user2 balance expect no fee deduction user2BalanceAfter := QueryAccountBalance(s.T(), s.chain.(*cosmos.CosmosChain), s.user2.FormattedAddress(), s.denom) @@ -1080,8 +1208,7 @@ func (s *IntegrationTestSuite) TestLanes() { user2BalanceBefore := QueryAccountBalance(s.T(), s.chain.(*cosmos.CosmosChain), s.user2.FormattedAddress(), s.denom) user1Balance := QueryAccountBalance(s.T(), s.chain.(*cosmos.CosmosChain), s.user1.FormattedAddress(), s.denom) // create free-tx, bid-tx, and normal-tx\ - bid, _ := CreateAuctionBidMsg( - s.T(), + bid, _ := s.CreateAuctionBidMsg( context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), @@ -1115,7 +1242,7 @@ func (s *IntegrationTestSuite) TestLanes() { height, err := s.chain.(*cosmos.CosmosChain).Height(context.Background()) require.NoError(s.T(), err) - txs := BroadcastTxs(s.T(), context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{ + s.BroadcastTxs( context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{ { User: s.user1, Msgs: []sdk.Msg{bid}, @@ -1145,12 +1272,6 @@ func (s *IntegrationTestSuite) TestLanes() { }, }) - // check block - WaitForHeight(s.T(), s.chain.(*cosmos.CosmosChain), height+1) - block := Block(s.T(), s.chain.(*cosmos.CosmosChain), int64(height+1)) - - VerifyBlock(s.T(), block, 0, "", txs[1:]) - // check user2 balance expect no fee deduction user2BalanceAfter := QueryAccountBalance(s.T(), s.chain.(*cosmos.CosmosChain), s.user2.FormattedAddress(), s.denom) require.Equal(s.T(), user2BalanceBefore, user2BalanceAfter+delegation.Amount.Int64()) @@ -1171,8 +1292,7 @@ func (s *IntegrationTestSuite) TestLanes() { GasPrice: 10, } - bid, bundledTx := CreateAuctionBidMsg( - s.T(), + bid, bundledTx := s.CreateAuctionBidMsg( context.Background(), s.user3, s.chain.(*cosmos.CosmosChain), @@ -1196,7 +1316,7 @@ func (s *IntegrationTestSuite) TestLanes() { height, err := s.chain.(*cosmos.CosmosChain).Height(context.Background()) require.NoError(s.T(), err) - txs := BroadcastTxs(s.T(), context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{ + txs := s.BroadcastTxs(context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{ { User: s.user3, Msgs: []sdk.Msg{bid}, @@ -1248,8 +1368,7 @@ func (s *IntegrationTestSuite) TestLanes() { // create bid-tx w/ user3 DelegateTx - bid, bundledTx := CreateAuctionBidMsg( - s.T(), + bid, bundledTx := s.CreateAuctionBidMsg( context.Background(), s.user3, s.chain.(*cosmos.CosmosChain), @@ -1273,7 +1392,7 @@ func (s *IntegrationTestSuite) TestLanes() { height, err := s.chain.(*cosmos.CosmosChain).Height(context.Background()) require.NoError(s.T(), err) - txs := BroadcastTxs(s.T(), context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{ + txs := s.BroadcastTxs( context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{ { User: s.user3, Msgs: []sdk.Msg{bid}, diff --git a/tests/integration/chain_setup.go b/tests/integration/chain_setup.go index c13c95f5..2fe1b64b 100644 --- a/tests/integration/chain_setup.go +++ b/tests/integration/chain_setup.go @@ -7,6 +7,14 @@ import ( "strings" "testing" "time" + "os" + "io" + "path" + "archive/tar" + "bytes" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/crypto/keyring" "cosmossdk.io/math" rpctypes "github.com/cometbft/cometbft/rpc/core/types" @@ -29,6 +37,11 @@ import ( auctiontypes "github.com/skip-mev/block-sdk/x/auction/types" ) +type KeyringOverride struct { + keyringOptions keyring.Option + cdc codec.Codec +} + // ChainBuilderFromChainSpec creates an interchaintest chain builder factory given a ChainSpec // and returns the associated chain func ChainBuilderFromChainSpec(t *testing.T, spec *interchaintest.ChainSpec) ibc.Chain { @@ -73,19 +86,18 @@ func BuildInterchain(t *testing.T, ctx context.Context, chain ibc.Chain) *interc } // CreateTx creates a new transaction to be signed by the given user, including a provided set of messages -func CreateTx(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain, user cosmos.User, seqIncrement, height uint64, GasPrice int64, msgs ...sdk.Msg) []byte { - // create a broadcaster - broadcaster := cosmos.NewBroadcaster(t, chain) - +func (s *IntegrationTestSuite) CreateTx(ctx context.Context, chain *cosmos.CosmosChain, user cosmos.User, seqIncrement, height uint64, GasPrice int64, msgs ...sdk.Msg) []byte { // create tx factory + Client Context - txf, err := broadcaster.GetFactory(ctx, user) - require.NoError(t, err) + txf, err := s.bc.GetFactory(ctx, user) + s.Require().NoError(err) - cc, err := broadcaster.GetClientContext(ctx, user) - require.NoError(t, err) + cc, err := s.bc.GetClientContext(ctx, user) + s.Require().NoError(err) + + txf = txf.WithSimulateAndExecute(true) txf, err = txf.Prepare(cc) - require.NoError(t, err) + s.Require().NoError(err) // set timeout height if height != 0 { @@ -94,7 +106,7 @@ func CreateTx(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain, user // get gas for tx _, gas, err := tx.CalculateGas(cc, txf, msgs...) - require.NoError(t, err) + s.Require().NoError(err) txf.WithGas(gas) // update sequence number @@ -103,30 +115,27 @@ func CreateTx(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain, user // sign the tx txBuilder, err := txf.BuildUnsignedTx(msgs...) - require.NoError(t, err) + s.Require().NoError(err) - require.NoError(t, tx.Sign(ctx, txf, cc.GetFromName(), txBuilder, true)) + s.Require().NoError(tx.Sign(cc.CmdContext, txf, cc.GetFromName(), txBuilder, true)) // encode and return bz, err := cc.TxConfig.TxEncoder()(txBuilder.GetTx()) - require.NoError(t, err) + s.Require().NoError(err) return bz } // SimulateTx simulates the provided messages, and checks whether the provided failure condition is met -func SimulateTx(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain, user cosmos.User, height uint64, expectFail bool, msgs ...sdk.Msg) { - // create a broadcaster - broadcaster := cosmos.NewBroadcaster(t, chain) - +func (s *IntegrationTestSuite) SimulateTx(ctx context.Context, chain *cosmos.CosmosChain, user cosmos.User, height uint64, expectFail bool, msgs ...sdk.Msg) { // create tx factory + Client Context - txf, err := broadcaster.GetFactory(ctx, user) - require.NoError(t, err) + txf, err := s.bc.GetFactory(ctx, user) + s.Require().NoError(err) - cc, err := broadcaster.GetClientContext(ctx, user) - require.NoError(t, err) + cc, err := s.bc.GetClientContext(ctx, user) + s.Require().NoError(err) txf, err = txf.Prepare(cc) - require.NoError(t, err) + s.Require().NoError(err) // set timeout height if height != 0 { @@ -135,7 +144,7 @@ func SimulateTx(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain, us // get gas for tx _, _, err = tx.CalculateGas(cc, txf, msgs...) - require.Equal(t, err != nil, expectFail) + s.Require().Equal(err != nil, expectFail) } type Tx struct { @@ -149,16 +158,16 @@ type Tx struct { } // CreateAuctionBidMsg creates a new AuctionBid tx signed by the given user, the order of txs in the MsgAuctionBid will be determined by the contents + order of the MessageForUsers -func CreateAuctionBidMsg(t *testing.T, ctx context.Context, searcher cosmos.User, chain *cosmos.CosmosChain, bid sdk.Coin, txsPerUser []Tx) (*auctiontypes.MsgAuctionBid, [][]byte) { +func (s *IntegrationTestSuite) CreateAuctionBidMsg(ctx context.Context, searcher cosmos.User, chain *cosmos.CosmosChain, bid sdk.Coin, txsPerUser []Tx) (*auctiontypes.MsgAuctionBid, [][]byte) { // for each MessagesForUser get the signed bytes txs := make([][]byte, len(txsPerUser)) for i, tx := range txsPerUser { - txs[i] = CreateTx(t, ctx, chain, tx.User, tx.SequenceIncrement, tx.Height, tx.GasPrice, tx.Msgs...) + txs[i] = s.CreateTx(ctx, chain, tx.User, tx.SequenceIncrement, tx.Height, tx.GasPrice, tx.Msgs...) } bech32SearcherAddress := searcher.FormattedAddress() accAddr, err := sdk.AccAddressFromBech32(bech32SearcherAddress) - require.NoError(t, err) + s.Require().NoError(err) // create a message auction bid return auctiontypes.NewMsgAuctionBid( @@ -171,26 +180,43 @@ func CreateAuctionBidMsg(t *testing.T, ctx context.Context, searcher cosmos.User // BroadcastTxs broadcasts the given messages for each user. This function returns the broadcasted txs. If a message // is not expected to be included in a block, set SkipInclusionCheck to true and the method // will not block on the tx's inclusion in a block, otherwise this method will block on the tx's inclusion -func BroadcastTxs(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain, msgsPerUser []Tx) [][]byte { +func (s *IntegrationTestSuite) BroadcastTxs(ctx context.Context, chain *cosmos.CosmosChain, msgsPerUser []Tx) [][]byte { + return s.BroadcastTxsWithCallback(ctx, chain, msgsPerUser, nil) +} + +// BroadcastTxs broadcasts the given messages for each user. This function returns the broadcasted txs. If a message +// is not expected to be included in a block, set SkipInclusionCheck to true and the method +// will not block on the tx's inclusion in a block, otherwise this method will block on the tx's inclusion. The callback +// function is called for each tx that is included in a block. +func (s *IntegrationTestSuite) BroadcastTxsWithCallback( + ctx context.Context, + chain *cosmos.CosmosChain, + msgsPerUser []Tx, + cb func(tx []byte, resp *rpctypes.ResultTx), +) [][]byte { txs := make([][]byte, len(msgsPerUser)) for i, msg := range msgsPerUser { - txs[i] = CreateTx(t, ctx, chain, msg.User, msg.SequenceIncrement, msg.Height, msg.GasPrice, msg.Msgs...) + txs[i] = s.CreateTx(ctx, chain, msg.User, msg.SequenceIncrement, msg.Height, msg.GasPrice, msg.Msgs...) } // broadcast each tx - require.True(t, len(chain.Nodes()) > 0) + s.Require().True(len(chain.Nodes()) > 0) client := chain.Nodes()[0].Client for i, tx := range txs { // broadcast tx - _, err := client.BroadcastTxSync(ctx, tx) + resp, err := client.BroadcastTxSync(ctx, tx) // check execution was successful if !msgsPerUser[i].ExpectFail { - require.NoError(t, err) + s.Require().Equal(resp.Code, uint32(0)) } else { - require.Error(t, err) + if resp != nil { + s.Require().NotEqual(resp.Code, uint32(0)) + } else { + s.Require().Error(err) + } } } @@ -205,18 +231,22 @@ func BroadcastTxs(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain, tx := tx // pin eg.Go(func() error { - return testutil.WaitForCondition(4*time.Second, 500*time.Millisecond, func() (bool, error) { + return testutil.WaitForCondition(30*time.Second, 500*time.Millisecond, func() (bool, error) { res, err := client.Tx(context.Background(), comettypes.Tx(tx).Hash(), false) - if err != nil || res.TxResult.Code != uint32(0) { return false, nil } + + if cb != nil { + cb(tx, res) + } + return true, nil }) }) } - require.NoError(t, eg.Wait()) + s.Require().NoError(eg.Wait()) return txs } @@ -313,12 +343,12 @@ func Block(t *testing.T, chain *cosmos.CosmosChain, height int64) *rpctypes.Resu // WaitForHeight waits for the chain to reach the given height func WaitForHeight(t *testing.T, chain *cosmos.CosmosChain, height uint64) { // wait for next height - err := testutil.WaitForCondition(30*time.Second, time.Second, func() (bool, error) { + err := testutil.WaitForCondition(30*time.Second, 100 * time.Millisecond, func() (bool, error) { pollHeight, err := chain.Height(context.Background()) if err != nil { return false, err } - return pollHeight == height, nil + return pollHeight >= height, nil }) require.NoError(t, err) } @@ -340,3 +370,73 @@ func VerifyBlock(t *testing.T, block *rpctypes.ResultBlock, offset int, bidTxHas func TxHash(tx []byte) string { return strings.ToUpper(hex.EncodeToString(comettypes.Tx(tx).Hash())) } + +func (s *IntegrationTestSuite) setupBroadcaster() { + bc := cosmos.NewBroadcaster(s.T(), s.chain.(*cosmos.CosmosChain)) + + if s.broadcasterOverrides == nil { + s.bc = bc + return + } + + // get the key-ring-dir from the node locally + keyringDir := s.keyringDirFromNode() + + // create a new keyring + kr, err := keyring.New("", keyring.BackendTest, keyringDir, os.Stdin, s.broadcasterOverrides.cdc, s.broadcasterOverrides.keyringOptions) + s.Require().NoError(err) + + // override factory + client context keyrings + bc.ConfigureFactoryOptions( + func(factory tx.Factory) tx.Factory { + return factory.WithKeybase(kr) + }, + ) + + bc.ConfigureClientContextOptions( + func(cc client.Context) client.Context { + return cc.WithKeyring(kr) + }, + ) + + s.bc = bc +} + +// sniped from here: https://github.com/strangelove-ventures/interchaintest ref: 9341b001214d26be420f1ca1ab0f15bad17faee6 +func (s *IntegrationTestSuite) keyringDirFromNode() (string) { + node := s.chain.(*cosmos.CosmosChain).Nodes()[0] + + // create a temp-dir + localDir := s.T().TempDir() + + containerKeyringDir := path.Join(node.HomeDir(), "keyring-test") + reader, _, err := node.DockerClient.CopyFromContainer(context.Background(), node.ContainerID(), containerKeyringDir) + s.Require().NoError(err) + + s.Require().NoError(os.Mkdir(path.Join(localDir, "keyring-test"), os.ModePerm)) + + tr := tar.NewReader(reader) + for { + hdr, err := tr.Next() + if err == io.EOF { + break // End of archive + } + s.Require().NoError(err) + + var fileBuff bytes.Buffer + _, err = io.Copy(&fileBuff, tr) + s.Require().NoError(err) + + name := hdr.Name + extractedFileName := path.Base(name) + isDirectory := extractedFileName == "" + if isDirectory { + continue + } + + filePath := path.Join(localDir, "keyring-test", extractedFileName) + s.Require().NoError(os.WriteFile(filePath, fileBuff.Bytes(), os.ModePerm)) + } + + return localDir +} diff --git a/tests/integration/go.mod b/tests/integration/go.mod index e233853f..e5e57895 100644 --- a/tests/integration/go.mod +++ b/tests/integration/go.mod @@ -16,9 +16,9 @@ require ( github.com/cometbft/cometbft v0.38.0 github.com/cosmos/cosmos-sdk v0.50.0-rc.0 github.com/skip-mev/block-sdk v1.0.0 // reference local - github.com/strangelove-ventures/interchaintest/v7 v7.0.0-20230721183422-fb937bb0e165 + github.com/strangelove-ventures/interchaintest/v7 v7.0.0-20230905210439-3e17efc70581 github.com/stretchr/testify v1.8.4 - go.uber.org/zap v1.24.0 + go.uber.org/zap v1.25.0 golang.org/x/sync v0.3.0 google.golang.org/grpc v1.58.1 ) @@ -46,7 +46,7 @@ require ( github.com/Microsoft/go-winio v0.6.0 // indirect github.com/avast/retry-go/v4 v4.5.0 // indirect github.com/aws/aws-sdk-go v1.44.224 // indirect - github.com/benbjohnson/clock v1.1.0 // indirect + github.com/benbjohnson/clock v1.3.0 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 // indirect @@ -185,7 +185,6 @@ require ( github.com/zondax/ledger-go v0.14.1 // indirect go.etcd.io/bbolt v1.3.7 // indirect go.opencensus.io v0.24.0 // indirect - go.uber.org/atomic v1.10.0 // indirect go.uber.org/multierr v1.10.0 // indirect golang.org/x/crypto v0.13.0 // indirect golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 // indirect diff --git a/tests/integration/go.sum b/tests/integration/go.sum index a208be07..59cf040a 100644 --- a/tests/integration/go.sum +++ b/tests/integration/go.sum @@ -266,8 +266,9 @@ github.com/aws/aws-sdk-go v1.44.122/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX github.com/aws/aws-sdk-go v1.44.224 h1:09CiaaF35nRmxrzWZ2uRq5v6Ghg/d2RiPjZnSgtt+RQ= github.com/aws/aws-sdk-go v1.44.224/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= -github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= +github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= +github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -1069,11 +1070,9 @@ go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= -go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= -go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= -go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI= -go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= +go.uber.org/goleak v1.2.0 h1:xqgm/S+aQvhWFTtR0XK3Jvg7z8kGV8P4X14IzwN3Eqk= +go.uber.org/goleak v1.2.0/go.mod h1:XJYK+MuIchqpmGmUSAzotztawfKvYLUIgg7guXrwVUo= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= @@ -1083,8 +1082,8 @@ go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9E go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI= -go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60= -go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg= +go.uber.org/zap v1.25.0 h1:4Hvk6GtkucQ790dqmj7l1eEnRdKm3k3ZUrUMS2d5+5c= +go.uber.org/zap v1.25.0/go.mod h1:JIAUzQIH94IC4fOJQm7gMmBJP5k7wQfdcnYdPoEXJYk= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= diff --git a/x/auction/ante/ante.go b/x/auction/ante/ante.go index e5538f58..95269161 100644 --- a/x/auction/ante/ante.go +++ b/x/auction/ante/ante.go @@ -48,13 +48,6 @@ func NewAuctionDecorator(ak keeper.Keeper, txEncoder sdk.TxEncoder, lane MEVLane // AnteHandle validates that the auction bid is valid if one exists. If valid it will deduct the entrance fee from the // bidder's account. func (ad AuctionDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) { - // If comet is re-checking a transaction, we only need to check if the transaction is in the application-side mempool. - if ctx.IsReCheckTx() { - if !ad.mempool.Contains(tx) { - return ctx, fmt.Errorf("transaction not found in application-side mempool") - } - } - bidInfo, err := ad.lane.GetAuctionBidInfo(tx) if err != nil { return ctx, err @@ -62,6 +55,13 @@ func (ad AuctionDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, // Validate the auction bid if one exists. if bidInfo != nil { + // If comet is re-checking a transaction, we only need to check if the transaction is in the application-side mempool. + if ctx.IsReCheckTx() { + if !ad.mempool.Contains(tx) { + return ctx, fmt.Errorf("transaction not found in application-side mempool") + } + } + // Auction transactions must have a timeout set to a valid block height. if err := ad.ValidateTimeout(ctx, int64(bidInfo.Timeout)); err != nil { return ctx, err @@ -71,6 +71,7 @@ func (ad AuctionDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, // is checkTx or recheckTx. Otherwise, the ABCI handlers (VerifyVoteExtension, ExtendVoteExtension, etc.) // will always compare the auction bid to the highest bidding transaction in the mempool leading to // poor liveness guarantees. + // TODO(nikhil/david): refactor this logic (is this necessary?) topBid := sdk.Coin{} if ctx.IsCheckTx() || ctx.IsReCheckTx() { if topBidTx := ad.lane.GetTopAuctionTx(ctx); topBidTx != nil { diff --git a/x/auction/ante/ante_test.go b/x/auction/ante/ante_test.go index 3822db45..0f07afbe 100644 --- a/x/auction/ante/ante_test.go +++ b/x/auction/ante/ante_test.go @@ -96,7 +96,7 @@ func (suite *AnteTestSuite) SetupTest() { } suite.mevLane = mev.NewMEVLane( mevConfig, - mev.NewDefaultAuctionFactory(suite.encodingConfig.TxConfig.TxDecoder()), + mev.NewDefaultAuctionFactory(suite.encodingConfig.TxConfig.TxDecoder(), signer_extraction.NewDefaultAdapter()), ) // Base lane set up