Skip to content

Commit 0ca5c6d

Browse files
authored
Caplin: removed reusable states in reorg (not really used anymore) (#13893)
1 parent 52a4392 commit 0ca5c6d

File tree

3 files changed

+5
-14
lines changed

3 files changed

+5
-14
lines changed

cl/phase1/forkchoice/fork_graph/fork_graph_disk.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import (
2626
"github.com/spf13/afero"
2727

2828
libcommon "github.com/erigontech/erigon-lib/common"
29-
"github.com/erigontech/erigon-lib/common/dbg"
3029
"github.com/erigontech/erigon-lib/log/v3"
3130
"github.com/erigontech/erigon/cl/beacon/beacon_router_configuration"
3231
"github.com/erigontech/erigon/cl/beacon/beaconevents"
@@ -421,11 +420,8 @@ func (f *forkGraphDisk) getState(blockRoot libcommon.Hash, alwaysCopy bool, addC
421420
blocksInTheWay := []*cltypes.SignedBeaconBlock{}
422421
// Use the parent root as a reverse iterator.
423422
currentIteratorRoot := blockRoot
424-
var copyReferencedState, outState *state.CachingBeaconState
423+
var copyReferencedState *state.CachingBeaconState
425424
var err error
426-
if addChainSegment && dbg.CaplinEfficientReorg {
427-
outState = f.currentState
428-
}
429425

430426
// try and find the point of recconnection
431427
for copyReferencedState == nil {
@@ -434,7 +430,7 @@ func (f *forkGraphDisk) getState(blockRoot libcommon.Hash, alwaysCopy bool, addC
434430
// check if it is in the header
435431
bHeader, ok := f.GetHeader(currentIteratorRoot)
436432
if ok && bHeader.Slot%dumpSlotFrequency == 0 {
437-
copyReferencedState, err = f.readBeaconStateFromDisk(currentIteratorRoot, outState)
433+
copyReferencedState, err = f.readBeaconStateFromDisk(currentIteratorRoot)
438434
if err != nil {
439435
log.Trace("Could not retrieve state: Missing header", "missing", currentIteratorRoot, "err", err)
440436
copyReferencedState = nil
@@ -445,7 +441,7 @@ func (f *forkGraphDisk) getState(blockRoot libcommon.Hash, alwaysCopy bool, addC
445441
return nil, nil
446442
}
447443
if block.Block.Slot%dumpSlotFrequency == 0 {
448-
copyReferencedState, err = f.readBeaconStateFromDisk(currentIteratorRoot, outState)
444+
copyReferencedState, err = f.readBeaconStateFromDisk(currentIteratorRoot)
449445
if err != nil {
450446
log.Trace("Could not retrieve state: Missing header", "missing", currentIteratorRoot, "err", err)
451447
}

cl/phase1/forkchoice/fork_graph/fork_graph_disk_fs.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func getBeaconStateFilename(blockRoot libcommon.Hash) string {
3434
return fmt.Sprintf("%x.snappy_ssz", blockRoot)
3535
}
3636

37-
func (f *forkGraphDisk) readBeaconStateFromDisk(blockRoot libcommon.Hash, out *state.CachingBeaconState) (bs *state.CachingBeaconState, err error) {
37+
func (f *forkGraphDisk) readBeaconStateFromDisk(blockRoot libcommon.Hash) (bs *state.CachingBeaconState, err error) {
3838
var file afero.File
3939
f.stateDumpLock.Lock()
4040
defer f.stateDumpLock.Unlock()
@@ -72,11 +72,7 @@ func (f *forkGraphDisk) readBeaconStateFromDisk(blockRoot libcommon.Hash, out *s
7272
return nil, fmt.Errorf("failed to read snappy buffer: %w, root: %x", err, blockRoot)
7373
}
7474
f.sszBuffer = f.sszBuffer[:n]
75-
if out == nil {
76-
bs = state.New(f.beaconCfg)
77-
} else {
78-
bs = out
79-
}
75+
bs = state.New(f.beaconCfg)
8076

8177
if err = bs.DecodeSSZ(f.sszBuffer, int(v[0])); err != nil {
8278
return nil, fmt.Errorf("failed to decode beacon state: %w, root: %x, len: %d, decLen: %d, bs: %+v", err, blockRoot, n, len(f.sszBuffer), bs)

erigon-lib/common/dbg/experiments.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ var (
6767
CommitEachStage = EnvBool("COMMIT_EACH_STAGE", false)
6868

6969
CaplinSyncedDataMangerDeadlockDetection = EnvBool("CAPLIN_SYNCED_DATA_MANAGER_DEADLOCK_DETECTION", false)
70-
CaplinEfficientReorg = EnvBool("CAPLIN_EFFICIENT_REORG", true)
7170
)
7271

7372
func ReadMemStats(m *runtime.MemStats) {

0 commit comments

Comments
 (0)