From 221a3b92b77f4b3d3e5499eb27fa289ae44b0151 Mon Sep 17 00:00:00 2001 From: David Date: Tue, 1 Aug 2023 22:25:01 +0800 Subject: [PATCH] feat(proposer): update pool content query (#341) --- integration_test/nodes/docker-compose.yml | 2 +- pkg/rpc/methods.go | 10 ++++++---- pkg/tx_list_validator/tx_list_validator.go | 14 +------------- .../tx_list_validator_test.go | 7 ------- proposer/proposer.go | 19 +++++++++++++++++++ 5 files changed, 27 insertions(+), 25 deletions(-) diff --git a/integration_test/nodes/docker-compose.yml b/integration_test/nodes/docker-compose.yml index 64a816b99..c0e0706a7 100644 --- a/integration_test/nodes/docker-compose.yml +++ b/integration_test/nodes/docker-compose.yml @@ -14,7 +14,7 @@ services: - "0.0.0.0" l2_execution_engine: - image: gcr.io/evmchain/taiko-geth:taiko + image: gcr.io/evmchain/taiko-geth:sha-cb2c81a # TODO: change this tag back to `taiko` restart: unless-stopped pull_policy: always volumes: diff --git a/pkg/rpc/methods.go b/pkg/rpc/methods.go index 58d2e4a19..44f3ed002 100644 --- a/pkg/rpc/methods.go +++ b/pkg/rpc/methods.go @@ -28,7 +28,6 @@ var ( syncProgressRecheckDelay = 12 * time.Second waitL1OriginPollingInterval = 3 * time.Second defaultWaitL1OriginTimeout = 3 * time.Minute - minTxGasLimit = 21000 ) // ensureGenesisMatched fetches the L2 genesis block from TaikoL1 contract, @@ -212,11 +211,13 @@ func (c *Client) WaitL1Origin(ctx context.Context, blockID *big.Int) (*rawdb.L1O // upper limit. func (c *Client) GetPoolContent( ctx context.Context, + beneficiary common.Address, + baseFee *big.Int, maxTransactionsPerBlock uint64, blockMaxGasLimit uint32, maxBytesPerTxList uint64, locals []common.Address, - maxTransactions uint64, + maxTransactionsLists uint64, ) ([]types.Transactions, error) { var localsArg []string for _, local := range locals { @@ -228,12 +229,13 @@ func (c *Client) GetPoolContent( ctx, &result, "taiko_txPoolContent", + beneficiary, + baseFee, maxTransactionsPerBlock, blockMaxGasLimit, maxBytesPerTxList, - minTxGasLimit, localsArg, - maxTransactions, + maxTransactionsLists, ) return result, err diff --git a/pkg/tx_list_validator/tx_list_validator.go b/pkg/tx_list_validator/tx_list_validator.go index 1fa0bcf2b..d5365c0c4 100644 --- a/pkg/tx_list_validator/tx_list_validator.go +++ b/pkg/tx_list_validator/tx_list_validator.go @@ -59,9 +59,7 @@ func (v *TxListValidator) ValidateTxList( return txListBytes, hint, txIdx, nil } -// isTxListValid checks whether the transaction list is valid, must match -// the validation rule defined in LibInvalidTxList.sol. -// ref: https://github.com/taikoxyz/taiko-mono/blob/main/packages/bindings/contracts/libs/LibInvalidTxList.sol +// isTxListValid checks whether the transaction list is valid. func (v *TxListValidator) isTxListValid(blockID *big.Int, txListBytes []byte) (hint InvalidTxListReason, txIdx int) { if len(txListBytes) > int(v.maxBytesPerTxList) { log.Info("Transactions list binary too large", "length", len(txListBytes), "blockID", blockID) @@ -81,16 +79,6 @@ func (v *TxListValidator) isTxListValid(blockID *big.Int, txListBytes []byte) (h return HintNone, 0 } - sumGasLimit := uint64(0) - for _, tx := range txs { - sumGasLimit += tx.Gas() - } - - if sumGasLimit > v.blockMaxGasLimit { - log.Info("Accumulate gas limit too large", "blockID", blockID, "sumGasLimit", sumGasLimit) - return HintNone, 0 - } - log.Info("Transaction list is valid", "blockID", blockID) return HintOK, 0 } diff --git a/pkg/tx_list_validator/tx_list_validator_test.go b/pkg/tx_list_validator/tx_list_validator_test.go index 92b73b98e..f85b06529 100644 --- a/pkg/tx_list_validator/tx_list_validator_test.go +++ b/pkg/tx_list_validator/tx_list_validator_test.go @@ -79,13 +79,6 @@ func TestIsTxListValid(t *testing.T) { HintNone, 0, }, - { - "txListBytes gas limit too large", - chainID, - rlpEncodedTransactionBytes(6, true), - HintNone, - 0, - }, { "success empty tx list", chainID, diff --git a/proposer/proposer.go b/proposer/proposer.go index 01f80ce8a..23f7c1533 100644 --- a/proposer/proposer.go +++ b/proposer/proposer.go @@ -202,8 +202,27 @@ func (p *Proposer) ProposeOp(ctx context.Context) error { log.Info("Start fetching L2 execution engine's transaction pool content") + l2Head, err := p.rpc.L2.HeaderByNumber(ctx, nil) + if err != nil { + return err + } + + baseFee, err := p.rpc.TaikoL2.GetBasefee( + &bind.CallOpts{Context: ctx}, + uint32(time.Now().Unix()-int64(l2Head.Time)), + p.protocolConfigs.BlockMaxGasLimit, + uint32(l2Head.GasUsed), + ) + if err != nil { + return err + } + + log.Info("Current base fee", "fee", baseFee) + txLists, err := p.rpc.GetPoolContent( ctx, + p.L2SuggestedFeeRecipient(), + baseFee, p.protocolConfigs.BlockMaxTransactions, p.protocolConfigs.BlockMaxGasLimit, p.protocolConfigs.BlockMaxTxListBytes,