diff --git a/endtoend/BUILD.bazel b/endtoend/BUILD.bazel index f73d4907de..cb3782b300 100644 --- a/endtoend/BUILD.bazel +++ b/endtoend/BUILD.bazel @@ -7,8 +7,7 @@ go_test( srcs = [ "endtoend_test.go", "long_minimal_e2e_test.go", - "minimal_antiflake_e2e_1_test.go", - "minimal_antiflake_e2e_2_test.go", + "minimal_e2e_genesis_test.go", "minimal_e2e_test.go", "minimal_slashing_e2e_test.go", ], diff --git a/endtoend/README.md b/endtoend/README.md index 9fb7ee444a..4d03d40474 100644 --- a/endtoend/README.md +++ b/endtoend/README.md @@ -11,8 +11,8 @@ In order to "evaluate" the state of the beacon chain while the E2E is running, t Evaluators have 3 parts, the name for it's test name, a `policy` which declares which epoch(s) the evaluator should run, and then the `evaluation` which uses the beacon chain API to determine if the beacon chain passes certain conditions like finality. ## Current end-to-end tests -* Minimal Config - 4 beacon nodes, 64 validators, running for 6 epochs -* ~~Mainnet Config - 2 beacon nodes, 16,384 validators, running for 5 epochs~~ Disabled for now +* Minimal Config - 2 beacon nodes, 256 validators, running for 8 epochs +* Minimal Config Slashing Test - 2 beacon nodes, 256 validators, tests attester and proposer slashing ## Instructions If you wish to run all the E2E tests, you can run them through bazel with: @@ -20,8 +20,3 @@ If you wish to run all the E2E tests, you can run them through bazel with: ``` bazel test //endtoend:go_default_test --test_output=streamed --test_arg=-test.v --nocache_test_results ``` - -To run the anti-flake E2E tests, run: -``` -bazel test //endtoend:go_default_test --test_output=streamed --test_filter=TestEndToEnd_AntiFlake_MinimalConfig --test_arg=-test.v --nocache_test_results -``` \ No newline at end of file diff --git a/endtoend/components/beacon_node.go b/endtoend/components/beacon_node.go index 338965aeb7..7b10137051 100644 --- a/endtoend/components/beacon_node.go +++ b/endtoend/components/beacon_node.go @@ -54,8 +54,9 @@ func StartNewBeaconNode(t *testing.T, config *types.E2EConfig, index int, enr st fmt.Sprintf("--grpc-gateway-port=%d", e2e.TestParams.BeaconNodeRPCPort+index+40), fmt.Sprintf("--contract-deployment-block=%d", 0), fmt.Sprintf("--rpc-max-page-size=%d", params.BeaconConfig().MinGenesisActiveValidatorCount), - "--force-clear-db", fmt.Sprintf("--bootstrap-node=%s", enr), + "--force-clear-db", + "--e2e-config", } args = append(args, featureconfig.E2EBeaconChainFlags...) args = append(args, config.BeaconFlags...) diff --git a/endtoend/components/slasher.go b/endtoend/components/slasher.go index 214d8dfc79..8eff41285b 100644 --- a/endtoend/components/slasher.go +++ b/endtoend/components/slasher.go @@ -37,7 +37,7 @@ func StartSlashers(t *testing.T) []int { fmt.Sprintf("--beacon-rpc-provider=localhost:%d", e2e.TestParams.BeaconNodeRPCPort+i), "--force-clear-db", "--span-map-cache", - "--verbosity=debug", + "--e2e-config", } t.Logf("Starting slasher %d with flags: %s", i, strings.Join(args[2:], " ")) diff --git a/endtoend/components/validator.go b/endtoend/components/validator.go index 9d40aec0e9..0614c0af99 100644 --- a/endtoend/components/validator.go +++ b/endtoend/components/validator.go @@ -77,6 +77,7 @@ func StartNewValidatorClient(t *testing.T, config *types.E2EConfig, validatorNum fmt.Sprintf("--beacon-rpc-provider=localhost:%d", beaconRPCPort), "--grpc-headers=dummy=value,foo=bar", // Sending random headers shouldn't break anything. "--force-clear-db", + "--e2e-config", } args = append(args, featureconfig.E2EValidatorFlags...) args = append(args, config.ValidatorFlags...) diff --git a/endtoend/endtoend_test.go b/endtoend/endtoend_test.go index cfd7d7209c..5d97efe000 100644 --- a/endtoend/endtoend_test.go +++ b/endtoend/endtoend_test.go @@ -44,6 +44,8 @@ func runEndToEndTest(t *testing.T, config *types.E2EConfig) { defer helpers.LogOutput(t, config) defer helpers.KillProcesses(t, processIDs) + // Sleep depending on the count of validators, as generating the genesis state could take some time. + time.Sleep(time.Duration(params.BeaconConfig().MinGenesisDelay) * time.Second) beaconLogFile, err := os.Open(path.Join(e2e.TestParams.LogPath, fmt.Sprintf(e2e.BeaconNodeLogFileName, 0))) if err != nil { t.Fatal(err) diff --git a/endtoend/evaluators/slashing.go b/endtoend/evaluators/slashing.go index 8f63fd405a..cca22688c5 100644 --- a/endtoend/evaluators/slashing.go +++ b/endtoend/evaluators/slashing.go @@ -104,7 +104,7 @@ func insertDoubleAttestationIntoPool(conns ...*grpc.ClientConn) error { return errors.Wrap(err, "could not get chain head") } - _, privKeys, err := testutil.DeterministicDepositsAndKeys(64) + _, privKeys, err := testutil.DeterministicDepositsAndKeys(params.BeaconConfig().MinGenesisActiveValidatorCount) if err != nil { return err } @@ -192,7 +192,7 @@ func proposeDoubleBlock(conns ...*grpc.ClientConn) error { return errors.Wrap(err, "could not get chain head") } - _, privKeys, err := testutil.DeterministicDepositsAndKeys(64) + _, privKeys, err := testutil.DeterministicDepositsAndKeys(params.BeaconConfig().MinGenesisActiveValidatorCount) if err != nil { return err } diff --git a/endtoend/evaluators/validator.go b/endtoend/evaluators/validator.go index 10b27676c5..72ebf285bb 100644 --- a/endtoend/evaluators/validator.go +++ b/endtoend/evaluators/validator.go @@ -14,6 +14,8 @@ import ( "google.golang.org/grpc" ) +var expectedParticipation = 1 // 100% participation. + // ValidatorsAreActive ensures the expected amount of validators are active. var ValidatorsAreActive = types.Evaluator{ Name: "validators_active_epoch_%d", @@ -126,7 +128,7 @@ func validatorsParticipating(conns ...*grpc.ClientConn) error { } partRate := participation.Participation.GlobalParticipationRate - expected := float32(1) + expected := float32(expectedParticipation) if partRate < expected { return fmt.Errorf( "validator participation was below for epoch %d, expected %f, received: %f", diff --git a/endtoend/helpers/helpers.go b/endtoend/helpers/helpers.go index ea57e6f622..e753d98713 100644 --- a/endtoend/helpers/helpers.go +++ b/endtoend/helpers/helpers.go @@ -19,7 +19,7 @@ import ( ) const ( - maxPollingWaitTime = 60 * time.Second + maxPollingWaitTime = 60 * time.Second // A minute so timing out doesn't take very long. filePollingInterval = 500 * time.Millisecond ) diff --git a/endtoend/long_minimal_e2e_test.go b/endtoend/long_minimal_e2e_test.go index df539a2a79..329433ef6f 100644 --- a/endtoend/long_minimal_e2e_test.go +++ b/endtoend/long_minimal_e2e_test.go @@ -14,7 +14,7 @@ import ( func TestEndToEnd_Long_MinimalConfig(t *testing.T) { testutil.ResetCache() - params.UseMinimalConfig() + params.UseE2EConfig() epochsToRun := 20 var err error @@ -29,8 +29,8 @@ func TestEndToEnd_Long_MinimalConfig(t *testing.T) { } minimalConfig := &types.E2EConfig{ - BeaconFlags: []string{"--minimal-config", "--custom-genesis-delay=25"}, - ValidatorFlags: []string{"--minimal-config"}, + BeaconFlags: []string{}, + ValidatorFlags: []string{}, EpochsToRun: uint64(epochsToRun), TestSync: false, TestDeposits: true, diff --git a/endtoend/minimal_antiflake_e2e_2_test.go b/endtoend/minimal_antiflake_e2e_2_test.go deleted file mode 100644 index 0e3f5f5a41..0000000000 --- a/endtoend/minimal_antiflake_e2e_2_test.go +++ /dev/null @@ -1,36 +0,0 @@ -package endtoend - -import ( - "testing" - - ev "github.com/prysmaticlabs/prysm/endtoend/evaluators" - e2eParams "github.com/prysmaticlabs/prysm/endtoend/params" - "github.com/prysmaticlabs/prysm/endtoend/types" - "github.com/prysmaticlabs/prysm/shared/params" - "github.com/prysmaticlabs/prysm/shared/testutil" -) - -func TestEndToEnd_AntiFlake_MinimalConfig_2(t *testing.T) { - testutil.ResetCache() - params.UseMinimalConfig() - - minimalConfig := &types.E2EConfig{ - BeaconFlags: []string{"--minimal-config", "--custom-genesis-delay=25"}, - ValidatorFlags: []string{"--minimal-config"}, - EpochsToRun: 4, - TestSync: false, - TestSlasher: false, - Evaluators: []types.Evaluator{ - ev.PeersConnect, - ev.HealthzCheck, - ev.ValidatorsAreActive, - ev.ValidatorsParticipating, - ev.MetricsCheck, - }, - } - if err := e2eParams.Init(2); err != nil { - t.Fatal(err) - } - - runEndToEndTest(t, minimalConfig) -} diff --git a/endtoend/minimal_antiflake_e2e_1_test.go b/endtoend/minimal_e2e_genesis_test.go similarity index 76% rename from endtoend/minimal_antiflake_e2e_1_test.go rename to endtoend/minimal_e2e_genesis_test.go index 34ffcd0047..98938f9e5c 100644 --- a/endtoend/minimal_antiflake_e2e_1_test.go +++ b/endtoend/minimal_e2e_genesis_test.go @@ -10,13 +10,13 @@ import ( "github.com/prysmaticlabs/prysm/shared/testutil" ) -func TestEndToEnd_AntiFlake_MinimalConfig_1(t *testing.T) { +func TestEndToEnd_Genesis_MinimalConfig(t *testing.T) { testutil.ResetCache() - params.UseMinimalConfig() + params.UseE2EConfig() minimalConfig := &types.E2EConfig{ - BeaconFlags: []string{"--minimal-config", "--custom-genesis-delay=25"}, - ValidatorFlags: []string{"--minimal-config"}, + BeaconFlags: []string{}, + ValidatorFlags: []string{}, EpochsToRun: 4, TestSync: false, TestSlasher: false, diff --git a/endtoend/minimal_e2e_test.go b/endtoend/minimal_e2e_test.go index f838932db5..83c53cfd15 100644 --- a/endtoend/minimal_e2e_test.go +++ b/endtoend/minimal_e2e_test.go @@ -12,12 +12,12 @@ import ( func TestEndToEnd_MinimalConfig(t *testing.T) { testutil.ResetCache() - params.UseMinimalConfig() + params.UseE2EConfig() minimalConfig := &types.E2EConfig{ - BeaconFlags: []string{"--minimal-config", "--custom-genesis-delay=25"}, - ValidatorFlags: []string{"--minimal-config"}, - EpochsToRun: 6, + BeaconFlags: []string{}, + ValidatorFlags: []string{}, + EpochsToRun: 8, TestSync: true, TestSlasher: true, Evaluators: []types.Evaluator{ diff --git a/endtoend/minimal_slashing_e2e_test.go b/endtoend/minimal_slashing_e2e_test.go index 056d7c0a45..f29f64c333 100644 --- a/endtoend/minimal_slashing_e2e_test.go +++ b/endtoend/minimal_slashing_e2e_test.go @@ -12,11 +12,11 @@ import ( func TestEndToEnd_Slashing_MinimalConfig(t *testing.T) { testutil.ResetCache() - params.UseMinimalConfig() + params.UseE2EConfig() minimalConfig := &types.E2EConfig{ - BeaconFlags: []string{"--minimal-config", "--custom-genesis-delay=25"}, - ValidatorFlags: []string{"--minimal-config"}, + BeaconFlags: []string{}, + ValidatorFlags: []string{}, EpochsToRun: 3, TestSync: false, TestSlasher: true, diff --git a/shared/featureconfig/config.go b/shared/featureconfig/config.go index 89adb35278..8d31153b75 100644 --- a/shared/featureconfig/config.go +++ b/shared/featureconfig/config.go @@ -29,7 +29,11 @@ var log = logrus.WithField("prefix", "flags") // Flags is a struct to represent which features the client will perform on runtime. type Flags struct { - MinimalConfig bool // MinimalConfig as defined in the spec. + // Configuration related flags. + MinimalConfig bool // MinimalConfig as defined in the spec. + E2EConfig bool //E2EConfig made specifically for testing, do not use except in E2E. + + // Feature related flags. WriteSSZStateTransitions bool // WriteSSZStateTransitions to tmp directory. InitSyncNoVerify bool // InitSyncNoVerify when initial syncing w/o verifying block's contents. DisableDynamicCommitteeSubnets bool // Disables dynamic attestation committee subnets via p2p. @@ -280,6 +284,10 @@ func configureConfig(ctx *cli.Context, cfg *Flags) *Flags { log.Warn("Using minimal config") cfg.MinimalConfig = true params.UseMinimalConfig() + } else if ctx.Bool(e2eConfigFlag.Name) { + log.Warn("Using end-to-end testing config") + cfg.MinimalConfig = true + params.UseE2EConfig() } return cfg } diff --git a/shared/featureconfig/flags.go b/shared/featureconfig/flags.go index dad1b793b8..35a9c05420 100644 --- a/shared/featureconfig/flags.go +++ b/shared/featureconfig/flags.go @@ -17,6 +17,10 @@ var ( Name: "minimal-config", Usage: "Use minimal config with parameters as defined in the spec.", } + e2eConfigFlag = &cli.BoolFlag{ + Name: "e2e-config", + Usage: "Use the E2E testing config, only for use within end-to-end testing.", + } writeSSZStateTransitionsFlag = &cli.BoolFlag{ Name: "interop-write-ssz-state-transitions", Usage: "Write ssz states to disk after attempted state transition", @@ -415,6 +419,7 @@ var deprecatedFlags = []cli.Flag{ // ValidatorFlags contains a list of all the feature flags that apply to the validator client. var ValidatorFlags = append(deprecatedFlags, []cli.Flag{ minimalConfigFlag, + e2eConfigFlag, enableProtectAttesterFlag, enableProtectProposerFlag, enableExternalSlasherProtectionFlag, @@ -424,6 +429,7 @@ var ValidatorFlags = append(deprecatedFlags, []cli.Flag{ // SlasherFlags contains a list of all the feature flags that apply to the slasher client. var SlasherFlags = append(deprecatedFlags, []cli.Flag{ + e2eConfigFlag, enableHistoricalDetectionFlag, disableLookbackFlag, }...) @@ -440,6 +446,7 @@ var BeaconChainFlags = append(deprecatedFlags, []cli.Flag{ devModeFlag, customGenesisDelayFlag, minimalConfigFlag, + e2eConfigFlag, writeSSZStateTransitionsFlag, disableForkChoiceUnsafeFlag, disableDynamicCommitteeSubnets, @@ -469,7 +476,6 @@ var BeaconChainFlags = append(deprecatedFlags, []cli.Flag{ // E2EBeaconChainFlags contains a list of the beacon chain feature flags to be tested in E2E. var E2EBeaconChainFlags = []string{ "--cache-filtered-block-tree", - "--enable-byte-mempool", "--enable-state-gen-sig-verify", "--check-head-state", "--enable-state-field-trie", diff --git a/shared/params/config.go b/shared/params/config.go index 897a694ac9..d192cdf7d4 100644 --- a/shared/params/config.go +++ b/shared/params/config.go @@ -303,11 +303,32 @@ func MinimalSpecConfig() *BeaconChainConfig { return &minimalConfig } +// E2ETestConfig retrieves the configurations made specifically for E2E testing. +// Warning: This config is only for testing, it is not meant for use outside of E2E. +func E2ETestConfig() *BeaconChainConfig { + e2eConfig := MinimalSpecConfig() + + // Misc. + e2eConfig.MinGenesisActiveValidatorCount = 256 + e2eConfig.MinGenesisDelay = 30 // 30 seconds so E2E has enough time to process deposits and get started. + + // Time parameters. + e2eConfig.SecondsPerSlot = 8 + e2eConfig.SecondsPerETH1Block = 2 + e2eConfig.Eth1FollowDistance = 4 + return e2eConfig +} + // UseMinimalConfig for beacon chain services. func UseMinimalConfig() { beaconConfig = MinimalSpecConfig() } +// UseE2EConfig for beacon chain services. +func UseE2EConfig() { + beaconConfig = E2ETestConfig() +} + // UseMainnetConfig for beacon chain services. func UseMainnetConfig() { beaconConfig = MainnetConfig()