core, accounts, eth, trie: handle genesis state missing (#28171)
* core, accounts, eth, trie: handle genesis state missing * core, eth, trie: polish * core: manage txpool subscription in mainpool * eth/backend: fix test * cmd, eth: fix test * core/rawdb, trie/triedb/pathdb: address comments * eth, trie: address comments * eth: inline the function * eth: use synced flag * core/txpool: revert changes in txpool * core, eth, trie: rename functions
This commit is contained in:
@@ -76,3 +76,25 @@ func DeleteSkeletonHeader(db ethdb.KeyValueWriter, number uint64) {
|
||||
log.Crit("Failed to delete skeleton header", "err", err)
|
||||
}
|
||||
}
|
||||
|
||||
const (
|
||||
StateSyncUnknown = uint8(0) // flags the state snap sync is unknown
|
||||
StateSyncRunning = uint8(1) // flags the state snap sync is not completed yet
|
||||
StateSyncFinished = uint8(2) // flags the state snap sync is completed
|
||||
)
|
||||
|
||||
// ReadSnapSyncStatusFlag retrieves the state snap sync status flag.
|
||||
func ReadSnapSyncStatusFlag(db ethdb.KeyValueReader) uint8 {
|
||||
blob, err := db.Get(snapSyncStatusFlagKey)
|
||||
if err != nil || len(blob) != 1 {
|
||||
return StateSyncUnknown
|
||||
}
|
||||
return blob[0]
|
||||
}
|
||||
|
||||
// WriteSnapSyncStatusFlag stores the state snap sync status flag into database.
|
||||
func WriteSnapSyncStatusFlag(db ethdb.KeyValueWriter, flag uint8) {
|
||||
if err := db.Put(snapSyncStatusFlagKey, []byte{flag}); err != nil {
|
||||
log.Crit("Failed to store sync status flag", "err", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -555,7 +555,7 @@ func InspectDatabase(db ethdb.Database, keyPrefix, keyStart []byte) error {
|
||||
lastPivotKey, fastTrieProgressKey, snapshotDisabledKey, SnapshotRootKey, snapshotJournalKey,
|
||||
snapshotGeneratorKey, snapshotRecoveryKey, txIndexTailKey, fastTxLookupLimitKey,
|
||||
uncleanShutdownKey, badBlockKey, transitionStatusKey, skeletonSyncStatusKey,
|
||||
persistentStateIDKey, trieJournalKey, snapshotSyncStatusKey,
|
||||
persistentStateIDKey, trieJournalKey, snapshotSyncStatusKey, snapSyncStatusFlagKey,
|
||||
} {
|
||||
if bytes.Equal(key, meta) {
|
||||
metadata.Add(size)
|
||||
|
||||
@@ -91,6 +91,9 @@ var (
|
||||
// transitionStatusKey tracks the eth2 transition status.
|
||||
transitionStatusKey = []byte("eth2-transition")
|
||||
|
||||
// snapSyncStatusFlagKey flags that status of snap sync.
|
||||
snapSyncStatusFlagKey = []byte("SnapSyncStatus")
|
||||
|
||||
// Data item prefixes (use single byte to avoid mixing data types, avoid `i`, used for indexes).
|
||||
headerPrefix = []byte("h") // headerPrefix + num (uint64 big endian) + hash -> header
|
||||
headerTDSuffix = []byte("t") // headerPrefix + num (uint64 big endian) + hash + headerTDSuffix -> td
|
||||
|
||||
Reference in New Issue
Block a user