prysm-pulse/testing/endtoend/evaluators/data.go
Raul Jordan d077483577
Add V3 Suffix to All Prysm Packages (#11083)
* v3 import renamings

* tidy

* fmt

* rev

* Update beacon-chain/core/epoch/precompute/reward_penalty_test.go

* Update beacon-chain/core/helpers/validators_test.go

* Update beacon-chain/db/alias.go

* Update beacon-chain/db/alias.go

* Update beacon-chain/db/alias.go

* Update beacon-chain/db/iface/BUILD.bazel

* Update beacon-chain/db/kv/kv.go

* Update beacon-chain/db/kv/state.go

* Update beacon-chain/rpc/prysm/v1alpha1/validator/attester_test.go

* Update beacon-chain/rpc/prysm/v1alpha1/validator/attester_test.go

* Update beacon-chain/sync/initial-sync/service.go

* fix deps

* fix bad replacements

* fix bad replacements

* change back

* gohashtree version

* fix deps

Co-authored-by: Nishant Das <nishdas93@gmail.com>
Co-authored-by: Potuz <potuz@prysmaticlabs.com>
2022-08-16 12:20:13 +00:00

45 lines
1.4 KiB
Go

package evaluators
import (
"context"
"errors"
types "github.com/prysmaticlabs/prysm/v3/consensus-types/primitives"
eth "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
e2etypes "github.com/prysmaticlabs/prysm/v3/testing/endtoend/types"
"google.golang.org/grpc"
)
const epochToCheck = 50 // must be more than 46 (32 hot states + 16 chkpt interval)
// ColdStateCheckpoint checks data from the database using cold state storage.
var ColdStateCheckpoint = e2etypes.Evaluator{
Name: "cold_state_assignments_from_epoch_%d",
Policy: func(currentEpoch types.Epoch) bool {
return currentEpoch == epochToCheck
},
Evaluation: checkColdStateCheckpoint,
}
// Checks the first node for an old checkpoint using cold state storage.
func checkColdStateCheckpoint(conns ...*grpc.ClientConn) error {
ctx := context.Background()
client := eth.NewBeaconChainClient(conns[0])
for i := types.Epoch(0); i < epochToCheck; i++ {
res, err := client.ListValidatorAssignments(ctx, &eth.ListValidatorAssignmentsRequest{
QueryFilter: &eth.ListValidatorAssignmentsRequest_Epoch{Epoch: i},
})
if err != nil {
return err
}
// A simple check to ensure we received some data.
if res == nil || res.Epoch != i {
return errors.New("failed to return a validator assignments response for an old epoch " +
"using cold state storage from the database")
}
}
return nil
}