mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 23:26:44 +00:00
Merge pull request #20 from streamingfast/fix/bring-v1.13.5-sei-12
Fix/bring v1.13.5 sei 12
This commit is contained in:
commit
6ab0d196ba
2 changed files with 43 additions and 43 deletions
|
|
@ -45,17 +45,17 @@ import (
|
||||||
|
|
||||||
// A BlockTest checks handling of entire blocks.
|
// A BlockTest checks handling of entire blocks.
|
||||||
type BlockTest struct {
|
type BlockTest struct {
|
||||||
json btJSON
|
Json BtJSON
|
||||||
}
|
}
|
||||||
|
|
||||||
// UnmarshalJSON implements json.Unmarshaler interface.
|
// UnmarshalJSON implements json.Unmarshaler interface.
|
||||||
func (t *BlockTest) UnmarshalJSON(in []byte) error {
|
func (t *BlockTest) UnmarshalJSON(in []byte) error {
|
||||||
return json.Unmarshal(in, &t.json)
|
return json.Unmarshal(in, &t.Json)
|
||||||
}
|
}
|
||||||
|
|
||||||
type btJSON struct {
|
type BtJSON struct {
|
||||||
Blocks []btBlock `json:"blocks"`
|
Blocks []BtBlock `json:"blocks"`
|
||||||
Genesis btHeader `json:"genesisBlockHeader"`
|
Genesis BtHeader `json:"genesisBlockHeader"`
|
||||||
Pre core.GenesisAlloc `json:"pre"`
|
Pre core.GenesisAlloc `json:"pre"`
|
||||||
Post core.GenesisAlloc `json:"postState"`
|
Post core.GenesisAlloc `json:"postState"`
|
||||||
BestBlock common.UnprefixedHash `json:"lastblockhash"`
|
BestBlock common.UnprefixedHash `json:"lastblockhash"`
|
||||||
|
|
@ -63,16 +63,16 @@ type btJSON struct {
|
||||||
SealEngine string `json:"sealEngine"`
|
SealEngine string `json:"sealEngine"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type btBlock struct {
|
type BtBlock struct {
|
||||||
BlockHeader *btHeader
|
BlockHeader *BtHeader
|
||||||
ExpectException string
|
ExpectException string
|
||||||
Rlp string
|
Rlp string
|
||||||
UncleHeaders []*btHeader
|
UncleHeaders []*BtHeader
|
||||||
}
|
}
|
||||||
|
|
||||||
//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
|
||||||
|
|
@ -96,7 +96,7 @@ type btHeader struct {
|
||||||
ParentBeaconBlockRoot *common.Hash
|
ParentBeaconBlockRoot *common.Hash
|
||||||
}
|
}
|
||||||
|
|
||||||
type btHeaderMarshaling struct {
|
type BtHeaderMarshaling struct {
|
||||||
ExtraData hexutil.Bytes
|
ExtraData hexutil.Bytes
|
||||||
Number *math.HexOrDecimal256
|
Number *math.HexOrDecimal256
|
||||||
Difficulty *math.HexOrDecimal256
|
Difficulty *math.HexOrDecimal256
|
||||||
|
|
@ -109,9 +109,9 @@ type btHeaderMarshaling struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *BlockTest) Run(snapshotter bool, scheme string, tracer *tracing.Hooks, postCheck func(error, *core.BlockChain)) (result error) {
|
func (t *BlockTest) Run(snapshotter bool, scheme string, tracer *tracing.Hooks, postCheck func(error, *core.BlockChain)) (result error) {
|
||||||
config, ok := Forks[t.json.Network]
|
config, ok := Forks[t.Json.Network]
|
||||||
if !ok {
|
if !ok {
|
||||||
return UnsupportedForkError{t.json.Network}
|
return UnsupportedForkError{t.Json.Network}
|
||||||
}
|
}
|
||||||
// import pre accounts & construct test genesis block & state root
|
// import pre accounts & construct test genesis block & state root
|
||||||
var (
|
var (
|
||||||
|
|
@ -134,11 +134,11 @@ func (t *BlockTest) Run(snapshotter bool, scheme string, tracer *tracing.Hooks,
|
||||||
}
|
}
|
||||||
triedb.Close() // close the db to prevent memory leak
|
triedb.Close() // close the db to prevent memory leak
|
||||||
|
|
||||||
if gblock.Hash() != t.json.Genesis.Hash {
|
if gblock.Hash() != t.Json.Genesis.Hash {
|
||||||
return fmt.Errorf("genesis block hash doesn't match test: computed=%x, test=%x", gblock.Hash().Bytes()[:6], t.json.Genesis.Hash[:6])
|
return fmt.Errorf("genesis block hash doesn't match test: computed=%x, test=%x", gblock.Hash().Bytes()[:6], t.Json.Genesis.Hash[:6])
|
||||||
}
|
}
|
||||||
if gblock.Root() != t.json.Genesis.StateRoot {
|
if gblock.Root() != t.Json.Genesis.StateRoot {
|
||||||
return fmt.Errorf("genesis block state root does not match test: computed=%x, test=%x", gblock.Root().Bytes()[:6], t.json.Genesis.StateRoot[:6])
|
return fmt.Errorf("genesis block state root does not match test: computed=%x, test=%x", gblock.Root().Bytes()[:6], t.Json.Genesis.StateRoot[:6])
|
||||||
}
|
}
|
||||||
// Wrap the original engine within the beacon-engine
|
// Wrap the original engine within the beacon-engine
|
||||||
engine := beacon.New(ethash.NewFaker())
|
engine := beacon.New(ethash.NewFaker())
|
||||||
|
|
@ -166,8 +166,8 @@ func (t *BlockTest) Run(snapshotter bool, scheme string, tracer *tracing.Hooks,
|
||||||
defer postCheck(result, chain)
|
defer postCheck(result, chain)
|
||||||
}
|
}
|
||||||
cmlast := chain.CurrentBlock().Hash()
|
cmlast := chain.CurrentBlock().Hash()
|
||||||
if common.Hash(t.json.BestBlock) != cmlast {
|
if common.Hash(t.Json.BestBlock) != cmlast {
|
||||||
return fmt.Errorf("last block hash validation mismatch: want: %x, have: %x", t.json.BestBlock, cmlast)
|
return fmt.Errorf("last block hash validation mismatch: want: %x, have: %x", t.Json.BestBlock, cmlast)
|
||||||
}
|
}
|
||||||
newDB, err := chain.State()
|
newDB, err := chain.State()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -188,19 +188,19 @@ func (t *BlockTest) Run(snapshotter bool, scheme string, tracer *tracing.Hooks,
|
||||||
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,
|
BlobGasUsed: t.Json.Genesis.BlobGasUsed,
|
||||||
ExcessBlobGas: t.json.Genesis.ExcessBlobGas,
|
ExcessBlobGas: t.Json.Genesis.ExcessBlobGas,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -217,11 +217,11 @@ See https://github.com/ethereum/tests/wiki/Blockchain-Tests-II
|
||||||
expected we are expected to ignore it and continue processing and then validate the
|
expected we are expected to ignore it and continue processing and then validate the
|
||||||
post state.
|
post state.
|
||||||
*/
|
*/
|
||||||
func (t *BlockTest) insertBlocks(blockchain *core.BlockChain) ([]btBlock, error) {
|
func (t *BlockTest) insertBlocks(blockchain *core.BlockChain) ([]BtBlock, error) {
|
||||||
validBlocks := make([]btBlock, 0)
|
validBlocks := make([]BtBlock, 0)
|
||||||
// insert the test blocks, which will execute all transactions
|
// insert the test blocks, which will execute all transactions
|
||||||
for bi, b := range t.json.Blocks {
|
for bi, b := range t.Json.Blocks {
|
||||||
cb, err := b.decode()
|
cb, err := b.Decode()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if b.BlockHeader == nil {
|
if b.BlockHeader == nil {
|
||||||
continue // OK - block is supposed to be invalid, continue with next block
|
continue // OK - block is supposed to be invalid, continue with next block
|
||||||
|
|
@ -257,7 +257,7 @@ func (t *BlockTest) insertBlocks(blockchain *core.BlockChain) ([]btBlock, error)
|
||||||
return validBlocks, nil
|
return validBlocks, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func validateHeader(h *btHeader, h2 *types.Header) error {
|
func validateHeader(h *BtHeader, h2 *types.Header) error {
|
||||||
if h.Bloom != h2.Bloom {
|
if h.Bloom != h2.Bloom {
|
||||||
return fmt.Errorf("bloom: want: %x have: %x", h.Bloom, h2.Bloom)
|
return fmt.Errorf("bloom: want: %x have: %x", h.Bloom, h2.Bloom)
|
||||||
}
|
}
|
||||||
|
|
@ -323,7 +323,7 @@ func validateHeader(h *btHeader, h2 *types.Header) error {
|
||||||
|
|
||||||
func (t *BlockTest) validatePostState(statedb vm.StateDB) error {
|
func (t *BlockTest) validatePostState(statedb vm.StateDB) error {
|
||||||
// validate post state accounts in test file against what we have in state db
|
// validate post state accounts in test file against what we have in state db
|
||||||
for addr, acct := range t.json.Post {
|
for addr, acct := range t.Json.Post {
|
||||||
// address is indirectly verified by the other fields, as it's the db key
|
// address is indirectly verified by the other fields, as it's the db key
|
||||||
code2 := statedb.GetCode(addr)
|
code2 := statedb.GetCode(addr)
|
||||||
balance2 := statedb.GetBalance(addr)
|
balance2 := statedb.GetBalance(addr)
|
||||||
|
|
@ -347,9 +347,9 @@ func (t *BlockTest) validatePostState(statedb vm.StateDB) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *BlockTest) validateImportedHeaders(cm *core.BlockChain, validBlocks []btBlock) error {
|
func (t *BlockTest) validateImportedHeaders(cm *core.BlockChain, validBlocks []BtBlock) error {
|
||||||
// to get constant lookup when verifying block headers by hash (some tests have many blocks)
|
// to get constant lookup when verifying block headers by hash (some tests have many blocks)
|
||||||
bmap := make(map[common.Hash]btBlock, len(t.json.Blocks))
|
bmap := make(map[common.Hash]BtBlock, len(t.Json.Blocks))
|
||||||
for _, b := range validBlocks {
|
for _, b := range validBlocks {
|
||||||
bmap[b.BlockHeader.Hash] = b
|
bmap[b.BlockHeader.Hash] = b
|
||||||
}
|
}
|
||||||
|
|
@ -366,7 +366,7 @@ func (t *BlockTest) validateImportedHeaders(cm *core.BlockChain, validBlocks []b
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bb *btBlock) decode() (*types.Block, error) {
|
func (bb *BtBlock) Decode() (*types.Block, error) {
|
||||||
data, err := hexutil.Decode(bb.Rlp)
|
data, err := hexutil.Decode(bb.Rlp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
||||||
|
|
@ -12,10 +12,10 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ = (*btHeaderMarshaling)(nil)
|
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
|
||||||
|
|
@ -65,7 +65,7 @@ func (b btHeader) MarshalJSON() ([]byte, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue