mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-27 21:57:16 +00:00
d58d3f2c57
* rewrite/refactor deposit testing code keep track of sent deposits so that they can be compared in detail with the validator set retreived from the API. * fix bugs in evaluator and retry * lint + deepsource appeasement * typo s/Sprintf/Printf/ * gosec, more like nosec * fix gosec number - 204->304 * type switch to get signed block from container * improve comments * centralizing constants and adding comments * lock around Depositor to avoid future races Co-authored-by: Kasey Kirkham <kasey@users.noreply.github.com>
45 lines
1.4 KiB
Go
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(_ e2etypes.EvaluationContext, 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, ð.ListValidatorAssignmentsRequest{
|
|
QueryFilter: ð.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
|
|
}
|