You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The stategen.StateManager interface defines methods to retrieve the state by root for initial sync and during regular block syncing, StateByRoot and StateByRootInitialSync. These methods both have identical logic to check if the zero root is being requested and retrieve the state from the database in that case. This happens in interop / when truly starting from genesis (not using initial sync) before the justified/finalized checkpoints have been set to roots beyond the genesis block's parent root. So in practice this is not a common problem, but the code is logically incorrect, as demonstrated by a simple program running against the database of a synced beacon node db:
package main
import (
"context"
log "github.com/sirupsen/logrus"
"github.com/prysmaticlabs/prysm/beacon-chain/db/kv"
"github.com/prysmaticlabs/prysm/config/params"
)
func main() {
path := "/var/lib/prysm/prater"
ctx := context.Background()
db, err := kv.NewKVStore(ctx, path, &kv.Config{})
if err != nil {
log.Fatalf("error calling NewKVStore, err=%v", err)
}
state, err := db.State(ctx, params.BeaconConfig().ZeroHash)
if err != nil {
log.Fatalf("error calling State() method on db, err=%v", err)
}
if state == nil || state.IsNil() {
log.Fatalf("got nil state from db.State")
}
log.Info("%#x", state.FinalizedCheckpoint().Root)
}
$ go run main.go
FATA[0000] got nil state from db.State
exit status 1
However the state can be fetched as expected using the beacondb GenesisState method. Suggested solution is to change StateByRoot/StateByRootInitialSync to use this method when the zero root is detected, in place of attempting to fetch the state via the zero root.
Has this worked before in a previous version?
unclear, it seems that this bug likely only occurs in edge cases, and it may be the case that something in the interop set up prevents it from happening.
🔬 Minimal Reproduction
run the program above
🔥 Error
$ go run main.go
FATA[0000] got nil state from db.State
exit status 1
What version of Prysm are you running? (Which release)
current develop branch
The text was updated successfully, but these errors were encountered:
🐞 Bug Report
Description
The stategen.StateManager interface defines methods to retrieve the state by root for initial sync and during regular block syncing,
StateByRoot
andStateByRootInitialSync
. These methods both have identical logic to check if the zero root is being requested and retrieve the state from the database in that case. This happens in interop / when truly starting from genesis (not using initial sync) before the justified/finalized checkpoints have been set to roots beyond the genesis block's parent root. So in practice this is not a common problem, but the code is logically incorrect, as demonstrated by a simple program running against the database of a synced beacon node db:However the state can be fetched as expected using the beacondb
GenesisState
method. Suggested solution is to changeStateByRoot
/StateByRootInitialSync
to use this method when the zero root is detected, in place of attempting to fetch the state via the zero root.Has this worked before in a previous version?
unclear, it seems that this bug likely only occurs in edge cases, and it may be the case that something in the interop set up prevents it from happening.
🔬 Minimal Reproduction
run the program above
🔥 Error
What version of Prysm are you running? (Which release)
current develop branch
The text was updated successfully, but these errors were encountered: