mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-22 12:46:44 +00:00
review feedback from Gary part 1
Co-authored-by: Gary Rong <garyrong0905@gmail.com>
This commit is contained in:
parent
a0e6f53977
commit
d729550a5d
4 changed files with 19 additions and 15 deletions
|
|
@ -194,6 +194,7 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
|
|||
Time: pre.Env.ParentTimestamp,
|
||||
ExcessBlobGas: pre.Env.ParentExcessBlobGas,
|
||||
BlobGasUsed: pre.Env.ParentBlobGasUsed,
|
||||
BaseFee: pre.Env.ParentBaseFee,
|
||||
}
|
||||
header := &types.Header{
|
||||
Time: pre.Env.Timestamp,
|
||||
|
|
|
|||
|
|
@ -118,6 +118,7 @@ func Transition(ctx *cli.Context) error {
|
|||
}
|
||||
}
|
||||
prestate.Pre = inputData.Alloc
|
||||
|
||||
if btStr != stdinSelector && btStr != "" {
|
||||
if err := readFile(btStr, "BT", &inputData.BT); err != nil {
|
||||
return err
|
||||
|
|
@ -125,6 +126,7 @@ func Transition(ctx *cli.Context) error {
|
|||
}
|
||||
|
||||
prestate.BT = inputData.BT
|
||||
|
||||
// Set the block environment
|
||||
if envStr != stdinSelector {
|
||||
var env stEnv
|
||||
|
|
@ -195,8 +197,10 @@ func Transition(ctx *cli.Context) error {
|
|||
return err
|
||||
}
|
||||
// Dump the execution result
|
||||
collector := make(Alloc)
|
||||
var btleaves map[common.Hash]hexutil.Bytes
|
||||
var (
|
||||
collector = make(Alloc)
|
||||
btleaves map[common.Hash]hexutil.Bytes
|
||||
)
|
||||
isBinary := chainConfig.IsVerkle(big.NewInt(int64(prestate.Env.Number)), prestate.Env.Timestamp)
|
||||
if !isBinary {
|
||||
s.DumpToCollector(collector, nil)
|
||||
|
|
@ -492,7 +496,6 @@ func genBinTrieFromAlloc(alloc core.GenesisAlloc) (*bintrie.BinaryTrie, error) {
|
|||
return nil, fmt.Errorf("error inserting storage: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
account := &types.StateAccount{
|
||||
Balance: uint256.MustFromBig(acc.Balance),
|
||||
Nonce: acc.Nonce,
|
||||
|
|
@ -503,7 +506,6 @@ func genBinTrieFromAlloc(alloc core.GenesisAlloc) (*bintrie.BinaryTrie, error) {
|
|||
if err != nil {
|
||||
return nil, fmt.Errorf("error inserting account: %w", err)
|
||||
}
|
||||
|
||||
err = bt.UpdateContractCode(addr, common.BytesToHash(account.CodeHash), acc.Code)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error inserting code: %w", err)
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ package state
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
|
|
@ -224,17 +225,17 @@ func (s *StateDB) DumpToCollector(c DumpCollector, conf *DumpConfig) (nextKey []
|
|||
|
||||
// DumpBinTrieLeaves collects all binary trie leaf nodes into the provided map.
|
||||
func (s *StateDB) DumpBinTrieLeaves(collector map[common.Hash]hexutil.Bytes) error {
|
||||
if s.trie == nil {
|
||||
trie, err := s.db.OpenTrie(s.originalRoot)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
s.trie = trie
|
||||
}
|
||||
|
||||
it, err := s.trie.(*bintrie.BinaryTrie).NodeIterator(nil)
|
||||
tr, err := s.db.OpenTrie(s.originalRoot)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
return err
|
||||
}
|
||||
btr, ok := tr.(*bintrie.BinaryTrie)
|
||||
if !ok {
|
||||
return errors.New("trie is not a binary trie")
|
||||
}
|
||||
it, err := btr.NodeIterator(nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for it.Next(true) {
|
||||
if it.Leaf() {
|
||||
|
|
|
|||
|
|
@ -118,8 +118,8 @@ func (t *BlockTest) Run(snapshotter bool, scheme string, witness bool, tracer *t
|
|||
}
|
||||
// import pre accounts & construct test genesis block & state root
|
||||
// Commit genesis state
|
||||
gspec := t.genesis(config)
|
||||
var (
|
||||
gspec = t.genesis(config)
|
||||
db = rawdb.NewMemoryDatabase()
|
||||
tconf = &triedb.Config{
|
||||
Preimages: true,
|
||||
|
|
|
|||
Loading…
Reference in a new issue