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

Improve E2E to be more consistent with timing, and allow for custom flags #4620

Merged
merged 47 commits into from Jan 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
a3e9fbb
Add committees helper, benchmark, results show 62ms for 8k validators…
prestonvanloon Dec 16, 2019
6486186
Add regression test with same data
prestonvanloon Dec 16, 2019
bf8c9d5
fix epoch conversion
prestonvanloon Dec 16, 2019
0e37614
lint
prestonvanloon Dec 16, 2019
4f6d403
undo and lint
prestonvanloon Dec 16, 2019
b4e5406
Merge branch 'master' of github.com:prysmaticlabs/prysm into zoom-zoo…
prestonvanloon Dec 16, 2019
057da91
Begin work on adding mainnet config benchmark
0xKiwi Dec 16, 2019
9f494a1
Merge branch 'zoom-zoom-assignments' of https://github.com/prysmaticl…
0xKiwi Dec 16, 2019
7985566
Try more to get mainnet e2e
0xKiwi Dec 16, 2019
ac34c11
Try to fix delay
0xKiwi Dec 17, 2019
cb1b891
Merge branch 'master' of https://github.com/prysmaticlabs/Prysm into …
0xKiwi Dec 17, 2019
dbe3d20
Get past chainstart on e2e
0xKiwi Dec 18, 2019
3deda02
Merge branch 'master' of https://github.com/prysmaticlabs/Prysm into …
0xKiwi Jan 4, 2020
0d8151c
Try to fix flaky
0xKiwi Jan 4, 2020
47bac9e
Merge branch 'master' of https://github.com/prysmaticlabs/Prysm into …
0xKiwi Jan 22, 2020
7592de4
Get demo config working
0xKiwi Jan 22, 2020
f813744
Merge branch 'master' of https://github.com/prysmaticlabs/Prysm into …
0xKiwi Jan 22, 2020
f8128a2
Remove unneeded changes
0xKiwi Jan 22, 2020
0e86ac3
Change how flags are enabled
0xKiwi Jan 22, 2020
7d723cc
Merge branch 'master' into mainnet-e2e
0xKiwi Jan 22, 2020
da62b3b
Lower shard count
0xKiwi Jan 22, 2020
7f1fdcc
Merge branch 'master' of https://github.com/prysmaticlabs/Prysm into …
0xKiwi Jan 22, 2020
39cede8
Merge branch 'mainnet-e2e' of https://github.com/0xKiwi/Prysm into ma…
0xKiwi Jan 22, 2020
00e2930
Temp skip
0xKiwi Jan 22, 2020
52fb235
Fix e2e
0xKiwi Jan 23, 2020
46caff6
Merge branch 'master' of https://github.com/prysmaticlabs/Prysm into …
0xKiwi Jan 23, 2020
e3dc962
Fix testing to run until last epoch
0xKiwi Jan 23, 2020
95e47c6
Fix
0xKiwi Jan 23, 2020
805fb0f
Merge branch 'master' into mainnet-e2e
0xKiwi Jan 23, 2020
f6352af
Add ending time log and remove att cache flag
0xKiwi Jan 23, 2020
5a4e30a
Merge branch 'master' of https://github.com/prysmaticlabs/Prysm into …
0xKiwi Jan 23, 2020
2139902
Merge branch 'mainnet-e2e' of https://github.com/0xKiwi/Prysm into ma…
0xKiwi Jan 23, 2020
9527900
Fix ordering
0xKiwi Jan 23, 2020
d44606c
Merge branch 'master' into mainnet-e2e
0xKiwi Jan 23, 2020
5a6603e
Reenable flag
0xKiwi Jan 23, 2020
e3b3958
Merge branch 'mainnet-e2e' of https://github.com/0xKiwi/Prysm into ma…
0xKiwi Jan 23, 2020
d696735
Change ports from default
0xKiwi Jan 23, 2020
0c122a2
Merge branch 'master' of https://github.com/prysmaticlabs/Prysm into …
0xKiwi Jan 23, 2020
519b028
Add no log for if there are no err logs
0xKiwi Jan 23, 2020
105b694
Merge branch 'master' of https://github.com/prysmaticlabs/Prysm into …
0xKiwi Jan 23, 2020
3f73a27
Merge branch 'master' of https://github.com/prysmaticlabs/Prysm into …
0xKiwi Jan 24, 2020
bcf288e
Add block evaluator
0xKiwi Jan 24, 2020
fc6cd42
Try to improve evaluators
0xKiwi Jan 24, 2020
da1b95e
Merge branch 'master' of https://github.com/prysmaticlabs/Prysm into …
0xKiwi Jan 25, 2020
2b57bc4
Progress on attestation evaluator
0xKiwi Jan 25, 2020
69c22b4
Remove attestation evaluator
0xKiwi Jan 25, 2020
c891f00
Fix e2e
0xKiwi Jan 25, 2020
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
41 changes: 16 additions & 25 deletions endtoend/beacon_node.go
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/pkg/errors"
ev "github.com/prysmaticlabs/prysm/endtoend/evaluators"
"github.com/prysmaticlabs/prysm/shared/params"
)

type beaconNodeInfo struct {
Expand All @@ -28,12 +29,12 @@ type beaconNodeInfo struct {
}

type end2EndConfig struct {
minimalConfig bool
beaconFlags []string
validatorFlags []string
tmpPath string
epochsToRun uint64
numValidators uint64
numBeaconNodes uint64
enableSSZCache bool
contractAddr common.Address
evaluators []ev.Evaluator
}
Expand Down Expand Up @@ -69,31 +70,21 @@ func startNewBeaconNode(t *testing.T, config *end2EndConfig, beaconNodes []*beac

args := []string{
"--no-genesis-delay",
"--verbosity=debug",
"--force-clear-db",
"--no-discovery",
"--new-cache",
"--enable-shuffled-index-cache",
"--enable-skip-slots-cache",
"--enable-attestation-cache",
"--http-web3provider=http://127.0.0.1:8545",
"--web3provider=ws://127.0.0.1:8546",
"--http-web3provider=http://127.0.0.1:8745",
"--web3provider=ws://127.0.0.1:8746",
fmt.Sprintf("--datadir=%s/eth2-beacon-node-%d", tmpPath, index),
fmt.Sprintf("--deposit-contract=%s", config.contractAddr.Hex()),
fmt.Sprintf("--rpc-port=%d", 4000+index),
fmt.Sprintf("--p2p-udp-port=%d", 12000+index),
fmt.Sprintf("--p2p-tcp-port=%d", 13000+index),
fmt.Sprintf("--monitoring-port=%d", 8080+index),
fmt.Sprintf("--grpc-gateway-port=%d", 3200+index),
fmt.Sprintf("--rpc-port=%d", 4200+index),
fmt.Sprintf("--p2p-udp-port=%d", 12200+index),
fmt.Sprintf("--p2p-tcp-port=%d", 13200+index),
fmt.Sprintf("--monitoring-port=%d", 8280+index),
fmt.Sprintf("--grpc-gateway-port=%d", 3400+index),
fmt.Sprintf("--contract-deployment-block=%d", 0),
fmt.Sprintf("--rpc-max-page-size=%d", params.BeaconConfig().MinGenesisActiveValidatorCount),
}

if config.minimalConfig {
args = append(args, "--minimal-config")
}
if config.enableSSZCache {
args = append(args, "--enable-ssz-cache")
}
args = append(args, config.beaconFlags...)

// After the first node is made, have all following nodes connect to all previously made nodes.
if index >= 1 {
Expand All @@ -102,7 +93,7 @@ func startNewBeaconNode(t *testing.T, config *end2EndConfig, beaconNodes []*beac
}
}

t.Logf("Starting beacon chain with flags: %s", strings.Join(args, " "))
t.Logf("Starting beacon chain %d with flags: %s", index, strings.Join(args, " "))
cmd := exec.Command(binaryPath, args...)
cmd.Stdout = stdOutFile
cmd.Stderr = stdOutFile
Expand All @@ -122,9 +113,9 @@ func startNewBeaconNode(t *testing.T, config *end2EndConfig, beaconNodes []*beac
return &beaconNodeInfo{
processID: cmd.Process.Pid,
datadir: fmt.Sprintf("%s/eth2-beacon-node-%d", tmpPath, index),
rpcPort: 4000 + uint64(index),
monitorPort: 8080 + uint64(index),
grpcPort: 3200 + uint64(index),
rpcPort: 4200 + uint64(index),
monitorPort: 8280 + uint64(index),
grpcPort: 3400 + uint64(index),
multiAddr: multiAddr,
}
}
Expand Down
10 changes: 8 additions & 2 deletions endtoend/demo_e2e_test.go
Expand Up @@ -14,9 +14,15 @@ func TestEndToEnd_DemoConfig(t *testing.T) {
params.UseDemoBeaconConfig()

demoConfig := &end2EndConfig{
minimalConfig: false,
beaconFlags: []string{
"--enable-ssz-cache",
"--cache-proposer-indices",
"--cache-filtered-block-tree",
"--enable-skip-slots-cache",
"--enable-attestation-cache",
},
epochsToRun: 5,
numBeaconNodes: 4,
numBeaconNodes: 2,
numValidators: params.BeaconConfig().MinGenesisActiveValidatorCount,
evaluators: []ev.Evaluator{
ev.ValidatorsAreActive,
Expand Down
50 changes: 22 additions & 28 deletions endtoend/endtoend_test.go
Expand Up @@ -55,16 +55,16 @@ func runEndToEndTest(t *testing.T, config *end2EndConfig) {
if err != nil {
t.Fatal(err)
}
if err := waitForTextInFile(beaconLogFile, "Sending genesis time notification"); err != nil {
t.Fatalf("failed to find genesis in logs, this means the chain did not start: %v", err)
if err := waitForTextInFile(beaconLogFile, "Chain started within the last epoch"); err != nil {
t.Fatalf("failed to find chain start in logs, this means the chain did not start: %v", err)
}

// Failing early in case chain doesn't start.
if t.Failed() {
return
}

conn, err := grpc.Dial("127.0.0.1:4000", grpc.WithInsecure())
conn, err := grpc.Dial("127.0.0.1:4200", grpc.WithInsecure())
if err != nil {
t.Fatalf("Failed to dial: %v", err)
}
Expand All @@ -78,30 +78,24 @@ func runEndToEndTest(t *testing.T, config *end2EndConfig) {
// Small offset so evaluators perform in the middle of an epoch.
epochSeconds := params.BeaconConfig().SecondsPerSlot * params.BeaconConfig().SlotsPerEpoch
genesisTime := time.Unix(genesis.GenesisTime.Seconds+int64(epochSeconds/2), 0)
currentEpoch := uint64(0)
ticker := GetEpochTicker(genesisTime, epochSeconds)
for c := range ticker.C() {
if c >= config.epochsToRun || t.Failed() {
ticker.Done()
break
}

for currentEpoch := range ticker.C() {
for _, evaluator := range config.evaluators {
// Only run if the policy says so.
if !evaluator.Policy(currentEpoch) {
continue
}
t.Run(fmt.Sprintf(evaluator.Name, currentEpoch), func(t *testing.T) {
if err := evaluator.Evaluation(beaconClient); err != nil {
t.Fatalf("evaluation failed for epoch %d: %v", currentEpoch, err)
t.Errorf("evaluation failed for epoch %d: %v", currentEpoch, err)
}
})
}
currentEpoch++
}

if currentEpoch < config.epochsToRun {
t.Fatalf("Test ended prematurely, only reached epoch %d", currentEpoch)
if t.Failed() || currentEpoch >= config.epochsToRun {
ticker.Done()
break
}
}
}

Expand Down Expand Up @@ -151,22 +145,21 @@ func killProcesses(t *testing.T, pIDs []int) {
}

func logOutput(t *testing.T, tmpPath string, config *end2EndConfig) {
if t.Failed() {
// Log out errors from beacon chain nodes.
for i := uint64(0); i < config.numBeaconNodes; i++ {
beaconLogFile, err := os.Open(path.Join(tmpPath, fmt.Sprintf(beaconNodeLogFileName, i)))
if err != nil {
t.Fatal(err)
}
logErrorOutput(t, beaconLogFile, "beacon chain node", i)
// Log out errors from beacon chain nodes.
for i := uint64(0); i < config.numBeaconNodes; i++ {
beaconLogFile, err := os.Open(path.Join(tmpPath, fmt.Sprintf(beaconNodeLogFileName, i)))
if err != nil {
t.Fatal(err)
}
logErrorOutput(t, beaconLogFile, "beacon chain node", i)

validatorLogFile, err := os.Open(path.Join(tmpPath, fmt.Sprintf(validatorLogFileName, i)))
if err != nil {
t.Fatal(err)
}
logErrorOutput(t, validatorLogFile, "validator client", i)
validatorLogFile, err := os.Open(path.Join(tmpPath, fmt.Sprintf(validatorLogFileName, i)))
if err != nil {
t.Fatal(err)
}
logErrorOutput(t, validatorLogFile, "validator client", i)
}
t.Logf("Ending time: %s\n", time.Now().String())
}

func logErrorOutput(t *testing.T, file *os.File, title string, index uint64) {
Expand All @@ -181,6 +174,7 @@ func logErrorOutput(t *testing.T, file *os.File, title string, index uint64) {
}

if len(errorLines) < 1 {
t.Logf("No error logs detected for %s %d", title, index)
return
}

Expand Down
4 changes: 3 additions & 1 deletion endtoend/eth1.go
Expand Up @@ -45,9 +45,11 @@ func startEth1(t *testing.T, tmpPath string) (common.Address, string, int) {
"--rpcaddr=0.0.0.0",
"--rpccorsdomain=\"*\"",
"--rpcvhosts=\"*\"",
"--rpcport=8745",
"--ws",
"--wsaddr=0.0.0.0",
"--wsorigins=\"*\"",
"--wsport=8746",
"--dev",
"--dev.period=0",
"--ipcdisable",
Expand All @@ -68,7 +70,7 @@ func startEth1(t *testing.T, tmpPath string) (common.Address, string, int) {
}

// Connect to the started geth dev chain.
client, err := rpc.DialHTTP("http://127.0.0.1:8545")
client, err := rpc.DialHTTP("http://127.0.0.1:8745")
if err != nil {
t.Fatalf("Failed to connect to ipc: %v", err)
}
Expand Down
39 changes: 28 additions & 11 deletions endtoend/evaluators/validator.go
Expand Up @@ -44,7 +44,9 @@ func afterNthEpoch(afterEpoch uint64) func(uint64) bool {

func validatorsAreActive(client eth.BeaconChainClient) error {
// Balances actually fluctuate but we just want to check initial balance.
validatorRequest := &eth.ListValidatorsRequest{}
validatorRequest := &eth.ListValidatorsRequest{
PageSize: int32(params.BeaconConfig().MinGenesisActiveValidatorCount),
}
validators, err := client.ListValidators(context.Background(), validatorRequest)
if err != nil {
return errors.Wrap(err, "failed to get validators")
Expand All @@ -56,24 +58,39 @@ func validatorsAreActive(client eth.BeaconChainClient) error {
return fmt.Errorf("expected validator count to be %d, recevied %d", expectedCount, receivedCount)
}

effBalanceLowCount := 0
activeEpochWrongCount := 0
exitEpochWrongCount := 0
withdrawEpochWrongCount := 0
for _, item := range validators.ValidatorList {
if item.Validator.EffectiveBalance < params.BeaconConfig().MaxEffectiveBalance {
effBalanceLowCount++
}
if item.Validator.ActivationEpoch != 0 {
return fmt.Errorf("expected genesis validator epoch to be 0, received %d", item.Validator.ActivationEpoch)
activeEpochWrongCount++
}
if item.Validator.ExitEpoch != params.BeaconConfig().FarFutureEpoch {
return fmt.Errorf("expected genesis validator exit epoch to be far future, received %d", item.Validator.ExitEpoch)
exitEpochWrongCount++
}
if item.Validator.WithdrawableEpoch != params.BeaconConfig().FarFutureEpoch {
return fmt.Errorf("expected genesis validator withdrawable epoch to be far future, received %d", item.Validator.WithdrawableEpoch)
}
if item.Validator.EffectiveBalance != params.BeaconConfig().MaxEffectiveBalance {
return fmt.Errorf(
"expected genesis validator effective balance to be %d, received %d",
params.BeaconConfig().MaxEffectiveBalance,
item.Validator.EffectiveBalance,
)
withdrawEpochWrongCount++
}
}

if effBalanceLowCount > 0 {
return fmt.Errorf(
"%d validators did not have genesis validator effective balance of %d",
effBalanceLowCount,
params.BeaconConfig().MaxEffectiveBalance,
)
} else if activeEpochWrongCount > 0 {
return fmt.Errorf("%d validators did not have genesis validator epoch of 0", activeEpochWrongCount)
} else if exitEpochWrongCount > 0 {
return fmt.Errorf("%d validators did not have genesis validator exit epoch of far future epoch", exitEpochWrongCount)
} else if activeEpochWrongCount > 0 {
return fmt.Errorf("%d validators did not have genesis validator withdrawable epoch of far future epoch", activeEpochWrongCount)
}

return nil
}

Expand Down
13 changes: 11 additions & 2 deletions endtoend/minimal_e2e_test.go
Expand Up @@ -13,10 +13,19 @@ func TestEndToEnd_MinimalConfig(t *testing.T) {
params.UseMinimalConfig()

minimalConfig := &end2EndConfig{
minimalConfig: true,
beaconFlags: []string{
"--minimal-config",
"--enable-ssz-cache",
"--cache-proposer-indices",
"--cache-filtered-block-tree",
"--enable-skip-slots-cache",
"--enable-attestation-cache",
},
validatorFlags: []string{
"--minimal-config",
},
epochsToRun: 5,
numBeaconNodes: 4,
enableSSZCache: true,
numValidators: params.BeaconConfig().MinGenesisActiveValidatorCount,
evaluators: []ev.Evaluator{
ev.ValidatorsAreActive,
Expand Down
18 changes: 8 additions & 10 deletions endtoend/validator.go
Expand Up @@ -58,27 +58,26 @@ func initializeValidators(
"--force-clear-db",
fmt.Sprintf("--interop-num-validators=%d", validatorsPerNode),
fmt.Sprintf("--interop-start-index=%d", validatorsPerNode*n),
fmt.Sprintf("--monitoring-port=%d", 9080+n),
fmt.Sprintf("--monitoring-port=%d", 9280+n),
fmt.Sprintf("--datadir=%s/eth2-val-%d", tmpPath, n),
fmt.Sprintf("--beacon-rpc-provider=localhost:%d", 4000+n),
}
if config.minimalConfig {
args = append(args, "--minimal-config")
fmt.Sprintf("--beacon-rpc-provider=localhost:%d", 4200+n),
}
args = append(args, config.validatorFlags...)

cmd := exec.Command(binaryPath, args...)
cmd.Stdout = file
cmd.Stderr = file
t.Logf("Starting validator client with flags: %s", strings.Join(args, " "))
t.Logf("Starting validator client %d with flags: %s", n, strings.Join(args, " "))
if err := cmd.Start(); err != nil {
t.Fatal(err)
}
valClients[n] = &validatorClientInfo{
processID: cmd.Process.Pid,
monitorPort: 9080 + n,
monitorPort: 9280 + n,
}
}

client, err := rpc.DialHTTP("http://127.0.0.1:8545")
client, err := rpc.DialHTTP("http://127.0.0.1:8745")
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -124,8 +123,7 @@ func initializeValidators(
t.Fatal(err)
}

// "Safe" amount of blocks to mine to make sure the deposits are seen.
if err := mineBlocks(web3, keystore, 20); err != nil {
if err := mineBlocks(web3, keystore, params.BeaconConfig().Eth1FollowDistance); err != nil {
t.Fatalf("failed to mine blocks %v", err)
}

Expand Down