mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-19 03:10:48 +00:00
more cleanups
This commit is contained in:
parent
6eee5253b8
commit
c62c486918
5 changed files with 18 additions and 28 deletions
|
|
@ -19,6 +19,7 @@ package core
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
|
||||
"github.com/ethereum/go-ethereum/consensus"
|
||||
|
|
@ -143,6 +144,7 @@ func (v *BlockValidator) ValidateBody(block *types.Block) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// StateRootSource computes a new state root during block execution.
|
||||
type StateRootSource interface {
|
||||
IntermediateRoot(deleteEmptyObjects bool) common.Hash
|
||||
Error() error
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ import (
|
|||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/ethereum/go-ethereum/core/types/bal"
|
||||
"io"
|
||||
"math/big"
|
||||
"runtime"
|
||||
|
|
@ -32,6 +31,8 @@ import (
|
|||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/ethereum/go-ethereum/core/types/bal"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/common/lru"
|
||||
"github.com/ethereum/go-ethereum/common/mclock"
|
||||
|
|
@ -2124,16 +2125,13 @@ func (bc *BlockChain) processBlockWithAccessList(parentRoot common.Hash, block *
|
|||
sdb := state.NewMPTDatabase(bc.triedb, bc.codedb).WithSnapshot(bc.snaps)
|
||||
|
||||
al := block.AccessList()
|
||||
// Preprocess the access list once for the whole block; the resulting
|
||||
// structure is read-only and shared by the prefetch reader, the state
|
||||
// transition and every per-transaction execution reader.
|
||||
prepared := bal.NewAccessListReader(*al)
|
||||
prefetchReader, err := sdb.ReaderWithPrefetch(parentRoot, prepared.StorageKeys())
|
||||
reader := bal.NewAccessListReader(*al)
|
||||
prefetchReader, err := sdb.ReaderWithPrefetch(parentRoot, reader.StorageKeys())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
stateTransition, err := state.NewBALStateTransition(block, prefetchReader, sdb, parentRoot, prepared)
|
||||
stateTransition, err := state.NewBALStateTransition(block, prefetchReader, sdb, parentRoot, reader)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -2202,9 +2200,6 @@ func (bc *BlockChain) processBlockWithAccessList(parentRoot common.Hash, block *
|
|||
|
||||
if m := res.StateTransitionMetrics; m != nil {
|
||||
stats.AccountHashes = m.AccountUpdate + m.StateUpdate + m.StateHash
|
||||
stats.AccountCommits = m.AccountCommits
|
||||
stats.StorageCommits = m.StorageCommits
|
||||
stats.DatabaseCommit = m.TrieDBCommits
|
||||
//stats.Prefetch = m.StatePrefetch
|
||||
}
|
||||
//stats.Prefetch = prefetchReader.(state.PrefetcherMetricer).Metrics().Elapsed
|
||||
|
|
|
|||
|
|
@ -83,13 +83,6 @@ type BALStateTransitionMetrics struct {
|
|||
StatePrefetch time.Duration
|
||||
StateUpdate time.Duration
|
||||
StateHash time.Duration
|
||||
|
||||
// commit metrics
|
||||
AccountCommits time.Duration
|
||||
StorageCommits time.Duration
|
||||
SnapshotCommits time.Duration
|
||||
TrieDBCommits time.Duration
|
||||
TotalCommitTime time.Duration
|
||||
}
|
||||
|
||||
// NewBALStateTransition creates a BALStateTransition instance
|
||||
|
|
@ -190,7 +183,7 @@ func (s *BALStateTransition) updateAccount(addr common.Address) (*types.StateAcc
|
|||
func (s *BALStateTransition) commitAccount(addr common.Address) (*AccountUpdate, *trienode.NodeSet, error) {
|
||||
op := &AccountUpdate{
|
||||
Address: addr,
|
||||
Data: s.postStates[addr], // TODO: cache the updated state account somewhere
|
||||
Data: s.postStates[addr],
|
||||
}
|
||||
var prestate *types.StateAccount
|
||||
if ps, exist := s.prestates.Load(addr); exist {
|
||||
|
|
@ -299,7 +292,6 @@ func (s *BALStateTransition) CommitWithUpdate(block uint64, deleteEmptyObjects b
|
|||
// off some milliseconds from the commit operation. Also accumulate the code
|
||||
// writes to run in parallel with the computations.
|
||||
var (
|
||||
start = time.Now()
|
||||
root common.Hash
|
||||
workers errgroup.Group
|
||||
)
|
||||
|
|
@ -320,7 +312,6 @@ func (s *BALStateTransition) CommitWithUpdate(block uint64, deleteEmptyObjects b
|
|||
if err := merge(set); err != nil {
|
||||
return err
|
||||
}
|
||||
s.metrics.AccountCommits = time.Since(start)
|
||||
return nil
|
||||
})
|
||||
|
||||
|
|
@ -350,7 +341,6 @@ func (s *BALStateTransition) CommitWithUpdate(block uint64, deleteEmptyObjects b
|
|||
}
|
||||
lock.Lock()
|
||||
updates[crypto.Keccak256Hash(address[:])] = update
|
||||
s.metrics.StorageCommits = time.Since(start) // overwrite with the longest storage commit runtime
|
||||
lock.Unlock()
|
||||
return nil
|
||||
})
|
||||
|
|
|
|||
|
|
@ -220,9 +220,13 @@ type ReaderWithBlockLevelAccessList struct {
|
|||
TxIndex int
|
||||
}
|
||||
|
||||
// NewReaderWithAccessList wraps a base reader with a shared, already
|
||||
// preprocessed access list. This is the cheap constructor used on the hot path:
|
||||
// the prepared list is built once per block and borrowed by every per-tx reader.
|
||||
// NewReaderWithAccessList constructs a reader for accessing states
|
||||
// with the mutations made by transactions prior to txIndex.
|
||||
//
|
||||
// The txIndex refers to the call frame as such:
|
||||
// - 0 for pre‑execution system contract calls.
|
||||
// - 1 … n for transactions (in block order).
|
||||
// - n + 1 for post‑execution system contract calls.
|
||||
func NewReaderWithAccessList(base Reader, prepared *bal.AccessListReader, txIndex int) *ReaderWithBlockLevelAccessList {
|
||||
return &ReaderWithBlockLevelAccessList{
|
||||
Reader: base,
|
||||
|
|
|
|||
|
|
@ -41,10 +41,9 @@ var (
|
|||
transactionTestDir = filepath.Join(baseDir, "TransactionTests")
|
||||
rlpTestDir = filepath.Join(baseDir, "RLPTests")
|
||||
difficultyTestDir = filepath.Join(baseDir, "BasicTests")
|
||||
executionSpecBlockchainTestDir = filepath.Join(".", "spec-tests", "fixtures", "blockchain_tests")
|
||||
executionSpecBALBlockchainTestDir = filepath.Join(".", "spec-tests-bal", "fixtures", "blockchain_tests")
|
||||
executionSpecStateTestDir = filepath.Join(".", "spec-tests", "fixtures", "state_tests")
|
||||
executionSpecTransactionTestDir = filepath.Join(".", "spec-tests", "fixtures", "transaction_tests")
|
||||
executionSpecBlockchainTestDir = filepath.Join(".", "spec-tests", "fixtures", "blockchain_tests")
|
||||
executionSpecStateTestDir = filepath.Join(".", "spec-tests", "fixtures", "state_tests")
|
||||
executionSpecTransactionTestDir = filepath.Join(".", "spec-tests", "fixtures", "transaction_tests")
|
||||
benchmarksDir = filepath.Join(".", "evm-benchmarks", "benchmarks")
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue