mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 12:57:18 +00:00
Fix cold state replay to start at correct slot (#6361)
* Fix off by 1 * Regression tests * Merge branch 'master' of github.com:prysmaticlabs/prysm into fix-offset * Go fmt * Merge refs/heads/master into fix-offset * Merge refs/heads/master into fix-offset
This commit is contained in:
parent
81786159e9
commit
c417b00675
@ -312,11 +312,7 @@ func (s *State) genesisRoot(ctx context.Context) ([32]byte, error) {
|
||||
// If the archived root is not available at that exact input slot due to an event of skip block,
|
||||
// this will look back and return the last available archived root (ie. the one with the highest slot below input slot).
|
||||
func (s *State) archivedRoot(ctx context.Context, slot uint64) ([32]byte, error) {
|
||||
archivedIndex := uint64(0)
|
||||
if slot/params.BeaconConfig().SlotsPerArchivedPoint > 1 {
|
||||
archivedIndex = slot/params.BeaconConfig().SlotsPerArchivedPoint - 1
|
||||
}
|
||||
|
||||
archivedIndex := slot / params.BeaconConfig().SlotsPerArchivedPoint
|
||||
for archivedIndex > 0 {
|
||||
if ctx.Err() != nil {
|
||||
return [32]byte{}, ctx.Err()
|
||||
|
@ -630,7 +630,14 @@ func TestArchivedState_CanGetSpecificIndex(t *testing.T) {
|
||||
if err := db.SaveState(ctx, beaconState, r); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
got, err := service.archivedState(ctx, params.BeaconConfig().SlotsPerArchivedPoint*2)
|
||||
got, err := service.archivedState(ctx, params.BeaconConfig().SlotsPerArchivedPoint)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !reflect.DeepEqual(got.InnerStateUnsafe(), beaconState.InnerStateUnsafe()) {
|
||||
t.Error("Did not get wanted state")
|
||||
}
|
||||
got, err = service.archivedState(ctx, params.BeaconConfig().SlotsPerArchivedPoint*2)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user