Skip to content

Commit

Permalink
Patch release 2.55.1 (#8917)
Browse files Browse the repository at this point in the history
Cherry pick PRs #8851, #8911, #8817, #8913, #8908

---------

Co-authored-by: Alex Sharov <[email protected]>
Co-authored-by: a <[email protected]>
Co-authored-by: Giulio rebuffo <[email protected]>
Co-authored-by: Mark Holt <[email protected]>
  • Loading branch information
5 people authored Dec 6, 2023
1 parent b39f324 commit 12889fd
Show file tree
Hide file tree
Showing 104 changed files with 5,010 additions and 694 deletions.
2 changes: 0 additions & 2 deletions cl/abstract/beacon_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,6 @@ type BeaconStateMutator interface {
AddCurrentEpochAtteastation(attestation *solid.PendingAttestation)
AddPreviousEpochAttestation(attestation *solid.PendingAttestation)

IncrementSlashingSegmentAt(index int, delta uint64)

AppendValidator(in solid.Validator)

ResetEth1DataVotes()
Expand Down
59 changes: 40 additions & 19 deletions cl/antiquary/antiquary.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,39 +12,54 @@ import (
"github.com/ledgerwatch/erigon/cl/clparams"
"github.com/ledgerwatch/erigon/cl/persistence"
"github.com/ledgerwatch/erigon/cl/persistence/beacon_indicies"
state_accessors "github.com/ledgerwatch/erigon/cl/persistence/state"
"github.com/ledgerwatch/erigon/cl/phase1/core/state"
"github.com/ledgerwatch/erigon/cl/utils"
"github.com/ledgerwatch/erigon/turbo/snapshotsync/freezeblocks"
"github.com/ledgerwatch/log/v3"
"github.com/spf13/afero"
)

const safetyMargin = 10_000 // We retire snapshots 10k blocks after the finalized head

// Antiquary is where the snapshots go, aka old history, it is what keep track of the oldest records.
type Antiquary struct {
mainDB kv.RwDB // this is the main DB
dirs datadir.Dirs
downloader proto_downloader.DownloaderClient
logger log.Logger
sn *freezeblocks.CaplinSnapshots
ctx context.Context
beaconDB persistence.BlockSource
backfilled *atomic.Bool
cfg *clparams.BeaconChainConfig
mainDB kv.RwDB // this is the main DB
dirs datadir.Dirs
downloader proto_downloader.DownloaderClient
logger log.Logger
sn *freezeblocks.CaplinSnapshots
snReader freezeblocks.BeaconSnapshotReader
ctx context.Context
beaconDB persistence.BlockSource
backfilled *atomic.Bool
cfg *clparams.BeaconChainConfig
states bool
fs afero.Fs
validatorsTable *state_accessors.StaticValidatorTable
genesisState *state.CachingBeaconState
// set to nil
currentState *state.CachingBeaconState
}

func NewAntiquary(ctx context.Context, cfg *clparams.BeaconChainConfig, dirs datadir.Dirs, downloader proto_downloader.DownloaderClient, mainDB kv.RwDB, sn *freezeblocks.CaplinSnapshots, reader freezeblocks.BeaconSnapshotReader, beaconDB persistence.BlockSource, logger log.Logger) *Antiquary {
func NewAntiquary(ctx context.Context, genesisState *state.CachingBeaconState, validatorsTable *state_accessors.StaticValidatorTable, cfg *clparams.BeaconChainConfig, dirs datadir.Dirs, downloader proto_downloader.DownloaderClient, mainDB kv.RwDB, sn *freezeblocks.CaplinSnapshots, reader freezeblocks.BeaconSnapshotReader, beaconDB persistence.BlockSource, logger log.Logger, states bool, fs afero.Fs) *Antiquary {
backfilled := &atomic.Bool{}
backfilled.Store(false)
return &Antiquary{
mainDB: mainDB,
dirs: dirs,
downloader: downloader,
logger: logger,
sn: sn,
beaconDB: beaconDB,
ctx: ctx,
backfilled: backfilled,
cfg: cfg,
mainDB: mainDB,
dirs: dirs,
downloader: downloader,
logger: logger,
sn: sn,
beaconDB: beaconDB,
ctx: ctx,
backfilled: backfilled,
cfg: cfg,
states: states,
snReader: reader,
fs: fs,
validatorsTable: validatorsTable,
genesisState: genesisState,
}
}

Expand Down Expand Up @@ -94,6 +109,7 @@ func (a *Antiquary) Loop() error {
return err
}
defer logInterval.Stop()

// Now write the snapshots as indicies
for i := from; i < a.sn.BlocksAvailable(); i++ {
// read the snapshot
Expand Down Expand Up @@ -141,6 +157,10 @@ func (a *Antiquary) Loop() error {
}
}

if a.states {
go a.loopStates(a.ctx)
}

// write the indicies
if err := beacon_indicies.WriteLastBeaconSnapshot(tx, frozenSlots); err != nil {
return err
Expand Down Expand Up @@ -235,6 +255,7 @@ func (a *Antiquary) antiquate(from, to uint64) error {
return err
}
defer tx.Rollback()
a.validatorsTable.SetSlot(to)
if err := beacon_indicies.WriteLastBeaconSnapshot(tx, to-1); err != nil {
return err
}
Expand Down
Loading

0 comments on commit 12889fd

Please sign in to comment.