diff --git a/abci/abci.go b/abci/abci.go index d2896ceb..ce2a2117 100644 --- a/abci/abci.go +++ b/abci/abci.go @@ -70,8 +70,12 @@ func (h *ProposalHandler) PrepareProposalHandler() sdk.PrepareProposalHandler { "height", req.Height, ) + // Get the max gas limit and max block size for the proposal. + _, maxGasLimit := proposals.GetBlockLimits(ctx) + proposal := proposals.NewProposal(h.logger, req.MaxTxBytes, maxGasLimit) + // Fill the proposal with transactions from each lane. - finalProposal, err := h.prepareLanesHandler(ctx, proposals.NewProposalWithContext(ctx, h.logger)) + finalProposal, err := h.prepareLanesHandler(ctx, proposal) if err != nil { h.logger.Error("failed to prepare proposal", "err", err) return &abci.ResponsePrepareProposal{Txs: make([][]byte, 0)}, err diff --git a/abci/abci_test.go b/abci/abci_test.go index 580c5865..8e9c6971 100644 --- a/abci/abci_test.go +++ b/abci/abci_test.go @@ -60,7 +60,8 @@ func (s *ProposalsTestSuite) TestPrepareProposal() { proposalHandler := s.setUpProposalHandlers([]block.Lane{defaultLane}).PrepareProposalHandler() - resp, err := proposalHandler(s.ctx, &cometabci.RequestPrepareProposal{Height: 2}) + maxTxBytes := s.ctx.ConsensusParams().Block.MaxBytes + resp, err := proposalHandler(s.ctx, &cometabci.RequestPrepareProposal{Height: 2, MaxTxBytes: maxTxBytes}) s.Require().NoError(err) s.Require().NotNil(resp) s.Require().Equal(0, len(resp.Txs)) @@ -84,7 +85,9 @@ func (s *ProposalsTestSuite) TestPrepareProposal() { s.Require().NoError(defaultLane.Insert(sdk.Context{}, tx)) proposalHandler := s.setUpProposalHandlers([]block.Lane{defaultLane}).PrepareProposalHandler() - resp, err := proposalHandler(s.ctx, &cometabci.RequestPrepareProposal{Height: 2}) + + maxTxBytes := s.ctx.ConsensusParams().Block.MaxBytes + resp, err := proposalHandler(s.ctx, &cometabci.RequestPrepareProposal{Height: 2, MaxTxBytes: maxTxBytes}) s.Require().NotNil(resp) s.Require().NoError(err) @@ -124,7 +127,9 @@ func (s *ProposalsTestSuite) TestPrepareProposal() { s.Require().NoError(defaultLane.Insert(sdk.Context{}, tx2)) proposalHandler := s.setUpProposalHandlers([]block.Lane{defaultLane}).PrepareProposalHandler() - resp, err := proposalHandler(s.ctx, &cometabci.RequestPrepareProposal{Height: 2}) + + maxTxBytes := s.ctx.ConsensusParams().Block.MaxBytes + resp, err := proposalHandler(s.ctx, &cometabci.RequestPrepareProposal{Height: 2, MaxTxBytes: maxTxBytes}) s.Require().NotNil(resp) s.Require().NoError(err) @@ -164,7 +169,9 @@ func (s *ProposalsTestSuite) TestPrepareProposal() { s.Require().NoError(defaultLane.Insert(sdk.Context{}, tx2)) proposalHandler := s.setUpProposalHandlers([]block.Lane{defaultLane}).PrepareProposalHandler() - resp, err := proposalHandler(s.ctx, &cometabci.RequestPrepareProposal{Height: 2}) + + maxTxBytes := s.ctx.ConsensusParams().Block.MaxBytes + resp, err := proposalHandler(s.ctx, &cometabci.RequestPrepareProposal{Height: 2, MaxTxBytes: maxTxBytes}) s.Require().NotNil(resp) s.Require().NoError(err) @@ -179,7 +186,8 @@ func (s *ProposalsTestSuite) TestPrepareProposal() { proposalHandler := s.setUpProposalHandlers([]block.Lane{mevLane, defaultLane}).PrepareProposalHandler() - resp, err := proposalHandler(s.ctx, &cometabci.RequestPrepareProposal{Height: 2}) + maxTxBytes := s.ctx.ConsensusParams().Block.MaxBytes + resp, err := proposalHandler(s.ctx, &cometabci.RequestPrepareProposal{Height: 2, MaxTxBytes: maxTxBytes}) s.Require().NoError(err) s.Require().NotNil(resp) s.Require().Equal(0, len(resp.Txs)) @@ -209,7 +217,8 @@ func (s *ProposalsTestSuite) TestPrepareProposal() { proposalHandler := s.setUpProposalHandlers([]block.Lane{mevLane, defaultLane}).PrepareProposalHandler() - resp, err := proposalHandler(s.ctx, &cometabci.RequestPrepareProposal{Height: 2}) + maxTxBytes := s.ctx.ConsensusParams().Block.MaxBytes + resp, err := proposalHandler(s.ctx, &cometabci.RequestPrepareProposal{Height: 2, MaxTxBytes: maxTxBytes}) s.Require().NoError(err) s.Require().NotNil(resp) @@ -248,7 +257,8 @@ func (s *ProposalsTestSuite) TestPrepareProposal() { proposalHandler := s.setUpProposalHandlers([]block.Lane{mevLane, defaultLane}).PrepareProposalHandler() - resp, err := proposalHandler(s.ctx, &cometabci.RequestPrepareProposal{Height: 2}) + maxTxBytes := s.ctx.ConsensusParams().Block.MaxBytes + resp, err := proposalHandler(s.ctx, &cometabci.RequestPrepareProposal{Height: 2, MaxTxBytes: maxTxBytes}) s.Require().NoError(err) s.Require().NotNil(resp) @@ -288,7 +298,8 @@ func (s *ProposalsTestSuite) TestPrepareProposal() { proposalHandler := s.setUpProposalHandlers([]block.Lane{mevLane, defaultLane}).PrepareProposalHandler() - resp, err := proposalHandler(s.ctx, &cometabci.RequestPrepareProposal{Height: 2}) + maxTxBytes := s.ctx.ConsensusParams().Block.MaxBytes + resp, err := proposalHandler(s.ctx, &cometabci.RequestPrepareProposal{Height: 2, MaxTxBytes: maxTxBytes}) s.Require().NoError(err) s.Require().NotNil(resp) @@ -325,7 +336,8 @@ func (s *ProposalsTestSuite) TestPrepareProposal() { proposal := s.getTxBytes(freeTx) - resp, err := proposalHandler(s.ctx, &cometabci.RequestPrepareProposal{Height: 2}) + maxTxBytes := s.ctx.ConsensusParams().Block.MaxBytes + resp, err := proposalHandler(s.ctx, &cometabci.RequestPrepareProposal{Height: 2, MaxTxBytes: maxTxBytes}) s.Require().NoError(err) s.Require().NotNil(resp) @@ -392,7 +404,8 @@ func (s *ProposalsTestSuite) TestPrepareProposal() { proposalHandler := s.setUpProposalHandlers([]block.Lane{mevLane, freeLane, defaultLane}).PrepareProposalHandler() proposal := s.getTxBytes(tx, bundleTxs[0], bundleTxs[1], bundleTxs[2], bundleTxs[3], freeTx, normalTx) - resp, err := proposalHandler(s.ctx, &cometabci.RequestPrepareProposal{Height: 2}) + maxTxBytes := s.ctx.ConsensusParams().Block.MaxBytes + resp, err := proposalHandler(s.ctx, &cometabci.RequestPrepareProposal{Height: 2, MaxTxBytes: maxTxBytes}) s.Require().NoError(err) s.Require().NotNil(resp) @@ -444,7 +457,8 @@ func (s *ProposalsTestSuite) TestPrepareProposal() { proposal := s.getTxBytes(tx, bundleTxs[0], normalTx) // Should be theoretically sufficient to fit the bid tx and the bundled tx + normal tx - resp, err := proposalHandler(s.ctx, &cometabci.RequestPrepareProposal{Height: 2}) + maxTxBytes := s.ctx.ConsensusParams().Block.MaxBytes + resp, err := proposalHandler(s.ctx, &cometabci.RequestPrepareProposal{Height: 2, MaxTxBytes: maxTxBytes}) s.Require().NoError(err) s.Require().NotNil(resp) @@ -485,13 +499,14 @@ func (s *ProposalsTestSuite) TestPrepareProposalEdgeCases() { s.Require().NoError(err) proposalHandler := abci.NewProposalHandler( - log.NewTestLogger(s.T()), + log.NewNopLogger(), s.encodingConfig.TxConfig.TxDecoder(), s.encodingConfig.TxConfig.TxEncoder(), mempool, ).PrepareProposalHandler() - resp, err := proposalHandler(s.ctx, &cometabci.RequestPrepareProposal{Height: 2}) + maxTxBytes := s.ctx.ConsensusParams().Block.MaxBytes + resp, err := proposalHandler(s.ctx, &cometabci.RequestPrepareProposal{Height: 2, MaxTxBytes: maxTxBytes}) s.Require().NoError(err) s.Require().NotNil(resp) @@ -531,13 +546,14 @@ func (s *ProposalsTestSuite) TestPrepareProposalEdgeCases() { s.Require().NoError(err) proposalHandler := abci.NewProposalHandler( - log.NewTestLogger(s.T()), + log.NewNopLogger(), s.encodingConfig.TxConfig.TxDecoder(), s.encodingConfig.TxConfig.TxEncoder(), mempool, ).PrepareProposalHandler() - resp, err := proposalHandler(s.ctx, &cometabci.RequestPrepareProposal{Height: 2}) + maxTxBytes := s.ctx.ConsensusParams().Block.MaxBytes + resp, err := proposalHandler(s.ctx, &cometabci.RequestPrepareProposal{Height: 2, MaxTxBytes: maxTxBytes}) s.Require().NoError(err) s.Require().NotNil(resp) @@ -579,13 +595,14 @@ func (s *ProposalsTestSuite) TestPrepareProposalEdgeCases() { s.Require().NoError(err) proposalHandler := abci.NewProposalHandler( - log.NewTestLogger(s.T()), + log.NewNopLogger(), s.encodingConfig.TxConfig.TxDecoder(), s.encodingConfig.TxConfig.TxEncoder(), mempool, ).PrepareProposalHandler() - resp, err := proposalHandler(s.ctx, &cometabci.RequestPrepareProposal{Height: 2}) + maxTxBytes := s.ctx.ConsensusParams().Block.MaxBytes + resp, err := proposalHandler(s.ctx, &cometabci.RequestPrepareProposal{Height: 2, MaxTxBytes: maxTxBytes}) s.Require().NoError(err) s.Require().NotNil(resp) @@ -627,13 +644,14 @@ func (s *ProposalsTestSuite) TestPrepareProposalEdgeCases() { s.Require().NoError(err) proposalHandler := abci.NewProposalHandler( - log.NewTestLogger(s.T()), + log.NewNopLogger(), s.encodingConfig.TxConfig.TxDecoder(), s.encodingConfig.TxConfig.TxEncoder(), mempool, ).PrepareProposalHandler() - resp, err := proposalHandler(s.ctx, &cometabci.RequestPrepareProposal{Height: 2}) + maxTxBytes := s.ctx.ConsensusParams().Block.MaxBytes + resp, err := proposalHandler(s.ctx, &cometabci.RequestPrepareProposal{Height: 2, MaxTxBytes: maxTxBytes}) s.Require().NoError(err) s.Require().NotNil(resp) @@ -1295,7 +1313,9 @@ func (s *ProposalsTestSuite) TestPrepareProcessParity() { // Create a proposal with the retrieved transactions // Set up the default lane with no transactions proposalHandler := s.setUpProposalHandlers([]block.Lane{freelane, defaultLane}).PrepareProposalHandler() - resp, err := proposalHandler(s.ctx, &cometabci.RequestPrepareProposal{Height: 2}) + + maxTxBytes := s.ctx.ConsensusParams().Block.MaxBytes + resp, err := proposalHandler(s.ctx, &cometabci.RequestPrepareProposal{Height: 2, MaxTxBytes: maxTxBytes}) s.Require().NoError(err) s.Require().NotNil(resp) diff --git a/abci/utils_test.go b/abci/utils_test.go index 3dccd2f6..bf298b0f 100644 --- a/abci/utils_test.go +++ b/abci/utils_test.go @@ -78,7 +78,7 @@ func (s *ProposalsTestSuite) setUpCustomMatchHandlerLane(maxBlockSpace math.Lega func (s *ProposalsTestSuite) setUpStandardLane(maxBlockSpace math.LegacyDec, expectedExecution map[sdk.Tx]bool) *defaultlane.DefaultLane { cfg := base.LaneConfig{ - Logger: log.NewTestLogger(s.T()), + Logger: log.NewNopLogger(), TxEncoder: s.encodingConfig.TxConfig.TxEncoder(), TxDecoder: s.encodingConfig.TxConfig.TxDecoder(), AnteHandler: s.setUpAnteHandler(expectedExecution), @@ -91,7 +91,7 @@ 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()), + Logger: log.NewNopLogger(), TxEncoder: s.encodingConfig.TxConfig.TxEncoder(), TxDecoder: s.encodingConfig.TxConfig.TxDecoder(), AnteHandler: s.setUpAnteHandler(expectedExecution), @@ -105,7 +105,7 @@ 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()), + Logger: log.NewNopLogger(), TxEncoder: s.encodingConfig.TxConfig.TxEncoder(), TxDecoder: s.encodingConfig.TxConfig.TxDecoder(), AnteHandler: s.setUpAnteHandler(expectedExecution), @@ -139,11 +139,11 @@ func (s *ProposalsTestSuite) setUpPanicLane(name string, maxBlockSpace math.Lega } func (s *ProposalsTestSuite) setUpProposalHandlers(lanes []block.Lane) *abci.ProposalHandler { - mempool, err := block.NewLanedMempool(log.NewTestLogger(s.T()), lanes) + mempool, err := block.NewLanedMempool(log.NewNopLogger(), lanes) s.Require().NoError(err) return abci.NewProposalHandler( - log.NewTestLogger(s.T()), + log.NewNopLogger(), s.encodingConfig.TxConfig.TxDecoder(), s.encodingConfig.TxConfig.TxEncoder(), mempool, diff --git a/lanes/base/abci_test.go b/lanes/base/abci_test.go index 5801e414..9fb4b789 100644 --- a/lanes/base/abci_test.go +++ b/lanes/base/abci_test.go @@ -1632,7 +1632,7 @@ func (s *BaseTestSuite) initLane( expectedExecution map[sdk.Tx]bool, ) *defaultlane.DefaultLane { config := base.NewLaneConfig( - log.NewTestLogger(s.T()), + log.NewNopLogger(), s.encodingConfig.TxConfig.TxEncoder(), s.encodingConfig.TxConfig.TxDecoder(), s.setUpAnteHandler(expectedExecution), diff --git a/lanes/mev/mev_test.go b/lanes/mev/mev_test.go index 3d9eb00c..ea500c22 100644 --- a/lanes/mev/mev_test.go +++ b/lanes/mev/mev_test.go @@ -55,7 +55,7 @@ func (s *MEVTestSuite) initLane( expectedExecution map[sdk.Tx]bool, ) *mev.MEVLane { config := base.NewLaneConfig( - log.NewTestLogger(s.T()), + log.NewNopLogger(), s.encCfg.TxConfig.TxEncoder(), s.encCfg.TxConfig.TxDecoder(), s.setUpAnteHandler(expectedExecution),