mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 22:56:43 +00:00
cosmatic: add some comments & remove unneccesary codes
This commit is contained in:
parent
72251d3346
commit
a3640a5708
2 changed files with 1 additions and 60 deletions
|
|
@ -96,21 +96,13 @@ func (p *ParallelStateProcessor) executeParallel(block *types.Block, statedb *st
|
||||||
preStateProvider PreStateProvider
|
preStateProvider PreStateProvider
|
||||||
workers errgroup.Group
|
workers errgroup.Group
|
||||||
postState = statedb.Copy()
|
postState = statedb.Copy()
|
||||||
// statedbbal = statedb.Copy()
|
|
||||||
// wg sync.WaitGroup
|
|
||||||
)
|
)
|
||||||
// leave some cpus for prefetching
|
// leave some cpus for prefetching
|
||||||
workers.SetLimit(runtime.NumCPU() / 2)
|
workers.SetLimit(runtime.NumCPU() / 2)
|
||||||
|
|
||||||
// Fetch prestate for each tx
|
|
||||||
|
|
||||||
// todo: handle gp with RW lock
|
|
||||||
switch preStateType {
|
switch preStateType {
|
||||||
case BALPreState:
|
case BALPreState:
|
||||||
{
|
{
|
||||||
// start := time.Now()
|
|
||||||
// statedb.PrefetchStateBAL(block.NumberU64())
|
|
||||||
// PrefetchBALTime += time.Since(start)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case SeqPreState:
|
case SeqPreState:
|
||||||
|
|
@ -195,8 +187,7 @@ func (p *ParallelStateProcessor) executeParallel(block *types.Block, statedb *st
|
||||||
// Merge state changes
|
// Merge state changes
|
||||||
// - Append receipts
|
// - Append receipts
|
||||||
// - Sum usedGas
|
// - Sum usedGas
|
||||||
// - Collect state state changes: simple overwrite
|
// - TODO: validate state changes are the same with bal
|
||||||
// - Ommit preimages for now
|
|
||||||
usedGas := uint64(0)
|
usedGas := uint64(0)
|
||||||
|
|
||||||
// set it to avoid read bal post state, -2 is a magic tx number
|
// set it to avoid read bal post state, -2 is a magic tx number
|
||||||
|
|
|
||||||
|
|
@ -473,56 +473,6 @@ func (s *StateDB) MergePostBal() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *StateDB) MergePostBalBuggy() {
|
|
||||||
if balType != BalPreblockKeysPostValues {
|
|
||||||
panic("MergePostBal is only supported with BalPreblockKeysPostValues")
|
|
||||||
}
|
|
||||||
start := time.Now()
|
|
||||||
var (
|
|
||||||
postBal = AllBlockTxPostValues[s.blockNumber]
|
|
||||||
)
|
|
||||||
StateLoadTime += time.Since(start)
|
|
||||||
|
|
||||||
postState := s.Copy()
|
|
||||||
postState.prefetcher = nil
|
|
||||||
for txIndex := range len(postBal) {
|
|
||||||
postVals := postBal[txIndex]
|
|
||||||
start := time.Now()
|
|
||||||
for addr, acct := range postVals {
|
|
||||||
account := postState.getStateObject(addr)
|
|
||||||
if account == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if acct.Destruct {
|
|
||||||
account.markSelfdestructed()
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
account.SetNonce(acct.Nonce)
|
|
||||||
if acct.Balance != nil {
|
|
||||||
account.SetBalance(acct.Balance)
|
|
||||||
}
|
|
||||||
if acct.Code != nil {
|
|
||||||
account.SetCode(crypto.Keccak256Hash(acct.Code), acct.Code)
|
|
||||||
}
|
|
||||||
// Will cause failure if postState.Finalise is not called.
|
|
||||||
for k, v := range acct.StorageKV {
|
|
||||||
account.SetState(k, v)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
StateSetTime += time.Since(start)
|
|
||||||
|
|
||||||
start = time.Now()
|
|
||||||
// postState.Finalise(true)
|
|
||||||
StateFinalizeTime += time.Since(start)
|
|
||||||
|
|
||||||
start = time.Now()
|
|
||||||
s.postStates[txIndex] = postState.Copy()
|
|
||||||
StateCopyTime += time.Since(start)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *StateDB) PrestateAtIndex(txIndex int) (*StateDB, error) {
|
func (s *StateDB) PrestateAtIndex(txIndex int) (*StateDB, error) {
|
||||||
if balType != BalPreblockKeysPostValues {
|
if balType != BalPreblockKeysPostValues {
|
||||||
return nil, fmt.Errorf("PreStateAtTxIndex is only supported with BalPreblockKeysPostValues")
|
return nil, fmt.Errorf("PreStateAtTxIndex is only supported with BalPreblockKeysPostValues")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue