From 9bb4b9c94f3bc2a8fef1c793d13bf749d8c0614f Mon Sep 17 00:00:00 2001 From: Gavin Yu Date: Thu, 27 Jun 2024 15:33:33 +0800 Subject: [PATCH] feat(taiko-client): call `CreateAccessList` (#17691) --- go.mod | 2 +- go.sum | 2 ++ packages/taiko-client/pkg/rpc/ethclient.go | 12 ++++++++++++ .../taiko-client/proposer/proposer_test.go | 1 - .../proposer/transaction_builder/blob.go | 16 ---------------- .../proposer/transaction_builder/calldata.go | 17 ----------------- .../proof_submitter/transaction/builder.go | 19 ------------------- 7 files changed, 15 insertions(+), 54 deletions(-) diff --git a/go.mod b/go.mod index e1948907df..2760e043f8 100644 --- a/go.mod +++ b/go.mod @@ -321,6 +321,6 @@ require ( replace github.com/ethereum/go-ethereum v1.13.15 => github.com/taikoxyz/taiko-geth v0.0.0-20240504072040-7e1b8b65a3f8 -replace github.com/ethereum-optimism/optimism v1.7.4 => github.com/taikoxyz/optimism v0.0.0-20240624055706-43346f17fbdb +replace github.com/ethereum-optimism/optimism v1.7.4 => github.com/taikoxyz/optimism v0.0.0-20240627061604-7871b0ec8bbb replace github.com/uber/jaeger-client-go => github.com/uber/jaeger-client-go v2.25.0+incompatible diff --git a/go.sum b/go.sum index 1a1c94c7e9..d08ad2a249 100644 --- a/go.sum +++ b/go.sum @@ -1167,6 +1167,8 @@ github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d h1:vfofYNRScrDd github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d/go.mod h1:RRCYJbIwD5jmqPI9XoAFR0OcDxqUctll6zUj/+B4S48= github.com/taikoxyz/optimism v0.0.0-20240624055706-43346f17fbdb h1:t4JcXSwxpUIYq5HrIYCkIfRBc/cytoC6X4YjeJF+qck= github.com/taikoxyz/optimism v0.0.0-20240624055706-43346f17fbdb/go.mod h1:jKn73pLX8eDIG0Y3XeuUSetepecM8OvRflyPHbi05B4= +github.com/taikoxyz/optimism v0.0.0-20240627061604-7871b0ec8bbb h1:qlJDLlAgHbUrgyYK3OZ3CtS8zP71AIDjjn22KWCPA+w= +github.com/taikoxyz/optimism v0.0.0-20240627061604-7871b0ec8bbb/go.mod h1:jKn73pLX8eDIG0Y3XeuUSetepecM8OvRflyPHbi05B4= github.com/taikoxyz/taiko-geth v0.0.0-20240504072040-7e1b8b65a3f8 h1:z4juQ4Nyp2T836JTCNC8t3vrbr0K9v2pPUV/ir2dy9s= github.com/taikoxyz/taiko-geth v0.0.0-20240504072040-7e1b8b65a3f8/go.mod h1:nqByouVW0a0qx5KKgvYgoXba+pYEHznAAQp6LhZilgM= github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA= diff --git a/packages/taiko-client/pkg/rpc/ethclient.go b/packages/taiko-client/pkg/rpc/ethclient.go index 4b6c7b7e39..fb90be78bc 100644 --- a/packages/taiko-client/pkg/rpc/ethclient.go +++ b/packages/taiko-client/pkg/rpc/ethclient.go @@ -372,6 +372,18 @@ func (c *EthClient) SendTransaction(ctx context.Context, tx *types.Transaction) return c.ethClient.SendTransaction(ctxWithTimeout, tx) } +// CreateAccessList tries to create an access list for a specific transaction based on the +// current pending state of the blockchain. +func (c *EthClient) CreateAccessList( + ctx context.Context, + msg ethereum.CallMsg, +) (*types.AccessList, uint64, string, error) { + ctxWithTimeout, cancel := ctxWithTimeoutOrDefault(ctx, c.timeout) + defer cancel() + + return c.gethClient.CreateAccessList(ctxWithTimeout, msg) +} + // TransactionArgs represents the arguments to construct a new transaction // or a message call. type TransactionArgs struct { diff --git a/packages/taiko-client/proposer/proposer_test.go b/packages/taiko-client/proposer/proposer_test.go index fb77e99b1c..7feebcda4b 100644 --- a/packages/taiko-client/proposer/proposer_test.go +++ b/packages/taiko-client/proposer/proposer_test.go @@ -85,7 +85,6 @@ func (s *ProposerTestSuite) SetupTest() { MaxTierFeePriceBumps: 3, ExtraData: "test", L1BlockBuilderTip: common.Big0, - BlobAllowed: true, ProposeBlockTxGasLimit: 10_000_000, TxmgrConfigs: &txmgr.CLIConfig{ L1RPCURL: os.Getenv("L1_NODE_WS_ENDPOINT"), diff --git a/packages/taiko-client/proposer/transaction_builder/blob.go b/packages/taiko-client/proposer/transaction_builder/blob.go index 6a4e83f5ff..2dda18194d 100644 --- a/packages/taiko-client/proposer/transaction_builder/blob.go +++ b/packages/taiko-client/proposer/transaction_builder/blob.go @@ -9,7 +9,6 @@ import ( "github.com/ethereum-optimism/optimism/op-service/eth" "github.com/ethereum-optimism/optimism/op-service/txmgr" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto/kzg4844" @@ -128,15 +127,6 @@ func (b *BlobTransactionBuilder) Build( return nil, err } } - // Calculate TaikoData.State slot hash (includes slot 0-6 currently) - var slotHashes []common.Hash - for i := 0; i < 7; i++ { - packedData := append( - common.LeftPadBytes(b.taikoL1Address.Bytes(), 32), - common.LeftPadBytes(big.NewInt(int64(i)).Bytes(), 32)..., - ) - slotHashes = append(slotHashes, crypto.Keccak256Hash(packedData)) - } return &txmgr.TxCandidate{ TxData: data, @@ -144,11 +134,5 @@ func (b *BlobTransactionBuilder) Build( To: to, GasLimit: b.gasLimit, Value: maxFee, - AccessList: types.AccessList{ - { - Address: b.taikoL1Address, - StorageKeys: slotHashes, - }, - }, }, nil } diff --git a/packages/taiko-client/proposer/transaction_builder/calldata.go b/packages/taiko-client/proposer/transaction_builder/calldata.go index 7168646310..5fef780f53 100644 --- a/packages/taiko-client/proposer/transaction_builder/calldata.go +++ b/packages/taiko-client/proposer/transaction_builder/calldata.go @@ -7,7 +7,6 @@ import ( "github.com/ethereum-optimism/optimism/op-service/txmgr" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" "github.com/taikoxyz/taiko-mono/packages/taiko-client/bindings/encoding" @@ -115,27 +114,11 @@ func (b *CalldataTransactionBuilder) Build( } } - // Calculate TaikoData.State slot hash (includes slot 0-6 currently) - var slotHashes []common.Hash - for i := 0; i < 7; i++ { - packedData := append( - common.LeftPadBytes(b.taikoL1Address.Bytes(), 32), - common.LeftPadBytes(big.NewInt(int64(i)).Bytes(), 32)..., - ) - slotHashes = append(slotHashes, crypto.Keccak256Hash(packedData)) - } - return &txmgr.TxCandidate{ TxData: data, Blobs: nil, To: to, GasLimit: b.gasLimit, Value: maxFee, - AccessList: types.AccessList{ - { - Address: b.taikoL1Address, - StorageKeys: slotHashes, - }, - }, }, nil } diff --git a/packages/taiko-client/prover/proof_submitter/transaction/builder.go b/packages/taiko-client/prover/proof_submitter/transaction/builder.go index 33ea11d968..86b2104e90 100644 --- a/packages/taiko-client/prover/proof_submitter/transaction/builder.go +++ b/packages/taiko-client/prover/proof_submitter/transaction/builder.go @@ -5,12 +5,9 @@ import ( "fmt" "math/big" - "github.com/ethereum/go-ethereum/crypto" - "github.com/ethereum-optimism/optimism/op-service/txmgr" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/log" "github.com/taikoxyz/taiko-mono/packages/taiko-client/bindings" @@ -105,28 +102,12 @@ func (a *ProveBlockTxBuilder) Build( } } - // Calculate TaikoData.State slot hash (includes slot 0-6 currently) - var slotHashes []common.Hash - for i := 0; i < 7; i++ { - packedData := append( - common.LeftPadBytes(a.taikoL1Address.Bytes(), 32), - common.LeftPadBytes(big.NewInt(int64(i)).Bytes(), 32)..., - ) - slotHashes = append(slotHashes, crypto.Keccak256Hash(packedData)) - } - return &txmgr.TxCandidate{ TxData: data, To: &to, Blobs: nil, GasLimit: txOpts.GasLimit, Value: txOpts.Value, - AccessList: types.AccessList{ - { - Address: a.taikoL1Address, - StorageKeys: slotHashes, - }, - }, }, nil } }