Skip to content

Commit 542df88

Browse files
committed
core: initial version of state snapshots
1 parent 2a5ed1a commit 542df88

30 files changed

Lines changed: 1635 additions & 85 deletions

‎accounts/abi/bind/backends/simulated.go‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ func (b *SimulatedBackend) rollback() {
124124
statedb, _ := b.blockchain.State()
125125

126126
b.pendingBlock = blocks[0]
127-
b.pendingState, _ = state.New(b.pendingBlock.Root(), statedb.Database())
127+
b.pendingState, _ = state.New(b.pendingBlock.Root(), statedb.Database(), nil)
128128
}
129129

130130
// stateByBlockNumber retrieves a state by a given blocknumber.
@@ -480,7 +480,7 @@ func (b *SimulatedBackend) SendTransaction(ctx context.Context, tx *types.Transa
480480
statedb, _ := b.blockchain.State()
481481

482482
b.pendingBlock = blocks[0]
483-
b.pendingState, _ = state.New(b.pendingBlock.Root(), statedb.Database())
483+
b.pendingState, _ = state.New(b.pendingBlock.Root(), statedb.Database(), nil)
484484
return nil
485485
}
486486

@@ -593,7 +593,7 @@ func (b *SimulatedBackend) AdjustTime(adjustment time.Duration) error {
593593
statedb, _ := b.blockchain.State()
594594

595595
b.pendingBlock = blocks[0]
596-
b.pendingState, _ = state.New(b.pendingBlock.Root(), statedb.Database())
596+
b.pendingState, _ = state.New(b.pendingBlock.Root(), statedb.Database(), nil)
597597

598598
return nil
599599
}

‎cmd/evm/runner.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,10 @@ func runCmd(ctx *cli.Context) error {
129129
genesisConfig = gen
130130
db := rawdb.NewMemoryDatabase()
131131
genesis := gen.ToBlock(db)
132-
statedb, _ = state.New(genesis.Root(), state.NewDatabase(db))
132+
statedb, _ = state.New(genesis.Root(), state.NewDatabase(db), nil)
133133
chainConfig = gen.Config
134134
} else {
135-
statedb, _ = state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()))
135+
statedb, _ = state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()), nil)
136136
genesisConfig = new(core.Genesis)
137137
}
138138
if ctx.GlobalString(SenderFlag.Name) != "" {

‎cmd/geth/chaincmd.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ func dump(ctx *cli.Context) error {
544544
fmt.Println("{}")
545545
utils.Fatalf("block not found")
546546
} else {
547-
state, err := state.New(block.Root(), state.NewDatabase(chainDb))
547+
state, err := state.New(block.Root(), state.NewDatabase(chainDb), nil)
548548
if err != nil {
549549
utils.Fatalf("could not create new state: %v", err)
550550
}

‎core/blockchain.go‎

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import (
3434
"github.com/ethereum/go-ethereum/consensus"
3535
"github.com/ethereum/go-ethereum/core/rawdb"
3636
"github.com/ethereum/go-ethereum/core/state"
37+
"github.com/ethereum/go-ethereum/core/state/snapshot"
3738
"github.com/ethereum/go-ethereum/core/types"
3839
"github.com/ethereum/go-ethereum/core/vm"
3940
"github.com/ethereum/go-ethereum/ethdb"
@@ -61,6 +62,10 @@ var (
6162
storageUpdateTimer = metrics.NewRegisteredTimer("chain/storage/updates", nil)
6263
storageCommitTimer = metrics.NewRegisteredTimer("chain/storage/commits", nil)
6364

65+
snapshotAccountReadTimer = metrics.NewRegisteredTimer("chain/snapshot/accountreads", nil)
66+
snapshotStorageReadTimer = metrics.NewRegisteredTimer("chain/snapshot/storagereads", nil)
67+
snapshotCommitTimer = metrics.NewRegisteredTimer("chain/snapshot/commits", nil)
68+
6469
blockInsertTimer = metrics.NewRegisteredTimer("chain/inserts", nil)
6570
blockValidationTimer = metrics.NewRegisteredTimer("chain/validation", nil)
6671
blockExecutionTimer = metrics.NewRegisteredTimer("chain/execution", nil)
@@ -135,9 +140,10 @@ type BlockChain struct {
135140
chainConfig *params.ChainConfig // Chain & network configuration
136141
cacheConfig *CacheConfig // Cache configuration for pruning
137142

138-
db ethdb.Database // Low level persistent database to store final content in
139-
triegc *prque.Prque // Priority queue mapping block numbers to tries to gc
140-
gcproc time.Duration // Accumulates canonical block processing for trie dumping
143+
db ethdb.Database // Low level persistent database to store final content in
144+
snaps *snapshot.SnapshotTree // Snapshot tree for fast trie leaf access
145+
triegc *prque.Prque // Priority queue mapping block numbers to tries to gc
146+
gcproc time.Duration // Accumulates canonical block processing for trie dumping
141147

142148
hc *HeaderChain
143149
rmLogsFeed event.Feed
@@ -293,6 +299,11 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, chainConfig *par
293299
}
294300
}
295301
}
302+
// Load any existing snapshot, regenerating it if loading failed
303+
head := bc.CurrentBlock()
304+
if bc.snaps, err = snapshot.New(bc.db, "snapshot.rlp", head.NumberU64(), head.Root()); err != nil {
305+
return nil, err
306+
}
296307
// Take ownership of this particular state
297308
go bc.update()
298309
return bc, nil
@@ -339,7 +350,7 @@ func (bc *BlockChain) loadLastState() error {
339350
return bc.Reset()
340351
}
341352
// Make sure the state associated with the block is available
342-
if _, err := state.New(currentBlock.Root(), bc.stateCache); err != nil {
353+
if _, err := state.New(currentBlock.Root(), bc.stateCache, bc.snaps); err != nil {
343354
// Dangling block without a state associated, init from scratch
344355
log.Warn("Head state missing, repairing chain", "number", currentBlock.Number(), "hash", currentBlock.Hash())
345356
if err := bc.repair(&currentBlock); err != nil {
@@ -401,7 +412,7 @@ func (bc *BlockChain) SetHead(head uint64) error {
401412
if newHeadBlock == nil {
402413
newHeadBlock = bc.genesisBlock
403414
} else {
404-
if _, err := state.New(newHeadBlock.Root(), bc.stateCache); err != nil {
415+
if _, err := state.New(newHeadBlock.Root(), bc.stateCache, bc.snaps); err != nil {
405416
// Rewound state missing, rolled back to before pivot, reset to genesis
406417
newHeadBlock = bc.genesisBlock
407418
}
@@ -524,7 +535,7 @@ func (bc *BlockChain) State() (*state.StateDB, error) {
524535

525536
// StateAt returns a new mutable state based on a particular point in time.
526537
func (bc *BlockChain) StateAt(root common.Hash) (*state.StateDB, error) {
527-
return state.New(root, bc.stateCache)
538+
return state.New(root, bc.stateCache, bc.snaps)
528539
}
529540

530541
// StateCache returns the caching database underpinning the blockchain instance.
@@ -576,7 +587,7 @@ func (bc *BlockChain) ResetWithGenesisBlock(genesis *types.Block) error {
576587
func (bc *BlockChain) repair(head **types.Block) error {
577588
for {
578589
// Abort if we've rewound to a head block that does have associated state
579-
if _, err := state.New((*head).Root(), bc.stateCache); err == nil {
590+
if _, err := state.New((*head).Root(), bc.stateCache, bc.snaps); err == nil {
580591
log.Info("Rewound blockchain to past state", "number", (*head).Number(), "hash", (*head).Hash())
581592
return nil
582593
}
@@ -839,6 +850,10 @@ func (bc *BlockChain) Stop() {
839850

840851
bc.wg.Wait()
841852

853+
// Ensure that the entirety of the state snapshot is journalled to disk.
854+
if err := bc.snaps.Journal(bc.CurrentBlock().Root()); err != nil {
855+
log.Error("Failed to journal state snapshot", "err", err)
856+
}
842857
// Ensure the state of a recent block is also stored to disk before exiting.
843858
// We're writing three different states to catch different restart scenarios:
844859
// - HEAD: So we don't need to reprocess any blocks in the general case
@@ -1647,7 +1662,7 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals bool) (int, er
16471662
if parent == nil {
16481663
parent = bc.GetHeader(block.ParentHash(), block.NumberU64()-1)
16491664
}
1650-
statedb, err := state.New(parent.Root, bc.stateCache)
1665+
statedb, err := state.New(parent.Root, bc.stateCache, bc.snaps)
16511666
if err != nil {
16521667
return it.index, err
16531668
}
@@ -1656,9 +1671,9 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals bool) (int, er
16561671
var followupInterrupt uint32
16571672
if !bc.cacheConfig.TrieCleanNoPrefetch {
16581673
if followup, err := it.peek(); followup != nil && err == nil {
1659-
throwaway, _ := state.New(parent.Root, bc.stateCache)
1674+
throwaway, _ := state.New(parent.Root, bc.stateCache, bc.snaps)
16601675
go func(start time.Time, followup *types.Block, throwaway *state.StateDB, interrupt *uint32) {
1661-
bc.prefetcher.Prefetch(followup, throwaway, bc.vmConfig, interrupt)
1676+
bc.prefetcher.Prefetch(followup, throwaway, bc.vmConfig, &followupInterrupt)
16621677

16631678
blockPrefetchExecuteTimer.Update(time.Since(start))
16641679
if atomic.LoadUint32(interrupt) == 1 {
@@ -1676,14 +1691,16 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals bool) (int, er
16761691
return it.index, err
16771692
}
16781693
// Update the metrics touched during block processing
1679-
accountReadTimer.Update(statedb.AccountReads) // Account reads are complete, we can mark them
1680-
storageReadTimer.Update(statedb.StorageReads) // Storage reads are complete, we can mark them
1681-
accountUpdateTimer.Update(statedb.AccountUpdates) // Account updates are complete, we can mark them
1682-
storageUpdateTimer.Update(statedb.StorageUpdates) // Storage updates are complete, we can mark them
1694+
accountReadTimer.Update(statedb.AccountReads) // Account reads are complete, we can mark them
1695+
storageReadTimer.Update(statedb.StorageReads) // Storage reads are complete, we can mark them
1696+
accountUpdateTimer.Update(statedb.AccountUpdates) // Account updates are complete, we can mark them
1697+
storageUpdateTimer.Update(statedb.StorageUpdates) // Storage updates are complete, we can mark them
1698+
snapshotAccountReadTimer.Update(statedb.SnapshotAccountReads) // Account reads are complete, we can mark them
1699+
snapshotStorageReadTimer.Update(statedb.SnapshotStorageReads) // Storage reads are complete, we can mark them
16831700

16841701
triehash := statedb.AccountHashes + statedb.StorageHashes // Save to not double count in validation
1685-
trieproc := statedb.AccountReads + statedb.AccountUpdates
1686-
trieproc += statedb.StorageReads + statedb.StorageUpdates
1702+
trieproc := statedb.SnapshotAccountReads + statedb.AccountReads + statedb.AccountUpdates
1703+
trieproc += statedb.SnapshotStorageReads + statedb.StorageReads + statedb.StorageUpdates
16871704

16881705
blockExecutionTimer.Update(time.Since(substart) - trieproc - triehash)
16891706

@@ -1712,10 +1729,11 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals bool) (int, er
17121729
atomic.StoreUint32(&followupInterrupt, 1)
17131730

17141731
// Update the metrics touched during block commit
1715-
accountCommitTimer.Update(statedb.AccountCommits) // Account commits are complete, we can mark them
1716-
storageCommitTimer.Update(statedb.StorageCommits) // Storage commits are complete, we can mark them
1732+
accountCommitTimer.Update(statedb.AccountCommits) // Account commits are complete, we can mark them
1733+
storageCommitTimer.Update(statedb.StorageCommits) // Storage commits are complete, we can mark them
1734+
snapshotCommitTimer.Update(statedb.SnapshotCommits) // Snapshot commits are complete, we can mark them
17171735

1718-
blockWriteTimer.Update(time.Since(substart) - statedb.AccountCommits - statedb.StorageCommits)
1736+
blockWriteTimer.Update(time.Since(substart) - statedb.AccountCommits - statedb.StorageCommits - statedb.SnapshotCommits)
17191737
blockInsertTimer.UpdateSince(start)
17201738

17211739
switch status {

‎core/chain_makers.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ func GenerateChain(config *params.ChainConfig, parent *types.Block, engine conse
228228
return nil, nil
229229
}
230230
for i := 0; i < n; i++ {
231-
statedb, err := state.New(parent.Root(), state.NewDatabase(db))
231+
statedb, err := state.New(parent.Root(), state.NewDatabase(db), nil)
232232
if err != nil {
233233
panic(err)
234234
}

‎core/genesis.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ func SetupGenesisBlockWithOverride(db ethdb.Database, genesis *Genesis, override
178178
// We have the genesis block in database(perhaps in ancient database)
179179
// but the corresponding state is missing.
180180
header := rawdb.ReadHeader(db, stored, 0)
181-
if _, err := state.New(header.Root, state.NewDatabaseWithCache(db, 0)); err != nil {
181+
if _, err := state.New(header.Root, state.NewDatabaseWithCache(db, 0), nil); err != nil {
182182
if genesis == nil {
183183
genesis = DefaultGenesisBlock()
184184
}
@@ -259,7 +259,7 @@ func (g *Genesis) ToBlock(db ethdb.Database) *types.Block {
259259
if db == nil {
260260
db = rawdb.NewMemoryDatabase()
261261
}
262-
statedb, _ := state.New(common.Hash{}, state.NewDatabase(db))
262+
statedb, _ := state.New(common.Hash{}, state.NewDatabase(db), nil)
263263
for addr, account := range g.Alloc {
264264
statedb.AddBalance(addr, account.Balance)
265265
statedb.SetCode(addr, account.Code)

‎core/rawdb/accessors_snapshot.go‎

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
// Copyright 2019 The go-ethereum Authors
2+
// This file is part of the go-ethereum library.
3+
//
4+
// The go-ethereum library is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU Lesser General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// The go-ethereum library is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU Lesser General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU Lesser General Public License
15+
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
16+
17+
package rawdb
18+
19+
import (
20+
"encoding/binary"
21+
22+
"github.com/ethereum/go-ethereum/common"
23+
"github.com/ethereum/go-ethereum/ethdb"
24+
"github.com/ethereum/go-ethereum/log"
25+
)
26+
27+
// ReadSnapshotBlock retrieves the number and root of the block whose state is
28+
// contained in the persisted snapshot.
29+
func ReadSnapshotBlock(db ethdb.KeyValueReader) (uint64, common.Hash) {
30+
data, _ := db.Get(snapshotBlockKey)
31+
if len(data) != 8+common.HashLength {
32+
return 0, common.Hash{}
33+
}
34+
return binary.BigEndian.Uint64(data[:8]), common.BytesToHash(data[8:])
35+
}
36+
37+
// WriteSnapshotBlock stores the number and root of the block whose state is
38+
// contained in the persisted snapshot.
39+
func WriteSnapshotBlock(db ethdb.KeyValueWriter, number uint64, root common.Hash) {
40+
if err := db.Put(snapshotBlockKey, append(encodeBlockNumber(number), root.Bytes()...)); err != nil {
41+
log.Crit("Failed to store snapsnot block's number and root", "err", err)
42+
}
43+
}
44+
45+
// DeleteSnapshotBlock deletes the number and hash of the block whose state is
46+
// contained in the persisted snapshot. Since snapshots are not immutable, this
47+
// method can be used during updates, so a crash or failure will mark the entire
48+
// snapshot invalid.
49+
func DeleteSnapshotBlock(db ethdb.KeyValueWriter) {
50+
if err := db.Delete(snapshotBlockKey); err != nil {
51+
log.Crit("Failed to remove snapsnot block's number and hash", "err", err)
52+
}
53+
}
54+
55+
// ReadAccountSnapshot retrieves the snapshot entry of an account trie leaf.
56+
func ReadAccountSnapshot(db ethdb.KeyValueReader, hash common.Hash) []byte {
57+
data, _ := db.Get(accountSnapshotKey(hash))
58+
return data
59+
}
60+
61+
// WriteAccountSnapshot stores the snapshot entry of an account trie leaf.
62+
func WriteAccountSnapshot(db ethdb.KeyValueWriter, hash common.Hash, entry []byte) {
63+
if err := db.Put(accountSnapshotKey(hash), entry); err != nil {
64+
log.Crit("Failed to store account snapshot", "err", err)
65+
}
66+
}
67+
68+
// DeleteAccountSnapshot removes the snapshot entry of an account trie leaf.
69+
func DeleteAccountSnapshot(db ethdb.KeyValueWriter, hash common.Hash) {
70+
if err := db.Delete(accountSnapshotKey(hash)); err != nil {
71+
log.Crit("Failed to delete account snapshot", "err", err)
72+
}
73+
}
74+
75+
// ReadStorageSnapshot retrieves the snapshot entry of an storage trie leaf.
76+
func ReadStorageSnapshot(db ethdb.KeyValueReader, accountHash, storageHash common.Hash) []byte {
77+
data, _ := db.Get(storageSnapshotKey(accountHash, storageHash))
78+
return data
79+
}
80+
81+
// WriteStorageSnapshot stores the snapshot entry of an storage trie leaf.
82+
func WriteStorageSnapshot(db ethdb.KeyValueWriter, accountHash, storageHash common.Hash, entry []byte) {
83+
if err := db.Put(storageSnapshotKey(accountHash, storageHash), entry); err != nil {
84+
log.Crit("Failed to store storage snapshot", "err", err)
85+
}
86+
}
87+
88+
// DeleteStorageSnapshot removes the snapshot entry of an storage trie leaf.
89+
func DeleteStorageSnapshot(db ethdb.KeyValueWriter, accountHash, storageHash common.Hash) {
90+
if err := db.Delete(storageSnapshotKey(accountHash, storageHash)); err != nil {
91+
log.Crit("Failed to delete storage snapshot", "err", err)
92+
}
93+
}
94+
95+
// IterateStorageSnapshots returns an iterator for walking the entire storage
96+
// space of a specific account.
97+
func IterateStorageSnapshots(db ethdb.Iteratee, accountHash common.Hash) ethdb.Iterator {
98+
return db.NewIteratorWithPrefix(storageSnapshotsKey(accountHash))
99+
}

‎core/rawdb/database.go‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,8 @@ func InspectDatabase(db ethdb.Database) error {
239239
hashNumPairing common.StorageSize
240240
trieSize common.StorageSize
241241
txlookupSize common.StorageSize
242+
accountSnapSize common.StorageSize
243+
storageSnapSize common.StorageSize
242244
preimageSize common.StorageSize
243245
bloomBitsSize common.StorageSize
244246
cliqueSnapsSize common.StorageSize
@@ -280,6 +282,10 @@ func InspectDatabase(db ethdb.Database) error {
280282
receiptSize += size
281283
case bytes.HasPrefix(key, txLookupPrefix) && len(key) == (len(txLookupPrefix)+common.HashLength):
282284
txlookupSize += size
285+
case bytes.HasPrefix(key, StateSnapshotPrefix) && len(key) == (len(StateSnapshotPrefix)+common.HashLength):
286+
accountSnapSize += size
287+
case bytes.HasPrefix(key, StateSnapshotPrefix) && len(key) == (len(StateSnapshotPrefix)+2*common.HashLength):
288+
storageSnapSize += size
283289
case bytes.HasPrefix(key, preimagePrefix) && len(key) == (len(preimagePrefix)+common.HashLength):
284290
preimageSize += size
285291
case bytes.HasPrefix(key, bloomBitsPrefix) && len(key) == (len(bloomBitsPrefix)+10+common.HashLength):
@@ -331,6 +337,8 @@ func InspectDatabase(db ethdb.Database) error {
331337
{"Key-Value store", "Bloombit index", bloomBitsSize.String()},
332338
{"Key-Value store", "Trie nodes", trieSize.String()},
333339
{"Key-Value store", "Trie preimages", preimageSize.String()},
340+
{"Key-Value store", "Account snapshot", accountSnapSize.String()},
341+
{"Key-Value store", "Storage snapshot", storageSnapSize.String()},
334342
{"Key-Value store", "Clique snapshots", cliqueSnapsSize.String()},
335343
{"Key-Value store", "Singleton metadata", metadata.String()},
336344
{"Ancient store", "Headers", ancientHeaders.String()},

‎core/rawdb/schema.go‎

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ var (
4141
// fastTrieProgressKey tracks the number of trie entries imported during fast sync.
4242
fastTrieProgressKey = []byte("TrieSync")
4343

44+
// snapshotBlockKey tracks the number and hash of the last snapshot.
45+
snapshotBlockKey = []byte("SnapshotBlock")
46+
4447
// Data item prefixes (use single byte to avoid mixing data types, avoid `i`, used for indexes).
4548
headerPrefix = []byte("h") // headerPrefix + num (uint64 big endian) + hash -> header
4649
headerTDSuffix = []byte("t") // headerPrefix + num (uint64 big endian) + hash + headerTDSuffix -> td
@@ -50,8 +53,9 @@ var (
5053
blockBodyPrefix = []byte("b") // blockBodyPrefix + num (uint64 big endian) + hash -> block body
5154
blockReceiptsPrefix = []byte("r") // blockReceiptsPrefix + num (uint64 big endian) + hash -> block receipts
5255

53-
txLookupPrefix = []byte("l") // txLookupPrefix + hash -> transaction/receipt lookup metadata
54-
bloomBitsPrefix = []byte("B") // bloomBitsPrefix + bit (uint16 big endian) + section (uint64 big endian) + hash -> bloom bits
56+
txLookupPrefix = []byte("l") // txLookupPrefix + hash -> transaction/receipt lookup metadata
57+
bloomBitsPrefix = []byte("B") // bloomBitsPrefix + bit (uint16 big endian) + section (uint64 big endian) + hash -> bloom bits
58+
StateSnapshotPrefix = []byte("s") // StateSnapshotPrefix + account hash [+ storage hash] -> account/storage trie value
5559

5660
preimagePrefix = []byte("secure-key-") // preimagePrefix + hash -> preimage
5761
configPrefix = []byte("ethereum-config-") // config prefix for the db
@@ -145,6 +149,21 @@ func txLookupKey(hash common.Hash) []byte {
145149
return append(txLookupPrefix, hash.Bytes()...)
146150
}
147151

152+
// accountSnapshotKey = StateSnapshotPrefix + hash
153+
func accountSnapshotKey(hash common.Hash) []byte {
154+
return append(StateSnapshotPrefix, hash.Bytes()...)
155+
}
156+
157+
// storageSnapshotKey = StateSnapshotPrefix + account hash + storage hash
158+
func storageSnapshotKey(accountHash, storageHash common.Hash) []byte {
159+
return append(append(StateSnapshotPrefix, accountHash.Bytes()...), storageHash.Bytes()...)
160+
}
161+
162+
// storageSnapshotsKey = StateSnapshotPrefix + account hash + storage hash
163+
func storageSnapshotsKey(accountHash common.Hash) []byte {
164+
return append(StateSnapshotPrefix, accountHash.Bytes()...)
165+
}
166+
148167
// bloomBitsKey = bloomBitsPrefix + bit (uint16 big endian) + section (uint64 big endian) + hash
149168
func bloomBitsKey(bit uint, section uint64, hash common.Hash) []byte {
150169
key := append(append(bloomBitsPrefix, make([]byte, 10)...), hash.Bytes()...)

0 commit comments

Comments
 (0)