mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
core/state: enable lookup of preimages from disk during dump operation
This commit is contained in:
parent
7df4ebd5ec
commit
bebe04b56b
2 changed files with 17 additions and 11 deletions
|
|
@ -23,6 +23,7 @@ import (
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||||
|
"github.com/ethereum/go-ethereum/core/rawdb"
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
"github.com/ethereum/go-ethereum/log"
|
"github.com/ethereum/go-ethereum/log"
|
||||||
"github.com/ethereum/go-ethereum/rlp"
|
"github.com/ethereum/go-ethereum/rlp"
|
||||||
|
|
@ -153,25 +154,28 @@ func (s *StateDB) DumpToCollector(c DumpCollector, conf *DumpConfig) (nextKey []
|
||||||
if err := rlp.DecodeBytes(it.Value, &data); err != nil {
|
if err := rlp.DecodeBytes(it.Value, &data); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
account := DumpAccount{
|
|
||||||
Balance: data.Balance.String(),
|
|
||||||
Nonce: data.Nonce,
|
|
||||||
Root: data.Root[:],
|
|
||||||
CodeHash: data.CodeHash,
|
|
||||||
SecureKey: it.Key,
|
|
||||||
}
|
|
||||||
var (
|
var (
|
||||||
addrBytes = s.trie.GetKey(it.Key)
|
account = DumpAccount{
|
||||||
addr = common.BytesToAddress(addrBytes)
|
Balance: data.Balance.String(),
|
||||||
|
Nonce: data.Nonce,
|
||||||
|
Root: data.Root[:],
|
||||||
|
CodeHash: data.CodeHash,
|
||||||
|
SecureKey: it.Key,
|
||||||
|
}
|
||||||
address *common.Address
|
address *common.Address
|
||||||
|
addr common.Address
|
||||||
|
addrBytes = s.trie.GetKey(it.Key)
|
||||||
)
|
)
|
||||||
|
if addrBytes == nil { // Preimage not present in memory. Check database.
|
||||||
|
addrBytes = rawdb.ReadPreimage(s.Database().DiskDB(), common.BytesToHash(it.Key))
|
||||||
|
}
|
||||||
if addrBytes == nil {
|
if addrBytes == nil {
|
||||||
// Preimage missing
|
|
||||||
missingPreimages++
|
missingPreimages++
|
||||||
if conf.OnlyWithAddresses {
|
if conf.OnlyWithAddresses {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
addr = common.BytesToAddress(addrBytes)
|
||||||
address = &addr
|
address = &addr
|
||||||
}
|
}
|
||||||
obj := newObject(s, addr, &data)
|
obj := newObject(s, addr, &data)
|
||||||
|
|
|
||||||
|
|
@ -116,7 +116,9 @@ func (t *BlockTest) Run(snapshotter bool, scheme string, tracer vm.EVMLogger, po
|
||||||
// import pre accounts & construct test genesis block & state root
|
// import pre accounts & construct test genesis block & state root
|
||||||
var (
|
var (
|
||||||
db = rawdb.NewMemoryDatabase()
|
db = rawdb.NewMemoryDatabase()
|
||||||
tconf = &trie.Config{}
|
tconf = &trie.Config{
|
||||||
|
Preimages: true,
|
||||||
|
}
|
||||||
)
|
)
|
||||||
if scheme == rawdb.PathScheme {
|
if scheme == rawdb.PathScheme {
|
||||||
tconf.PathDB = pathdb.Defaults
|
tconf.PathDB = pathdb.Defaults
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue