mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
fixes to replay ~500 blocks
This commit is contained in:
parent
54e060f094
commit
a80c2aa8b5
3 changed files with 15 additions and 18 deletions
|
|
@ -1746,6 +1746,7 @@ func (bc *BlockChain) insertChain(chain types.Blocks, setHead bool) (int, error)
|
|||
|
||||
if parent.Number.Uint64() == conversionBlock {
|
||||
bc.StartVerkleTransition(parent.Root, emptyVerkleRoot, bc.Config(), &parent.Time)
|
||||
bc.stateCache.SetLastMerkleRoot(parent.Root)
|
||||
}
|
||||
statedb, err := state.New(parent.Root, bc.stateCache, bc.snaps)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -1080,6 +1080,10 @@ func (s *StateDB) clearJournalAndRefund() {
|
|||
// deleteStorage iterates the storage trie belongs to the account and mark all
|
||||
// slots inside as deleted.
|
||||
func (s *StateDB) deleteStorage(addr common.Address, addrHash common.Hash, root common.Hash) (bool, map[common.Hash][]byte, *trienode.NodeSet, error) {
|
||||
// verkle: a deletion is akin to overwriting with 0s
|
||||
if s.GetTrie().IsVerkle() {
|
||||
return false, nil, nil, nil
|
||||
}
|
||||
start := time.Now()
|
||||
tr, err := s.db.OpenStorageTrie(s.originalRoot, addr, root, s.trie)
|
||||
// XXX NOTE: it might just be possible to use an empty trie here, as verkle will not
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ import (
|
|||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/ethdb"
|
||||
"github.com/ethereum/go-ethereum/rlp"
|
||||
"github.com/ethereum/go-ethereum/trie/trienode"
|
||||
"github.com/gballet/go-verkle"
|
||||
)
|
||||
|
|
@ -67,22 +66,7 @@ func (t *TransitionTrie) GetStorage(addr common.Address, key []byte) ([]byte, er
|
|||
return val, nil
|
||||
}
|
||||
// TODO also insert value into overlay
|
||||
rlpval, err := t.base.GetStorage(addr, key)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(rlpval) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
// the value will come as RLP, decode it so that the
|
||||
// interface is consistent.
|
||||
_, content, _, err := rlp.Split(rlpval)
|
||||
if err != nil || len(content) == 0 {
|
||||
return nil, err
|
||||
}
|
||||
var v [32]byte
|
||||
copy(v[32-len(content):], content)
|
||||
return v[:], nil
|
||||
return t.base.GetStorage(addr, key)
|
||||
}
|
||||
|
||||
// GetAccount abstract an account read from the trie.
|
||||
|
|
@ -111,7 +95,15 @@ func (t *TransitionTrie) GetAccount(address common.Address) (*types.StateAccount
|
|||
// by the caller while they are stored in the trie. If a node was not found in the
|
||||
// database, a trie.MissingNodeError is returned.
|
||||
func (t *TransitionTrie) UpdateStorage(address common.Address, key []byte, value []byte) error {
|
||||
return t.overlay.UpdateStorage(address, key, value)
|
||||
var v []byte
|
||||
if len(value) >= 32 {
|
||||
v = value[:32]
|
||||
} else {
|
||||
var val [32]byte
|
||||
copy(val[32-len(value):], value[:])
|
||||
v = val[:]
|
||||
}
|
||||
return t.overlay.UpdateStorage(address, key, v)
|
||||
}
|
||||
|
||||
// UpdateAccount abstract an account write to the trie.
|
||||
|
|
|
|||
Loading…
Reference in a new issue