Skip to content

Commit

Permalink
feat(taiko-client): use taiko-geth params (#17044)
Browse files Browse the repository at this point in the history
  • Loading branch information
mask-pp authored and davidtaikocha committed May 20, 2024
1 parent 8c98018 commit e77ced3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/decred/dcrd/dcrec/secp256k1/v4"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
consensus "github.com/ethereum/go-ethereum/consensus/taiko"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/log"

Expand All @@ -17,12 +18,6 @@ import (
"github.com/taikoxyz/taiko-mono/packages/taiko-client/pkg/rpc"
)

var (
// Each TaikoL2.anchor transaction should use this value as it's gas limit.
AnchorGasLimit uint64 = 250_000
GoldenTouchAddress = common.HexToAddress("0x0000777735367b36bC9B61C50022d9D0700dB4Ec")
)

// AnchorTxConstructor is responsible for assembling the anchor transaction (TaikoL2.anchor) in
// each L2 block, which must be the first transaction, and its sender must be the golden touch account.
type AnchorTxConstructor struct {
Expand Down Expand Up @@ -87,22 +82,22 @@ func (c *AnchorTxConstructor) transactOpts(
)

// Get the nonce of golden touch account at the specified parentHeight.
nonce, err := c.rpc.L2AccountNonce(ctx, GoldenTouchAddress, parentHeight)
nonce, err := c.rpc.L2AccountNonce(ctx, consensus.GoldenTouchAccount, parentHeight)
if err != nil {
return nil, err
}

log.Info(
"Golden touch account nonce",
"address", GoldenTouchAddress,
"address", consensus.GoldenTouchAccount,
"nonce", nonce,
"parent", parentHeight,
)

return &bind.TransactOpts{
From: GoldenTouchAddress,
From: consensus.GoldenTouchAccount,
Signer: func(address common.Address, tx *types.Transaction) (*types.Transaction, error) {
if address != GoldenTouchAddress {
if address != consensus.GoldenTouchAccount {
return nil, bind.ErrNotAuthorized
}
signature, err := c.signTxPayload(signer.Hash(tx).Bytes())
Expand All @@ -115,7 +110,7 @@ func (c *AnchorTxConstructor) transactOpts(
Context: ctx,
GasFeeCap: baseFee,
GasTipCap: common.Big0,
GasLimit: AnchorGasLimit,
GasLimit: consensus.AnchorGasLimit,
NoSend: true,
}, nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
consensus "github.com/ethereum/go-ethereum/consensus/taiko"
"github.com/ethereum/go-ethereum/crypto"
"github.com/stretchr/testify/suite"

Expand All @@ -32,7 +33,7 @@ func (s *AnchorTxConstructorTestSuite) SetupTest() {
}

func (s *AnchorTxConstructorTestSuite) TestGasLimit() {
s.Greater(AnchorGasLimit, uint64(0))
s.Greater(consensus.AnchorGasLimit, uint64(0))
}

func (s *AnchorTxConstructorTestSuite) TestAssembleAnchorTx() {
Expand Down
3 changes: 2 additions & 1 deletion packages/taiko-client/driver/chain_syncer/blob/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/beacon/engine"
"github.com/ethereum/go-ethereum/common"
consensus "github.com/ethereum/go-ethereum/consensus/taiko"
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/log"
Expand Down Expand Up @@ -454,7 +455,7 @@ func (s *Syncer) createExecutionPayloads(
BlockMetadata: &engine.BlockMetadata{
HighestBlockID: headBlockID,
Beneficiary: event.Meta.Coinbase,
GasLimit: uint64(event.Meta.GasLimit) + anchorTxConstructor.AnchorGasLimit,
GasLimit: uint64(event.Meta.GasLimit) + consensus.AnchorGasLimit,
Timestamp: event.Meta.Timestamp,
TxList: txListBytes,
MixHash: event.Meta.Difficulty,
Expand Down

0 comments on commit e77ced3

Please sign in to comment.