mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-23 05:06:43 +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,
|
Time: pre.Env.ParentTimestamp,
|
||||||
ExcessBlobGas: pre.Env.ParentExcessBlobGas,
|
ExcessBlobGas: pre.Env.ParentExcessBlobGas,
|
||||||
BlobGasUsed: pre.Env.ParentBlobGasUsed,
|
BlobGasUsed: pre.Env.ParentBlobGasUsed,
|
||||||
|
BaseFee: pre.Env.ParentBaseFee,
|
||||||
}
|
}
|
||||||
header := &types.Header{
|
header := &types.Header{
|
||||||
Time: pre.Env.Timestamp,
|
Time: pre.Env.Timestamp,
|
||||||
|
|
|
||||||
|
|
@ -118,6 +118,7 @@ func Transition(ctx *cli.Context) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
prestate.Pre = inputData.Alloc
|
prestate.Pre = inputData.Alloc
|
||||||
|
|
||||||
if btStr != stdinSelector && btStr != "" {
|
if btStr != stdinSelector && btStr != "" {
|
||||||
if err := readFile(btStr, "BT", &inputData.BT); err != nil {
|
if err := readFile(btStr, "BT", &inputData.BT); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
@ -125,6 +126,7 @@ func Transition(ctx *cli.Context) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
prestate.BT = inputData.BT
|
prestate.BT = inputData.BT
|
||||||
|
|
||||||
// Set the block environment
|
// Set the block environment
|
||||||
if envStr != stdinSelector {
|
if envStr != stdinSelector {
|
||||||
var env stEnv
|
var env stEnv
|
||||||
|
|
@ -195,8 +197,10 @@ func Transition(ctx *cli.Context) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// Dump the execution result
|
// Dump the execution result
|
||||||
collector := make(Alloc)
|
var (
|
||||||
var btleaves map[common.Hash]hexutil.Bytes
|
collector = make(Alloc)
|
||||||
|
btleaves map[common.Hash]hexutil.Bytes
|
||||||
|
)
|
||||||
isBinary := chainConfig.IsVerkle(big.NewInt(int64(prestate.Env.Number)), prestate.Env.Timestamp)
|
isBinary := chainConfig.IsVerkle(big.NewInt(int64(prestate.Env.Number)), prestate.Env.Timestamp)
|
||||||
if !isBinary {
|
if !isBinary {
|
||||||
s.DumpToCollector(collector, nil)
|
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)
|
return nil, fmt.Errorf("error inserting storage: %w", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
account := &types.StateAccount{
|
account := &types.StateAccount{
|
||||||
Balance: uint256.MustFromBig(acc.Balance),
|
Balance: uint256.MustFromBig(acc.Balance),
|
||||||
Nonce: acc.Nonce,
|
Nonce: acc.Nonce,
|
||||||
|
|
@ -503,7 +506,6 @@ func genBinTrieFromAlloc(alloc core.GenesisAlloc) (*bintrie.BinaryTrie, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error inserting account: %w", err)
|
return nil, fmt.Errorf("error inserting account: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = bt.UpdateContractCode(addr, common.BytesToHash(account.CodeHash), acc.Code)
|
err = bt.UpdateContractCode(addr, common.BytesToHash(account.CodeHash), acc.Code)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error inserting code: %w", err)
|
return nil, fmt.Errorf("error inserting code: %w", err)
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ package state
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"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.
|
// DumpBinTrieLeaves collects all binary trie leaf nodes into the provided map.
|
||||||
func (s *StateDB) DumpBinTrieLeaves(collector map[common.Hash]hexutil.Bytes) error {
|
func (s *StateDB) DumpBinTrieLeaves(collector map[common.Hash]hexutil.Bytes) error {
|
||||||
if s.trie == nil {
|
tr, err := s.db.OpenTrie(s.originalRoot)
|
||||||
trie, err := s.db.OpenTrie(s.originalRoot)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
s.trie = trie
|
|
||||||
}
|
|
||||||
|
|
||||||
it, err := s.trie.(*bintrie.BinaryTrie).NodeIterator(nil)
|
|
||||||
if err != nil {
|
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) {
|
for it.Next(true) {
|
||||||
if it.Leaf() {
|
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
|
// import pre accounts & construct test genesis block & state root
|
||||||
// Commit genesis state
|
// Commit genesis state
|
||||||
gspec := t.genesis(config)
|
|
||||||
var (
|
var (
|
||||||
|
gspec = t.genesis(config)
|
||||||
db = rawdb.NewMemoryDatabase()
|
db = rawdb.NewMemoryDatabase()
|
||||||
tconf = &triedb.Config{
|
tconf = &triedb.Config{
|
||||||
Preimages: true,
|
Preimages: true,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue