mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
feat(consensus): update TaikoL2 address building rule (#132)
* feat(consensus): update `TaikoL2` address building rule * chore: update ci * chore: update ci * test: fix lint errors * feat: update genesis JSONs
This commit is contained in:
parent
4da63b8b91
commit
91e836daf6
4 changed files with 157 additions and 137 deletions
|
|
@ -27,22 +27,32 @@ var (
|
|||
ErrEmptyWithdrawalsHash = errors.New("withdrawals hash missing")
|
||||
ErrAnchorTxNotFound = errors.New("anchor transaction not found")
|
||||
|
||||
GoldenTouchAccount = common.HexToAddress("0x0000777735367b36bC9B61C50022d9D0700dB4Ec")
|
||||
AnchorSelector = crypto.Keccak256([]byte("anchor(bytes32,bytes32,uint64,uint32)"))[:4]
|
||||
AnchorGasLimit = uint64(250_000)
|
||||
TaikoL2Address = common.HexToAddress("0x1000777700000000000000000000000000000001")
|
||||
GoldenTouchAccount = common.HexToAddress("0x0000777735367b36bC9B61C50022d9D0700dB4Ec")
|
||||
TaikoL2AddressSuffix = "10001"
|
||||
AnchorSelector = crypto.Keccak256([]byte("anchor(bytes32,bytes32,uint64,uint32)"))[:4]
|
||||
AnchorGasLimit = uint64(250_000)
|
||||
)
|
||||
|
||||
// Taiko is a consensus engine used by L2 rollup.
|
||||
type Taiko struct {
|
||||
chainConfig *params.ChainConfig
|
||||
chainConfig *params.ChainConfig
|
||||
taikoL2Address common.Address
|
||||
}
|
||||
|
||||
var _ = new(Taiko)
|
||||
|
||||
func New(chainConfig *params.ChainConfig) *Taiko {
|
||||
crypto.Keccak256()
|
||||
return &Taiko{chainConfig}
|
||||
taikoL2AddressPrefix := strings.TrimPrefix(chainConfig.ChainID.String(), "0")
|
||||
|
||||
return &Taiko{
|
||||
chainConfig: chainConfig,
|
||||
taikoL2Address: common.HexToAddress(
|
||||
"0x" +
|
||||
taikoL2AddressPrefix +
|
||||
strings.Repeat("0", common.AddressLength*2-len(taikoL2AddressPrefix)-len(TaikoL2AddressSuffix)) +
|
||||
TaikoL2AddressSuffix,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
// check all method stubs for interface `Engine` without affect performance.
|
||||
|
|
@ -306,7 +316,7 @@ func (t *Taiko) ValidateAnchorTx(tx *types.Transaction, header *types.Header) (b
|
|||
return false, nil
|
||||
}
|
||||
|
||||
if tx.To() == nil || *tx.To() != TaikoL2Address {
|
||||
if tx.To() == nil || *tx.To() != t.taikoL2Address {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package taiko_test
|
|||
import (
|
||||
"bytes"
|
||||
"math/big"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
|
|
@ -40,6 +41,15 @@ func init() {
|
|||
config.Taiko = true
|
||||
testEngine = taiko.New(config)
|
||||
|
||||
taikoL2AddressPrefix := strings.TrimPrefix(config.ChainID.String(), "0")
|
||||
|
||||
taikoL2Address := common.HexToAddress(
|
||||
"0x" +
|
||||
taikoL2AddressPrefix +
|
||||
strings.Repeat("0", common.AddressLength*2-len(taikoL2AddressPrefix)-len(taiko.TaikoL2AddressSuffix)) +
|
||||
taiko.TaikoL2AddressSuffix,
|
||||
)
|
||||
|
||||
genesis = &core.Genesis{
|
||||
Config: config,
|
||||
Alloc: core.GenesisAlloc{testAddr: {Balance: big.NewInt(2e15)}},
|
||||
|
|
@ -56,7 +66,7 @@ func init() {
|
|||
GasFeeCap: new(big.Int).SetUint64(875_000_000),
|
||||
Data: taiko.AnchorSelector,
|
||||
Gas: taiko.AnchorGasLimit,
|
||||
To: &taiko.TaikoL2Address,
|
||||
To: &taikoL2Address,
|
||||
}),
|
||||
types.MustSignNewTx(testKey, types.LatestSigner(genesis.Config), &types.LegacyTx{
|
||||
Nonce: 0,
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue