req size check (#269)
This commit is contained in:
parent
6a19dafece
commit
43d6b048ef
@ -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
|
||||
|
||||
@ -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))
|
||||
@ -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)
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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))
|
||||
@ -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)
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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)
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user