mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-04 00:44:27 +00:00
68edad13bc
* Begin working on end to end tests using geth dev chain * Start on beacon node set up * More progress on bnode setup * Complete flow until chainstart, begin work on evaluators * More progress on evaluators * Start changing bazel run to direct binary * Move endtoend to inside beacon-chain * use bazel provided geth, use bazel test * tempdir * use fork rules_go * Change to use UUID dir and bazel binaries * Truncate UUID a bit * Get full run from chainstart to evaluating * Rewrite to react to logs rather than arbitrarily wait * Fix export * Move evaluators to evaluators.go * Add peer check test * Add more comments * Remove unneeded exports * Check all nodes have the correct amount of peers * Change name to onGenesisEpoch * Remove extra wait times where not needed * Cleanup * Add log for beacon start * Fix deposit amount * Make room for eth1follow distnce * Cleanup and fix minimal test * Goimports * Fix imports * gazelle and minimal * manual * Fix for comments * Make timing rely on reading logs, and cleanup * Fix for comments * Fix workspace * Cleanup * Fix visibility * Cleanup and some comments * Address comments * Fix for v0.9 * Modify for v0.9 * Move to own package outside of beacon-chain * Gazelle * Polishing, logging * Fix filenames * Add more logs * Add flag logging * Cover for page not having libp2p info * Improve multiAddr detection * Add more logs * Add missing flags * Add log printing to defer * Get multiAddr from logs * Fix logging and detection * Change evaluators to rely on EpochTimer * Add evaluator for ValidatorParticipation * Fix validator participation evaluator * Cleanup, comments and fix participation calculation * Cleanup * Let the file searcher search for longer * Change participation to check for full * Log out file contents if text isnt found * Split into different files * Disable IPC and use RPC instead, change tmp dir to bazel dir * Change visibility * Gazelle * Add e2e tag * new line
55 lines
1.7 KiB
Go
55 lines
1.7 KiB
Go
package evaluators
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
ptypes "github.com/gogo/protobuf/types"
|
|
"github.com/pkg/errors"
|
|
"github.com/prysmaticlabs/prysm/proto/eth/v1alpha1"
|
|
"github.com/prysmaticlabs/prysm/shared/params"
|
|
)
|
|
|
|
// FinalizationOccurs is an evaluator to make sure finalization is performing as it should.
|
|
// Requires to be run after at least 4 epochs have passed.
|
|
var FinalizationOccurs = Evaluator{
|
|
Name: "finalizes_at_epoch_%d",
|
|
Policy: afterNthEpoch(3),
|
|
Evaluation: finalizationOccurs,
|
|
}
|
|
|
|
func finalizationOccurs(client eth.BeaconChainClient) error {
|
|
chainHead, err := client.GetChainHead(context.Background(), &ptypes.Empty{})
|
|
if err != nil {
|
|
return errors.Wrap(err, "failed to get chain head")
|
|
}
|
|
currentEpoch := chainHead.BlockSlot / params.BeaconConfig().SlotsPerEpoch
|
|
finalizedEpoch := chainHead.FinalizedSlot / params.BeaconConfig().SlotsPerEpoch
|
|
|
|
expectedFinalizedEpoch := currentEpoch - 2
|
|
if expectedFinalizedEpoch != finalizedEpoch {
|
|
return fmt.Errorf(
|
|
"expected finalized epoch to be %d, received: %d",
|
|
expectedFinalizedEpoch,
|
|
finalizedEpoch,
|
|
)
|
|
}
|
|
previousJustifiedEpoch := chainHead.PreviousJustifiedSlot / params.BeaconConfig().SlotsPerEpoch
|
|
currentJustifiedEpoch := chainHead.JustifiedSlot / params.BeaconConfig().SlotsPerEpoch
|
|
if previousJustifiedEpoch+1 != currentJustifiedEpoch {
|
|
return fmt.Errorf(
|
|
"there should be no gaps between current and previous justified epochs, received current %d and previous %d",
|
|
currentJustifiedEpoch,
|
|
previousJustifiedEpoch,
|
|
)
|
|
}
|
|
if currentJustifiedEpoch+1 != currentEpoch {
|
|
return fmt.Errorf(
|
|
"there should be no gaps between current epoch and current justified epoch, received current %d and justified %d",
|
|
currentEpoch,
|
|
currentJustifiedEpoch,
|
|
)
|
|
}
|
|
return nil
|
|
}
|