mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-19 14:29:27 +00:00
fix test by accepting a non-deployed contract
This commit is contained in:
parent
9cef9dc75e
commit
a0ad1eecc0
6 changed files with 49 additions and 20 deletions
|
|
@ -396,6 +396,9 @@ func GenerateChain(config *params.ChainConfig, parent *types.Block, engine conse
|
||||||
evm := vm.NewEVM(blockContext, statedb, cm.config, vm.Config{})
|
evm := vm.NewEVM(blockContext, statedb, cm.config, vm.Config{})
|
||||||
ProcessParentBlockHash(b.header.ParentHash, evm)
|
ProcessParentBlockHash(b.header.ParentHash, evm)
|
||||||
}
|
}
|
||||||
|
if config.IsVerkle(b.header.Number, b.header.Time) {
|
||||||
|
InitializeBinaryTransitionRegistry(statedb)
|
||||||
|
}
|
||||||
|
|
||||||
// Execute any user modifications to the block
|
// Execute any user modifications to the block
|
||||||
if gen != nil {
|
if gen != nil {
|
||||||
|
|
|
||||||
|
|
@ -211,25 +211,24 @@ func LoadTransitionState(reader StateReader, root common.Hash) *overlay.Transiti
|
||||||
|
|
||||||
endedBytes, err := reader.Storage(params.BinaryTransitionRegistryAddress, transitionEndedKey)
|
endedBytes, err := reader.Storage(params.BinaryTransitionRegistryAddress, transitionEndedKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Registry exists but can't read ended flag - treat as still in transition
|
return nil
|
||||||
endedBytes = common.Hash{}
|
|
||||||
}
|
}
|
||||||
ended := endedBytes != (common.Hash{})
|
ended := endedBytes != (common.Hash{})
|
||||||
|
|
||||||
currentAccountBytes, err := reader.Storage(params.BinaryTransitionRegistryAddress, conversionProgressAddressKey)
|
currentAccountBytes, err := reader.Storage(params.BinaryTransitionRegistryAddress, conversionProgressAddressKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(fmt.Errorf("error reading conversion account pointer: %w", err))
|
return nil
|
||||||
}
|
}
|
||||||
currentAccount := common.BytesToAddress(currentAccountBytes[12:])
|
currentAccount := common.BytesToAddress(currentAccountBytes[12:])
|
||||||
|
|
||||||
currentSlotHash, err := reader.Storage(params.BinaryTransitionRegistryAddress, conversionProgressSlotKey)
|
currentSlotHash, err := reader.Storage(params.BinaryTransitionRegistryAddress, conversionProgressSlotKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(fmt.Errorf("error reading conversion slot pointer: %w", err))
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
storageProcessedBytes, err := reader.Storage(params.BinaryTransitionRegistryAddress, conversionProgressStorageProcessed)
|
storageProcessedBytes, err := reader.Storage(params.BinaryTransitionRegistryAddress, conversionProgressStorageProcessed)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(fmt.Errorf("error reading conversion storage processing completion status: %w", err))
|
return nil
|
||||||
}
|
}
|
||||||
storageProcessed := storageProcessedBytes[0] == 1
|
storageProcessed := storageProcessedBytes[0] == 1
|
||||||
|
|
||||||
|
|
@ -308,7 +307,8 @@ func (db *CachingDB) ReadersWithCacheStats(stateRoot common.Hash) (ReaderWithSta
|
||||||
|
|
||||||
// OpenTrie opens the main account trie at a specific root hash.
|
// OpenTrie opens the main account trie at a specific root hash.
|
||||||
func (db *CachingDB) OpenTrie(root common.Hash) (Trie, error) {
|
func (db *CachingDB) OpenTrie(root common.Hash) (Trie, error) {
|
||||||
reader, err := db.StateReader(root)
|
reader, err := db.triedb.StateReader(root)
|
||||||
|
flatReader := newFlatReader(reader)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
tr, err := trie.NewStateTrie(trie.StateTrieID(root), db.triedb)
|
tr, err := trie.NewStateTrie(trie.StateTrieID(root), db.triedb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -317,12 +317,12 @@ func (db *CachingDB) OpenTrie(root common.Hash) (Trie, error) {
|
||||||
return tr, nil
|
return tr, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if isTransitionActive(reader) || db.triedb.IsVerkle() {
|
if isTransitionActive(flatReader) || db.triedb.IsVerkle() {
|
||||||
bt, err := bintrie.NewBinaryTrie(root, db.triedb)
|
bt, err := bintrie.NewBinaryTrie(root, db.triedb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("could not open the overlay tree: %w", err)
|
return nil, fmt.Errorf("could not open the overlay tree: %w", err)
|
||||||
}
|
}
|
||||||
ts := LoadTransitionState(reader, root)
|
ts := LoadTransitionState(flatReader, root)
|
||||||
if !ts.InTransition() {
|
if !ts.InTransition() {
|
||||||
// Transition complete, use BinaryTrie only
|
// Transition complete, use BinaryTrie only
|
||||||
return bt, nil
|
return bt, nil
|
||||||
|
|
|
||||||
|
|
@ -94,9 +94,7 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg
|
||||||
ProcessParentBlockHash(block.ParentHash(), evm)
|
ProcessParentBlockHash(block.ParentHash(), evm)
|
||||||
}
|
}
|
||||||
if config.IsVerkle(header.Number, header.Time) {
|
if config.IsVerkle(header.Number, header.Time) {
|
||||||
statedb.SetCode(params.BinaryTransitionRegistryAddress, []byte{1, 2, 3}, tracing.CodeChangeUnspecified)
|
InitializeBinaryTransitionRegistry(statedb)
|
||||||
statedb.SetNonce(params.BinaryTransitionRegistryAddress, 1, tracing.NonceChangeUnspecified)
|
|
||||||
statedb.SetState(params.BinaryTransitionRegistryAddress, common.Hash{}, common.Hash{1})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Iterate over and process the individual transactions
|
// Iterate over and process the individual transactions
|
||||||
|
|
|
||||||
35
core/transition_registry.go
Normal file
35
core/transition_registry.go
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
// Copyright 2026 The go-ethereum Authors
|
||||||
|
// This file is part of the go-ethereum library.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
package core
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/ethereum/go-ethereum/common"
|
||||||
|
"github.com/ethereum/go-ethereum/core/state"
|
||||||
|
"github.com/ethereum/go-ethereum/core/tracing"
|
||||||
|
"github.com/ethereum/go-ethereum/params"
|
||||||
|
)
|
||||||
|
|
||||||
|
// InitializeBinaryTransitionRegistry seeds the transition registry account used
|
||||||
|
// during the MPT->BinaryTrie transition.
|
||||||
|
func InitializeBinaryTransitionRegistry(statedb *state.StateDB) {
|
||||||
|
if statedb == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
statedb.SetCode(params.BinaryTransitionRegistryAddress, []byte{1, 2, 3}, tracing.CodeChangeUnspecified)
|
||||||
|
statedb.SetNonce(params.BinaryTransitionRegistryAddress, 1, tracing.NonceChangeUnspecified)
|
||||||
|
statedb.SetState(params.BinaryTransitionRegistryAddress, common.Hash{}, common.Hash{1})
|
||||||
|
}
|
||||||
|
|
@ -26,12 +26,10 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/core"
|
"github.com/ethereum/go-ethereum/core"
|
||||||
"github.com/ethereum/go-ethereum/core/rawdb"
|
"github.com/ethereum/go-ethereum/core/rawdb"
|
||||||
"github.com/ethereum/go-ethereum/core/state"
|
"github.com/ethereum/go-ethereum/core/state"
|
||||||
"github.com/ethereum/go-ethereum/core/tracing"
|
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
"github.com/ethereum/go-ethereum/core/vm"
|
"github.com/ethereum/go-ethereum/core/vm"
|
||||||
"github.com/ethereum/go-ethereum/eth/tracers"
|
"github.com/ethereum/go-ethereum/eth/tracers"
|
||||||
"github.com/ethereum/go-ethereum/log"
|
"github.com/ethereum/go-ethereum/log"
|
||||||
"github.com/ethereum/go-ethereum/params"
|
|
||||||
"github.com/ethereum/go-ethereum/trie"
|
"github.com/ethereum/go-ethereum/trie"
|
||||||
"github.com/ethereum/go-ethereum/triedb"
|
"github.com/ethereum/go-ethereum/triedb"
|
||||||
)
|
)
|
||||||
|
|
@ -254,9 +252,7 @@ func (eth *Ethereum) stateAtTransaction(ctx context.Context, block *types.Block,
|
||||||
core.ProcessParentBlockHash(block.ParentHash(), evm)
|
core.ProcessParentBlockHash(block.ParentHash(), evm)
|
||||||
}
|
}
|
||||||
if eth.blockchain.Config().IsVerkle(block.Number(), block.Time()) {
|
if eth.blockchain.Config().IsVerkle(block.Number(), block.Time()) {
|
||||||
statedb.SetCode(params.BinaryTransitionRegistryAddress, []byte{1, 2, 3}, tracing.CodeChangeUnspecified)
|
core.InitializeBinaryTransitionRegistry(statedb)
|
||||||
statedb.SetNonce(params.BinaryTransitionRegistryAddress, 1, tracing.NonceChangeUnspecified)
|
|
||||||
statedb.SetState(params.BinaryTransitionRegistryAddress, common.Hash{}, common.Hash{1})
|
|
||||||
}
|
}
|
||||||
if txIndex == 0 && len(block.Transactions()) == 0 {
|
if txIndex == 0 && len(block.Transactions()) == 0 {
|
||||||
return nil, context, statedb, release, nil
|
return nil, context, statedb, release, nil
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,6 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/core"
|
"github.com/ethereum/go-ethereum/core"
|
||||||
"github.com/ethereum/go-ethereum/core/state"
|
"github.com/ethereum/go-ethereum/core/state"
|
||||||
"github.com/ethereum/go-ethereum/core/stateless"
|
"github.com/ethereum/go-ethereum/core/stateless"
|
||||||
"github.com/ethereum/go-ethereum/core/tracing"
|
|
||||||
"github.com/ethereum/go-ethereum/core/txpool"
|
"github.com/ethereum/go-ethereum/core/txpool"
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
"github.com/ethereum/go-ethereum/core/vm"
|
"github.com/ethereum/go-ethereum/core/vm"
|
||||||
|
|
@ -268,9 +267,7 @@ func (miner *Miner) prepareWork(genParams *generateParams, witness bool) (*envir
|
||||||
core.ProcessParentBlockHash(header.ParentHash, env.evm)
|
core.ProcessParentBlockHash(header.ParentHash, env.evm)
|
||||||
}
|
}
|
||||||
if miner.chainConfig.IsVerkle(header.Number, header.Time) {
|
if miner.chainConfig.IsVerkle(header.Number, header.Time) {
|
||||||
env.state.SetCode(params.BinaryTransitionRegistryAddress, []byte{1, 2, 3}, tracing.CodeChangeUnspecified)
|
core.InitializeBinaryTransitionRegistry(env.state)
|
||||||
env.state.SetNonce(params.BinaryTransitionRegistryAddress, 1, tracing.NonceChangeUnspecified)
|
|
||||||
env.state.SetState(params.BinaryTransitionRegistryAddress, common.Hash{}, common.Hash{1})
|
|
||||||
}
|
}
|
||||||
return env, nil
|
return env, nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue