From 538c1a49ca44515ece746a91e9d89ccfa2e08ee9 Mon Sep 17 00:00:00 2001 From: Ivan Martinez Date: Fri, 10 Apr 2020 20:23:32 -0400 Subject: [PATCH 01/11] Begin work on fixing e2e for v0.11 --- endtoend/components/BUILD.bazel | 3 +++ endtoend/components/beacon_node.go | 32 ++++++++++++++++++------ endtoend/components/eth1.go | 2 +- endtoend/endtoend_test.go | 3 +++ endtoend/minimal_antiflake_e2e_1_test.go | 3 +-- endtoend/params/params.go | 4 ++- validator/client/validator_propose.go | 2 +- 7 files changed, 36 insertions(+), 13 deletions(-) diff --git a/endtoend/components/BUILD.bazel b/endtoend/components/BUILD.bazel index 0c16ca3ef5f9..bee77a252ca9 100644 --- a/endtoend/components/BUILD.bazel +++ b/endtoend/components/BUILD.bazel @@ -16,14 +16,17 @@ go_library( "//endtoend/helpers:go_default_library", "//endtoend/params:go_default_library", "//endtoend/types:go_default_library", + "//shared/bytesutil:go_default_library", "//shared/featureconfig:go_default_library", "//shared/params:go_default_library", "//shared/testutil:go_default_library", + "@com_github_btcsuite_btcd//btcec:go_default_library", "@com_github_ethereum_go_ethereum//accounts/abi/bind:go_default_library", "@com_github_ethereum_go_ethereum//accounts/keystore:go_default_library", "@com_github_ethereum_go_ethereum//core/types:go_default_library", "@com_github_ethereum_go_ethereum//ethclient:go_default_library", "@com_github_ethereum_go_ethereum//rpc:go_default_library", + "@com_github_libp2p_go_libp2p_core//crypto:go_default_library", "@io_bazel_rules_go//go/tools/bazel:go_default_library", ], ) diff --git a/endtoend/components/beacon_node.go b/endtoend/components/beacon_node.go index b193213cbf2d..b3cbf8fe9bc8 100644 --- a/endtoend/components/beacon_node.go +++ b/endtoend/components/beacon_node.go @@ -1,16 +1,21 @@ package components import ( + "encoding/hex" "fmt" "io/ioutil" + "os" "os/exec" + "path" "strings" "testing" "github.com/bazelbuild/rules_go/go/tools/bazel" + "github.com/btcsuite/btcd/btcec" "github.com/prysmaticlabs/prysm/endtoend/helpers" e2e "github.com/prysmaticlabs/prysm/endtoend/params" "github.com/prysmaticlabs/prysm/endtoend/types" + "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/featureconfig" "github.com/prysmaticlabs/prysm/shared/params" ) @@ -36,6 +41,17 @@ func StartNewBeaconNode(t *testing.T, config *types.E2EConfig, multiAddrs []stri t.Fatal("beacon chain binary not found") } + seed := bytesutil.ToBytes(uint64(e2e.TestParams.BeaconNodeRPCPort), btcec.PrivKeyBytesLen) + file, err := os.Create(path.Join(e2e.TestParams.TestPath, fmt.Sprintf("enr-key-%d", index))) + if err != nil { + t.Fatal(err) + } + hexBytes := make([]byte, hex.EncodedLen(len(seed))) + hex.Encode(hexBytes, seed) + if _, err := file.Write(hexBytes); err != nil { + t.Fatal(err) + } + stdOutFile, err := helpers.DeleteAndCreateFile(e2e.TestParams.LogPath, fmt.Sprintf(e2e.BeaconNodeLogFileName, index)) if err != nil { t.Fatal(err) @@ -49,6 +65,7 @@ func StartNewBeaconNode(t *testing.T, config *types.E2EConfig, multiAddrs []stri fmt.Sprintf("--http-web3provider=http://127.0.0.1:%d", e2e.TestParams.Eth1RPCPort), fmt.Sprintf("--web3provider=ws://127.0.0.1:%d", e2e.TestParams.Eth1RPCPort+1), fmt.Sprintf("--min-sync-peers=%d", e2e.TestParams.BeaconNodeCount-1), + fmt.Sprintf("--p2p-priv-key=%s", file.Name()), fmt.Sprintf("--p2p-udp-port=%d", e2e.TestParams.BeaconNodeRPCPort+index+10), //12200 fmt.Sprintf("--p2p-tcp-port=%d", e2e.TestParams.BeaconNodeRPCPort+index+20), //13200 fmt.Sprintf("--monitoring-port=%d", e2e.TestParams.BeaconNodeRPCPort+index+30), //8280 @@ -56,7 +73,6 @@ func StartNewBeaconNode(t *testing.T, config *types.E2EConfig, multiAddrs []stri fmt.Sprintf("--contract-deployment-block=%d", 0), fmt.Sprintf("--rpc-max-page-size=%d", params.BeaconConfig().MinGenesisActiveValidatorCount), "--force-clear-db", - "--no-discovery", } args = append(args, featureconfig.E2EBeaconChainFlags...) args = append(args, config.BeaconFlags...) @@ -74,16 +90,16 @@ func StartNewBeaconNode(t *testing.T, config *types.E2EConfig, multiAddrs []stri t.Fatalf("Failed to start beacon node: %v", err) } - if err = helpers.WaitForTextInFile(stdOutFile, "Node started p2p server"); err != nil { + if err = helpers.WaitForTextInFile(stdOutFile, "RPC-API listening on port"); err != nil { t.Fatalf("could not find multiaddr for node %d, this means the node had issues starting: %v", index, err) } + // + //multiAddr, err := getMultiAddrFromLogFile(stdOutFile.Name()) + //if err != nil { + // t.Fatalf("could not get multiaddr for node %d: %v", index, err) + //} - multiAddr, err := getMultiAddrFromLogFile(stdOutFile.Name()) - if err != nil { - t.Fatalf("could not get multiaddr for node %d: %v", index, err) - } - - return multiAddr, cmd.Process.Pid + return "", cmd.Process.Pid } func getMultiAddrFromLogFile(name string) (string, error) { diff --git a/endtoend/components/eth1.go b/endtoend/components/eth1.go index 06bfc7804e05..748c5e022bb0 100644 --- a/endtoend/components/eth1.go +++ b/endtoend/components/eth1.go @@ -52,7 +52,7 @@ func StartEth1Node(t *testing.T) (string, int) { "--wsaddr=0.0.0.0", "--wsorigins=\"*\"", "--dev", - "--dev.period=0", + "--dev.period=2", "--ipcdisable", } cmd := exec.Command(binaryPath, args...) diff --git a/endtoend/endtoend_test.go b/endtoend/endtoend_test.go index a0ced4846351..84c31426a928 100644 --- a/endtoend/endtoend_test.go +++ b/endtoend/endtoend_test.go @@ -49,6 +49,9 @@ func runEndToEndTest(t *testing.T, config *types.E2EConfig) { if err := helpers.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) } + if err := helpers.WaitForTextInFile(beaconLogFile, "FODDD"); 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() { diff --git a/endtoend/minimal_antiflake_e2e_1_test.go b/endtoend/minimal_antiflake_e2e_1_test.go index 8cac16c60503..3ace9e5dc92a 100644 --- a/endtoend/minimal_antiflake_e2e_1_test.go +++ b/endtoend/minimal_antiflake_e2e_1_test.go @@ -11,7 +11,6 @@ import ( ) func TestEndToEnd_AntiFlake_MinimalConfig_1(t *testing.T) { - t.Skip("Temp skip for #5127, need proper network implementations") testutil.ResetCache() params.UseMinimalConfig() @@ -26,7 +25,7 @@ func TestEndToEnd_AntiFlake_MinimalConfig_1(t *testing.T) { ev.ValidatorsAreActive, }, } - if err := e2eParams.Init(4); err != nil { + if err := e2eParams.Init(1); err != nil { t.Fatal(err) } diff --git a/endtoend/params/params.go b/endtoend/params/params.go index d0c7c6fb4a58..b2c0650f327e 100644 --- a/endtoend/params/params.go +++ b/endtoend/params/params.go @@ -2,7 +2,9 @@ package params import ( "errors" + "fmt" "os" + "path" "strconv" "github.com/bazelbuild/rules_go/go/tools/bazel" @@ -54,7 +56,7 @@ func Init(beaconNodeCount int) error { } TestParams = &Params{ - TestPath: testPath, + TestPath: path.Join(testPath, fmt.Sprintf("shard-%d", testIndex)), LogPath: logPath, TestShardIndex: testIndex, BeaconNodeCount: beaconNodeCount, diff --git a/validator/client/validator_propose.go b/validator/client/validator_propose.go index 0420e62ec681..336f7c903ff4 100644 --- a/validator/client/validator_propose.go +++ b/validator/client/validator_propose.go @@ -79,7 +79,7 @@ func (v *validator) ProposeBlock(ctx context.Context, slot uint64, pubKey [48]by Graffiti: v.graffiti, }) if err != nil { - log.WithError(err).Error("Failed to request block from beacon node") + log.WithField("blockSlot", slot).WithError(err).Error("Failed to request block from beacon node") if v.emitAccountMetrics { validatorProposeFailVec.WithLabelValues(fmtKey).Inc() } From b5e8e61c9fedf30d70389944d71b8ab55e38cd7e Mon Sep 17 00:00:00 2001 From: Ivan Martinez Date: Fri, 10 Apr 2020 23:25:59 -0400 Subject: [PATCH 02/11] Start bootnode work --- endtoend/components/beacon_node.go | 64 ++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/endtoend/components/beacon_node.go b/endtoend/components/beacon_node.go index b3cbf8fe9bc8..667e6ae486a5 100644 --- a/endtoend/components/beacon_node.go +++ b/endtoend/components/beacon_node.go @@ -73,6 +73,7 @@ func StartNewBeaconNode(t *testing.T, config *types.E2EConfig, multiAddrs []stri fmt.Sprintf("--contract-deployment-block=%d", 0), fmt.Sprintf("--rpc-max-page-size=%d", params.BeaconConfig().MinGenesisActiveValidatorCount), "--force-clear-db", + "--bootstrap-node=\"\"", } args = append(args, featureconfig.E2EBeaconChainFlags...) args = append(args, config.BeaconFlags...) @@ -102,6 +103,69 @@ func StartNewBeaconNode(t *testing.T, config *types.E2EConfig, multiAddrs []stri return "", cmd.Process.Pid } +// StartBootnode starts a bootnode and returns its ENR and process ID. +func StartBootnode(t *testing.T, config *types.E2EConfig) (string, int) { + binaryPath, found := bazel.FindBinary("beacon-chain", "beacon-chain") + if !found { + t.Log(binaryPath) + t.Fatal("beacon chain binary not found") + } + + seed := bytesutil.ToBytes(uint64(e2e.TestParams.BeaconNodeRPCPort), btcec.PrivKeyBytesLen) + file, err := os.Create(path.Join(e2e.TestParams.TestPath, fmt.Sprintf("enr-key-%d", index))) + if err != nil { + t.Fatal(err) + } + hexBytes := make([]byte, hex.EncodedLen(len(seed))) + hex.Encode(hexBytes, seed) + if _, err := file.Write(hexBytes); err != nil { + t.Fatal(err) + } + + stdOutFile, err := helpers.DeleteAndCreateFile(e2e.TestParams.LogPath, fmt.Sprintf(e2e.BeaconNodeLogFileName, index)) + if err != nil { + t.Fatal(err) + } + + args := []string{ + fmt.Sprintf("--datadir=%s/eth2-beacon-node-%d", e2e.TestParams.TestPath, index), + fmt.Sprintf("--log-file=%s", stdOutFile.Name()), + fmt.Sprintf("--deposit-contract=%s", e2e.TestParams.ContractAddress.Hex()), + fmt.Sprintf("--rpc-port=%d", e2e.TestParams.BeaconNodeRPCPort+index), + fmt.Sprintf("--http-web3provider=http://127.0.0.1:%d", e2e.TestParams.Eth1RPCPort), + fmt.Sprintf("--web3provider=ws://127.0.0.1:%d", e2e.TestParams.Eth1RPCPort+1), + fmt.Sprintf("--min-sync-peers=%d", e2e.TestParams.BeaconNodeCount-1), + fmt.Sprintf("--p2p-priv-key=%s", file.Name()), + fmt.Sprintf("--p2p-udp-port=%d", e2e.TestParams.BeaconNodeRPCPort+index+10), //12200 + fmt.Sprintf("--p2p-tcp-port=%d", e2e.TestParams.BeaconNodeRPCPort+index+20), //13200 + fmt.Sprintf("--monitoring-port=%d", e2e.TestParams.BeaconNodeRPCPort+index+30), //8280 + fmt.Sprintf("--grpc-gateway-port=%d", e2e.TestParams.BeaconNodeRPCPort+index+40), // 3400 + fmt.Sprintf("--contract-deployment-block=%d", 0), + fmt.Sprintf("--rpc-max-page-size=%d", params.BeaconConfig().MinGenesisActiveValidatorCount), + "--force-clear-db", + "--bootstrap-node=\"\"", + } + args = append(args, featureconfig.E2EBeaconChainFlags...) + args = append(args, config.BeaconFlags...) + + cmd := exec.Command(binaryPath, args...) + t.Logf("Starting boot node with flags: %s", strings.Join(args[2:], " ")) + if err := cmd.Start(); err != nil { + t.Fatalf("Failed to start beacon node: %v", err) + } + + if err = helpers.WaitForTextInFile(stdOutFile, "RPC-API listening on port"); err != nil { + t.Fatalf("could not find multiaddr for node %d, this means the node had issues starting: %v", index, err) + } + // + //multiAddr, err := getMultiAddrFromLogFile(stdOutFile.Name()) + //if err != nil { + // t.Fatalf("could not get multiaddr for node %d: %v", index, err) + //} + + return "", cmd.Process.Pid +} + func getMultiAddrFromLogFile(name string) (string, error) { byteContent, err := ioutil.ReadFile(name) if err != nil { From d6090c3a278353d2aeee01ec3e69fc45d6a24f1d Mon Sep 17 00:00:00 2001 From: Ivan Martinez Date: Sat, 11 Apr 2020 14:33:37 -0400 Subject: [PATCH 03/11] Begin implementing bootnode into e2e --- endtoend/BUILD.bazel | 1 + endtoend/components/BUILD.bazel | 1 - endtoend/components/beacon_node.go | 79 ++++++++++-------------------- endtoend/endtoend_test.go | 2 + endtoend/params/params.go | 7 ++- 5 files changed, 36 insertions(+), 54 deletions(-) diff --git a/endtoend/BUILD.bazel b/endtoend/BUILD.bazel index 2c050c870a0e..14009e9d1c07 100644 --- a/endtoend/BUILD.bazel +++ b/endtoend/BUILD.bazel @@ -16,6 +16,7 @@ go_test( "//beacon-chain", "//slasher", "//validator", + "//tools/bootnode", "@com_github_ethereum_go_ethereum//cmd/geth", ], shard_count = 4, diff --git a/endtoend/components/BUILD.bazel b/endtoend/components/BUILD.bazel index bee77a252ca9..bf2bbb52b7da 100644 --- a/endtoend/components/BUILD.bazel +++ b/endtoend/components/BUILD.bazel @@ -26,7 +26,6 @@ go_library( "@com_github_ethereum_go_ethereum//core/types:go_default_library", "@com_github_ethereum_go_ethereum//ethclient:go_default_library", "@com_github_ethereum_go_ethereum//rpc:go_default_library", - "@com_github_libp2p_go_libp2p_core//crypto:go_default_library", "@io_bazel_rules_go//go/tools/bazel:go_default_library", ], ) diff --git a/endtoend/components/beacon_node.go b/endtoend/components/beacon_node.go index 667e6ae486a5..cfb69be02423 100644 --- a/endtoend/components/beacon_node.go +++ b/endtoend/components/beacon_node.go @@ -41,17 +41,6 @@ func StartNewBeaconNode(t *testing.T, config *types.E2EConfig, multiAddrs []stri t.Fatal("beacon chain binary not found") } - seed := bytesutil.ToBytes(uint64(e2e.TestParams.BeaconNodeRPCPort), btcec.PrivKeyBytesLen) - file, err := os.Create(path.Join(e2e.TestParams.TestPath, fmt.Sprintf("enr-key-%d", index))) - if err != nil { - t.Fatal(err) - } - hexBytes := make([]byte, hex.EncodedLen(len(seed))) - hex.Encode(hexBytes, seed) - if _, err := file.Write(hexBytes); err != nil { - t.Fatal(err) - } - stdOutFile, err := helpers.DeleteAndCreateFile(e2e.TestParams.LogPath, fmt.Sprintf(e2e.BeaconNodeLogFileName, index)) if err != nil { t.Fatal(err) @@ -65,11 +54,10 @@ func StartNewBeaconNode(t *testing.T, config *types.E2EConfig, multiAddrs []stri fmt.Sprintf("--http-web3provider=http://127.0.0.1:%d", e2e.TestParams.Eth1RPCPort), fmt.Sprintf("--web3provider=ws://127.0.0.1:%d", e2e.TestParams.Eth1RPCPort+1), fmt.Sprintf("--min-sync-peers=%d", e2e.TestParams.BeaconNodeCount-1), - fmt.Sprintf("--p2p-priv-key=%s", file.Name()), - fmt.Sprintf("--p2p-udp-port=%d", e2e.TestParams.BeaconNodeRPCPort+index+10), //12200 - fmt.Sprintf("--p2p-tcp-port=%d", e2e.TestParams.BeaconNodeRPCPort+index+20), //13200 - fmt.Sprintf("--monitoring-port=%d", e2e.TestParams.BeaconNodeRPCPort+index+30), //8280 - fmt.Sprintf("--grpc-gateway-port=%d", e2e.TestParams.BeaconNodeRPCPort+index+40), // 3400 + fmt.Sprintf("--p2p-udp-port=%d", e2e.TestParams.BeaconNodeRPCPort+index+10), + fmt.Sprintf("--p2p-tcp-port=%d", e2e.TestParams.BeaconNodeRPCPort+index+20), + fmt.Sprintf("--monitoring-port=%d", e2e.TestParams.BeaconNodeRPCPort+index+30), + 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", @@ -105,14 +93,14 @@ func StartNewBeaconNode(t *testing.T, config *types.E2EConfig, multiAddrs []stri // StartBootnode starts a bootnode and returns its ENR and process ID. func StartBootnode(t *testing.T, config *types.E2EConfig) (string, int) { - binaryPath, found := bazel.FindBinary("beacon-chain", "beacon-chain") + binaryPath, found := bazel.FindBinary("tools/bootnode", "bootnode") if !found { t.Log(binaryPath) - t.Fatal("beacon chain binary not found") + t.Fatal("boot node binary not found") } seed := bytesutil.ToBytes(uint64(e2e.TestParams.BeaconNodeRPCPort), btcec.PrivKeyBytesLen) - file, err := os.Create(path.Join(e2e.TestParams.TestPath, fmt.Sprintf("enr-key-%d", index))) + file, err := os.Create(path.Join(e2e.TestParams.TestPath, "enr-key")) if err != nil { t.Fatal(err) } @@ -122,66 +110,53 @@ func StartBootnode(t *testing.T, config *types.E2EConfig) (string, int) { t.Fatal(err) } - stdOutFile, err := helpers.DeleteAndCreateFile(e2e.TestParams.LogPath, fmt.Sprintf(e2e.BeaconNodeLogFileName, index)) + stdOutFile, err := helpers.DeleteAndCreateFile(e2e.TestParams.LogPath, e2e.BootNodeLogFileName) if err != nil { t.Fatal(err) } args := []string{ - fmt.Sprintf("--datadir=%s/eth2-beacon-node-%d", e2e.TestParams.TestPath, index), fmt.Sprintf("--log-file=%s", stdOutFile.Name()), - fmt.Sprintf("--deposit-contract=%s", e2e.TestParams.ContractAddress.Hex()), - fmt.Sprintf("--rpc-port=%d", e2e.TestParams.BeaconNodeRPCPort+index), - fmt.Sprintf("--http-web3provider=http://127.0.0.1:%d", e2e.TestParams.Eth1RPCPort), - fmt.Sprintf("--web3provider=ws://127.0.0.1:%d", e2e.TestParams.Eth1RPCPort+1), - fmt.Sprintf("--min-sync-peers=%d", e2e.TestParams.BeaconNodeCount-1), - fmt.Sprintf("--p2p-priv-key=%s", file.Name()), - fmt.Sprintf("--p2p-udp-port=%d", e2e.TestParams.BeaconNodeRPCPort+index+10), //12200 - fmt.Sprintf("--p2p-tcp-port=%d", e2e.TestParams.BeaconNodeRPCPort+index+20), //13200 - fmt.Sprintf("--monitoring-port=%d", e2e.TestParams.BeaconNodeRPCPort+index+30), //8280 - fmt.Sprintf("--grpc-gateway-port=%d", e2e.TestParams.BeaconNodeRPCPort+index+40), // 3400 - fmt.Sprintf("--contract-deployment-block=%d", 0), - fmt.Sprintf("--rpc-max-page-size=%d", params.BeaconConfig().MinGenesisActiveValidatorCount), - "--force-clear-db", - "--bootstrap-node=\"\"", + fmt.Sprintf("--private=%s", file.Name()), + fmt.Sprintf("--discv5-port=%d", e2e.TestParams.BootNodePort), + fmt.Sprintf("--kad-port=%d", e2e.TestParams.BootNodePort+10), + fmt.Sprintf("--metrics-port=%d", e2e.TestParams.BootNodePort+20), } - args = append(args, featureconfig.E2EBeaconChainFlags...) - args = append(args, config.BeaconFlags...) cmd := exec.Command(binaryPath, args...) - t.Logf("Starting boot node with flags: %s", strings.Join(args[2:], " ")) + t.Logf("Starting boot node with flags: %s", strings.Join(args[1:], " ")) if err := cmd.Start(); err != nil { t.Fatalf("Failed to start beacon node: %v", err) } - if err = helpers.WaitForTextInFile(stdOutFile, "RPC-API listening on port"); err != nil { - t.Fatalf("could not find multiaddr for node %d, this means the node had issues starting: %v", index, err) + if err = helpers.WaitForTextInFile(stdOutFile, "Running bootnode"); err != nil { + t.Fatalf("could not find enr for bootnode, this means the bootnode had issues starting: %v", err) } - // - //multiAddr, err := getMultiAddrFromLogFile(stdOutFile.Name()) - //if err != nil { - // t.Fatalf("could not get multiaddr for node %d: %v", index, err) - //} - return "", cmd.Process.Pid + enr, err := getENRFromLogFile(stdOutFile.Name()) + if err != nil { + t.Fatalf("could not get enr for bootnode: %v", err) + } + + return enr, cmd.Process.Pid } -func getMultiAddrFromLogFile(name string) (string, error) { +func getENRFromLogFile(name string) (string, error) { byteContent, err := ioutil.ReadFile(name) if err != nil { return "", err } contents := string(byteContent) - searchText := "\"Node started p2p server\" multiAddr=\"" + searchText := "Running bootnode: " startIdx := strings.Index(contents, searchText) if startIdx == -1 { - return "", fmt.Errorf("did not find peer text in %s", contents) + return "", fmt.Errorf("did not find ENR text in %s", contents) } startIdx += len(searchText) - endIdx := strings.Index(contents[startIdx:], "\"") + endIdx := strings.Index(contents[startIdx:], "prefix=bootnode") if endIdx == -1 { - return "", fmt.Errorf("did not find peer text in %s", contents) + return "", fmt.Errorf("did not find ENR text in %s", contents) } - return contents[startIdx : startIdx+endIdx], nil + return contents[startIdx : startIdx+endIdx-1], nil } diff --git a/endtoend/endtoend_test.go b/endtoend/endtoend_test.go index 84c31426a928..454d210dbddf 100644 --- a/endtoend/endtoend_test.go +++ b/endtoend/endtoend_test.go @@ -30,6 +30,8 @@ func runEndToEndTest(t *testing.T, config *types.E2EConfig) { t.Logf("Log Path: %s\n\n", e2e.TestParams.LogPath) keystorePath, eth1PID := components.StartEth1Node(t) + bootnodeENR, _ := components.StartBootnode(t, config) + fmt.Println(bootnodeENR) multiAddrs, bProcessIDs := components.StartBeaconNodes(t, config) valProcessIDs := components.StartValidators(t, config, keystorePath) processIDs := append(valProcessIDs, bProcessIDs...) diff --git a/endtoend/params/params.go b/endtoend/params/params.go index b2c0650f327e..a1bb3c8ac8d8 100644 --- a/endtoend/params/params.go +++ b/endtoend/params/params.go @@ -19,6 +19,7 @@ type Params struct { BeaconNodeCount int Eth1RPCPort int ContractAddress common.Address + BootNodePort int BeaconNodeRPCPort int BeaconNodeMetricsPort int ValidatorMetricsPort int @@ -29,6 +30,9 @@ type Params struct { // TestParams is the globally accessible var for getting config elements. var TestParams *Params +// BootNodeLogFileName is the file name used for the beacon chain node logs. +var BootNodeLogFileName = "bootnode.log" + // BeaconNodeLogFileName is the file name used for the beacon chain node logs. var BeaconNodeLogFileName = "beacon-%d.log" @@ -61,7 +65,8 @@ func Init(beaconNodeCount int) error { TestShardIndex: testIndex, BeaconNodeCount: beaconNodeCount, Eth1RPCPort: 3100 + testIndex*100, // Multiplying 100 here so the test index doesn't conflict with the other node ports. - BeaconNodeRPCPort: 4100 + testIndex*100, + BootNodePort: 4100 + testIndex*100, + BeaconNodeRPCPort: 4150 + testIndex*100, BeaconNodeMetricsPort: 5100 + testIndex*100, ValidatorMetricsPort: 6100 + testIndex*100, SlasherRPCPort: 7100 + testIndex*100, From 71081bf029ca3775aa8afee6d9ed719dd3a18599 Mon Sep 17 00:00:00 2001 From: Ivan Martinez Date: Sat, 11 Apr 2020 21:07:03 -0400 Subject: [PATCH 04/11] Fix E2E for v0.11 --- endtoend/components/BUILD.bazel | 1 + endtoend/components/beacon_node.go | 58 +++++++++++------------- endtoend/endtoend_test.go | 11 ++--- endtoend/helpers/helpers.go | 1 - endtoend/minimal_antiflake_e2e_1_test.go | 5 +- endtoend/minimal_antiflake_e2e_2_test.go | 4 +- endtoend/minimal_e2e_test.go | 1 - endtoend/minimal_slashing_e2e_test.go | 1 - validator/client/validator_aggregate.go | 2 +- 9 files changed, 38 insertions(+), 46 deletions(-) diff --git a/endtoend/components/BUILD.bazel b/endtoend/components/BUILD.bazel index bf2bbb52b7da..bee77a252ca9 100644 --- a/endtoend/components/BUILD.bazel +++ b/endtoend/components/BUILD.bazel @@ -26,6 +26,7 @@ go_library( "@com_github_ethereum_go_ethereum//core/types:go_default_library", "@com_github_ethereum_go_ethereum//ethclient:go_default_library", "@com_github_ethereum_go_ethereum//rpc:go_default_library", + "@com_github_libp2p_go_libp2p_core//crypto:go_default_library", "@io_bazel_rules_go//go/tools/bazel:go_default_library", ], ) diff --git a/endtoend/components/beacon_node.go b/endtoend/components/beacon_node.go index cfb69be02423..4e792cfbe687 100644 --- a/endtoend/components/beacon_node.go +++ b/endtoend/components/beacon_node.go @@ -1,31 +1,26 @@ package components import ( - "encoding/hex" "fmt" "io/ioutil" - "os" "os/exec" - "path" "strings" "testing" "github.com/bazelbuild/rules_go/go/tools/bazel" - "github.com/btcsuite/btcd/btcec" "github.com/prysmaticlabs/prysm/endtoend/helpers" e2e "github.com/prysmaticlabs/prysm/endtoend/params" "github.com/prysmaticlabs/prysm/endtoend/types" - "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/featureconfig" "github.com/prysmaticlabs/prysm/shared/params" ) // StartBeaconNodes starts the requested amount of beacon nodes, passing in the deposit contract given. -func StartBeaconNodes(t *testing.T, config *types.E2EConfig) ([]string, []int) { +func StartBeaconNodes(t *testing.T, config *types.E2EConfig, enr string) ([]string, []int) { var multiAddrs []string var processIDs []int for i := 0; i < e2e.TestParams.BeaconNodeCount; i++ { - multiAddr, pID := StartNewBeaconNode(t, config, multiAddrs) + multiAddr, pID := StartNewBeaconNode(t, config, i, enr) multiAddrs = append(multiAddrs, multiAddr) processIDs = append(processIDs, pID) } @@ -33,8 +28,7 @@ func StartBeaconNodes(t *testing.T, config *types.E2EConfig) ([]string, []int) { } // StartNewBeaconNode starts a fresh beacon node, connecting to all passed in beacon nodes. -func StartNewBeaconNode(t *testing.T, config *types.E2EConfig, multiAddrs []string) (string, int) { - index := len(multiAddrs) +func StartNewBeaconNode(t *testing.T, config *types.E2EConfig, index int, enr string) (string, int) { binaryPath, found := bazel.FindBinary("beacon-chain", "beacon-chain") if !found { t.Log(binaryPath) @@ -61,18 +55,11 @@ func StartNewBeaconNode(t *testing.T, config *types.E2EConfig, multiAddrs []stri fmt.Sprintf("--contract-deployment-block=%d", 0), fmt.Sprintf("--rpc-max-page-size=%d", params.BeaconConfig().MinGenesisActiveValidatorCount), "--force-clear-db", - "--bootstrap-node=\"\"", + fmt.Sprintf("--bootstrap-node=%s", enr), } args = append(args, featureconfig.E2EBeaconChainFlags...) args = append(args, config.BeaconFlags...) - // After the first node is made, have all following nodes connect to all previously made nodes. - if index >= 1 { - for p := 0; p < index; p++ { - args = append(args, fmt.Sprintf("--peer=%s", multiAddrs[p])) - } - } - cmd := exec.Command(binaryPath, args...) t.Logf("Starting beacon chain %d with flags: %s", index, strings.Join(args[2:], " ")) if err := cmd.Start(); err != nil { @@ -92,23 +79,30 @@ func StartNewBeaconNode(t *testing.T, config *types.E2EConfig, multiAddrs []stri } // StartBootnode starts a bootnode and returns its ENR and process ID. -func StartBootnode(t *testing.T, config *types.E2EConfig) (string, int) { +func StartBootnode(t *testing.T) (string, int) { binaryPath, found := bazel.FindBinary("tools/bootnode", "bootnode") if !found { t.Log(binaryPath) t.Fatal("boot node binary not found") } - - seed := bytesutil.ToBytes(uint64(e2e.TestParams.BeaconNodeRPCPort), btcec.PrivKeyBytesLen) - file, err := os.Create(path.Join(e2e.TestParams.TestPath, "enr-key")) - if err != nil { - t.Fatal(err) - } - hexBytes := make([]byte, hex.EncodedLen(len(seed))) - hex.Encode(hexBytes, seed) - if _, err := file.Write(hexBytes); err != nil { - t.Fatal(err) - } + // + //seed := bytesutil.ToBytes(uint64(e2e.TestParams.BeaconNodeRPCPort), btcec.PrivKeyBytesLen) + //keyFile, err := helpers.DeleteAndCreateFile(e2e.TestParams.TestPath, "enr-key") + //if err != nil { + // t.Fatal(err) + //} + //keyss, err := crypto.UnmarshalSecp256k1PrivateKey(seed) + //if err != nil { + // t.Fatal(err) + //} + //keyBytes, err := keyss.GetPublic().Raw() + //if err != nil { + // t.Fatal(err) + //} + //keyStr := hex.EncodeToString(keyBytes) + //if _, err := keyFile.WriteString(keyStr); err != nil { + // t.Fatal(err) + //} stdOutFile, err := helpers.DeleteAndCreateFile(e2e.TestParams.LogPath, e2e.BootNodeLogFileName) if err != nil { @@ -117,13 +111,15 @@ func StartBootnode(t *testing.T, config *types.E2EConfig) (string, int) { args := []string{ fmt.Sprintf("--log-file=%s", stdOutFile.Name()), - fmt.Sprintf("--private=%s", file.Name()), + //fmt.Sprintf("--private=%s", keyFile.Name()), fmt.Sprintf("--discv5-port=%d", e2e.TestParams.BootNodePort), fmt.Sprintf("--kad-port=%d", e2e.TestParams.BootNodePort+10), fmt.Sprintf("--metrics-port=%d", e2e.TestParams.BootNodePort+20), } cmd := exec.Command(binaryPath, args...) + cmd.Stdout = stdOutFile + cmd.Stderr = stdOutFile t.Logf("Starting boot node with flags: %s", strings.Join(args[1:], " ")) if err := cmd.Start(); err != nil { t.Fatalf("Failed to start beacon node: %v", err) @@ -154,7 +150,7 @@ func getENRFromLogFile(name string) (string, error) { return "", fmt.Errorf("did not find ENR text in %s", contents) } startIdx += len(searchText) - endIdx := strings.Index(contents[startIdx:], "prefix=bootnode") + endIdx := strings.Index(contents[startIdx:], " prefix=bootnode") if endIdx == -1 { return "", fmt.Errorf("did not find ENR text in %s", contents) } diff --git a/endtoend/endtoend_test.go b/endtoend/endtoend_test.go index 454d210dbddf..e54b7140e9a7 100644 --- a/endtoend/endtoend_test.go +++ b/endtoend/endtoend_test.go @@ -30,9 +30,9 @@ func runEndToEndTest(t *testing.T, config *types.E2EConfig) { t.Logf("Log Path: %s\n\n", e2e.TestParams.LogPath) keystorePath, eth1PID := components.StartEth1Node(t) - bootnodeENR, _ := components.StartBootnode(t, config) + bootnodeENR, _ := components.StartBootnode(t) fmt.Println(bootnodeENR) - multiAddrs, bProcessIDs := components.StartBeaconNodes(t, config) + multiAddrs, bProcessIDs := components.StartBeaconNodes(t, config, bootnodeENR) valProcessIDs := components.StartValidators(t, config, keystorePath) processIDs := append(valProcessIDs, bProcessIDs...) processIDs = append(processIDs, eth1PID) @@ -51,9 +51,6 @@ func runEndToEndTest(t *testing.T, config *types.E2EConfig) { if err := helpers.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) } - if err := helpers.WaitForTextInFile(beaconLogFile, "FODDD"); 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() { @@ -105,9 +102,9 @@ func runEndToEndTest(t *testing.T, config *types.E2EConfig) { return } - multiAddr, processID := components.StartNewBeaconNode(t, config, multiAddrs) - multiAddrs = append(multiAddrs, multiAddr) index := e2e.TestParams.BeaconNodeCount + multiAddr, processID := components.StartNewBeaconNode(t, config, index, bootnodeENR) + multiAddrs = append(multiAddrs, multiAddr) syncConn, err := grpc.Dial(fmt.Sprintf("127.0.0.1:%d", e2e.TestParams.BeaconNodeRPCPort+index), grpc.WithInsecure()) if err != nil { t.Fatalf("Failed to dial: %v", err) diff --git a/endtoend/helpers/helpers.go b/endtoend/helpers/helpers.go index 1f510f64da54..9560eaef1c43 100644 --- a/endtoend/helpers/helpers.go +++ b/endtoend/helpers/helpers.go @@ -140,5 +140,4 @@ func LogErrorOutput(t *testing.T, file io.Reader, title string, index int) { } t.Log(err) } - t.Logf("===================== End of %s %d error output ====================\n", title, index) } diff --git a/endtoend/minimal_antiflake_e2e_1_test.go b/endtoend/minimal_antiflake_e2e_1_test.go index 3ace9e5dc92a..84a50d6a9256 100644 --- a/endtoend/minimal_antiflake_e2e_1_test.go +++ b/endtoend/minimal_antiflake_e2e_1_test.go @@ -17,15 +17,16 @@ func TestEndToEnd_AntiFlake_MinimalConfig_1(t *testing.T) { minimalConfig := &types.E2EConfig{ BeaconFlags: []string{"--minimal-config", "--custom-genesis-delay=10"}, ValidatorFlags: []string{"--minimal-config"}, - EpochsToRun: 3, + EpochsToRun: 4, TestSync: false, TestSlasher: false, Evaluators: []types.Evaluator{ ev.PeersConnect, ev.ValidatorsAreActive, + ev.ValidatorsParticipating, }, } - if err := e2eParams.Init(1); err != nil { + if err := e2eParams.Init(4); err != nil { t.Fatal(err) } diff --git a/endtoend/minimal_antiflake_e2e_2_test.go b/endtoend/minimal_antiflake_e2e_2_test.go index d5ba4b93ddc4..e788b80d04b4 100644 --- a/endtoend/minimal_antiflake_e2e_2_test.go +++ b/endtoend/minimal_antiflake_e2e_2_test.go @@ -11,19 +11,19 @@ import ( ) func TestEndToEnd_AntiFlake_MinimalConfig_2(t *testing.T) { - t.Skip("Temp skip for #5127, need proper network implementations") testutil.ResetCache() params.UseMinimalConfig() minimalConfig := &types.E2EConfig{ BeaconFlags: []string{"--minimal-config", "--custom-genesis-delay=10"}, ValidatorFlags: []string{"--minimal-config"}, - EpochsToRun: 3, + EpochsToRun: 4, TestSync: false, TestSlasher: false, Evaluators: []types.Evaluator{ ev.PeersConnect, ev.ValidatorsAreActive, + ev.ValidatorsParticipating, }, } if err := e2eParams.Init(4); err != nil { diff --git a/endtoend/minimal_e2e_test.go b/endtoend/minimal_e2e_test.go index c4937c2321a0..e83fd2552a30 100644 --- a/endtoend/minimal_e2e_test.go +++ b/endtoend/minimal_e2e_test.go @@ -13,7 +13,6 @@ import ( ) func TestEndToEnd_MinimalConfig(t *testing.T) { - t.Skip("To be resolved until 5119 gets in") testutil.ResetCache() params.UseMinimalConfig() diff --git a/endtoend/minimal_slashing_e2e_test.go b/endtoend/minimal_slashing_e2e_test.go index 889c0a0e8f2a..b70bba102351 100644 --- a/endtoend/minimal_slashing_e2e_test.go +++ b/endtoend/minimal_slashing_e2e_test.go @@ -11,7 +11,6 @@ import ( ) func TestEndToEnd_Slashing_MinimalConfig(t *testing.T) { - t.Skip("To be resolved until 5119 gets in") testutil.ResetCache() params.UseMinimalConfig() diff --git a/validator/client/validator_aggregate.go b/validator/client/validator_aggregate.go index 0339989e6c50..c83140b995d8 100644 --- a/validator/client/validator_aggregate.go +++ b/validator/client/validator_aggregate.go @@ -89,7 +89,7 @@ func (v *validator) SubmitAggregateAndProof(ctx context.Context, slot uint64, pu SlotSignature: slotSig, }) if err != nil { - log.Errorf("Could not submit slot signature to beacon node: %v", err) + log.WithField("slot", slot).Errorf("Could not submit slot signature to beacon node: %v", err) if v.emitAccountMetrics { validatorAggFailVec.WithLabelValues(fmtKey).Inc() } From 4ce66ea6546c9e2555da83267315e6a58fc0136a Mon Sep 17 00:00:00 2001 From: Ivan Martinez Date: Sat, 11 Apr 2020 21:11:32 -0400 Subject: [PATCH 05/11] Remove extra --- endtoend/components/beacon_node.go | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/endtoend/components/beacon_node.go b/endtoend/components/beacon_node.go index 4e792cfbe687..57681c6610f6 100644 --- a/endtoend/components/beacon_node.go +++ b/endtoend/components/beacon_node.go @@ -16,19 +16,17 @@ import ( ) // StartBeaconNodes starts the requested amount of beacon nodes, passing in the deposit contract given. -func StartBeaconNodes(t *testing.T, config *types.E2EConfig, enr string) ([]string, []int) { - var multiAddrs []string +func StartBeaconNodes(t *testing.T, config *types.E2EConfig, enr string) []int { var processIDs []int for i := 0; i < e2e.TestParams.BeaconNodeCount; i++ { - multiAddr, pID := StartNewBeaconNode(t, config, i, enr) - multiAddrs = append(multiAddrs, multiAddr) + pID := StartNewBeaconNode(t, config, i, enr) processIDs = append(processIDs, pID) } - return multiAddrs, processIDs + return processIDs } // StartNewBeaconNode starts a fresh beacon node, connecting to all passed in beacon nodes. -func StartNewBeaconNode(t *testing.T, config *types.E2EConfig, index int, enr string) (string, int) { +func StartNewBeaconNode(t *testing.T, config *types.E2EConfig, index int, enr string) int { binaryPath, found := bazel.FindBinary("beacon-chain", "beacon-chain") if !found { t.Log(binaryPath) @@ -69,13 +67,8 @@ func StartNewBeaconNode(t *testing.T, config *types.E2EConfig, index int, enr st if err = helpers.WaitForTextInFile(stdOutFile, "RPC-API listening on port"); err != nil { t.Fatalf("could not find multiaddr for node %d, this means the node had issues starting: %v", index, err) } - // - //multiAddr, err := getMultiAddrFromLogFile(stdOutFile.Name()) - //if err != nil { - // t.Fatalf("could not get multiaddr for node %d: %v", index, err) - //} - return "", cmd.Process.Pid + return cmd.Process.Pid } // StartBootnode starts a bootnode and returns its ENR and process ID. From 166235e393af6719a6f7792adcd7de5f9ac9163e Mon Sep 17 00:00:00 2001 From: Ivan Martinez Date: Sat, 11 Apr 2020 21:19:25 -0400 Subject: [PATCH 06/11] gaz --- endtoend/components/BUILD.bazel | 3 --- 1 file changed, 3 deletions(-) diff --git a/endtoend/components/BUILD.bazel b/endtoend/components/BUILD.bazel index bee77a252ca9..0c16ca3ef5f9 100644 --- a/endtoend/components/BUILD.bazel +++ b/endtoend/components/BUILD.bazel @@ -16,17 +16,14 @@ go_library( "//endtoend/helpers:go_default_library", "//endtoend/params:go_default_library", "//endtoend/types:go_default_library", - "//shared/bytesutil:go_default_library", "//shared/featureconfig:go_default_library", "//shared/params:go_default_library", "//shared/testutil:go_default_library", - "@com_github_btcsuite_btcd//btcec:go_default_library", "@com_github_ethereum_go_ethereum//accounts/abi/bind:go_default_library", "@com_github_ethereum_go_ethereum//accounts/keystore:go_default_library", "@com_github_ethereum_go_ethereum//core/types:go_default_library", "@com_github_ethereum_go_ethereum//ethclient:go_default_library", "@com_github_ethereum_go_ethereum//rpc:go_default_library", - "@com_github_libp2p_go_libp2p_core//crypto:go_default_library", "@io_bazel_rules_go//go/tools/bazel:go_default_library", ], ) From 1b3801cf5ff6b6cac48b4c0a47e61dff7c6fb630 Mon Sep 17 00:00:00 2001 From: Ivan Martinez Date: Sat, 11 Apr 2020 21:20:49 -0400 Subject: [PATCH 07/11] Remove unused key gen code --- endtoend/components/beacon_node.go | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/endtoend/components/beacon_node.go b/endtoend/components/beacon_node.go index 57681c6610f6..445329e5c71a 100644 --- a/endtoend/components/beacon_node.go +++ b/endtoend/components/beacon_node.go @@ -78,24 +78,6 @@ func StartBootnode(t *testing.T) (string, int) { t.Log(binaryPath) t.Fatal("boot node binary not found") } - // - //seed := bytesutil.ToBytes(uint64(e2e.TestParams.BeaconNodeRPCPort), btcec.PrivKeyBytesLen) - //keyFile, err := helpers.DeleteAndCreateFile(e2e.TestParams.TestPath, "enr-key") - //if err != nil { - // t.Fatal(err) - //} - //keyss, err := crypto.UnmarshalSecp256k1PrivateKey(seed) - //if err != nil { - // t.Fatal(err) - //} - //keyBytes, err := keyss.GetPublic().Raw() - //if err != nil { - // t.Fatal(err) - //} - //keyStr := hex.EncodeToString(keyBytes) - //if _, err := keyFile.WriteString(keyStr); err != nil { - // t.Fatal(err) - //} stdOutFile, err := helpers.DeleteAndCreateFile(e2e.TestParams.LogPath, e2e.BootNodeLogFileName) if err != nil { @@ -104,7 +86,6 @@ func StartBootnode(t *testing.T) (string, int) { args := []string{ fmt.Sprintf("--log-file=%s", stdOutFile.Name()), - //fmt.Sprintf("--private=%s", keyFile.Name()), fmt.Sprintf("--discv5-port=%d", e2e.TestParams.BootNodePort), fmt.Sprintf("--kad-port=%d", e2e.TestParams.BootNodePort+10), fmt.Sprintf("--metrics-port=%d", e2e.TestParams.BootNodePort+20), From f2cf43b2d849522875c8fecbb37d668328520836 Mon Sep 17 00:00:00 2001 From: Ivan Martinez Date: Sat, 11 Apr 2020 21:31:57 -0400 Subject: [PATCH 08/11] Remove trailing multiaddr code --- endtoend/endtoend_test.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/endtoend/endtoend_test.go b/endtoend/endtoend_test.go index e54b7140e9a7..51a454a2ba6d 100644 --- a/endtoend/endtoend_test.go +++ b/endtoend/endtoend_test.go @@ -32,7 +32,7 @@ func runEndToEndTest(t *testing.T, config *types.E2EConfig) { keystorePath, eth1PID := components.StartEth1Node(t) bootnodeENR, _ := components.StartBootnode(t) fmt.Println(bootnodeENR) - multiAddrs, bProcessIDs := components.StartBeaconNodes(t, config, bootnodeENR) + bProcessIDs := components.StartBeaconNodes(t, config, bootnodeENR) valProcessIDs := components.StartValidators(t, config, keystorePath) processIDs := append(valProcessIDs, bProcessIDs...) processIDs = append(processIDs, eth1PID) @@ -103,8 +103,7 @@ func runEndToEndTest(t *testing.T, config *types.E2EConfig) { } index := e2e.TestParams.BeaconNodeCount - multiAddr, processID := components.StartNewBeaconNode(t, config, index, bootnodeENR) - multiAddrs = append(multiAddrs, multiAddr) + processID := components.StartNewBeaconNode(t, config, index, bootnodeENR) syncConn, err := grpc.Dial(fmt.Sprintf("127.0.0.1:%d", e2e.TestParams.BeaconNodeRPCPort+index), grpc.WithInsecure()) if err != nil { t.Fatalf("Failed to dial: %v", err) From aa4e24f2c0b4d09b60d3c5d19c229a42b75a054e Mon Sep 17 00:00:00 2001 From: Ivan Martinez Date: Sat, 11 Apr 2020 23:50:16 -0400 Subject: [PATCH 09/11] add skip for slashing --- endtoend/endtoend_test.go | 1 - endtoend/minimal_slashing_e2e_test.go | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/endtoend/endtoend_test.go b/endtoend/endtoend_test.go index 51a454a2ba6d..b29901a5d762 100644 --- a/endtoend/endtoend_test.go +++ b/endtoend/endtoend_test.go @@ -31,7 +31,6 @@ func runEndToEndTest(t *testing.T, config *types.E2EConfig) { keystorePath, eth1PID := components.StartEth1Node(t) bootnodeENR, _ := components.StartBootnode(t) - fmt.Println(bootnodeENR) bProcessIDs := components.StartBeaconNodes(t, config, bootnodeENR) valProcessIDs := components.StartValidators(t, config, keystorePath) processIDs := append(valProcessIDs, bProcessIDs...) diff --git a/endtoend/minimal_slashing_e2e_test.go b/endtoend/minimal_slashing_e2e_test.go index b70bba102351..889c0a0e8f2a 100644 --- a/endtoend/minimal_slashing_e2e_test.go +++ b/endtoend/minimal_slashing_e2e_test.go @@ -11,6 +11,7 @@ import ( ) func TestEndToEnd_Slashing_MinimalConfig(t *testing.T) { + t.Skip("To be resolved until 5119 gets in") testutil.ResetCache() params.UseMinimalConfig() From 912fe26971736b6e26116894d9d664f3aaebefe5 Mon Sep 17 00:00:00 2001 From: Ivan Martinez Date: Sun, 12 Apr 2020 00:58:57 -0400 Subject: [PATCH 10/11] Fix slashing e2e --- endtoend/endtoend_test.go | 10 +++++----- endtoend/evaluators/BUILD.bazel | 2 +- endtoend/evaluators/slashing.go | 15 ++++++++++++--- endtoend/minimal_slashing_e2e_test.go | 1 - 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/endtoend/endtoend_test.go b/endtoend/endtoend_test.go index b29901a5d762..344e1009786c 100644 --- a/endtoend/endtoend_test.go +++ b/endtoend/endtoend_test.go @@ -38,11 +38,6 @@ func runEndToEndTest(t *testing.T, config *types.E2EConfig) { defer helpers.LogOutput(t, config) defer helpers.KillProcesses(t, processIDs) - if config.TestSlasher { - slasherPIDs := components.StartSlashers(t) - defer helpers.KillProcesses(t, slasherPIDs) - } - beaconLogFile, err := os.Open(path.Join(e2e.TestParams.LogPath, fmt.Sprintf(e2e.BeaconNodeLogFileName, 0))) if err != nil { t.Fatal(err) @@ -74,6 +69,11 @@ func runEndToEndTest(t *testing.T, config *types.E2EConfig) { epochSeconds := params.BeaconConfig().SecondsPerSlot * params.BeaconConfig().SlotsPerEpoch genesisTime := time.Unix(genesis.GenesisTime.Seconds+int64(epochSeconds/2), 0) + if config.TestSlasher { + slasherPIDs := components.StartSlashers(t) + defer helpers.KillProcesses(t, slasherPIDs) + } + ticker := helpers.GetEpochTicker(genesisTime, epochSeconds) for currentEpoch := range ticker.C() { for _, evaluator := range config.Evaluators { diff --git a/endtoend/evaluators/BUILD.bazel b/endtoend/evaluators/BUILD.bazel index d165b17af60a..cbddb3f8b722 100644 --- a/endtoend/evaluators/BUILD.bazel +++ b/endtoend/evaluators/BUILD.bazel @@ -12,6 +12,7 @@ go_library( importpath = "github.com/prysmaticlabs/prysm/endtoend/evaluators", visibility = ["//endtoend:__subpackages__"], deps = [ + "//beacon-chain/core/helpers:go_default_library", "//endtoend/types:go_default_library", "//shared/bytesutil:go_default_library", "//shared/params:go_default_library", @@ -21,7 +22,6 @@ go_library( "@com_github_pkg_errors//:go_default_library", "@com_github_prysmaticlabs_ethereumapis//eth/v1alpha1:go_default_library", "@com_github_prysmaticlabs_go_bitfield//:go_default_library", - "@com_github_prysmaticlabs_go_ssz//:go_default_library", "@org_golang_google_grpc//:go_default_library", ], ) diff --git a/endtoend/evaluators/slashing.go b/endtoend/evaluators/slashing.go index db27b5dd04a9..278a87644357 100644 --- a/endtoend/evaluators/slashing.go +++ b/endtoend/evaluators/slashing.go @@ -6,9 +6,10 @@ import ( ptypes "github.com/gogo/protobuf/types" eth "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1" "github.com/prysmaticlabs/go-bitfield" - "github.com/prysmaticlabs/go-ssz" + "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" "github.com/prysmaticlabs/prysm/endtoend/types" "github.com/prysmaticlabs/prysm/shared/bytesutil" + "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/sliceutil" "github.com/prysmaticlabs/prysm/shared/testutil" "google.golang.org/grpc" @@ -79,7 +80,15 @@ func insertDoubleAttestationIntoPool(conns ...*grpc.ClientConn) error { blockRoot := bytesutil.ToBytes32([]byte("muahahahaha I'm an evil validator")) attData.BeaconBlockRoot = blockRoot[:] - dataRoot, err := ssz.HashTreeRoot(attData) + req := ð.DomainRequest{ + Epoch: chainHead.HeadEpoch, + Domain: params.BeaconConfig().DomainBeaconAttester[:], + } + resp, err := valClient.DomainData(ctx, req) + if err != nil { + return err + } + signingRoot, err := helpers.ComputeSigningRoot(attData, resp.SignatureDomain) if err != nil { return err } @@ -97,7 +106,7 @@ func insertDoubleAttestationIntoPool(conns ...*grpc.ClientConn) error { att := ð.Attestation{ AggregationBits: attBitfield, Data: attData, - Signature: privKeys[committee[i]].Sign(dataRoot[:]).Marshal(), + Signature: privKeys[committee[i]].Sign(signingRoot[:]).Marshal(), } for _, conn := range conns { client := eth.NewBeaconNodeValidatorClient(conn) diff --git a/endtoend/minimal_slashing_e2e_test.go b/endtoend/minimal_slashing_e2e_test.go index 889c0a0e8f2a..b70bba102351 100644 --- a/endtoend/minimal_slashing_e2e_test.go +++ b/endtoend/minimal_slashing_e2e_test.go @@ -11,7 +11,6 @@ import ( ) func TestEndToEnd_Slashing_MinimalConfig(t *testing.T) { - t.Skip("To be resolved until 5119 gets in") testutil.ResetCache() params.UseMinimalConfig() From 4a611a9e4dd24981a0f438b41d960bad83f148c2 Mon Sep 17 00:00:00 2001 From: Ivan Martinez Date: Sun, 12 Apr 2020 01:59:27 -0400 Subject: [PATCH 11/11] Fix docker image build --- tools/bootnode/BUILD.bazel | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/bootnode/BUILD.bazel b/tools/bootnode/BUILD.bazel index 0a20d5d06ba5..503f1795970a 100644 --- a/tools/bootnode/BUILD.bazel +++ b/tools/bootnode/BUILD.bazel @@ -46,6 +46,8 @@ go_image( tags = ["manual"], visibility = ["//visibility:private"], deps = [ + "//proto/beacon/p2p/v1:go_default_library", + "//shared/params:go_default_library", "//shared/logutil:go_default_library", "//shared/version:go_default_library", "@com_github_btcsuite_btcd//btcec:go_default_library", @@ -63,6 +65,8 @@ go_image( "@com_github_libp2p_go_libp2p_kad_dht//opts:go_default_library", "@com_github_multiformats_go_multiaddr//:go_default_library", "@com_github_pkg_errors//:go_default_library", + "@com_github_prysmaticlabs_go_bitfield//:go_default_library", + "@com_github_prysmaticlabs_go_ssz//:go_default_library", "@com_github_sirupsen_logrus//:go_default_library", "@org_uber_go_automaxprocs//:go_default_library", ],