Skip to content

Commit 876a028

Browse files
committed
fixes
Signed-off-by: Ignacio Hagopian <[email protected]>
1 parent b4f3596 commit 876a028

File tree

4 files changed

+17
-9
lines changed

4 files changed

+17
-9
lines changed

consensus/beacon/consensus.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -347,10 +347,6 @@ func (beacon *Beacon) Prepare(chain consensus.ChainHeaderReader, header *types.H
347347

348348
// Finalize implements consensus.Engine and processes withdrawals on top.
349349
func (beacon *Beacon) Finalize(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header, withdrawals []*types.Withdrawal) {
350-
if false && !beacon.IsPoSHeader(header) {
351-
beacon.ethone.Finalize(chain, header, state, txs, uncles, nil)
352-
return
353-
}
354350
// Withdrawals processing.
355351
for _, w := range withdrawals {
356352
// Convert amount from gwei to wei.
@@ -373,6 +369,11 @@ func (beacon *Beacon) Finalize(chain consensus.ChainHeaderReader, header *types.
373369
log.Error("error performing the transition", "err", err)
374370
}
375371
}
372+
373+
if !beacon.IsPoSHeader(header) {
374+
beacon.ethone.Finalize(chain, header, state, txs, uncles, nil)
375+
return
376+
}
376377
}
377378

378379
// FinalizeAndAssemble implements consensus.Engine, setting the final state and

core/blockchain.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, genesis *Genesis
322322
// for it to be able to recover if interrupted during the transition
323323
// but that's left out to a later PR since there's not really a need
324324
// right now.
325-
bc.stateCache.InitTransitionStatus(true, true)
325+
bc.stateCache.InitTransitionStatus(false, false)
326326
}
327327

328328
if !bc.stateCache.Transitioned() && !bc.HasState(head.Root) {
@@ -1530,6 +1530,8 @@ func (bc *BlockChain) InsertChain(chain types.Blocks) (int, error) {
15301530
return bc.insertChain(chain, true)
15311531
}
15321532

1533+
var count int
1534+
15331535
// insertChain is the internal implementation of InsertChain, which assumes that
15341536
// 1) chains are contiguous, and 2) The chain mutex is held.
15351537
//
@@ -1667,7 +1669,6 @@ func (bc *BlockChain) insertChain(chain types.Blocks, setHead bool) (int, error)
16671669
activeState.StopPrefetcher()
16681670
}
16691671
}()
1670-
16711672
for ; block != nil && err == nil || errors.Is(err, ErrKnownBlock); block, err = it.next() {
16721673
// If the chain is terminating, stop processing blocks
16731674
if bc.insertStopped() {
@@ -1736,7 +1737,12 @@ func (bc *BlockChain) insertChain(chain types.Blocks, setHead bool) (int, error)
17361737
bc.stateCache.SetLastMerkleRoot(parent.Root)
17371738
}
17381739
}
1739-
statedb, err := state.New(parent.Root, bc.stateCache, bc.snaps)
1740+
rootz := parent.Root
1741+
if count > 0 {
1742+
rootz = state.LastCommittedRoot
1743+
}
1744+
count++
1745+
statedb, err := state.New(rootz, bc.stateCache, bc.snaps)
17401746
if err != nil {
17411747
return it.index, err
17421748
}

core/state/database.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,6 @@ func (db *cachingDB) OpenTrie(root common.Hash) (Trie, error) {
349349
mpt Trie
350350
err error
351351
)
352-
fmt.Printf("opening trie with root %x, %v %v\n", root, db.InTransition(), db.Transitioned())
353352

354353
// TODO separate both cases when I can be certain that it won't
355354
// find a Verkle trie where is expects a Transitoion trie.
@@ -415,7 +414,6 @@ func (db *cachingDB) OpenStorageTrie(stateRoot common.Hash, address common.Addre
415414
}
416415
}
417416
if db.InTransition() {
418-
fmt.Printf("OpenStorageTrie during transition, state root=%x root=%x\n", stateRoot, root)
419417
mpt, err := db.openStorageMPTrie(db.LastMerkleRoot, address, root, nil)
420418
if err != nil {
421419
return nil, err

core/state/statedb.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1356,9 +1356,12 @@ func (s *StateDB) Commit(block uint64, deleteEmptyObjects bool) (common.Hash, er
13561356
s.storagesOrigin = make(map[common.Address]map[common.Hash][]byte)
13571357
s.stateObjectsDirty = make(map[common.Address]struct{})
13581358
s.stateObjectsDestruct = make(map[common.Address]*types.StateAccount)
1359+
LastCommittedRoot = root
13591360
return root, nil
13601361
}
13611362

1363+
var LastCommittedRoot common.Hash
1364+
13621365
// Prepare handles the preparatory steps for executing a state transition with.
13631366
// This method must be invoked before state transition.
13641367
//

0 commit comments

Comments
 (0)