mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-20 11:46:44 +00:00
wip: decouple access list from block and update tests
This commit is contained in:
parent
5dbbf3dc8e
commit
136765c085
7 changed files with 28 additions and 15 deletions
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
# version:spec-tests v5.1.0
|
||||
# https://github.com/ethereum/execution-spec-tests/releases
|
||||
# https://github.com/ethereum/execution-spec-tests/releases/download/bal%40v2.0.0
|
||||
68b2f29a3e3a794b5a9a23692190847f177e0a7a24891ccc7d7ad267ca59e4e0 fixtures_bal.tar.gz
|
||||
# https://github.com/ethereum/execution-spec-tests/releases/download/bal%40v3.0.1
|
||||
57d0f109f0557ec33d6ecd6cbd77b55415a658aefe583c4035157e1021ae512a fixtures_bal.tar.gz
|
||||
|
||||
# version:golang 1.25.1
|
||||
# https://go.dev/dl/
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ import (
|
|||
"bufio"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/ethereum/go-ethereum/cmd/utils"
|
||||
"maps"
|
||||
"os"
|
||||
"regexp"
|
||||
|
|
@ -118,7 +117,7 @@ func runBlockTest(ctx *cli.Context, fname string) ([]testResult, error) {
|
|||
test := tests[name]
|
||||
result := &testResult{Name: name, Pass: true}
|
||||
var finalRoot *common.Hash
|
||||
if err := test.Run(false, rawdb.PathScheme, ctx.Bool(WitnessCrossCheckFlag.Name), ctx.Bool(utils.ExperimentalBALFlag.Name), tracer, func(res error, chain *core.BlockChain) {
|
||||
if err := test.Run(false, rawdb.PathScheme, ctx.Bool(WitnessCrossCheckFlag.Name), tracer, func(res error, chain *core.BlockChain) {
|
||||
if ctx.Bool(DumpFlag.Name) {
|
||||
if s, _ := chain.State(); s != nil {
|
||||
result.State = dump(s)
|
||||
|
|
|
|||
|
|
@ -69,12 +69,12 @@ func latestBlobConfig(cfg *params.ChainConfig, time uint64) *BlobConfig {
|
|||
bc = s.BPO4
|
||||
case cfg.IsBPO3(london, time) && s.BPO3 != nil:
|
||||
bc = s.BPO3
|
||||
case cfg.IsAmsterdam(london, time) && s.Amsterdam != nil:
|
||||
bc = s.BPO2
|
||||
case cfg.IsBPO2(london, time) && s.BPO2 != nil:
|
||||
bc = s.BPO2
|
||||
case cfg.IsBPO1(london, time) && s.BPO1 != nil:
|
||||
bc = s.BPO1
|
||||
case cfg.IsAmsterdam(london, time) && s.Amsterdam != nil:
|
||||
bc = s.Amsterdam
|
||||
case cfg.IsOsaka(london, time) && s.Osaka != nil:
|
||||
bc = s.Osaka
|
||||
case cfg.IsPrague(london, time) && s.Prague != nil:
|
||||
|
|
|
|||
|
|
@ -112,12 +112,16 @@ func (v *BlockValidator) ValidateBody(block *types.Block) error {
|
|||
|
||||
// block access lists must be present after the Amsterdam hard fork
|
||||
if v.config.IsAmsterdam(block.Number(), block.Time()) {
|
||||
if block.Body().AccessList == nil {
|
||||
return fmt.Errorf("access list not present in block body")
|
||||
} else if *block.Header().BlockAccessListHash != block.Body().AccessList.Hash() {
|
||||
return fmt.Errorf("access list hash mismatch. local: %x. remote: %x\n", block.Body().AccessList.Hash(), *block.Header().BlockAccessListHash)
|
||||
} else if err := block.Body().AccessList.Validate(len(block.Transactions())); err != nil {
|
||||
return fmt.Errorf("invalid block access list: %v", err)
|
||||
if block.Header().BlockAccessListHash == nil {
|
||||
// TODO: verify that this check isn't also done elsewhere
|
||||
return fmt.Errorf("block access list hash not set in header")
|
||||
}
|
||||
if block.Body().AccessList != nil {
|
||||
if *block.Header().BlockAccessListHash != block.Body().AccessList.Hash() {
|
||||
return fmt.Errorf("access list hash mismatch. local: %x. remote: %x\n", block.Body().AccessList.Hash(), *block.Header().BlockAccessListHash)
|
||||
} else if err := block.Body().AccessList.Validate(len(block.Transactions())); err != nil {
|
||||
return fmt.Errorf("invalid block access list: %v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2211,7 +2211,15 @@ func (bc *BlockChain) ProcessBlock(parentRoot common.Hash, block *types.Block, s
|
|||
bc.reportBadBlock(block, res, err)
|
||||
return nil, err
|
||||
}
|
||||
if block.Body().AccessList != nil && block.Body().AccessList.Hash() != computedAccessListHash {
|
||||
if block.Body().AccessList == nil {
|
||||
// very ugly... deep copy the block body before setting the block access
|
||||
// list on it to prevent mutating the block instance passed by the caller.
|
||||
existingBody := block.Body()
|
||||
block = block.WithBody(*existingBody)
|
||||
existingBody = block.Body()
|
||||
existingBody.AccessList = computedAccessList
|
||||
block = block.WithBody(*existingBody)
|
||||
} else if block.Body().AccessList.Hash() != computedAccessListHash {
|
||||
err := fmt.Errorf("block access list hash mismatch (remote=%x computed=%x)", block.Body().AccessList.Hash(), computedAccessListHash)
|
||||
bc.reportBadBlock(block, res, err)
|
||||
return nil, err
|
||||
|
|
|
|||
|
|
@ -236,6 +236,8 @@ var (
|
|||
Cancun: DefaultCancunBlobConfig,
|
||||
Prague: DefaultPragueBlobConfig,
|
||||
Osaka: DefaultOsakaBlobConfig,
|
||||
BPO1: DefaultBPO1BlobConfig,
|
||||
BPO2: DefaultBPO2BlobConfig,
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -521,8 +521,8 @@ var Forks = map[string]*params.ChainConfig{
|
|||
Cancun: params.DefaultCancunBlobConfig,
|
||||
Prague: params.DefaultPragueBlobConfig,
|
||||
Osaka: params.DefaultOsakaBlobConfig,
|
||||
//BPO1: bpo1BlobConfig,
|
||||
//BPO2: bpo2BlobConfig,
|
||||
BPO1: bpo1BlobConfig,
|
||||
BPO2: bpo2BlobConfig,
|
||||
},
|
||||
},
|
||||
"OsakaToBPO1AtTime15k": {
|
||||
|
|
|
|||
Loading…
Reference in a new issue