mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
tests: improve cancun support
This commit is contained in:
parent
26722ef214
commit
cc2fea08e0
3 changed files with 119 additions and 66 deletions
|
|
@ -73,24 +73,27 @@ type btBlock struct {
|
||||||
//go:generate go run github.com/fjl/gencodec -type btHeader -field-override btHeaderMarshaling -out gen_btheader.go
|
//go:generate go run github.com/fjl/gencodec -type btHeader -field-override btHeaderMarshaling -out gen_btheader.go
|
||||||
|
|
||||||
type btHeader struct {
|
type btHeader struct {
|
||||||
Bloom types.Bloom
|
Bloom types.Bloom
|
||||||
Coinbase common.Address
|
Coinbase common.Address
|
||||||
MixHash common.Hash
|
MixHash common.Hash
|
||||||
Nonce types.BlockNonce
|
Nonce types.BlockNonce
|
||||||
Number *big.Int
|
Number *big.Int
|
||||||
Hash common.Hash
|
Hash common.Hash
|
||||||
ParentHash common.Hash
|
ParentHash common.Hash
|
||||||
ReceiptTrie common.Hash
|
ReceiptTrie common.Hash
|
||||||
StateRoot common.Hash
|
StateRoot common.Hash
|
||||||
TransactionsTrie common.Hash
|
TransactionsTrie common.Hash
|
||||||
UncleHash common.Hash
|
UncleHash common.Hash
|
||||||
ExtraData []byte
|
ExtraData []byte
|
||||||
Difficulty *big.Int
|
Difficulty *big.Int
|
||||||
GasLimit uint64
|
GasLimit uint64
|
||||||
GasUsed uint64
|
GasUsed uint64
|
||||||
Timestamp uint64
|
Timestamp uint64
|
||||||
BaseFeePerGas *big.Int
|
BaseFeePerGas *big.Int
|
||||||
WithdrawalsRoot *common.Hash
|
WithdrawalsRoot *common.Hash
|
||||||
|
BlobGasUsed *uint64
|
||||||
|
ExcessBlobGas *uint64
|
||||||
|
ParentBeaconBlockRoot *common.Hash
|
||||||
}
|
}
|
||||||
|
|
||||||
type btHeaderMarshaling struct {
|
type btHeaderMarshaling struct {
|
||||||
|
|
@ -101,6 +104,8 @@ type btHeaderMarshaling struct {
|
||||||
GasUsed math.HexOrDecimal64
|
GasUsed math.HexOrDecimal64
|
||||||
Timestamp math.HexOrDecimal64
|
Timestamp math.HexOrDecimal64
|
||||||
BaseFeePerGas *math.HexOrDecimal256
|
BaseFeePerGas *math.HexOrDecimal256
|
||||||
|
BlobGasUsed *math.HexOrDecimal64
|
||||||
|
ExcessBlobGas *math.HexOrDecimal64
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *BlockTest) Run(snapshotter bool, scheme string, tracer vm.EVMLogger) error {
|
func (t *BlockTest) Run(snapshotter bool, scheme string, tracer vm.EVMLogger) error {
|
||||||
|
|
@ -175,18 +180,20 @@ func (t *BlockTest) Run(snapshotter bool, scheme string, tracer vm.EVMLogger) er
|
||||||
|
|
||||||
func (t *BlockTest) genesis(config *params.ChainConfig) *core.Genesis {
|
func (t *BlockTest) genesis(config *params.ChainConfig) *core.Genesis {
|
||||||
return &core.Genesis{
|
return &core.Genesis{
|
||||||
Config: config,
|
Config: config,
|
||||||
Nonce: t.json.Genesis.Nonce.Uint64(),
|
Nonce: t.json.Genesis.Nonce.Uint64(),
|
||||||
Timestamp: t.json.Genesis.Timestamp,
|
Timestamp: t.json.Genesis.Timestamp,
|
||||||
ParentHash: t.json.Genesis.ParentHash,
|
ParentHash: t.json.Genesis.ParentHash,
|
||||||
ExtraData: t.json.Genesis.ExtraData,
|
ExtraData: t.json.Genesis.ExtraData,
|
||||||
GasLimit: t.json.Genesis.GasLimit,
|
GasLimit: t.json.Genesis.GasLimit,
|
||||||
GasUsed: t.json.Genesis.GasUsed,
|
GasUsed: t.json.Genesis.GasUsed,
|
||||||
Difficulty: t.json.Genesis.Difficulty,
|
Difficulty: t.json.Genesis.Difficulty,
|
||||||
Mixhash: t.json.Genesis.MixHash,
|
Mixhash: t.json.Genesis.MixHash,
|
||||||
Coinbase: t.json.Genesis.Coinbase,
|
Coinbase: t.json.Genesis.Coinbase,
|
||||||
Alloc: t.json.Pre,
|
Alloc: t.json.Pre,
|
||||||
BaseFee: t.json.Genesis.BaseFeePerGas,
|
BaseFee: t.json.Genesis.BaseFeePerGas,
|
||||||
|
BlobGasUsed: t.json.Genesis.BlobGasUsed,
|
||||||
|
ExcessBlobGas: t.json.Genesis.ExcessBlobGas,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -295,6 +302,15 @@ func validateHeader(h *btHeader, h2 *types.Header) error {
|
||||||
if !reflect.DeepEqual(h.WithdrawalsRoot, h2.WithdrawalsHash) {
|
if !reflect.DeepEqual(h.WithdrawalsRoot, h2.WithdrawalsHash) {
|
||||||
return fmt.Errorf("withdrawalsRoot: want: %v have: %v", h.WithdrawalsRoot, h2.WithdrawalsHash)
|
return fmt.Errorf("withdrawalsRoot: want: %v have: %v", h.WithdrawalsRoot, h2.WithdrawalsHash)
|
||||||
}
|
}
|
||||||
|
if !reflect.DeepEqual(h.BlobGasUsed, h2.BlobGasUsed) {
|
||||||
|
return fmt.Errorf("blobGasUsed: want: %v have: %v", h.BlobGasUsed, h2.BlobGasUsed)
|
||||||
|
}
|
||||||
|
if !reflect.DeepEqual(h.ExcessBlobGas, h2.ExcessBlobGas) {
|
||||||
|
return fmt.Errorf("excessBlobGas: want: %v have: %v", h.ExcessBlobGas, h2.ExcessBlobGas)
|
||||||
|
}
|
||||||
|
if !reflect.DeepEqual(h.ParentBeaconBlockRoot, h2.ParentBeaconRoot) {
|
||||||
|
return fmt.Errorf("parentBeaconBlockRoot: want: %v have: %v", h.ParentBeaconBlockRoot, h2.ParentBeaconRoot)
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,24 +17,27 @@ var _ = (*btHeaderMarshaling)(nil)
|
||||||
// MarshalJSON marshals as JSON.
|
// MarshalJSON marshals as JSON.
|
||||||
func (b btHeader) MarshalJSON() ([]byte, error) {
|
func (b btHeader) MarshalJSON() ([]byte, error) {
|
||||||
type btHeader struct {
|
type btHeader struct {
|
||||||
Bloom types.Bloom
|
Bloom types.Bloom
|
||||||
Coinbase common.Address
|
Coinbase common.Address
|
||||||
MixHash common.Hash
|
MixHash common.Hash
|
||||||
Nonce types.BlockNonce
|
Nonce types.BlockNonce
|
||||||
Number *math.HexOrDecimal256
|
Number *math.HexOrDecimal256
|
||||||
Hash common.Hash
|
Hash common.Hash
|
||||||
ParentHash common.Hash
|
ParentHash common.Hash
|
||||||
ReceiptTrie common.Hash
|
ReceiptTrie common.Hash
|
||||||
StateRoot common.Hash
|
StateRoot common.Hash
|
||||||
TransactionsTrie common.Hash
|
TransactionsTrie common.Hash
|
||||||
UncleHash common.Hash
|
UncleHash common.Hash
|
||||||
ExtraData hexutil.Bytes
|
ExtraData hexutil.Bytes
|
||||||
Difficulty *math.HexOrDecimal256
|
Difficulty *math.HexOrDecimal256
|
||||||
GasLimit math.HexOrDecimal64
|
GasLimit math.HexOrDecimal64
|
||||||
GasUsed math.HexOrDecimal64
|
GasUsed math.HexOrDecimal64
|
||||||
Timestamp math.HexOrDecimal64
|
Timestamp math.HexOrDecimal64
|
||||||
BaseFeePerGas *math.HexOrDecimal256
|
BaseFeePerGas *math.HexOrDecimal256
|
||||||
WithdrawalsRoot *common.Hash
|
WithdrawalsRoot *common.Hash
|
||||||
|
BlobGasUsed *math.HexOrDecimal64
|
||||||
|
ExcessBlobGas *math.HexOrDecimal64
|
||||||
|
ParentBeaconBlockRoot *common.Hash
|
||||||
}
|
}
|
||||||
var enc btHeader
|
var enc btHeader
|
||||||
enc.Bloom = b.Bloom
|
enc.Bloom = b.Bloom
|
||||||
|
|
@ -55,30 +58,36 @@ func (b btHeader) MarshalJSON() ([]byte, error) {
|
||||||
enc.Timestamp = math.HexOrDecimal64(b.Timestamp)
|
enc.Timestamp = math.HexOrDecimal64(b.Timestamp)
|
||||||
enc.BaseFeePerGas = (*math.HexOrDecimal256)(b.BaseFeePerGas)
|
enc.BaseFeePerGas = (*math.HexOrDecimal256)(b.BaseFeePerGas)
|
||||||
enc.WithdrawalsRoot = b.WithdrawalsRoot
|
enc.WithdrawalsRoot = b.WithdrawalsRoot
|
||||||
|
enc.BlobGasUsed = (*math.HexOrDecimal64)(b.BlobGasUsed)
|
||||||
|
enc.ExcessBlobGas = (*math.HexOrDecimal64)(b.ExcessBlobGas)
|
||||||
|
enc.ParentBeaconBlockRoot = b.ParentBeaconBlockRoot
|
||||||
return json.Marshal(&enc)
|
return json.Marshal(&enc)
|
||||||
}
|
}
|
||||||
|
|
||||||
// UnmarshalJSON unmarshals from JSON.
|
// UnmarshalJSON unmarshals from JSON.
|
||||||
func (b *btHeader) UnmarshalJSON(input []byte) error {
|
func (b *btHeader) UnmarshalJSON(input []byte) error {
|
||||||
type btHeader struct {
|
type btHeader struct {
|
||||||
Bloom *types.Bloom
|
Bloom *types.Bloom
|
||||||
Coinbase *common.Address
|
Coinbase *common.Address
|
||||||
MixHash *common.Hash
|
MixHash *common.Hash
|
||||||
Nonce *types.BlockNonce
|
Nonce *types.BlockNonce
|
||||||
Number *math.HexOrDecimal256
|
Number *math.HexOrDecimal256
|
||||||
Hash *common.Hash
|
Hash *common.Hash
|
||||||
ParentHash *common.Hash
|
ParentHash *common.Hash
|
||||||
ReceiptTrie *common.Hash
|
ReceiptTrie *common.Hash
|
||||||
StateRoot *common.Hash
|
StateRoot *common.Hash
|
||||||
TransactionsTrie *common.Hash
|
TransactionsTrie *common.Hash
|
||||||
UncleHash *common.Hash
|
UncleHash *common.Hash
|
||||||
ExtraData *hexutil.Bytes
|
ExtraData *hexutil.Bytes
|
||||||
Difficulty *math.HexOrDecimal256
|
Difficulty *math.HexOrDecimal256
|
||||||
GasLimit *math.HexOrDecimal64
|
GasLimit *math.HexOrDecimal64
|
||||||
GasUsed *math.HexOrDecimal64
|
GasUsed *math.HexOrDecimal64
|
||||||
Timestamp *math.HexOrDecimal64
|
Timestamp *math.HexOrDecimal64
|
||||||
BaseFeePerGas *math.HexOrDecimal256
|
BaseFeePerGas *math.HexOrDecimal256
|
||||||
WithdrawalsRoot *common.Hash
|
WithdrawalsRoot *common.Hash
|
||||||
|
BlobGasUsed *math.HexOrDecimal64
|
||||||
|
ExcessBlobGas *math.HexOrDecimal64
|
||||||
|
ParentBeaconBlockRoot *common.Hash
|
||||||
}
|
}
|
||||||
var dec btHeader
|
var dec btHeader
|
||||||
if err := json.Unmarshal(input, &dec); err != nil {
|
if err := json.Unmarshal(input, &dec); err != nil {
|
||||||
|
|
@ -138,5 +147,14 @@ func (b *btHeader) UnmarshalJSON(input []byte) error {
|
||||||
if dec.WithdrawalsRoot != nil {
|
if dec.WithdrawalsRoot != nil {
|
||||||
b.WithdrawalsRoot = dec.WithdrawalsRoot
|
b.WithdrawalsRoot = dec.WithdrawalsRoot
|
||||||
}
|
}
|
||||||
|
if dec.BlobGasUsed != nil {
|
||||||
|
b.BlobGasUsed = (*uint64)(dec.BlobGasUsed)
|
||||||
|
}
|
||||||
|
if dec.ExcessBlobGas != nil {
|
||||||
|
b.ExcessBlobGas = (*uint64)(dec.ExcessBlobGas)
|
||||||
|
}
|
||||||
|
if dec.ParentBeaconBlockRoot != nil {
|
||||||
|
b.ParentBeaconBlockRoot = dec.ParentBeaconBlockRoot
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -318,6 +318,25 @@ var Forks = map[string]*params.ChainConfig{
|
||||||
ShanghaiTime: u64(0),
|
ShanghaiTime: u64(0),
|
||||||
CancunTime: u64(0),
|
CancunTime: u64(0),
|
||||||
},
|
},
|
||||||
|
"ShanghaiToCancunAtTime15k": {
|
||||||
|
ChainID: big.NewInt(1),
|
||||||
|
HomesteadBlock: big.NewInt(0),
|
||||||
|
EIP150Block: big.NewInt(0),
|
||||||
|
EIP155Block: big.NewInt(0),
|
||||||
|
EIP158Block: big.NewInt(0),
|
||||||
|
ByzantiumBlock: big.NewInt(0),
|
||||||
|
ConstantinopleBlock: big.NewInt(0),
|
||||||
|
PetersburgBlock: big.NewInt(0),
|
||||||
|
IstanbulBlock: big.NewInt(0),
|
||||||
|
MuirGlacierBlock: big.NewInt(0),
|
||||||
|
BerlinBlock: big.NewInt(0),
|
||||||
|
LondonBlock: big.NewInt(0),
|
||||||
|
ArrowGlacierBlock: big.NewInt(0),
|
||||||
|
MergeNetsplitBlock: big.NewInt(0),
|
||||||
|
TerminalTotalDifficulty: big.NewInt(0),
|
||||||
|
ShanghaiTime: u64(0),
|
||||||
|
CancunTime: u64(15_000),
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// AvailableForks returns the set of defined fork names
|
// AvailableForks returns the set of defined fork names
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue