Skip to content

Commit

Permalink
feat(taiko-client): call CreateAccessList (#17691)
Browse files Browse the repository at this point in the history
  • Loading branch information
YoGhurt111 authored Jun 27, 2024
1 parent 3455e11 commit 9bb4b9c
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 54 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
12 changes: 12 additions & 0 deletions packages/taiko-client/pkg/rpc/ethclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 0 additions & 1 deletion packages/taiko-client/proposer/proposer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
16 changes: 0 additions & 16 deletions packages/taiko-client/proposer/transaction_builder/blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -128,27 +127,12 @@ 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,
Blobs: []*eth.Blob{blob},
To: to,
GasLimit: b.gasLimit,
Value: maxFee,
AccessList: types.AccessList{
{
Address: b.taikoL1Address,
StorageKeys: slotHashes,
},
},
}, nil
}
17 changes: 0 additions & 17 deletions packages/taiko-client/proposer/transaction_builder/calldata.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
}

0 comments on commit 9bb4b9c

Please sign in to comment.