Skip to content

Commit

Permalink
Merge branch 'main' into terpay/lane-ops
Browse files Browse the repository at this point in the history
  • Loading branch information
davidterpay authored Dec 6, 2023
2 parents 0899725 + 43d6b04 commit 0401f46
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 17 deletions.
6 changes: 5 additions & 1 deletion abci/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,13 @@ func (h *ProposalHandler) PrepareProposalHandler() sdk.PrepareProposalHandler {
return &abci.ResponsePrepareProposal{Txs: make([][]byte, 0)}, err
}

// 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.
prepareLanesHandler := ChainPrepareLanes(registry)
finalProposal, err := prepareLanesHandler(ctx, proposals.NewProposalWithContext(ctx, h.logger))
finalProposal, err := prepareLanesHandler(ctx, proposal)
if err != nil {
h.logger.Error("failed to prepare proposal", "err", err)
return &abci.ResponsePrepareProposal{Txs: make([][]byte, 0)}, err
Expand Down
52 changes: 36 additions & 16 deletions abci/abci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,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))
Expand All @@ -114,7 +115,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)

Expand Down Expand Up @@ -154,7 +157,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)

Expand Down Expand Up @@ -194,7 +199,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)

Expand All @@ -209,7 +216,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))
Expand Down Expand Up @@ -239,7 +247,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)

Expand Down Expand Up @@ -278,7 +287,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)

Expand Down Expand Up @@ -318,7 +328,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)

Expand Down Expand Up @@ -355,7 +366,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)

Expand Down Expand Up @@ -422,7 +434,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)

Expand Down Expand Up @@ -474,7 +487,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)

Expand Down Expand Up @@ -539,7 +553,8 @@ func (s *ProposalsTestSuite) TestPrepareProposalEdgeCases() {
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)

Expand Down Expand Up @@ -603,7 +618,8 @@ func (s *ProposalsTestSuite) TestPrepareProposalEdgeCases() {
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)

Expand Down Expand Up @@ -674,7 +690,8 @@ func (s *ProposalsTestSuite) TestPrepareProposalEdgeCases() {
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)

Expand Down Expand Up @@ -745,7 +762,8 @@ func (s *ProposalsTestSuite) TestPrepareProposalEdgeCases() {
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)

Expand Down Expand Up @@ -1407,7 +1425,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)

Expand Down

0 comments on commit 0401f46

Please sign in to comment.