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

feat(all): remove gas limit check #336

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
with:
repository: taikoxyz/taiko-mono
path: ${{ env.TAIKO_MONO_DIR }}
ref: alpha-4
ref: remove_gas_limit_check

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
Expand Down
2 changes: 1 addition & 1 deletion bindings/.githead
Original file line number Diff line number Diff line change
@@ -1 +1 @@
013912fc7b74e9212dcbd374f47cf6b3e22252d6
e6eabc9c3b36d8dffdc5f98e7b7c8a9b80064a6e
8 changes: 0 additions & 8 deletions bindings/encoding/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ var (
Name: "beneficiary",
Type: "address",
},
{
Name: "gasLimit",
Type: "uint32",
},
{
Name: "txListByteStart",
Type: "uint24",
Expand Down Expand Up @@ -75,10 +71,6 @@ var (
Name: "txListByteEnd",
Type: "uint24",
},
{
Name: "gasLimit",
Type: "uint32",
},
{
Name: "beneficiary",
Type: "address",
Expand Down
1 change: 0 additions & 1 deletion bindings/encoding/struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ type TaikoL1Evidence struct {
type TaikoL1BlockMetadataInput struct {
TxListHash [32]byte
Beneficiary common.Address
GasLimit uint32
TxListByteStart *big.Int
TxListByteEnd *big.Int
CacheTxListInfo uint8
Expand Down
2 changes: 0 additions & 2 deletions bindings/encoding/struct_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ var (
}
testMetaInput = TaikoL1BlockMetadataInput{
Beneficiary: common.BytesToAddress(randomHash().Bytes()),
GasLimit: rand.Uint32(),
TxListHash: randomHash(),
TxListByteStart: common.Big0,
TxListByteEnd: common.Big0,
Expand All @@ -49,7 +48,6 @@ var (
TxListHash: randomHash(),
TxListByteStart: common.Big0,
TxListByteEnd: common.Big256,
GasLimit: rand.Uint32(),
Beneficiary: common.BytesToAddress(randomHash().Bytes()),
Treasury: common.BytesToAddress(randomHash().Bytes()),
DepositsProcessed: []bindings.TaikoDataEthDeposit{},
Expand Down
98 changes: 46 additions & 52 deletions bindings/gen_taiko_l1.go

Large diffs are not rendered by default.

6 changes: 0 additions & 6 deletions cmd/flags/proposer.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,6 @@ var (
Usage: "Time interval to propose empty blocks",
Category: proposerCategory,
}
MinBlockGasLimit = &cli.Uint64Flag{
Name: "minimalBlockGasLimit",
Usage: "Minimal block gasLimit when proposing a block",
Category: proposerCategory,
}
MaxProposedTxListsPerEpoch = &cli.Uint64Flag{
Name: "maxProposedTxListsPerEpoch",
Value: 1,
Expand Down Expand Up @@ -84,7 +79,6 @@ var ProposerFlags = MergeFlags(CommonFlags, []cli.Flag{
TxPoolLocals,
TxPoolLocalsOnly,
ProposeEmptyBlocksInterval,
MinBlockGasLimit,
MaxProposedTxListsPerEpoch,
ProposeBlockTxGasLimit,
ProposeBlockTxReplacementMultiplier,
Expand Down
15 changes: 8 additions & 7 deletions driver/chain_syncer/calldata/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ type Syncer struct {
anchorConstructor *anchorTxConstructor.AnchorTxConstructor // TaikoL2.anchor transactions constructor
txListValidator *txListValidator.TxListValidator // Transactions list validator
// Used by BlockInserter
lastInsertedBlockID *big.Int
reorgDetectedFlag bool
lastInsertedBlockID *big.Int
blockAndTxMaxGasUsed uint32
reorgDetectedFlag bool
}

// NewSyncer creates a new syncer instance.
Expand Down Expand Up @@ -64,11 +65,11 @@ func NewSyncer(
progressTracker: progressTracker,
anchorConstructor: constructor,
txListValidator: txListValidator.NewTxListValidator(
uint64(configs.BlockMaxGasLimit),
configs.BlockMaxTransactions,
configs.BlockMaxTxListBytes,
rpc.L2ChainID,
),
blockAndTxMaxGasUsed: configs.BlockAndTxMaxGasUsed,
}, nil
}

Expand Down Expand Up @@ -334,18 +335,17 @@ func (s *Syncer) insertNewHead(
baseFee, err := s.rpc.TaikoL2.GetBasefee(
&bind.CallOpts{BlockNumber: parent.Number, Context: ctx},
uint32(event.Meta.Timestamp-parentTimestamp),
event.Meta.GasLimit+uint32(s.anchorConstructor.GasLimit()),
s.blockAndTxMaxGasUsed+uint32(s.anchorConstructor.GasLimit()), // TODO: use a correct gas limit
uint32(parent.GasUsed),
)
if err != nil {
return nil, fmt.Errorf("failed to get L2 baseFee: %w", encoding.TryParsingCustomError(err))
}

log.Debug(
"GetBasefee",
"Get base fee",
"baseFee", baseFee,
"timeSinceParent", uint32(event.Meta.Timestamp-parentTimestamp),
"gasLimit", uint64(event.Meta.GasLimit+uint32(s.anchorConstructor.GasLimit())),
"parentGasUsed", parent.GasUsed,
)

Expand Down Expand Up @@ -426,11 +426,12 @@ func (s *Syncer) createExecutionPayloads(
BlockMetadata: &engine.BlockMetadata{
HighestBlockID: headBlockID,
Beneficiary: event.Meta.Beneficiary,
GasLimit: uint64(event.Meta.GasLimit) + s.anchorConstructor.GasLimit(),
GasLimit: uint64(s.blockAndTxMaxGasUsed) + s.anchorConstructor.GasLimit(), // TODO: use a correct gas limit
Timestamp: event.Meta.Timestamp,
TxList: txListBytes,
MixHash: event.Meta.MixHash,
ExtraData: []byte{},
GasUsedLimit: uint64(s.blockAndTxMaxGasUsed),
},
BaseFeePerGas: baseFeee,
L1Origin: l1Origin,
Expand Down
2 changes: 0 additions & 2 deletions driver/chain_syncer/calldata/syncer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package calldata
import (
"context"
"math/big"
"math/rand"
"os"
"testing"
"time"
Expand Down Expand Up @@ -94,7 +93,6 @@ func (s *CalldataSyncerTestSuite) TestInsertNewHead() {
Beneficiary: common.BytesToAddress(testutils.RandomBytes(1024)),
TxListHash: testutils.RandomHash(),
MixHash: testutils.RandomHash(),
GasLimit: rand.Uint32(),
Timestamp: uint64(time.Now().Unix()),
},
},
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,4 @@ require (
gopkg.in/yaml.v3 v3.0.1 // indirect
)

replace github.com/ethereum/go-ethereum v1.11.5 => github.com/taikoxyz/taiko-geth v0.0.0-20230528194240-f4b7892dc112
replace github.com/ethereum/go-ethereum v1.11.5 => github.com/taikoxyz/taiko-geth v0.0.0-20230728124813-48bb5d8a8c5f
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,8 @@ github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKs
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d h1:vfofYNRScrDdvS342BElfbETmL1Aiz3i2t0zfRj16Hs=
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d/go.mod h1:RRCYJbIwD5jmqPI9XoAFR0OcDxqUctll6zUj/+B4S48=
github.com/taikoxyz/taiko-geth v0.0.0-20230528194240-f4b7892dc112 h1:3A4zdowD7VW+27Wa78jC5n57sTBndkdjhEvROYrddxQ=
github.com/taikoxyz/taiko-geth v0.0.0-20230528194240-f4b7892dc112/go.mod h1:it7x0DWnTDMfVFdXcU6Ti4KEFQynLHVRarcSlPr0HBo=
github.com/taikoxyz/taiko-geth v0.0.0-20230728124813-48bb5d8a8c5f h1:cVyewmAdTvKV5hw+WL+N/KW2INPo2UEB0TaeVZsiiE8=
github.com/taikoxyz/taiko-geth v0.0.0-20230728124813-48bb5d8a8c5f/go.mod h1:it7x0DWnTDMfVFdXcU6Ti4KEFQynLHVRarcSlPr0HBo=
github.com/thomaso-mirodin/intmath v0.0.0-20160323211736-5dc6d854e46e h1:cR8/SYRgyQCt5cNCMniB/ZScMkhI9nk8U5C7SbISXjo=
github.com/thomaso-mirodin/intmath v0.0.0-20160323211736-5dc6d854e46e/go.mod h1:Tu4lItkATkonrYuvtVjG0/rhy15qrNGNTjPdaphtZ/8=
github.com/tklauser/go-sysconf v0.3.11 h1:89WgdJhk5SNwJfu+GKyYveZ4IaJ7xAkecBo+KdJV0CM=
Expand Down
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:txList-with-gasUsed
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,8 +211,10 @@ 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 uint64,
maxTransactionsPerBlock uint64,
blockMaxGasLimit uint32,
blockAndTxMaxGasUsed uint64,
maxBytesPerTxList uint64,
locals []common.Address,
maxTransactions uint64,
Expand All @@ -228,10 +229,11 @@ func (c *Client) GetPoolContent(
ctx,
&result,
"taiko_txPoolContent",
beneficiary.Hex(),
baseFee,
maxTransactionsPerBlock,
blockMaxGasLimit,
blockAndTxMaxGasUsed,
maxBytesPerTxList,
minTxGasLimit,
localsArg,
maxTransactions,
)
Expand Down
21 changes: 4 additions & 17 deletions pkg/tx_list_validator/tx_list_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,18 @@ const (
)

type TxListValidator struct {
blockMaxGasLimit uint64
maxTransactionsPerBlock uint64
maxBytesPerTxList uint64
maxTransactionsPerBlock uint32
maxBytesPerTxList uint32
chainID *big.Int
}

// NewTxListValidator creates a new TxListValidator instance based on giving configurations.
func NewTxListValidator(
blockMaxGasLimit uint64,
maxTransactionsPerBlock uint64,
maxBytesPerTxList uint64,
maxTransactionsPerBlock uint32,
maxBytesPerTxList uint32,
chainID *big.Int,
) *TxListValidator {
return &TxListValidator{
blockMaxGasLimit: blockMaxGasLimit,
maxTransactionsPerBlock: maxTransactionsPerBlock,
maxBytesPerTxList: maxBytesPerTxList,
chainID: chainID,
Expand Down Expand Up @@ -81,16 +78,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
}
10 changes: 4 additions & 6 deletions pkg/tx_list_validator/tx_list_validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
)

var (
maxBlocksGasLimit = uint64(50)
maxBlockNumTxs = uint64(11)
maxTxlistBytes = uint64(10000)
maxBlocksGasLimit = uint32(50)

Check failure on line 18 in pkg/tx_list_validator/tx_list_validator_test.go

View workflow job for this annotation

GitHub Actions / Lint

var `maxBlocksGasLimit` is unused (unused)
maxBlockNumTxs = uint32(11)
maxTxlistBytes = uint32(10000)
chainID = genesis.Config.ChainID
testKey, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
testAddr = crypto.PubkeyToAddress(testKey.PublicKey)
Expand All @@ -32,7 +32,6 @@

func TestValidateTxList(t *testing.T) {
v := NewTxListValidator(
maxBlocksGasLimit,
maxBlockNumTxs,
maxTxlistBytes,
chainID,
Expand All @@ -46,7 +45,6 @@

func TestIsTxListValid(t *testing.T) {
v := NewTxListValidator(
maxBlocksGasLimit,
maxBlockNumTxs,
maxTxlistBytes,
chainID,
Expand Down Expand Up @@ -137,7 +135,7 @@
return b
}

func randBytes(l uint64) []byte {
func randBytes(l uint32) []byte {
b := make([]byte, l)
rand.Read(b)
return b
Expand Down
2 changes: 0 additions & 2 deletions proposer/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ type Config struct {
LocalAddresses []common.Address
LocalAddressesOnly bool
ProposeEmptyBlocksInterval *time.Duration
MinBlockGasLimit uint64
MaxProposedTxListsPerEpoch uint64
ProposeBlockTxGasLimit *uint64
BackOffRetryInterval time.Duration
Expand Down Expand Up @@ -102,7 +101,6 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) {
LocalAddresses: localAddresses,
LocalAddressesOnly: c.Bool(flags.TxPoolLocalsOnly.Name),
ProposeEmptyBlocksInterval: proposeEmptyBlocksInterval,
MinBlockGasLimit: c.Uint64(flags.MinBlockGasLimit.Name),
MaxProposedTxListsPerEpoch: c.Uint64(flags.MaxProposedTxListsPerEpoch.Name),
ProposeBlockTxGasLimit: proposeBlockTxGasLimit,
BackOffRetryInterval: time.Duration(c.Uint64(flags.BackOffRetryInterval.Name)) * time.Second,
Expand Down
Loading
Loading