Skip to content
This repository has been archived by the owner on May 11, 2024. It is now read-only.

Commit

Permalink
feat(proposer): update pool content query (#341)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtaikocha committed Aug 1, 2023
1 parent 1608aba commit 221a3b9
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 25 deletions.
2 changes: 1 addition & 1 deletion integration_test/nodes/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
10 changes: 6 additions & 4 deletions pkg/rpc/methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand All @@ -228,12 +229,13 @@ func (c *Client) GetPoolContent(
ctx,
&result,
"taiko_txPoolContent",
beneficiary,
baseFee,
maxTransactionsPerBlock,
blockMaxGasLimit,
maxBytesPerTxList,
minTxGasLimit,
localsArg,
maxTransactions,
maxTransactionsLists,
)

return result, err
Expand Down
14 changes: 1 addition & 13 deletions pkg/tx_list_validator/tx_list_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
}
7 changes: 0 additions & 7 deletions pkg/tx_list_validator/tx_list_validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
19 changes: 19 additions & 0 deletions proposer/proposer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 221a3b9

Please sign in to comment.