Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace no-genesis-delay with custom-genesis-delay #4678

Merged
merged 9 commits into from Jan 28, 2020
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -197,7 +197,7 @@ Open up two terminal windows. In the first, issue the command:

```text
bazel run //beacon-chain -- \
--no-genesis-delay \
--custom-genesis-delay=0 \
--bootstrap-node= \
--deposit-contract $(curl https://prylabs.net/contract) \
--clear-db \
Expand Down
1 change: 1 addition & 0 deletions beacon-chain/powchain/BUILD.bazel
Expand Up @@ -76,6 +76,7 @@ go_test(
"//shared/bls:go_default_library",
"//shared/bytesutil:go_default_library",
"//shared/event:go_default_library",
"//shared/featureconfig:go_default_library",
"//shared/params:go_default_library",
"//shared/testutil:go_default_library",
"//shared/trieutil:go_default_library",
Expand Down
6 changes: 3 additions & 3 deletions beacon-chain/powchain/log_processing.go
Expand Up @@ -240,12 +240,12 @@ func (s *Service) ProcessChainStart(genesisTime uint64, eth1BlockHash [32]byte,
}

func (s *Service) createGenesisTime(timeStamp uint64) uint64 {
if featureconfig.Get().NoGenesisDelay {
if featureconfig.Get().CustomGenesisDelay == 0 {
return timeStamp
}
timeStampRdDown := timeStamp - timeStamp%params.BeaconConfig().MinGenesisDelay
timeStampRdDown := timeStamp - timeStamp%featureconfig.Get().CustomGenesisDelay
// genesisTime will be set to the first second of the day, two days after it was triggered.
return timeStampRdDown + 2*params.BeaconConfig().MinGenesisDelay
return timeStampRdDown + 2*featureconfig.Get().CustomGenesisDelay
}

// processPastLogs processes all the past logs from the deposit contract and
Expand Down
5 changes: 5 additions & 0 deletions beacon-chain/powchain/log_processing_test.go
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/prysmaticlabs/prysm/beacon-chain/flags"
mockPOW "github.com/prysmaticlabs/prysm/beacon-chain/powchain/testing"
contracts "github.com/prysmaticlabs/prysm/contracts/deposit-contract"
"github.com/prysmaticlabs/prysm/shared/featureconfig"
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/prysmaticlabs/prysm/shared/testutil"
"github.com/prysmaticlabs/prysm/shared/trieutil"
Expand Down Expand Up @@ -322,6 +323,10 @@ func TestProcessETH2GenesisLog_8DuplicatePubkeys(t *testing.T) {
}

func TestProcessETH2GenesisLog(t *testing.T) {
config := &featureconfig.Flags{
CustomGenesisDelay: 0,
}
featureconfig.Init(config)
hook := logTest.NewGlobal()
testAcc, err := contracts.Setup()
if err != nil {
Expand Down
1 change: 0 additions & 1 deletion endtoend/beacon_node.go
Expand Up @@ -56,7 +56,6 @@ func startNewBeaconNode(t *testing.T, config *end2EndConfig, beaconNodes []*ev.B
}

args := []string{
"--no-genesis-delay",
"--force-clear-db",
"--no-discovery",
"--http-web3provider=http://127.0.0.1:8745",
Expand Down
2 changes: 1 addition & 1 deletion endtoend/demo_e2e_test.go
Expand Up @@ -15,7 +15,7 @@ func TestEndToEnd_DemoConfig(t *testing.T) {
params.UseDemoBeaconConfig()

demoConfig := &end2EndConfig{
beaconFlags: featureconfig.E2EBeaconChainFlags,
beaconFlags: append(featureconfig.E2EBeaconChainFlags, "--custom-genesis-delay=60"),
validatorFlags: featureconfig.E2EValidatorFlags,
epochsToRun: 5,
numBeaconNodes: 2,
Expand Down
2 changes: 1 addition & 1 deletion endtoend/minimal_e2e_test.go
Expand Up @@ -14,7 +14,7 @@ func TestEndToEnd_MinimalConfig(t *testing.T) {
params.UseMinimalConfig()

minimalConfig := &end2EndConfig{
beaconFlags: append(featureconfig.E2EBeaconChainFlags, "--minimal-config"),
beaconFlags: append(featureconfig.E2EBeaconChainFlags, "--minimal-config", "--custom-genesis-delay=15"),
validatorFlags: append(featureconfig.E2EValidatorFlags, "--minimal-config"),
epochsToRun: 6,
numBeaconNodes: 4,
Expand Down
1 change: 1 addition & 0 deletions shared/featureconfig/BUILD.bazel
Expand Up @@ -9,6 +9,7 @@ go_library(
importpath = "github.com/prysmaticlabs/prysm/shared/featureconfig",
visibility = ["//visibility:public"],
deps = [
"//shared/params:go_default_library",
"@com_github_sirupsen_logrus//:go_default_library",
"@com_github_urfave_cli//:go_default_library",
],
Expand Down
10 changes: 6 additions & 4 deletions shared/featureconfig/config.go
Expand Up @@ -19,6 +19,7 @@ The process for implementing new features using this package is as follows:
package featureconfig

import (
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
)
Expand All @@ -27,7 +28,7 @@ var log = logrus.WithField("prefix", "flags")

// Flags is a struct to represent which features the client will perform on runtime.
type Flags struct {
NoGenesisDelay bool // NoGenesisDelay signals to start the chain as quickly as possible.
CustomGenesisDelay uint64 // CustomGenesisDelay signals how long of a delay to set to start the chain.
MinimalConfig bool // MinimalConfig as defined in the spec.
WriteSSZStateTransitions bool // WriteSSZStateTransitions to tmp directory.
InitSyncNoVerify bool // InitSyncNoVerify when initial syncing w/o verifying block's contents.
Expand Down Expand Up @@ -76,9 +77,10 @@ func Init(c *Flags) {
func ConfigureBeaconChain(ctx *cli.Context) {
complainOnDeprecatedFlags(ctx)
cfg := &Flags{}
if ctx.GlobalBool(noGenesisDelayFlag.Name) {
log.Warn("Starting ETH2 with no genesis delay")
cfg.NoGenesisDelay = true
if ctx.GlobalUint64(customGenesisDelayFlag.Name) != params.BeaconConfig().MinGenesisDelay {
delay := ctx.GlobalUint64(customGenesisDelayFlag.Name)
log.Warnf("Starting ETH2 with genesis delay of %d seconds", delay)
cfg.CustomGenesisDelay = delay
}
if ctx.GlobalBool(minimalConfigFlag.Name) {
log.Warn("Using minimal config")
Expand Down
13 changes: 7 additions & 6 deletions shared/featureconfig/flags.go
@@ -1,6 +1,7 @@
package featureconfig

import (
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/urfave/cli"
)

Expand Down Expand Up @@ -68,11 +69,11 @@ var (
Usage: "Enables connection to a slasher service in order to retrieve slashable events. Slasher is connected to the beacon node using gRPC and " +
"the slasher-provider flag can be used to pass its address.",
}
noGenesisDelayFlag = cli.BoolFlag{
Name: "no-genesis-delay",
Usage: "Start the genesis event right away using the eth1 block timestamp which " +
"triggered the genesis as the genesis time. This flag should be used for local " +
"development and testing only.",
customGenesisDelayFlag = cli.Uint64Flag{
Name: "custom-genesis-delay",
Usage: "Start the genesis event with the configured genesis delay in seconds. " +
"This flag should be used for local development and testing only.",
Value: params.BeaconConfig().MinGenesisDelay,
}
cacheFilteredBlockTreeFlag = cli.BoolFlag{
Name: "cache-filtered-block-tree",
Expand Down Expand Up @@ -220,7 +221,7 @@ var E2EValidatorFlags = []string{

// BeaconChainFlags contains a list of all the feature flags that apply to the beacon-chain client.
var BeaconChainFlags = append(deprecatedFlags, []cli.Flag{
noGenesisDelayFlag,
customGenesisDelayFlag,
minimalConfigFlag,
writeSSZStateTransitionsFlag,
disableForkChoiceUnsafeFlag,
Expand Down
2 changes: 1 addition & 1 deletion validator/db/attestation_history_test.go
Expand Up @@ -10,7 +10,7 @@ import (
)

func TestAttestationHistory_InitializesNewPubKeys(t *testing.T) {
pubkeys := [][48]byte{[48]byte{30}, [48]byte{25}, [48]byte{20}}
pubkeys := [][48]byte{{30}, {25}, {20}}
db := SetupDB(t, pubkeys)
defer TeardownDB(t, db)

Expand Down
2 changes: 1 addition & 1 deletion validator/db/proposal_history_test.go
Expand Up @@ -11,7 +11,7 @@ import (
)

func TestProposalHistory_InitializesNewPubKeys(t *testing.T) {
pubkeys := [][48]byte{[48]byte{30}, [48]byte{25}, [48]byte{20}}
pubkeys := [][48]byte{{30}, {25}, {20}}
db := SetupDB(t, pubkeys)
defer TeardownDB(t, db)

Expand Down