Skip to content

Commit

Permalink
all: rename
Browse files Browse the repository at this point in the history
  • Loading branch information
rjl493456442 committed Dec 16, 2024
1 parent 4c3e54b commit 1c30900
Show file tree
Hide file tree
Showing 60 changed files with 247 additions and 244 deletions.
2 changes: 1 addition & 1 deletion cmd/devp2p/internal/ethtest/snap.go
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ func (s *Suite) TestSnapGetByteCodes(t *utesting.T) {
{
desc: `Here we request the empty state root (which is not an existing code hash). The server should deliver an empty response with no items.`,
nBytes: 10000,
hashes: []common.Hash{types.EmptyMerkleHash}, // TODO add verkle tests
hashes: []common.Hash{types.EmptyRootHash}, // TODO add verkle tests
expHashes: 0,
},
{
Expand Down
2 changes: 1 addition & 1 deletion cmd/evm/internal/t8ntool/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
func MakePreState(db ethdb.Database, accounts types.GenesisAlloc) *state.StateDB {
tdb := triedb.NewDatabase(db, &triedb.Config{Preimages: true})
sdb := state.NewDatabase(tdb, nil)
statedb, _ := state.New(types.EmptyMerkleHash, sdb) // TODO support verkle node in t8n
statedb, _ := state.New(types.EmptyRootHash, sdb) // TODO support verkle node in t8n
for addr, a := range accounts {
statedb.SetCode(addr, a.Code)
statedb.SetNonce(addr, a.Nonce)
Expand Down
6 changes: 3 additions & 3 deletions cmd/geth/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ func traverseState(ctx *cli.Context) error {
log.Error("Invalid account encountered during traversal", "err", err)
return err
}
if acc.Root != types.EmptyMerkleHash {
if acc.Root != types.EmptyRootHash {
id := trie.StorageTrieID(root, common.BytesToHash(accIter.Key), acc.Root)
storageTrie, err := trie.NewStateTrie(id, triedb)
if err != nil {
Expand Down Expand Up @@ -466,7 +466,7 @@ func traverseRawState(ctx *cli.Context) error {
log.Error("Invalid account encountered during traversal", "err", err)
return errors.New("invalid account")
}
if acc.Root != types.EmptyMerkleHash {
if acc.Root != types.EmptyRootHash {
id := trie.StorageTrieID(root, common.BytesToHash(accIter.LeafKey()), acc.Root)
storageTrie, err := trie.NewStateTrie(id, triedb)
if err != nil {
Expand Down Expand Up @@ -583,7 +583,7 @@ func dumpState(ctx *cli.Context) error {
Root common.Hash `json:"root"`
}{root})
for accIt.Next() {
account, err := types.FullAccount(accIt.Account(), false)
account, err := types.FullAccount(accIt.Account())
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/utils/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -610,15 +610,15 @@ func ExportSnapshotPreimages(chaindb ethdb.Database, snaptree *snapshot.Tree, fn
defer accIt.Release()

for accIt.Next() {
acc, err := types.FullAccount(accIt.Account(), false)
acc, err := types.FullAccount(accIt.Account())
if err != nil {
log.Error("Failed to get full account", "error", err)
return
}
preimages += 1
hashCh <- hashAndPreimageSize{Hash: accIt.Hash(), Size: common.AddressLength}

if acc.Root != (common.Hash{}) && acc.Root != types.EmptyMerkleHash {
if acc.Root != (common.Hash{}) && acc.Root != types.EmptyRootHash {
stIt, err := snaptree.StorageIterator(root, accIt.Hash(), common.Hash{})
if err != nil {
log.Error("Failed to create storage iterator", "error", err)
Expand Down
8 changes: 4 additions & 4 deletions core/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func hashAlloc(ga *types.GenesisAlloc, isVerkle bool) (common.Hash, error) {
// Create an ephemeral in-memory database for computing hash,
// all the derived states will be discarded to not pollute disk.
db := rawdb.NewMemoryDatabase()
statedb, err := state.New(types.EmptyRootHash(isVerkle), state.NewDatabase(triedb.NewDatabase(db, config), nil))
statedb, err := state.New(types.EmptyTreeRootHash(isVerkle), state.NewDatabase(triedb.NewDatabase(db, config), nil))
if err != nil {
return common.Hash{}, err
}
Expand All @@ -148,7 +148,7 @@ func hashAlloc(ga *types.GenesisAlloc, isVerkle bool) (common.Hash, error) {
// flushAlloc is very similar with hash, but the main difference is all the
// generated states will be persisted into the given database.
func flushAlloc(ga *types.GenesisAlloc, triedb *triedb.Database) (common.Hash, error) {
statedb, err := state.New(types.EmptyRootHash(triedb.IsVerkle()), state.NewDatabase(triedb, nil))
statedb, err := state.New(types.EmptyTreeRootHash(triedb.IsVerkle()), state.NewDatabase(triedb, nil))
if err != nil {
return common.Hash{}, err
}
Expand All @@ -169,7 +169,7 @@ func flushAlloc(ga *types.GenesisAlloc, triedb *triedb.Database) (common.Hash, e
return common.Hash{}, err
}
// Commit newly generated states into disk if it's not empty.
if root != types.EmptyRootHash(triedb.IsVerkle()) {
if root != types.EmptyTreeRootHash(triedb.IsVerkle()) {
if err := triedb.Commit(root, true); err != nil {
return common.Hash{}, err
}
Expand Down Expand Up @@ -292,7 +292,7 @@ func SetupGenesisBlockWithOverride(db ethdb.Database, triedb *triedb.Database, g
// is initialized with an external ancient store. Commit genesis state
// in this case.
header := rawdb.ReadHeader(db, stored, 0)
if header.Root != types.EmptyRootHash(triedb.IsVerkle()) && !triedb.Initialized(header.Root) {
if header.Root != types.EmptyTreeRootHash(triedb.IsVerkle()) && !triedb.Initialized(header.Root) {
if genesis == nil {
genesis = DefaultGenesisBlock()
}
Expand Down
2 changes: 1 addition & 1 deletion core/state/pruner/pruner.go
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ func extractGenesis(db ethdb.Database, stateBloom *stateBloom) error {
if err := rlp.DecodeBytes(accIter.LeafBlob(), &acc); err != nil {
return err
}
if acc.Root != types.EmptyMerkleHash {
if acc.Root != types.EmptyRootHash {
id := trie.StorageTrieID(genesis.Root(), common.BytesToHash(accIter.LeafKey()), acc.Root)
storageTrie, err := trie.NewStateTrie(id, triedb.NewDatabase(db, triedb.HashDefaults))
if err != nil {
Expand Down
7 changes: 5 additions & 2 deletions core/state/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func (r *flatReader) Account(addr common.Address) (*types.StateAccount, error) {
}
// Annotate the empty root hash, especially for merkle tree.
if acct.Root == (common.Hash{}) {
acct.Root = types.EmptyRootHash(r.isVerkle)
acct.Root = types.EmptyTreeRootHash(r.isVerkle)
}
return acct, nil
}
Expand Down Expand Up @@ -243,8 +243,11 @@ func (r *trieReader) Account(addr common.Address) (*types.StateAccount, error) {
return nil, err
}
if account == nil {
r.subRoots[addr] = types.EmptyRootHash(r.db.IsVerkle())
r.subRoots[addr] = types.EmptyTreeRootHash(r.db.IsVerkle())
} else {
// The root hash will be these values if the storage is empty:
// - merkle: types.EmptyRootHash
// - verkle: types.EmptyVerkleHash
r.subRoots[addr] = account.Root
}
return account, nil
Expand Down
4 changes: 2 additions & 2 deletions core/state/snapshot/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ func generateTrieRoot(db ethdb.KeyValueWriter, scheme string, it Iterator, accou
fullData []byte
)
if leafCallback == nil {
fullData, err = types.FullAccountRLP(it.(AccountIterator).Account(), false)
fullData, err = types.FullAccountRLP(it.(AccountIterator).Account())
if err != nil {
return stop(err)
}
Expand All @@ -302,7 +302,7 @@ func generateTrieRoot(db ethdb.KeyValueWriter, scheme string, it Iterator, accou
return stop(err)
}
// Fetch the next account and process it concurrently
account, err := types.FullAccount(it.(AccountIterator).Account(), false)
account, err := types.FullAccount(it.(AccountIterator).Account())
if err != nil {
return stop(err)
}
Expand Down
6 changes: 3 additions & 3 deletions core/state/snapshot/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ func generateAccounts(ctx *generatorContext, dl *diskLayer, accMarker []byte) er
if bytes.Equal(acc.CodeHash, types.EmptyCodeHash[:]) {
dataLen -= 32
}
if acc.Root == types.EmptyMerkleHash {
if acc.Root == types.EmptyRootHash {
dataLen -= 32
}
snapRecoveredAccountMeter.Mark(1)
Expand All @@ -609,7 +609,7 @@ func generateAccounts(ctx *generatorContext, dl *diskLayer, accMarker []byte) er

// If the iterated account is the contract, create a further loop to
// verify or regenerate the contract storage.
if acc.Root == types.EmptyMerkleHash {
if acc.Root == types.EmptyRootHash {
ctx.removeStorageAt(account)
} else {
var storeMarker []byte
Expand All @@ -629,7 +629,7 @@ func generateAccounts(ctx *generatorContext, dl *diskLayer, accMarker []byte) er
id := trie.StateTrieID(dl.root)
exhausted, last, err := dl.generateRange(ctx, id, rawdb.SnapshotAccountPrefix, snapAccount, origin, accountCheckRange, onAccount,
func(data []byte) ([]byte, error) {
return types.FullAccountRLP(data, false)
return types.FullAccountRLP(data)
},
)
if err != nil {
Expand Down
Loading

0 comments on commit 1c30900

Please sign in to comment.