Skip to content

Commit

Permalink
Caplin: fix reusable states during reorg (#13117)
Browse files Browse the repository at this point in the history
this seems to be source of instability
  • Loading branch information
Giulio2002 authored Dec 16, 2024
1 parent ac1ca33 commit 38482df
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion cl/phase1/forkchoice/fork_graph/fork_graph_disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/spf13/afero"

libcommon "github.com/erigontech/erigon-lib/common"
"github.com/erigontech/erigon-lib/common/dbg"
"github.com/erigontech/erigon-lib/log/v3"
"github.com/erigontech/erigon/cl/beacon/beacon_router_configuration"
"github.com/erigontech/erigon/cl/beacon/beaconevents"
Expand Down Expand Up @@ -355,7 +356,7 @@ func (f *forkGraphDisk) getState(blockRoot libcommon.Hash, alwaysCopy bool, addC
currentIteratorRoot := blockRoot
var copyReferencedState, outState *state.CachingBeaconState
var err error
if addChainSegment {
if addChainSegment && dbg.CaplinEfficientReorg {
outState = f.currentState
}

Expand Down
7 changes: 3 additions & 4 deletions cl/phase1/forkchoice/fork_graph/fork_graph_disk_fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,12 @@ func (f *forkGraphDisk) readBeaconStateFromDisk(blockRoot libcommon.Hash, out *s
}
defer cacheFile.Close()

f.sszBuffer = f.sszBuffer[:0]
b := bytes.NewBuffer(f.sszBuffer)
if _, err := io.Copy(b, cacheFile); err != nil {
b := bytes.Buffer{}
if _, err := io.Copy(&b, cacheFile); err != nil {
return nil, err
}

if err := bs.DecodeCaches(b); err != nil {
if err := bs.DecodeCaches(&b); err != nil {
return nil, err
}

Expand Down
1 change: 1 addition & 0 deletions erigon-lib/common/dbg/experiments.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ var (
CommitEachStage = EnvBool("COMMIT_EACH_STAGE", false)

CaplinSyncedDataMangerDeadlockDetection = EnvBool("CAPLIN_SYNCED_DATA_MANAGER_DEADLOCK_DETECTION", false)
CaplinEfficientReorg = EnvBool("CAPLIN_EFFICIENT_REORG", true)
)

func ReadMemStats(m *runtime.MemStats) {
Expand Down

0 comments on commit 38482df

Please sign in to comment.