mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-03-06 11:25:02 +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{})
|
||||
ProcessParentBlockHash(b.header.ParentHash, evm)
|
||||
}
|
||||
if config.IsVerkle(b.header.Number, b.header.Time) {
|
||||
InitializeBinaryTransitionRegistry(statedb)
|
||||
}
|
||||
|
||||
// Execute any user modifications to the block
|
||||
if gen != nil {
|
||||
|
|
|
|||
|
|
@ -211,25 +211,24 @@ func LoadTransitionState(reader StateReader, root common.Hash) *overlay.Transiti
|
|||
|
||||
endedBytes, err := reader.Storage(params.BinaryTransitionRegistryAddress, transitionEndedKey)
|
||||
if err != nil {
|
||||
// Registry exists but can't read ended flag - treat as still in transition
|
||||
endedBytes = common.Hash{}
|
||||
return nil
|
||||
}
|
||||
ended := endedBytes != (common.Hash{})
|
||||
|
||||
currentAccountBytes, err := reader.Storage(params.BinaryTransitionRegistryAddress, conversionProgressAddressKey)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("error reading conversion account pointer: %w", err))
|
||||
return nil
|
||||
}
|
||||
currentAccount := common.BytesToAddress(currentAccountBytes[12:])
|
||||
|
||||
currentSlotHash, err := reader.Storage(params.BinaryTransitionRegistryAddress, conversionProgressSlotKey)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("error reading conversion slot pointer: %w", err))
|
||||
return nil
|
||||
}
|
||||
|
||||
storageProcessedBytes, err := reader.Storage(params.BinaryTransitionRegistryAddress, conversionProgressStorageProcessed)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("error reading conversion storage processing completion status: %w", err))
|
||||
return nil
|
||||
}
|
||||
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.
|
||||
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 {
|
||||
tr, err := trie.NewStateTrie(trie.StateTrieID(root), db.triedb)
|
||||
if err != nil {
|
||||
|
|
@ -317,12 +317,12 @@ func (db *CachingDB) OpenTrie(root common.Hash) (Trie, error) {
|
|||
return tr, nil
|
||||
}
|
||||
|
||||
if isTransitionActive(reader) || db.triedb.IsVerkle() {
|
||||
if isTransitionActive(flatReader) || db.triedb.IsVerkle() {
|
||||
bt, err := bintrie.NewBinaryTrie(root, db.triedb)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not open the overlay tree: %w", err)
|
||||
}
|
||||
ts := LoadTransitionState(reader, root)
|
||||
ts := LoadTransitionState(flatReader, root)
|
||||
if !ts.InTransition() {
|
||||
// Transition complete, use BinaryTrie only
|
||||
return bt, nil
|
||||
|
|
|
|||
|
|
@ -94,9 +94,7 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg
|
|||
ProcessParentBlockHash(block.ParentHash(), evm)
|
||||
}
|
||||
if config.IsVerkle(header.Number, header.Time) {
|
||||
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})
|
||||
InitializeBinaryTransitionRegistry(statedb)
|
||||
}
|
||||
|
||||
// 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/rawdb"
|
||||
"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/vm"
|
||||
"github.com/ethereum/go-ethereum/eth/tracers"
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
"github.com/ethereum/go-ethereum/trie"
|
||||
"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)
|
||||
}
|
||||
if eth.blockchain.Config().IsVerkle(block.Number(), block.Time()) {
|
||||
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})
|
||||
core.InitializeBinaryTransitionRegistry(statedb)
|
||||
}
|
||||
if txIndex == 0 && len(block.Transactions()) == 0 {
|
||||
return nil, context, statedb, release, nil
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ import (
|
|||
"github.com/ethereum/go-ethereum/core"
|
||||
"github.com/ethereum/go-ethereum/core/state"
|
||||
"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/types"
|
||||
"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)
|
||||
}
|
||||
if miner.chainConfig.IsVerkle(header.Number, header.Time) {
|
||||
env.state.SetCode(params.BinaryTransitionRegistryAddress, []byte{1, 2, 3}, tracing.CodeChangeUnspecified)
|
||||
env.state.SetNonce(params.BinaryTransitionRegistryAddress, 1, tracing.NonceChangeUnspecified)
|
||||
env.state.SetState(params.BinaryTransitionRegistryAddress, common.Hash{}, common.Hash{1})
|
||||
core.InitializeBinaryTransitionRegistry(env.state)
|
||||
}
|
||||
return env, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue