From 28234cf7dac9ab70431128dee72a6bbc2adb11d8 Mon Sep 17 00:00:00 2001 From: James He Date: Thu, 14 Apr 2022 14:01:14 -0400 Subject: [PATCH 01/70] testing out fee-recipient evaluator --- testing/endtoend/components/validator.go | 1 + testing/endtoend/evaluators/fee_recipient.go | 56 ++++++++++++++++++++ testing/endtoend/minimal_e2e_test.go | 1 + 3 files changed, 58 insertions(+) create mode 100644 testing/endtoend/evaluators/fee_recipient.go diff --git a/testing/endtoend/components/validator.go b/testing/endtoend/components/validator.go index b0a6c36c2a06..f8ca8c7c269d 100644 --- a/testing/endtoend/components/validator.go +++ b/testing/endtoend/components/validator.go @@ -142,6 +142,7 @@ func (v *ValidatorNode) Start(ctx context.Context) error { fmt.Sprintf("--%s=localhost:%d", flags.BeaconRPCProviderFlag.Name, beaconRPCPort), fmt.Sprintf("--%s=%s", flags.GrpcHeadersFlag.Name, "dummy=value,foo=bar"), // Sending random headers shouldn't break anything. fmt.Sprintf("--%s=%s", cmdshared.VerbosityFlag.Name, "debug"), + fmt.Sprintf("--%s=%s",flags.SuggestedFeeRecipientFlag,"0x878705ba3f8bc32fcf7f4caa1a35e72af65cf766"), "--" + cmdshared.ForceClearDB.Name, "--" + cmdshared.E2EConfigFlag.Name, "--" + cmdshared.AcceptTosFlag.Name, diff --git a/testing/endtoend/evaluators/fee_recipient.go b/testing/endtoend/evaluators/fee_recipient.go new file mode 100644 index 000000000000..b27609788ab6 --- /dev/null +++ b/testing/endtoend/evaluators/fee_recipient.go @@ -0,0 +1,56 @@ +package evaluators + +import ( + "context" + + "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/pkg/errors" + ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + "github.com/prysmaticlabs/prysm/testing/endtoend/helpers" + e2e "github.com/prysmaticlabs/prysm/testing/endtoend/params" + "github.com/prysmaticlabs/prysm/testing/endtoend/policies" + "github.com/prysmaticlabs/prysm/testing/endtoend/types" + "google.golang.org/grpc" + "google.golang.org/protobuf/types/known/emptypb" +) + +var FeeRecipientIsPresent = types.Evaluator{ + Name: "Fee_Recipient_Is_Present_%d", + Policy: policies.AfterNthEpoch(helpers.BellatrixE2EForkEpoch), + Evaluation: feeRecipientIsPresent, +} + +func feeRecipientIsPresent(conns ...*grpc.ClientConn) error { + conn := conns[0] + client := ethpb.NewBeaconChainClient(conn) + chainHead, err := client.GetChainHead(context.Background(), &emptypb.Empty{}) + if err != nil { + return errors.Wrap(err, "failed to get chain head") + } + req := ðpb.ListBlocksRequest{QueryFilter: ðpb.ListBlocksRequest_Epoch{Epoch: chainHead.HeadEpoch.Sub(1)}} + blks, err := client.ListBeaconBlocks(context.Background(), req) + if err != nil { + return errors.Wrap(err, "failed to list blocks") + } + // check if fee recipient is set + isFeeRecipientPresent := false + for _, ctr := range blks.BlockContainers { + switch ctr.Block.(type) { + case *ethpb.BeaconBlockContainer_BellatrixBlock: + hex,err := hexutil.Decode("0x878705ba3f8bc32fcf7f4caa1a35e72af65cf766") + if err != nil { + return errors.Wrap(err, "failed to decode fee recipient") + } + if (ctr.GetBellatrixBlock().Block.Body.ExecutionPayload.FeeRecipient == hex){ + isFeeRecipientPresent = true + } + } + if isFeeRecipientPresent { + break + } + } + if !isFeeRecipientPresent { + return errors.New("fee recipient is not set") + } + return nil +} \ No newline at end of file diff --git a/testing/endtoend/minimal_e2e_test.go b/testing/endtoend/minimal_e2e_test.go index 4f88ef39e322..c7aad7125221 100644 --- a/testing/endtoend/minimal_e2e_test.go +++ b/testing/endtoend/minimal_e2e_test.go @@ -94,6 +94,7 @@ func e2eMinimal(t *testing.T, args *testArgs) { ev.AllNodesHaveSameHead, ev.ValidatorSyncParticipation, ev.TransactionsPresent, + } testConfig := &types.E2EConfig{ BeaconFlags: []string{ From 16ebb53a07dd8385f209fcc99d39d51617ea2a5c Mon Sep 17 00:00:00 2001 From: James He Date: Thu, 14 Apr 2022 16:19:02 -0400 Subject: [PATCH 02/70] fixing bazel linter --- testing/endtoend/components/eth1/miner.go | 3 ++- testing/endtoend/evaluators/BUILD.bazel | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/testing/endtoend/components/eth1/miner.go b/testing/endtoend/components/eth1/miner.go index c5ee275d233e..6481fe7ebe39 100644 --- a/testing/endtoend/components/eth1/miner.go +++ b/testing/endtoend/components/eth1/miner.go @@ -192,7 +192,8 @@ func (m *Miner) Start(ctx context.Context) error { if err = WaitForBlocks(web3, store, params.BeaconConfig().Eth1FollowDistance); err != nil { return fmt.Errorf("unable to advance chain: %w", err) } - txOpts, err := bind.NewTransactorWithChainID(bytes.NewReader(jsonBytes), KeystorePassword, big.NewInt(NetworkId)) + txOpts, err := bind.NewTransactorWithChainID(bytes.NewReader(jsonBytes), KeystorePassword, big.NewInt(Ne + tworkId)) if err != nil { return err } diff --git a/testing/endtoend/evaluators/BUILD.bazel b/testing/endtoend/evaluators/BUILD.bazel index 3c13dda75b23..27e118b96771 100644 --- a/testing/endtoend/evaluators/BUILD.bazel +++ b/testing/endtoend/evaluators/BUILD.bazel @@ -8,6 +8,7 @@ go_library( "api_middleware.go", "data.go", "execution_engine.go", + "fee_recipient.go", "finality.go", "fork.go", "metrics.go", From bc26e2510e971fbc40ad52bac554b6294e9c81aa Mon Sep 17 00:00:00 2001 From: James He Date: Thu, 14 Apr 2022 16:28:43 -0400 Subject: [PATCH 03/70] adjusting comparison --- testing/endtoend/evaluators/fee_recipient.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/testing/endtoend/evaluators/fee_recipient.go b/testing/endtoend/evaluators/fee_recipient.go index b27609788ab6..54d9a78f4f96 100644 --- a/testing/endtoend/evaluators/fee_recipient.go +++ b/testing/endtoend/evaluators/fee_recipient.go @@ -7,7 +7,6 @@ import ( "github.com/pkg/errors" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/testing/endtoend/helpers" - e2e "github.com/prysmaticlabs/prysm/testing/endtoend/params" "github.com/prysmaticlabs/prysm/testing/endtoend/policies" "github.com/prysmaticlabs/prysm/testing/endtoend/types" "google.golang.org/grpc" @@ -37,11 +36,8 @@ func feeRecipientIsPresent(conns ...*grpc.ClientConn) error { for _, ctr := range blks.BlockContainers { switch ctr.Block.(type) { case *ethpb.BeaconBlockContainer_BellatrixBlock: - hex,err := hexutil.Decode("0x878705ba3f8bc32fcf7f4caa1a35e72af65cf766") - if err != nil { - return errors.Wrap(err, "failed to decode fee recipient") - } - if (ctr.GetBellatrixBlock().Block.Body.ExecutionPayload.FeeRecipient == hex){ + fr := ctr.GetBellatrixBlock().Block.Body.ExecutionPayload.FeeRecipient + if len(fr)!= 0 && hexutil.Encode(fr) == "0x878705ba3f8bc32fcf7f4caa1a35e72af65cf766" { isFeeRecipientPresent = true } } From f01c7a20c17e30bb9c79cf7584c119b11ca0d935 Mon Sep 17 00:00:00 2001 From: James He Date: Thu, 14 Apr 2022 16:40:56 -0400 Subject: [PATCH 04/70] typo on file rolling back --- testing/endtoend/components/eth1/miner.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/testing/endtoend/components/eth1/miner.go b/testing/endtoend/components/eth1/miner.go index 6481fe7ebe39..c5ee275d233e 100644 --- a/testing/endtoend/components/eth1/miner.go +++ b/testing/endtoend/components/eth1/miner.go @@ -192,8 +192,7 @@ func (m *Miner) Start(ctx context.Context) error { if err = WaitForBlocks(web3, store, params.BeaconConfig().Eth1FollowDistance); err != nil { return fmt.Errorf("unable to advance chain: %w", err) } - txOpts, err := bind.NewTransactorWithChainID(bytes.NewReader(jsonBytes), KeystorePassword, big.NewInt(Ne - tworkId)) + txOpts, err := bind.NewTransactorWithChainID(bytes.NewReader(jsonBytes), KeystorePassword, big.NewInt(NetworkId)) if err != nil { return err } From 0058de00ed7f272a40dec55c1b5cabe2c03de17b Mon Sep 17 00:00:00 2001 From: James He Date: Thu, 14 Apr 2022 16:43:50 -0400 Subject: [PATCH 05/70] adding fee recipient is present to minimal e2e --- testing/endtoend/minimal_e2e_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/endtoend/minimal_e2e_test.go b/testing/endtoend/minimal_e2e_test.go index c7aad7125221..857c3a2e7937 100644 --- a/testing/endtoend/minimal_e2e_test.go +++ b/testing/endtoend/minimal_e2e_test.go @@ -94,7 +94,7 @@ func e2eMinimal(t *testing.T, args *testArgs) { ev.AllNodesHaveSameHead, ev.ValidatorSyncParticipation, ev.TransactionsPresent, - + ev.FeeRecipientIsPresent, } testConfig := &types.E2EConfig{ BeaconFlags: []string{ From 9ce5f5c160ca1b2d8ebc3159b0b7b7ecb7ac2257 Mon Sep 17 00:00:00 2001 From: James He Date: Thu, 14 Apr 2022 16:50:50 -0400 Subject: [PATCH 06/70] fixing gofmt --- testing/endtoend/components/validator.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/endtoend/components/validator.go b/testing/endtoend/components/validator.go index f8ca8c7c269d..0ebd39d86826 100644 --- a/testing/endtoend/components/validator.go +++ b/testing/endtoend/components/validator.go @@ -142,7 +142,7 @@ func (v *ValidatorNode) Start(ctx context.Context) error { fmt.Sprintf("--%s=localhost:%d", flags.BeaconRPCProviderFlag.Name, beaconRPCPort), fmt.Sprintf("--%s=%s", flags.GrpcHeadersFlag.Name, "dummy=value,foo=bar"), // Sending random headers shouldn't break anything. fmt.Sprintf("--%s=%s", cmdshared.VerbosityFlag.Name, "debug"), - fmt.Sprintf("--%s=%s",flags.SuggestedFeeRecipientFlag,"0x878705ba3f8bc32fcf7f4caa1a35e72af65cf766"), + fmt.Sprintf("--%s=%s", flags.SuggestedFeeRecipientFlag, "0x878705ba3f8bc32fcf7f4caa1a35e72af65cf766"), "--" + cmdshared.ForceClearDB.Name, "--" + cmdshared.E2EConfigFlag.Name, "--" + cmdshared.AcceptTosFlag.Name, From cde4eaea3e86f3547c57857716f255123ba70f70 Mon Sep 17 00:00:00 2001 From: James He Date: Thu, 14 Apr 2022 16:53:39 -0400 Subject: [PATCH 07/70] fixing gofmt --- testing/endtoend/evaluators/fee_recipient.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/testing/endtoend/evaluators/fee_recipient.go b/testing/endtoend/evaluators/fee_recipient.go index 54d9a78f4f96..bc5b55305d8a 100644 --- a/testing/endtoend/evaluators/fee_recipient.go +++ b/testing/endtoend/evaluators/fee_recipient.go @@ -16,7 +16,7 @@ import ( var FeeRecipientIsPresent = types.Evaluator{ Name: "Fee_Recipient_Is_Present_%d", Policy: policies.AfterNthEpoch(helpers.BellatrixE2EForkEpoch), - Evaluation: feeRecipientIsPresent, + Evaluation: feeRecipientIsPresent, } func feeRecipientIsPresent(conns ...*grpc.ClientConn) error { @@ -37,7 +37,7 @@ func feeRecipientIsPresent(conns ...*grpc.ClientConn) error { switch ctr.Block.(type) { case *ethpb.BeaconBlockContainer_BellatrixBlock: fr := ctr.GetBellatrixBlock().Block.Body.ExecutionPayload.FeeRecipient - if len(fr)!= 0 && hexutil.Encode(fr) == "0x878705ba3f8bc32fcf7f4caa1a35e72af65cf766" { + if len(fr) != 0 && hexutil.Encode(fr) == "0x878705ba3f8bc32fcf7f4caa1a35e72af65cf766" { isFeeRecipientPresent = true } } @@ -49,4 +49,4 @@ func feeRecipientIsPresent(conns ...*grpc.ClientConn) error { return errors.New("fee recipient is not set") } return nil -} \ No newline at end of file +} From 5bd0a722b3e6867309d84a41b1446641a12bc634 Mon Sep 17 00:00:00 2001 From: James He Date: Thu, 14 Apr 2022 17:24:31 -0400 Subject: [PATCH 08/70] fixing flag usage name --- testing/endtoend/components/validator.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/endtoend/components/validator.go b/testing/endtoend/components/validator.go index 0ebd39d86826..fc649132ae45 100644 --- a/testing/endtoend/components/validator.go +++ b/testing/endtoend/components/validator.go @@ -142,7 +142,7 @@ func (v *ValidatorNode) Start(ctx context.Context) error { fmt.Sprintf("--%s=localhost:%d", flags.BeaconRPCProviderFlag.Name, beaconRPCPort), fmt.Sprintf("--%s=%s", flags.GrpcHeadersFlag.Name, "dummy=value,foo=bar"), // Sending random headers shouldn't break anything. fmt.Sprintf("--%s=%s", cmdshared.VerbosityFlag.Name, "debug"), - fmt.Sprintf("--%s=%s", flags.SuggestedFeeRecipientFlag, "0x878705ba3f8bc32fcf7f4caa1a35e72af65cf766"), + fmt.Sprintf("--%s=%s", flags.SuggestedFeeRecipientFlag.Name, "0x878705ba3f8bc32fcf7f4caa1a35e72af65cf766"), "--" + cmdshared.ForceClearDB.Name, "--" + cmdshared.E2EConfigFlag.Name, "--" + cmdshared.AcceptTosFlag.Name, From 8a9e9ccc666df71e3e94502207517ecac6cb5dd8 Mon Sep 17 00:00:00 2001 From: James He Date: Fri, 15 Apr 2022 16:38:48 -0400 Subject: [PATCH 09/70] adding in log to help debug --- testing/endtoend/evaluators/fee_recipient.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/testing/endtoend/evaluators/fee_recipient.go b/testing/endtoend/evaluators/fee_recipient.go index bc5b55305d8a..59a3e50e2cba 100644 --- a/testing/endtoend/evaluators/fee_recipient.go +++ b/testing/endtoend/evaluators/fee_recipient.go @@ -11,6 +11,7 @@ import ( "github.com/prysmaticlabs/prysm/testing/endtoend/types" "google.golang.org/grpc" "google.golang.org/protobuf/types/known/emptypb" + "gopkg.in/src-d/go-log.v1" ) var FeeRecipientIsPresent = types.Evaluator{ @@ -40,6 +41,7 @@ func feeRecipientIsPresent(conns ...*grpc.ClientConn) error { if len(fr) != 0 && hexutil.Encode(fr) == "0x878705ba3f8bc32fcf7f4caa1a35e72af65cf766" { isFeeRecipientPresent = true } + log.Infof("Fee recipient in bellatrix block: %s, want 0x878705ba3f8bc32fcf7f4caa1a35e72af65cf766", hexutil.Encode(fr)) } if isFeeRecipientPresent { break From 465bc68e29a7e11d41f45c1e588aa50b3b87a78f Mon Sep 17 00:00:00 2001 From: James He Date: Fri, 15 Apr 2022 16:56:23 -0400 Subject: [PATCH 10/70] fixing log build --- testing/endtoend/evaluators/BUILD.bazel | 1 + testing/endtoend/evaluators/fee_recipient.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/testing/endtoend/evaluators/BUILD.bazel b/testing/endtoend/evaluators/BUILD.bazel index 27e118b96771..d43469616c27 100644 --- a/testing/endtoend/evaluators/BUILD.bazel +++ b/testing/endtoend/evaluators/BUILD.bazel @@ -45,6 +45,7 @@ go_library( "@com_github_pkg_errors//:go_default_library", "@com_github_prysmaticlabs_eth2_types//:go_default_library", "@com_github_prysmaticlabs_go_bitfield//:go_default_library", + "@com_github_sirupsen_logrus//:go_default_library", "@io_bazel_rules_go//proto/wkt:empty_go_proto", "@org_golang_google_grpc//:go_default_library", "@org_golang_google_protobuf//types/known/emptypb:go_default_library", diff --git a/testing/endtoend/evaluators/fee_recipient.go b/testing/endtoend/evaluators/fee_recipient.go index 59a3e50e2cba..7696520df12a 100644 --- a/testing/endtoend/evaluators/fee_recipient.go +++ b/testing/endtoend/evaluators/fee_recipient.go @@ -9,9 +9,9 @@ import ( "github.com/prysmaticlabs/prysm/testing/endtoend/helpers" "github.com/prysmaticlabs/prysm/testing/endtoend/policies" "github.com/prysmaticlabs/prysm/testing/endtoend/types" + log "github.com/sirupsen/logrus" "google.golang.org/grpc" "google.golang.org/protobuf/types/known/emptypb" - "gopkg.in/src-d/go-log.v1" ) var FeeRecipientIsPresent = types.Evaluator{ From fc0ece8ca0c233aa7d92be8bbbf68b703723e8f2 Mon Sep 17 00:00:00 2001 From: James He Date: Mon, 18 Apr 2022 21:39:56 -0400 Subject: [PATCH 11/70] trying to figure out why suggested fee recipient isn't working in e2e, adding more logging temporarily --- .../validator/proposer_execution_payload.go | 8 +++++- testing/endtoend/minimal_e2e_test.go | 28 +++++++++---------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/beacon-chain/rpc/prysm/v1alpha1/validator/proposer_execution_payload.go b/beacon-chain/rpc/prysm/v1alpha1/validator/proposer_execution_payload.go index 4123cfdddae1..8a284dbb2a6b 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/validator/proposer_execution_payload.go +++ b/beacon-chain/rpc/prysm/v1alpha1/validator/proposer_execution_payload.go @@ -122,6 +122,7 @@ func (vs *Server) getExecutionPayload(ctx context.Context, slot types.Slot, vIdx burnAddr := bytesutil.PadTo([]byte{}, fieldparams.FeeRecipientLength) switch err == nil { case true: + log.Infof("getExecutionPayload: validator %d has fee recipient %v", vIdx, recipient) feeRecipient = recipient case errors.As(err, kv.ErrNotFoundFeeRecipient): // If fee recipient is not found in DB and not set from beacon node CLI, @@ -147,7 +148,12 @@ func (vs *Server) getExecutionPayload(ctx context.Context, slot types.Slot, vIdx if payloadID == nil { return nil, errors.New("nil payload id") } - return vs.ExecutionEngineCaller.GetPayload(ctx, *payloadID) + payload, err := vs.ExecutionEngineCaller.GetPayload(ctx, *payloadID) + if err != nil { + return nil, errors.Wrap(err, "could not get payload") + } + log.Infof("getExecutionPayload: has payload %v", payload) + return payload, nil } // This returns the valid terminal block hash with an existence bool value. diff --git a/testing/endtoend/minimal_e2e_test.go b/testing/endtoend/minimal_e2e_test.go index 857c3a2e7937..5506dddc94d9 100644 --- a/testing/endtoend/minimal_e2e_test.go +++ b/testing/endtoend/minimal_e2e_test.go @@ -26,20 +26,20 @@ func TestEndToEnd_MinimalConfig(t *testing.T) { }) } -func TestEndToEnd_MinimalConfig_Web3Signer(t *testing.T) { - e2eMinimal(t, &testArgs{ - usePrysmSh: false, - useWeb3RemoteSigner: true, - }) -} - -// Run minimal e2e config with the current release validator against latest beacon node. -func TestEndToEnd_MinimalConfig_ValidatorAtCurrentRelease(t *testing.T) { - e2eMinimal(t, &testArgs{ - usePrysmSh: true, - useWeb3RemoteSigner: false, - }) -} +//func TestEndToEnd_MinimalConfig_Web3Signer(t *testing.T) { +// e2eMinimal(t, &testArgs{ +// usePrysmSh: false, +// useWeb3RemoteSigner: true, +// }) +//} +// +//// Run minimal e2e config with the current release validator against latest beacon node. +//func TestEndToEnd_MinimalConfig_ValidatorAtCurrentRelease(t *testing.T) { +// e2eMinimal(t, &testArgs{ +// usePrysmSh: true, +// useWeb3RemoteSigner: false, +// }) +//} func e2eMinimal(t *testing.T, args *testArgs) { params.UseE2EConfig() From aa8b0734f8cbdb039ddb20c0728ac0aa03e2b4a8 Mon Sep 17 00:00:00 2001 From: James He Date: Thu, 21 Apr 2022 09:11:32 -0400 Subject: [PATCH 12/70] rolling back logs --- .../validator/proposer_execution_payload.go | 8 +----- testing/endtoend/minimal_e2e_test.go | 28 +++++++++---------- 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/beacon-chain/rpc/prysm/v1alpha1/validator/proposer_execution_payload.go b/beacon-chain/rpc/prysm/v1alpha1/validator/proposer_execution_payload.go index 8a284dbb2a6b..4123cfdddae1 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/validator/proposer_execution_payload.go +++ b/beacon-chain/rpc/prysm/v1alpha1/validator/proposer_execution_payload.go @@ -122,7 +122,6 @@ func (vs *Server) getExecutionPayload(ctx context.Context, slot types.Slot, vIdx burnAddr := bytesutil.PadTo([]byte{}, fieldparams.FeeRecipientLength) switch err == nil { case true: - log.Infof("getExecutionPayload: validator %d has fee recipient %v", vIdx, recipient) feeRecipient = recipient case errors.As(err, kv.ErrNotFoundFeeRecipient): // If fee recipient is not found in DB and not set from beacon node CLI, @@ -148,12 +147,7 @@ func (vs *Server) getExecutionPayload(ctx context.Context, slot types.Slot, vIdx if payloadID == nil { return nil, errors.New("nil payload id") } - payload, err := vs.ExecutionEngineCaller.GetPayload(ctx, *payloadID) - if err != nil { - return nil, errors.Wrap(err, "could not get payload") - } - log.Infof("getExecutionPayload: has payload %v", payload) - return payload, nil + return vs.ExecutionEngineCaller.GetPayload(ctx, *payloadID) } // This returns the valid terminal block hash with an existence bool value. diff --git a/testing/endtoend/minimal_e2e_test.go b/testing/endtoend/minimal_e2e_test.go index ed8002e9b5b9..0bd6da9b2a01 100644 --- a/testing/endtoend/minimal_e2e_test.go +++ b/testing/endtoend/minimal_e2e_test.go @@ -26,20 +26,20 @@ func TestEndToEnd_MinimalConfig(t *testing.T) { }) } -//func TestEndToEnd_MinimalConfig_Web3Signer(t *testing.T) { -// e2eMinimal(t, &testArgs{ -// usePrysmSh: false, -// useWeb3RemoteSigner: true, -// }) -//} -// -//// Run minimal e2e config with the current release validator against latest beacon node. -//func TestEndToEnd_MinimalConfig_ValidatorAtCurrentRelease(t *testing.T) { -// e2eMinimal(t, &testArgs{ -// usePrysmSh: true, -// useWeb3RemoteSigner: false, -// }) -//} +func TestEndToEnd_MinimalConfig_Web3Signer(t *testing.T) { + e2eMinimal(t, &testArgs{ + usePrysmSh: false, + useWeb3RemoteSigner: true, + }) +} + +// Run minimal e2e config with the current release validator against latest beacon node. +func TestEndToEnd_MinimalConfig_ValidatorAtCurrentRelease(t *testing.T) { + e2eMinimal(t, &testArgs{ + usePrysmSh: true, + useWeb3RemoteSigner: false, + }) +} func e2eMinimal(t *testing.T, args *testArgs) { params.UseE2EConfig() From db27abd43538ecdb021dc2576e3bd43a546f993e Mon Sep 17 00:00:00 2001 From: James He Date: Thu, 21 Apr 2022 16:50:37 -0400 Subject: [PATCH 13/70] making e2e test more dynamic --- testing/endtoend/components/eth1/miner.go | 6 +- testing/endtoend/components/validator.go | 75 +++++++++++++++++--- testing/endtoend/evaluators/fee_recipient.go | 5 +- 3 files changed, 71 insertions(+), 15 deletions(-) diff --git a/testing/endtoend/components/eth1/miner.go b/testing/endtoend/components/eth1/miner.go index 4f9871d0f7c9..0552d959956c 100644 --- a/testing/endtoend/components/eth1/miner.go +++ b/testing/endtoend/components/eth1/miner.go @@ -26,6 +26,10 @@ import ( log "github.com/sirupsen/logrus" ) +const ( + EthAddress = "0x878705ba3f8bc32fcf7f4caa1a35e72af65cf766" +) + // Miner represents an ETH1 node which mines blocks. type Miner struct { e2etypes.ComponentRunner @@ -125,7 +129,7 @@ func (m *Miner) Start(ctx context.Context) error { "--ipcdisable", "--verbosity=4", "--mine", - "--unlock=0x878705ba3f8bc32fcf7f4caa1a35e72af65cf766", + fmt.Sprintf("--unlock=%s", EthAddress), "--allow-insecure-unlock", fmt.Sprintf("--password=%s", eth1Path+"/keystore/"+minerPasswordFile), } diff --git a/testing/endtoend/components/validator.go b/testing/endtoend/components/validator.go index 029621ed2188..5f206e07ce45 100644 --- a/testing/endtoend/components/validator.go +++ b/testing/endtoend/components/validator.go @@ -3,17 +3,19 @@ package components import ( "bytes" "context" - "encoding/hex" + "encoding/json" "fmt" "math/big" "os" "os/exec" "path" + "path/filepath" "strings" "github.com/bazelbuild/rules_go/go/tools/bazel" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/accounts/keystore" + "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/rpc" "github.com/pkg/errors" @@ -21,8 +23,10 @@ import ( "github.com/prysmaticlabs/prysm/cmd/validator/flags" "github.com/prysmaticlabs/prysm/config/features" "github.com/prysmaticlabs/prysm/config/params" + validator_service_config "github.com/prysmaticlabs/prysm/config/validator/service" contracts "github.com/prysmaticlabs/prysm/contracts/deposit" "github.com/prysmaticlabs/prysm/encoding/bytesutil" + "github.com/prysmaticlabs/prysm/io/file" "github.com/prysmaticlabs/prysm/runtime/interop" "github.com/prysmaticlabs/prysm/testing/endtoend/components/eth1" "github.com/prysmaticlabs/prysm/testing/endtoend/helpers" @@ -32,7 +36,10 @@ import ( ) const depositGasLimit = 4000000 +const FeeRecipientAddress = "0x055Fb65722E7b2455043BFEBf6177F1D2e9738D9" +const DefaultFeeRecipientAddress = "0x099Fb65722E7b2455043BFEBf6177F1D2e9738D9" +var ValidatorHexPubKeys []string = make([]string, 0) var _ e2etypes.ComponentRunner = (*ValidatorNode)(nil) var _ e2etypes.ComponentRunner = (*ValidatorNodeSet)(nil) @@ -132,6 +139,15 @@ func (v *ValidatorNode) Start(ctx context.Context) error { if err != nil { return err } + + _, pubs, err := interop.DeterministicallyGenerateKeys(uint64(offset), uint64(validatorNum)) + if err != nil { + return err + } + for _, pub := range pubs { + ValidatorHexPubKeys = append(ValidatorHexPubKeys, hexutil.Encode(pub.Marshal())) + } + args := []string{ fmt.Sprintf("--%s=%s/eth2-val-%d", cmdshared.DataDirFlag.Name, e2e.TestParams.TestPath, index), fmt.Sprintf("--%s=%s", cmdshared.LogFileName.Name, file.Name()), @@ -141,28 +157,27 @@ func (v *ValidatorNode) Start(ctx context.Context) error { fmt.Sprintf("--%s=localhost:%d", flags.BeaconRPCProviderFlag.Name, beaconRPCPort), fmt.Sprintf("--%s=%s", flags.GrpcHeadersFlag.Name, "dummy=value,foo=bar"), // Sending random headers shouldn't break anything. fmt.Sprintf("--%s=%s", cmdshared.VerbosityFlag.Name, "debug"), - fmt.Sprintf("--%s=%s", flags.SuggestedFeeRecipientFlag.Name, "0x878705ba3f8bc32fcf7f4caa1a35e72af65cf766"), "--" + cmdshared.ForceClearDB.Name, "--" + cmdshared.E2EConfigFlag.Name, "--" + cmdshared.AcceptTosFlag.Name, } + feeConfigPath, err := createFeeRecipientConfigPath(ValidatorHexPubKeys) + if err != nil { + return err + } + + args = append(args, fmt.Sprintf("--%s=%s", flags.FeeRecipientConfigFileFlag.Name, feeConfigPath)) + // Only apply e2e flags to the current branch. New flags may not exist in previous release. if !v.config.UsePrysmShValidator { args = append(args, features.E2EValidatorFlags...) } + if v.config.UseWeb3RemoteSigner { args = append(args, fmt.Sprintf("--%s=http://localhost:%d", flags.Web3SignerURLFlag.Name, Web3RemoteSignerPort)) // Write the pubkeys as comma seperated hex strings with 0x prefix. // See: https://docs.teku.consensys.net/en/latest/HowTo/External-Signer/Use-External-Signer/ - _, pubs, err := interop.DeterministicallyGenerateKeys(uint64(offset), uint64(validatorNum)) - if err != nil { - return err - } - var hexPubs []string - for _, pub := range pubs { - hexPubs = append(hexPubs, "0x"+hex.EncodeToString(pub.Marshal())) - } - args = append(args, fmt.Sprintf("--%s=%s", flags.Web3SignerPublicValidatorKeysFlag.Name, strings.Join(hexPubs, ","))) + args = append(args, fmt.Sprintf("--%s=%s", flags.Web3SignerPublicValidatorKeysFlag.Name, strings.Join(ValidatorHexPubKeys, ","))) } else { // When not using remote key signer, use interop keys. args = append(args, @@ -297,3 +312,41 @@ func sendDeposits(web3 *ethclient.Client, keystoreBytes []byte, num, offset int, } return nil } + +func createFeeRecipientConfigPath(pubkeys []string) (string, error) { + testNetDir := e2e.TestParams.TestPath + "/fee-recipient-config" + configPath := filepath.Join(testNetDir, "config.json") + if len(ValidatorHexPubKeys) == 0 { + return "", errors.New("number of validators must be greater than 0") + } + var feeRecipientConfig validator_service_config.FeeRecipientFileConfig + if len(ValidatorHexPubKeys) == 1 { + feeRecipientConfig = validator_service_config.FeeRecipientFileConfig{ + DefaultConfig: &validator_service_config.FeeRecipientFileOptions{ + FeeRecipient: DefaultFeeRecipientAddress, + }, + } + } else { + config := make(map[string]*validator_service_config.FeeRecipientFileOptions) + config[ValidatorHexPubKeys[0]] = &validator_service_config.FeeRecipientFileOptions{ + FeeRecipient: FeeRecipientAddress, + } + feeRecipientConfig = validator_service_config.FeeRecipientFileConfig{ + ProposeConfig: config, + DefaultConfig: &validator_service_config.FeeRecipientFileOptions{ + FeeRecipient: DefaultFeeRecipientAddress, + }, + } + } + jsonBytes, err := json.Marshal(feeRecipientConfig) + if err != nil { + return "", err + } + if err := file.MkdirAll(testNetDir); err != nil { + return "", err + } + if err := file.WriteFile(configPath, jsonBytes); err != nil { + return "", err + } + return configPath, nil +} diff --git a/testing/endtoend/evaluators/fee_recipient.go b/testing/endtoend/evaluators/fee_recipient.go index 7696520df12a..982e37e51fc5 100644 --- a/testing/endtoend/evaluators/fee_recipient.go +++ b/testing/endtoend/evaluators/fee_recipient.go @@ -5,11 +5,11 @@ import ( "github.com/ethereum/go-ethereum/common/hexutil" "github.com/pkg/errors" + field_params "github.com/prysmaticlabs/prysm/config/fieldparams" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/testing/endtoend/helpers" "github.com/prysmaticlabs/prysm/testing/endtoend/policies" "github.com/prysmaticlabs/prysm/testing/endtoend/types" - log "github.com/sirupsen/logrus" "google.golang.org/grpc" "google.golang.org/protobuf/types/known/emptypb" ) @@ -38,10 +38,9 @@ func feeRecipientIsPresent(conns ...*grpc.ClientConn) error { switch ctr.Block.(type) { case *ethpb.BeaconBlockContainer_BellatrixBlock: fr := ctr.GetBellatrixBlock().Block.Body.ExecutionPayload.FeeRecipient - if len(fr) != 0 && hexutil.Encode(fr) == "0x878705ba3f8bc32fcf7f4caa1a35e72af65cf766" { + if len(fr) != 0 && hexutil.Encode(fr) != field_params.EthBurnAddressHex { isFeeRecipientPresent = true } - log.Infof("Fee recipient in bellatrix block: %s, want 0x878705ba3f8bc32fcf7f4caa1a35e72af65cf766", hexutil.Encode(fr)) } if isFeeRecipientPresent { break From 30b9b7b5d8df3dd7b25126e8ca430e53b0673708 Mon Sep 17 00:00:00 2001 From: James He Date: Thu, 21 Apr 2022 17:09:49 -0400 Subject: [PATCH 14/70] fixing deepsource issue --- testing/endtoend/components/validator.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/endtoend/components/validator.go b/testing/endtoend/components/validator.go index 5f206e07ce45..896ef35e231a 100644 --- a/testing/endtoend/components/validator.go +++ b/testing/endtoend/components/validator.go @@ -328,7 +328,7 @@ func createFeeRecipientConfigPath(pubkeys []string) (string, error) { } } else { config := make(map[string]*validator_service_config.FeeRecipientFileOptions) - config[ValidatorHexPubKeys[0]] = &validator_service_config.FeeRecipientFileOptions{ + config[pubkeys[0]] = &validator_service_config.FeeRecipientFileOptions{ FeeRecipient: FeeRecipientAddress, } feeRecipientConfig = validator_service_config.FeeRecipientFileConfig{ From 41a59d7cca7f4d62eca5b4546f727fa169de1da3 Mon Sep 17 00:00:00 2001 From: James He Date: Thu, 21 Apr 2022 17:16:47 -0400 Subject: [PATCH 15/70] fixing bazel --- testing/endtoend/components/BUILD.bazel | 1 + testing/endtoend/evaluators/BUILD.bazel | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/endtoend/components/BUILD.bazel b/testing/endtoend/components/BUILD.bazel index d9732ec80dcd..1d3d353bbb49 100644 --- a/testing/endtoend/components/BUILD.bazel +++ b/testing/endtoend/components/BUILD.bazel @@ -25,6 +25,7 @@ go_library( "//cmd/validator/flags:go_default_library", "//config/features:go_default_library", "//config/params:go_default_library", + "//config/validator/service:go_default_library", "//contracts/deposit:go_default_library", "//crypto/bls:go_default_library", "//encoding/bytesutil:go_default_library", diff --git a/testing/endtoend/evaluators/BUILD.bazel b/testing/endtoend/evaluators/BUILD.bazel index d43469616c27..27e118b96771 100644 --- a/testing/endtoend/evaluators/BUILD.bazel +++ b/testing/endtoend/evaluators/BUILD.bazel @@ -45,7 +45,6 @@ go_library( "@com_github_pkg_errors//:go_default_library", "@com_github_prysmaticlabs_eth2_types//:go_default_library", "@com_github_prysmaticlabs_go_bitfield//:go_default_library", - "@com_github_sirupsen_logrus//:go_default_library", "@io_bazel_rules_go//proto/wkt:empty_go_proto", "@org_golang_google_grpc//:go_default_library", "@org_golang_google_protobuf//types/known/emptypb:go_default_library", From 76513a6defbbc83f6b22348bafe314c107e6cafb Mon Sep 17 00:00:00 2001 From: James He Date: Fri, 22 Apr 2022 15:27:00 -0400 Subject: [PATCH 16/70] adding in condition for latest release --- testing/endtoend/components/validator.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/testing/endtoend/components/validator.go b/testing/endtoend/components/validator.go index 896ef35e231a..0768abcea92f 100644 --- a/testing/endtoend/components/validator.go +++ b/testing/endtoend/components/validator.go @@ -161,13 +161,15 @@ func (v *ValidatorNode) Start(ctx context.Context) error { "--" + cmdshared.E2EConfigFlag.Name, "--" + cmdshared.AcceptTosFlag.Name, } - feeConfigPath, err := createFeeRecipientConfigPath(ValidatorHexPubKeys) - if err != nil { - return err - } - - args = append(args, fmt.Sprintf("--%s=%s", flags.FeeRecipientConfigFileFlag.Name, feeConfigPath)) + //TODO: Remove this once latest package supports this flag. + if !v.config.UsePrysmShValidator { + feeConfigPath, err := createFeeRecipientConfigPath(ValidatorHexPubKeys) + if err != nil { + return err + } + args = append(args, fmt.Sprintf("--%s=%s", flags.FeeRecipientConfigFileFlag.Name, feeConfigPath)) + } // Only apply e2e flags to the current branch. New flags may not exist in previous release. if !v.config.UsePrysmShValidator { args = append(args, features.E2EValidatorFlags...) From ec240d5c023b56d6bd97422fd87a0ac6578067e1 Mon Sep 17 00:00:00 2001 From: James He Date: Fri, 22 Apr 2022 16:12:19 -0400 Subject: [PATCH 17/70] duplicate condtion check. --- testing/endtoend/components/validator.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/testing/endtoend/components/validator.go b/testing/endtoend/components/validator.go index 0768abcea92f..d4ac4d6d9b8c 100644 --- a/testing/endtoend/components/validator.go +++ b/testing/endtoend/components/validator.go @@ -161,19 +161,16 @@ func (v *ValidatorNode) Start(ctx context.Context) error { "--" + cmdshared.E2EConfigFlag.Name, "--" + cmdshared.AcceptTosFlag.Name, } - //TODO: Remove this once latest package supports this flag. + // Only apply e2e flags to the current branch. New flags may not exist in previous release. if !v.config.UsePrysmShValidator { + args = append(args, features.E2EValidatorFlags...) + //TODO: Remove this once it is in current release. feeConfigPath, err := createFeeRecipientConfigPath(ValidatorHexPubKeys) if err != nil { return err } - args = append(args, fmt.Sprintf("--%s=%s", flags.FeeRecipientConfigFileFlag.Name, feeConfigPath)) } - // Only apply e2e flags to the current branch. New flags may not exist in previous release. - if !v.config.UsePrysmShValidator { - args = append(args, features.E2EValidatorFlags...) - } if v.config.UseWeb3RemoteSigner { args = append(args, fmt.Sprintf("--%s=http://localhost:%d", flags.Web3SignerURLFlag.Name, Web3RemoteSignerPort)) From 58e7662b46bd5df33ea566f79526ba09abf106ac Mon Sep 17 00:00:00 2001 From: James He Date: Wed, 15 Jun 2022 10:56:49 -0500 Subject: [PATCH 18/70] fixing gofmt --- testing/endtoend/minimal_e2e_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/testing/endtoend/minimal_e2e_test.go b/testing/endtoend/minimal_e2e_test.go index 08007db2325c..97e35a6bfcd5 100644 --- a/testing/endtoend/minimal_e2e_test.go +++ b/testing/endtoend/minimal_e2e_test.go @@ -95,4 +95,3 @@ func e2eMinimal(t *testing.T, args *testArgs) { newTestRunner(t, testConfig).run() } - From 7091a12f9d2e24506f7ad28d7d1ce97dbf0a0b50 Mon Sep 17 00:00:00 2001 From: James He Date: Wed, 15 Jun 2022 10:58:20 -0500 Subject: [PATCH 19/70] rolling back changes --- testing/endtoend/minimal_e2e_test.go | 78 ---------------------------- 1 file changed, 78 deletions(-) diff --git a/testing/endtoend/minimal_e2e_test.go b/testing/endtoend/minimal_e2e_test.go index 97e35a6bfcd5..3e1affa1705a 100644 --- a/testing/endtoend/minimal_e2e_test.go +++ b/testing/endtoend/minimal_e2e_test.go @@ -17,81 +17,3 @@ func TestEndToEnd_MinimalConfig_Web3Signer(t *testing.T) { func TestEndToEnd_MinimalConfig_CheckpointSync(t *testing.T) { e2eMinimal(t, types.WithCheckpointSync()).run() } - -func e2eMinimal(t *testing.T, args *testArgs) { - params.UseE2EConfig() - require.NoError(t, e2eParams.Init(e2eParams.StandardBeaconCount)) - - // Run for 12 epochs if not in long-running to confirm long-running has no issues. - var err error - epochsToRun := 12 - epochStr, longRunning := os.LookupEnv("E2E_EPOCHS") - if longRunning { - epochsToRun, err = strconv.Atoi(epochStr) - require.NoError(t, err) - } - // TODO(#10053): Web3signer does not support bellatrix yet. - if args.useWeb3RemoteSigner { - epochsToRun = helpers.BellatrixE2EForkEpoch - 1 - } - if args.usePrysmSh { - // If using prysm.sh, run for only 6 epochs. - // TODO(#9166): remove this block once v2 changes are live. - epochsToRun = helpers.AltairE2EForkEpoch - 1 - } - seed := 0 - seedStr, isValid := os.LookupEnv("E2E_SEED") - if isValid { - seed, err = strconv.Atoi(seedStr) - require.NoError(t, err) - } - tracingPort := e2eParams.TestParams.Ports.JaegerTracingPort - tracingEndpoint := fmt.Sprintf("127.0.0.1:%d", tracingPort) - evals := []types.Evaluator{ - ev.PeersConnect, - ev.HealthzCheck, - ev.MetricsCheck, - ev.ValidatorsAreActive, - ev.ValidatorsParticipatingAtEpoch(2), - ev.FinalizationOccurs(3), - ev.PeersCheck, - ev.ProcessesDepositsInBlocks, - ev.VerifyBlockGraffiti, - ev.ActivatesDepositedValidators, - ev.DepositedValidatorsAreActive, - ev.ProposeVoluntaryExit, - ev.ValidatorHasExited, - ev.ValidatorsVoteWithTheMajority, - ev.ColdStateCheckpoint, - ev.AltairForkTransition, - ev.BellatrixForkTransition, - ev.APIMiddlewareVerifyIntegrity, - ev.APIGatewayV1Alpha1VerifyIntegrity, - ev.FinishedSyncing, - ev.AllNodesHaveSameHead, - ev.ValidatorSyncParticipation, - ev.FeeRecipientIsPresent, - //ev.TransactionsPresent, TODO: Renable Transaction evaluator once it tx pool issues are fixed. - } - testConfig := &types.E2EConfig{ - BeaconFlags: []string{ - fmt.Sprintf("--slots-per-archive-point=%d", params.BeaconConfig().SlotsPerEpoch*16), - fmt.Sprintf("--tracing-endpoint=http://%s", tracingEndpoint), - "--enable-tracing", - "--trace-sample-fraction=1.0", - }, - ValidatorFlags: []string{}, - EpochsToRun: uint64(epochsToRun), - TestSync: true, - TestFeature: true, - TestDeposits: true, - UsePrysmShValidator: args.usePrysmSh, - UsePprof: !longRunning, - UseWeb3RemoteSigner: args.useWeb3RemoteSigner, - TracingSinkEndpoint: tracingEndpoint, - Evaluators: evals, - Seed: int64(seed), - } - - newTestRunner(t, testConfig).run() -} From 6ae653bd0a01ae986edfd983074950e1cb345a0c Mon Sep 17 00:00:00 2001 From: James He Date: Wed, 15 Jun 2022 11:00:39 -0500 Subject: [PATCH 20/70] adding fee recipient evaluator in new file --- testing/endtoend/endtoend_setup_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/testing/endtoend/endtoend_setup_test.go b/testing/endtoend/endtoend_setup_test.go index 8e78beee2107..328e5fdd747f 100644 --- a/testing/endtoend/endtoend_setup_test.go +++ b/testing/endtoend/endtoend_setup_test.go @@ -58,6 +58,7 @@ func e2eMinimal(t *testing.T, cfgo ...types.E2EConfigOpt) *testRunner { ev.FinishedSyncing, ev.AllNodesHaveSameHead, ev.ValidatorSyncParticipation, + ev.FeeRecipientIsPresent, //ev.TransactionsPresent, TODO: Renable Transaction evaluator once it tx pool issues are fixed. } testConfig := &types.E2EConfig{ From 7ff6609614c54bc5353bb61e93825c9a2ef190db Mon Sep 17 00:00:00 2001 From: James He Date: Wed, 15 Jun 2022 11:30:13 -0500 Subject: [PATCH 21/70] fixing validator component logic --- testing/endtoend/components/validator.go | 38 ++++++++------------ testing/endtoend/evaluators/fee_recipient.go | 4 +-- 2 files changed, 17 insertions(+), 25 deletions(-) diff --git a/testing/endtoend/components/validator.go b/testing/endtoend/components/validator.go index 2293f202d26b..9dc16cf6ad07 100644 --- a/testing/endtoend/components/validator.go +++ b/testing/endtoend/components/validator.go @@ -22,7 +22,6 @@ import ( "github.com/pkg/errors" cmdshared "github.com/prysmaticlabs/prysm/cmd" "github.com/prysmaticlabs/prysm/cmd/validator/flags" - "github.com/prysmaticlabs/prysm/config/features" "github.com/prysmaticlabs/prysm/config/params" validator_service_config "github.com/prysmaticlabs/prysm/config/validator/service" contracts "github.com/prysmaticlabs/prysm/contracts/deposit" @@ -213,7 +212,10 @@ func (v *ValidatorNode) Start(ctx context.Context) error { for _, pub := range pubs { ValidatorHexPubKeys = append(ValidatorHexPubKeys, hexutil.Encode(pub.Marshal())) } - + proposerSettingsPathPath, err := createProposerSettingsPath(ValidatorHexPubKeys) + if err != nil { + return err + } args := []string{ fmt.Sprintf("--%s=%s/eth2-val-%d", cmdshared.DataDirFlag.Name, e2e.TestParams.TestPath, index), fmt.Sprintf("--%s=%s", cmdshared.LogFileName.Name, file.Name()), @@ -223,21 +225,11 @@ func (v *ValidatorNode) Start(ctx context.Context) error { fmt.Sprintf("--%s=localhost:%d", flags.BeaconRPCProviderFlag.Name, beaconRPCPort), fmt.Sprintf("--%s=%s", flags.GrpcHeadersFlag.Name, "dummy=value,foo=bar"), // Sending random headers shouldn't break anything. fmt.Sprintf("--%s=%s", cmdshared.VerbosityFlag.Name, "debug"), + fmt.Sprintf("--%s=%s", flags.ProposerSettingsFlag.Name, proposerSettingsPathPath), "--" + cmdshared.ForceClearDB.Name, "--" + cmdshared.E2EConfigFlag.Name, "--" + cmdshared.AcceptTosFlag.Name, } - // Only apply e2e flags to the current branch. New flags may not exist in previous release. - if !v.config.UsePrysmShValidator { - args = append(args, features.E2EValidatorFlags...) - //TODO: Remove this once it is in current release. - feeConfigPath, err := createFeeRecipientConfigPath(ValidatorHexPubKeys) - if err != nil { - return err - } - args = append(args, fmt.Sprintf("--%s=%s", flags.FeeRecipientConfigFileFlag.Name, feeConfigPath)) - } - if v.config.UseWeb3RemoteSigner { args = append(args, fmt.Sprintf("--%s=http://localhost:%d", flags.Web3SignerURLFlag.Name, Web3RemoteSignerPort)) // Write the pubkeys as comma seperated hex strings with 0x prefix. @@ -402,32 +394,32 @@ func sendDeposits(web3 *ethclient.Client, keystoreBytes []byte, num, offset int, return nil } -func createFeeRecipientConfigPath(pubkeys []string) (string, error) { - testNetDir := e2e.TestParams.TestPath + "/fee-recipient-config" +func createProposerSettingsPath(pubkeys []string) (string, error) { + testNetDir := e2e.TestParams.TestPath + "/proposer-settings" configPath := filepath.Join(testNetDir, "config.json") if len(ValidatorHexPubKeys) == 0 { return "", errors.New("number of validators must be greater than 0") } - var feeRecipientConfig validator_service_config.FeeRecipientFileConfig + var proposerSettingsPayload validator_service_config.ProposerSettingsPayload if len(ValidatorHexPubKeys) == 1 { - feeRecipientConfig = validator_service_config.FeeRecipientFileConfig{ - DefaultConfig: &validator_service_config.FeeRecipientFileOptions{ + proposerSettingsPayload = validator_service_config.ProposerSettingsPayload{ + DefaultConfig: &validator_service_config.ProposerOptionPayload{ FeeRecipient: DefaultFeeRecipientAddress, }, } } else { - config := make(map[string]*validator_service_config.FeeRecipientFileOptions) - config[pubkeys[0]] = &validator_service_config.FeeRecipientFileOptions{ + config := make(map[string]*validator_service_config.ProposerOptionPayload) + config[pubkeys[0]] = &validator_service_config.ProposerOptionPayload{ FeeRecipient: FeeRecipientAddress, } - feeRecipientConfig = validator_service_config.FeeRecipientFileConfig{ + proposerSettingsPayload = validator_service_config.ProposerSettingsPayload{ ProposeConfig: config, - DefaultConfig: &validator_service_config.FeeRecipientFileOptions{ + DefaultConfig: &validator_service_config.ProposerOptionPayload{ FeeRecipient: DefaultFeeRecipientAddress, }, } } - jsonBytes, err := json.Marshal(feeRecipientConfig) + jsonBytes, err := json.Marshal(proposerSettingsPayload) if err != nil { return "", err } diff --git a/testing/endtoend/evaluators/fee_recipient.go b/testing/endtoend/evaluators/fee_recipient.go index 982e37e51fc5..10c244f6b7f9 100644 --- a/testing/endtoend/evaluators/fee_recipient.go +++ b/testing/endtoend/evaluators/fee_recipient.go @@ -5,7 +5,7 @@ import ( "github.com/ethereum/go-ethereum/common/hexutil" "github.com/pkg/errors" - field_params "github.com/prysmaticlabs/prysm/config/fieldparams" + "github.com/prysmaticlabs/prysm/config/params" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/testing/endtoend/helpers" "github.com/prysmaticlabs/prysm/testing/endtoend/policies" @@ -38,7 +38,7 @@ func feeRecipientIsPresent(conns ...*grpc.ClientConn) error { switch ctr.Block.(type) { case *ethpb.BeaconBlockContainer_BellatrixBlock: fr := ctr.GetBellatrixBlock().Block.Body.ExecutionPayload.FeeRecipient - if len(fr) != 0 && hexutil.Encode(fr) != field_params.EthBurnAddressHex { + if len(fr) != 0 && hexutil.Encode(fr) != params.BeaconConfig().EthBurnAddressHex { isFeeRecipientPresent = true } } From 6482ab6680b1f7ba79261f63ea68fc4265d1e649 Mon Sep 17 00:00:00 2001 From: James He Date: Wed, 15 Jun 2022 13:39:02 -0500 Subject: [PATCH 22/70] testing rpc client addition --- testing/endtoend/evaluators/fee_recipient.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/testing/endtoend/evaluators/fee_recipient.go b/testing/endtoend/evaluators/fee_recipient.go index 10c244f6b7f9..4185f7bdba32 100644 --- a/testing/endtoend/evaluators/fee_recipient.go +++ b/testing/endtoend/evaluators/fee_recipient.go @@ -49,5 +49,20 @@ func feeRecipientIsPresent(conns ...*grpc.ClientConn) error { if !isFeeRecipientPresent { return errors.New("fee recipient is not set") } + + //rpcclient, err := rpc.DialHTTP(fmt.Sprintf("http://127.0.0.1:%d", e2e.TestParams.Ports.Eth1RPCPort)) + //if err != nil { + // return err + //} + //defer rpcclient.Close() + //web3 := ethclient.NewClient(rpcclient) + //ctx := context.Background() + //latestBlockNum, _ := web3.BlockNumber(ctx) + //account := common.Address{1} + //accountBalance, _ := web3.BalanceAt(ctx, account, big.NewInt(int64(latestBlockNum))) + // + //if accountBalance.Uint64() < prevAccountBalance { + // + //} return nil } From db324b9f3dd487d110524684690a17a9387e9d83 Mon Sep 17 00:00:00 2001 From: James He Date: Wed, 15 Jun 2022 16:12:53 -0500 Subject: [PATCH 23/70] testing fee recipient evaluator --- testing/endtoend/evaluators/fee_recipient.go | 49 ++++++++++++++------ 1 file changed, 35 insertions(+), 14 deletions(-) diff --git a/testing/endtoend/evaluators/fee_recipient.go b/testing/endtoend/evaluators/fee_recipient.go index 4185f7bdba32..085fd3c289e8 100644 --- a/testing/endtoend/evaluators/fee_recipient.go +++ b/testing/endtoend/evaluators/fee_recipient.go @@ -2,12 +2,19 @@ package evaluators import ( "context" + "fmt" + "math/big" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/ethereum/go-ethereum/ethclient" + "github.com/ethereum/go-ethereum/rpc" "github.com/pkg/errors" "github.com/prysmaticlabs/prysm/config/params" + "github.com/prysmaticlabs/prysm/encoding/bytesutil" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/testing/endtoend/helpers" + e2e "github.com/prysmaticlabs/prysm/testing/endtoend/params" "github.com/prysmaticlabs/prysm/testing/endtoend/policies" "github.com/prysmaticlabs/prysm/testing/endtoend/types" "google.golang.org/grpc" @@ -32,6 +39,19 @@ func feeRecipientIsPresent(conns ...*grpc.ClientConn) error { if err != nil { return errors.Wrap(err, "failed to list blocks") } + + rpcclient, err := rpc.DialHTTP(fmt.Sprintf("http://127.0.0.1:%d", e2e.TestParams.Ports.Eth1RPCPort)) + if err != nil { + return err + } + defer rpcclient.Close() + web3 := ethclient.NewClient(rpcclient) + ctx := context.Background() + latestBlockNum, err := web3.BlockNumber(ctx) + if err != nil { + return err + } + var account common.Address // check if fee recipient is set isFeeRecipientPresent := false for _, ctr := range blks.BlockContainers { @@ -40,6 +60,7 @@ func feeRecipientIsPresent(conns ...*grpc.ClientConn) error { fr := ctr.GetBellatrixBlock().Block.Body.ExecutionPayload.FeeRecipient if len(fr) != 0 && hexutil.Encode(fr) != params.BeaconConfig().EthBurnAddressHex { isFeeRecipientPresent = true + account = common.BytesToAddress(fr) } } if isFeeRecipientPresent { @@ -50,19 +71,19 @@ func feeRecipientIsPresent(conns ...*grpc.ClientConn) error { return errors.New("fee recipient is not set") } - //rpcclient, err := rpc.DialHTTP(fmt.Sprintf("http://127.0.0.1:%d", e2e.TestParams.Ports.Eth1RPCPort)) - //if err != nil { - // return err - //} - //defer rpcclient.Close() - //web3 := ethclient.NewClient(rpcclient) - //ctx := context.Background() - //latestBlockNum, _ := web3.BlockNumber(ctx) - //account := common.Address{1} - //accountBalance, _ := web3.BalanceAt(ctx, account, big.NewInt(int64(latestBlockNum))) - // - //if accountBalance.Uint64() < prevAccountBalance { - // - //} + if !bytesutil.ZeroRoot(account.Bytes()) { + accountBalance, err := web3.BalanceAt(ctx, account, big.NewInt(int64(latestBlockNum))) + if err != nil { + return err + } + prevAccountBalance, err := web3.BalanceAt(ctx, account, big.NewInt(int64(latestBlockNum-1))) + if err != nil { + return err + } + if accountBalance.Uint64() <= prevAccountBalance.Uint64() { + return errors.Errorf("account balance didn't change after applying fee recipient for account: %s", account.Hex()) + } + } + return nil } From 23a38a2568e6da5d66e33a9846a778aacc3ad05d Mon Sep 17 00:00:00 2001 From: James He Date: Wed, 15 Jun 2022 16:29:11 -0500 Subject: [PATCH 24/70] fixing bazel: --- testing/endtoend/evaluators/BUILD.bazel | 3 +++ 1 file changed, 3 insertions(+) diff --git a/testing/endtoend/evaluators/BUILD.bazel b/testing/endtoend/evaluators/BUILD.bazel index 5c988863a9e2..5f702aa96969 100644 --- a/testing/endtoend/evaluators/BUILD.bazel +++ b/testing/endtoend/evaluators/BUILD.bazel @@ -44,7 +44,10 @@ go_library( "//testing/endtoend/types:go_default_library", "//testing/util:go_default_library", "//time/slots:go_default_library", + "@com_github_ethereum_go_ethereum//common:go_default_library", "@com_github_ethereum_go_ethereum//common/hexutil:go_default_library", + "@com_github_ethereum_go_ethereum//ethclient:go_default_library", + "@com_github_ethereum_go_ethereum//rpc:go_default_library", "@com_github_pkg_errors//:go_default_library", "@com_github_prysmaticlabs_go_bitfield//:go_default_library", "@io_bazel_rules_go//proto/wkt:empty_go_proto", From e40e4d2d52c3946a815aad00f731844250e9e0c9 Mon Sep 17 00:00:00 2001 From: James He Date: Wed, 15 Jun 2022 16:42:26 -0500 Subject: [PATCH 25/70] testing casting --- testing/endtoend/evaluators/fee_recipient.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/testing/endtoend/evaluators/fee_recipient.go b/testing/endtoend/evaluators/fee_recipient.go index 085fd3c289e8..5e97d26e076e 100644 --- a/testing/endtoend/evaluators/fee_recipient.go +++ b/testing/endtoend/evaluators/fee_recipient.go @@ -47,10 +47,7 @@ func feeRecipientIsPresent(conns ...*grpc.ClientConn) error { defer rpcclient.Close() web3 := ethclient.NewClient(rpcclient) ctx := context.Background() - latestBlockNum, err := web3.BlockNumber(ctx) - if err != nil { - return err - } + var account common.Address // check if fee recipient is set isFeeRecipientPresent := false @@ -72,11 +69,16 @@ func feeRecipientIsPresent(conns ...*grpc.ClientConn) error { } if !bytesutil.ZeroRoot(account.Bytes()) { - accountBalance, err := web3.BalanceAt(ctx, account, big.NewInt(int64(latestBlockNum))) + latestBlockNum, err := web3.BlockNumber(ctx) + if err != nil { + return err + } + intBlock := int64(latestBlockNum) + accountBalance, err := web3.BalanceAt(ctx, account, big.NewInt(intBlock)) if err != nil { return err } - prevAccountBalance, err := web3.BalanceAt(ctx, account, big.NewInt(int64(latestBlockNum-1))) + prevAccountBalance, err := web3.BalanceAt(ctx, account, big.NewInt(intBlock-1)) if err != nil { return err } From e97b43ea36b24f669b370405fcdbba6c7e05988b Mon Sep 17 00:00:00 2001 From: James He Date: Wed, 15 Jun 2022 16:56:44 -0500 Subject: [PATCH 26/70] test casting --- testing/endtoend/evaluators/fee_recipient.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/testing/endtoend/evaluators/fee_recipient.go b/testing/endtoend/evaluators/fee_recipient.go index 5e97d26e076e..1edee96fe8bc 100644 --- a/testing/endtoend/evaluators/fee_recipient.go +++ b/testing/endtoend/evaluators/fee_recipient.go @@ -17,6 +17,7 @@ import ( e2e "github.com/prysmaticlabs/prysm/testing/endtoend/params" "github.com/prysmaticlabs/prysm/testing/endtoend/policies" "github.com/prysmaticlabs/prysm/testing/endtoend/types" + "github.com/spf13/cast" "google.golang.org/grpc" "google.golang.org/protobuf/types/known/emptypb" ) @@ -73,7 +74,7 @@ func feeRecipientIsPresent(conns ...*grpc.ClientConn) error { if err != nil { return err } - intBlock := int64(latestBlockNum) + intBlock := cast.ToInt64(latestBlockNum) accountBalance, err := web3.BalanceAt(ctx, account, big.NewInt(intBlock)) if err != nil { return err From 441e40ad64637536085b41ce0a5a1aa16cb245ee Mon Sep 17 00:00:00 2001 From: James He Date: Wed, 15 Jun 2022 17:06:36 -0500 Subject: [PATCH 27/70] reverting --- testing/endtoend/evaluators/fee_recipient.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/testing/endtoend/evaluators/fee_recipient.go b/testing/endtoend/evaluators/fee_recipient.go index 1edee96fe8bc..5e97d26e076e 100644 --- a/testing/endtoend/evaluators/fee_recipient.go +++ b/testing/endtoend/evaluators/fee_recipient.go @@ -17,7 +17,6 @@ import ( e2e "github.com/prysmaticlabs/prysm/testing/endtoend/params" "github.com/prysmaticlabs/prysm/testing/endtoend/policies" "github.com/prysmaticlabs/prysm/testing/endtoend/types" - "github.com/spf13/cast" "google.golang.org/grpc" "google.golang.org/protobuf/types/known/emptypb" ) @@ -74,7 +73,7 @@ func feeRecipientIsPresent(conns ...*grpc.ClientConn) error { if err != nil { return err } - intBlock := cast.ToInt64(latestBlockNum) + intBlock := int64(latestBlockNum) accountBalance, err := web3.BalanceAt(ctx, account, big.NewInt(intBlock)) if err != nil { return err From 47fc71c6f6bf3be224207c5dcba8784013581628 Mon Sep 17 00:00:00 2001 From: James He Date: Wed, 15 Jun 2022 17:11:27 -0500 Subject: [PATCH 28/70] testing casting --- testing/endtoend/evaluators/fee_recipient.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/testing/endtoend/evaluators/fee_recipient.go b/testing/endtoend/evaluators/fee_recipient.go index 5e97d26e076e..faa42889f975 100644 --- a/testing/endtoend/evaluators/fee_recipient.go +++ b/testing/endtoend/evaluators/fee_recipient.go @@ -73,12 +73,11 @@ func feeRecipientIsPresent(conns ...*grpc.ClientConn) error { if err != nil { return err } - intBlock := int64(latestBlockNum) - accountBalance, err := web3.BalanceAt(ctx, account, big.NewInt(intBlock)) + accountBalance, err := web3.BalanceAt(ctx, account, big.NewInt(int64(latestBlockNum))) if err != nil { return err } - prevAccountBalance, err := web3.BalanceAt(ctx, account, big.NewInt(intBlock-1)) + prevAccountBalance, err := web3.BalanceAt(ctx, account, big.NewInt(int64(latestBlockNum)-int64(1))) if err != nil { return err } From 03c84a236a686481dc22ed4d2f685f137ee17957 Mon Sep 17 00:00:00 2001 From: James He Date: Wed, 15 Jun 2022 17:26:04 -0500 Subject: [PATCH 29/70] testing casting --- testing/endtoend/evaluators/fee_recipient.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/testing/endtoend/evaluators/fee_recipient.go b/testing/endtoend/evaluators/fee_recipient.go index faa42889f975..494190e7d21c 100644 --- a/testing/endtoend/evaluators/fee_recipient.go +++ b/testing/endtoend/evaluators/fee_recipient.go @@ -73,11 +73,11 @@ func feeRecipientIsPresent(conns ...*grpc.ClientConn) error { if err != nil { return err } - accountBalance, err := web3.BalanceAt(ctx, account, big.NewInt(int64(latestBlockNum))) + accountBalance, err := web3.BalanceAt(ctx, account, big.NewInt(0).SetUint64(latestBlockNum)) if err != nil { return err } - prevAccountBalance, err := web3.BalanceAt(ctx, account, big.NewInt(int64(latestBlockNum)-int64(1))) + prevAccountBalance, err := web3.BalanceAt(ctx, account, big.NewInt(0).SetUint64(latestBlockNum-1)) if err != nil { return err } From fd74a6c77ec30d96c38b147f7407b57160dc3bb5 Mon Sep 17 00:00:00 2001 From: James He Date: Thu, 16 Jun 2022 10:31:19 -0500 Subject: [PATCH 30/70] testing log --- testing/endtoend/evaluators/fee_recipient.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/testing/endtoend/evaluators/fee_recipient.go b/testing/endtoend/evaluators/fee_recipient.go index 494190e7d21c..3cf0fa592b6d 100644 --- a/testing/endtoend/evaluators/fee_recipient.go +++ b/testing/endtoend/evaluators/fee_recipient.go @@ -17,6 +17,7 @@ import ( e2e "github.com/prysmaticlabs/prysm/testing/endtoend/params" "github.com/prysmaticlabs/prysm/testing/endtoend/policies" "github.com/prysmaticlabs/prysm/testing/endtoend/types" + log "github.com/sirupsen/logrus" "google.golang.org/grpc" "google.golang.org/protobuf/types/known/emptypb" ) @@ -83,6 +84,8 @@ func feeRecipientIsPresent(conns ...*grpc.ClientConn) error { } if accountBalance.Uint64() <= prevAccountBalance.Uint64() { return errors.Errorf("account balance didn't change after applying fee recipient for account: %s", account.Hex()) + } else { + log.Infof("current account balance %v ,increased from previous account balance %v ", accountBalance, prevAccountBalance) } } From 640e1d7a69ec812861540c74dc7120e96f5caadf Mon Sep 17 00:00:00 2001 From: James He Date: Thu, 16 Jun 2022 11:33:56 -0500 Subject: [PATCH 31/70] adding bazel fix --- testing/endtoend/evaluators/BUILD.bazel | 1 + 1 file changed, 1 insertion(+) diff --git a/testing/endtoend/evaluators/BUILD.bazel b/testing/endtoend/evaluators/BUILD.bazel index 5f702aa96969..d648ab28da1e 100644 --- a/testing/endtoend/evaluators/BUILD.bazel +++ b/testing/endtoend/evaluators/BUILD.bazel @@ -50,6 +50,7 @@ go_library( "@com_github_ethereum_go_ethereum//rpc:go_default_library", "@com_github_pkg_errors//:go_default_library", "@com_github_prysmaticlabs_go_bitfield//:go_default_library", + "@com_github_sirupsen_logrus//:go_default_library", "@io_bazel_rules_go//proto/wkt:empty_go_proto", "@org_golang_google_grpc//:go_default_library", "@org_golang_google_protobuf//types/known/emptypb:go_default_library", From 377dd1a0f41cafc4bdbb5755d11288eab8b125af Mon Sep 17 00:00:00 2001 From: james-prysm Date: Thu, 16 Jun 2022 15:07:58 -0500 Subject: [PATCH 32/70] switching mixed case and adding temp logging --- testing/endtoend/components/validator.go | 4 ++-- testing/endtoend/evaluators/fee_recipient.go | 1 + testing/endtoend/minimal_e2e_test.go | 14 ++++++-------- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/testing/endtoend/components/validator.go b/testing/endtoend/components/validator.go index 9dc16cf6ad07..565b912c5318 100644 --- a/testing/endtoend/components/validator.go +++ b/testing/endtoend/components/validator.go @@ -36,8 +36,8 @@ import ( ) const depositGasLimit = 4000000 -const FeeRecipientAddress = "0x055Fb65722E7b2455043BFEBf6177F1D2e9738D9" -const DefaultFeeRecipientAddress = "0x099Fb65722E7b2455043BFEBf6177F1D2e9738D9" +const FeeRecipientAddress = "0x055FB65722e7B2455043BfeBf6177f1d2e9738d9" +const DefaultFeeRecipientAddress = "0x099FB65722e7b2455043bfebF6177f1D2E9738d9" var ValidatorHexPubKeys []string = make([]string, 0) var _ e2etypes.ComponentRunner = (*ValidatorNode)(nil) diff --git a/testing/endtoend/evaluators/fee_recipient.go b/testing/endtoend/evaluators/fee_recipient.go index 3cf0fa592b6d..b02dd4552797 100644 --- a/testing/endtoend/evaluators/fee_recipient.go +++ b/testing/endtoend/evaluators/fee_recipient.go @@ -59,6 +59,7 @@ func feeRecipientIsPresent(conns ...*grpc.ClientConn) error { if len(fr) != 0 && hexutil.Encode(fr) != params.BeaconConfig().EthBurnAddressHex { isFeeRecipientPresent = true account = common.BytesToAddress(fr) + log.Infof("fee recipient %s",hexutil.Encode(fr)) } } if isFeeRecipientPresent { diff --git a/testing/endtoend/minimal_e2e_test.go b/testing/endtoend/minimal_e2e_test.go index 3e1affa1705a..301a62c673c5 100644 --- a/testing/endtoend/minimal_e2e_test.go +++ b/testing/endtoend/minimal_e2e_test.go @@ -2,18 +2,16 @@ package endtoend import ( "testing" - - "github.com/prysmaticlabs/prysm/testing/endtoend/types" ) func TestEndToEnd_MinimalConfig(t *testing.T) { e2eMinimal(t).run() } -func TestEndToEnd_MinimalConfig_Web3Signer(t *testing.T) { - e2eMinimal(t, types.WithRemoteSigner()).run() -} +// func TestEndToEnd_MinimalConfig_Web3Signer(t *testing.T) { +// e2eMinimal(t, types.WithRemoteSigner()).run() +// } -func TestEndToEnd_MinimalConfig_CheckpointSync(t *testing.T) { - e2eMinimal(t, types.WithCheckpointSync()).run() -} +// func TestEndToEnd_MinimalConfig_CheckpointSync(t *testing.T) { +// e2eMinimal(t, types.WithCheckpointSync()).run() +// } From cd552b6461d9f725941b6682dcc2b8b81d727f28 Mon Sep 17 00:00:00 2001 From: James He Date: Thu, 16 Jun 2022 15:16:55 -0500 Subject: [PATCH 33/70] fixing gofmt --- testing/endtoend/evaluators/fee_recipient.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/endtoend/evaluators/fee_recipient.go b/testing/endtoend/evaluators/fee_recipient.go index b02dd4552797..2f56c9baaa1d 100644 --- a/testing/endtoend/evaluators/fee_recipient.go +++ b/testing/endtoend/evaluators/fee_recipient.go @@ -59,7 +59,7 @@ func feeRecipientIsPresent(conns ...*grpc.ClientConn) error { if len(fr) != 0 && hexutil.Encode(fr) != params.BeaconConfig().EthBurnAddressHex { isFeeRecipientPresent = true account = common.BytesToAddress(fr) - log.Infof("fee recipient %s",hexutil.Encode(fr)) + log.Infof("fee recipient %s", hexutil.Encode(fr)) } } if isFeeRecipientPresent { From 901727cc3cae024712e9cb4f431eba997e62eef9 Mon Sep 17 00:00:00 2001 From: James He Date: Fri, 17 Jun 2022 09:16:21 -0500 Subject: [PATCH 34/70] rolling back changes --- testing/endtoend/minimal_e2e_test.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/testing/endtoend/minimal_e2e_test.go b/testing/endtoend/minimal_e2e_test.go index 301a62c673c5..3e1affa1705a 100644 --- a/testing/endtoend/minimal_e2e_test.go +++ b/testing/endtoend/minimal_e2e_test.go @@ -2,16 +2,18 @@ package endtoend import ( "testing" + + "github.com/prysmaticlabs/prysm/testing/endtoend/types" ) func TestEndToEnd_MinimalConfig(t *testing.T) { e2eMinimal(t).run() } -// func TestEndToEnd_MinimalConfig_Web3Signer(t *testing.T) { -// e2eMinimal(t, types.WithRemoteSigner()).run() -// } +func TestEndToEnd_MinimalConfig_Web3Signer(t *testing.T) { + e2eMinimal(t, types.WithRemoteSigner()).run() +} -// func TestEndToEnd_MinimalConfig_CheckpointSync(t *testing.T) { -// e2eMinimal(t, types.WithCheckpointSync()).run() -// } +func TestEndToEnd_MinimalConfig_CheckpointSync(t *testing.T) { + e2eMinimal(t, types.WithCheckpointSync()).run() +} From c5d1de27d3433b5a67c0498ab0fd940816c7b0b1 Mon Sep 17 00:00:00 2001 From: James He Date: Fri, 17 Jun 2022 11:31:26 -0500 Subject: [PATCH 35/70] removing fee recipient evaluator when web3signer is used --- testing/endtoend/components/validator.go | 4 ++-- testing/endtoend/endtoend_setup_test.go | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/testing/endtoend/components/validator.go b/testing/endtoend/components/validator.go index 565b912c5318..276a7297d8b5 100644 --- a/testing/endtoend/components/validator.go +++ b/testing/endtoend/components/validator.go @@ -225,7 +225,6 @@ func (v *ValidatorNode) Start(ctx context.Context) error { fmt.Sprintf("--%s=localhost:%d", flags.BeaconRPCProviderFlag.Name, beaconRPCPort), fmt.Sprintf("--%s=%s", flags.GrpcHeadersFlag.Name, "dummy=value,foo=bar"), // Sending random headers shouldn't break anything. fmt.Sprintf("--%s=%s", cmdshared.VerbosityFlag.Name, "debug"), - fmt.Sprintf("--%s=%s", flags.ProposerSettingsFlag.Name, proposerSettingsPathPath), "--" + cmdshared.ForceClearDB.Name, "--" + cmdshared.E2EConfigFlag.Name, "--" + cmdshared.AcceptTosFlag.Name, @@ -247,7 +246,8 @@ func (v *ValidatorNode) Start(ctx context.Context) error { // When not using remote key signer, use interop keys. args = append(args, fmt.Sprintf("--%s=%d", flags.InteropNumValidators.Name, validatorNum), - fmt.Sprintf("--%s=%d", flags.InteropStartIndex.Name, offset)) + fmt.Sprintf("--%s=%d", flags.InteropStartIndex.Name, offset), + fmt.Sprintf("--%s=%s", flags.ProposerSettingsFlag.Name, proposerSettingsPathPath)) //TODO: web3signer does not support validator registration signing currently, move this when support is there. } args = append(args, config.ValidatorFlags...) diff --git a/testing/endtoend/endtoend_setup_test.go b/testing/endtoend/endtoend_setup_test.go index 328e5fdd747f..b8250652951d 100644 --- a/testing/endtoend/endtoend_setup_test.go +++ b/testing/endtoend/endtoend_setup_test.go @@ -58,7 +58,6 @@ func e2eMinimal(t *testing.T, cfgo ...types.E2EConfigOpt) *testRunner { ev.FinishedSyncing, ev.AllNodesHaveSameHead, ev.ValidatorSyncParticipation, - ev.FeeRecipientIsPresent, //ev.TransactionsPresent, TODO: Renable Transaction evaluator once it tx pool issues are fixed. } testConfig := &types.E2EConfig{ @@ -83,6 +82,10 @@ func e2eMinimal(t *testing.T, cfgo ...types.E2EConfigOpt) *testRunner { for _, o := range cfgo { o(testConfig) } + //TODO: web3signer does not currently support validator registration signing so evaluator will break code + if !testConfig.UseWeb3RemoteSigner { + testConfig.Evaluators = append(testConfig.Evaluators, ev.FeeRecipientIsPresent) + } return newTestRunner(t, testConfig) } From 1e653268b6877ed853283604ad43e4e38c6d3a72 Mon Sep 17 00:00:00 2001 From: James He Date: Fri, 17 Jun 2022 15:34:58 -0500 Subject: [PATCH 36/70] test only minimal config --- testing/endtoend/minimal_e2e_test.go | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/testing/endtoend/minimal_e2e_test.go b/testing/endtoend/minimal_e2e_test.go index 3e1affa1705a..9f499ada275a 100644 --- a/testing/endtoend/minimal_e2e_test.go +++ b/testing/endtoend/minimal_e2e_test.go @@ -2,18 +2,16 @@ package endtoend import ( "testing" - - "github.com/prysmaticlabs/prysm/testing/endtoend/types" ) func TestEndToEnd_MinimalConfig(t *testing.T) { e2eMinimal(t).run() } -func TestEndToEnd_MinimalConfig_Web3Signer(t *testing.T) { - e2eMinimal(t, types.WithRemoteSigner()).run() -} - -func TestEndToEnd_MinimalConfig_CheckpointSync(t *testing.T) { - e2eMinimal(t, types.WithCheckpointSync()).run() -} +//func TestEndToEnd_MinimalConfig_Web3Signer(t *testing.T) { +// e2eMinimal(t, types.WithRemoteSigner()).run() +//} +// +//func TestEndToEnd_MinimalConfig_CheckpointSync(t *testing.T) { +// e2eMinimal(t, types.WithCheckpointSync()).run() +//} From d8d05af27806ef6ea8bbc1bd3ef5a0898e1a6055 Mon Sep 17 00:00:00 2001 From: James He Date: Tue, 21 Jun 2022 10:10:06 -0500 Subject: [PATCH 37/70] reverting changes --- testing/endtoend/components/validator.go | 5 +++++ testing/endtoend/minimal_e2e_test.go | 16 +++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/testing/endtoend/components/validator.go b/testing/endtoend/components/validator.go index 276a7297d8b5..5ec4d1926245 100644 --- a/testing/endtoend/components/validator.go +++ b/testing/endtoend/components/validator.go @@ -22,6 +22,7 @@ import ( "github.com/pkg/errors" cmdshared "github.com/prysmaticlabs/prysm/cmd" "github.com/prysmaticlabs/prysm/cmd/validator/flags" + "github.com/prysmaticlabs/prysm/config/features" "github.com/prysmaticlabs/prysm/config/params" validator_service_config "github.com/prysmaticlabs/prysm/config/validator/service" contracts "github.com/prysmaticlabs/prysm/contracts/deposit" @@ -229,6 +230,10 @@ func (v *ValidatorNode) Start(ctx context.Context) error { "--" + cmdshared.E2EConfigFlag.Name, "--" + cmdshared.AcceptTosFlag.Name, } + // Only apply e2e flags to the current branch. New flags may not exist in previous release. + if !v.config.UsePrysmShValidator { + args = append(args, features.E2EValidatorFlags...) + } if v.config.UseWeb3RemoteSigner { args = append(args, fmt.Sprintf("--%s=http://localhost:%d", flags.Web3SignerURLFlag.Name, Web3RemoteSignerPort)) // Write the pubkeys as comma seperated hex strings with 0x prefix. diff --git a/testing/endtoend/minimal_e2e_test.go b/testing/endtoend/minimal_e2e_test.go index 9f499ada275a..3e1affa1705a 100644 --- a/testing/endtoend/minimal_e2e_test.go +++ b/testing/endtoend/minimal_e2e_test.go @@ -2,16 +2,18 @@ package endtoend import ( "testing" + + "github.com/prysmaticlabs/prysm/testing/endtoend/types" ) func TestEndToEnd_MinimalConfig(t *testing.T) { e2eMinimal(t).run() } -//func TestEndToEnd_MinimalConfig_Web3Signer(t *testing.T) { -// e2eMinimal(t, types.WithRemoteSigner()).run() -//} -// -//func TestEndToEnd_MinimalConfig_CheckpointSync(t *testing.T) { -// e2eMinimal(t, types.WithCheckpointSync()).run() -//} +func TestEndToEnd_MinimalConfig_Web3Signer(t *testing.T) { + e2eMinimal(t, types.WithRemoteSigner()).run() +} + +func TestEndToEnd_MinimalConfig_CheckpointSync(t *testing.T) { + e2eMinimal(t, types.WithCheckpointSync()).run() +} From a3ac174a941dd223cadd12cfa197e299f91c3709 Mon Sep 17 00:00:00 2001 From: James He Date: Tue, 21 Jun 2022 13:25:54 -0500 Subject: [PATCH 38/70] adding fee recipient evaluator to mainnet --- testing/endtoend/endtoend_setup_test.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/testing/endtoend/endtoend_setup_test.go b/testing/endtoend/endtoend_setup_test.go index b8250652951d..3cc1f68e0a32 100644 --- a/testing/endtoend/endtoend_setup_test.go +++ b/testing/endtoend/endtoend_setup_test.go @@ -162,7 +162,10 @@ func e2eMainnet(t *testing.T, usePrysmSh, useMultiClient bool, cfgo ...types.E2E for _, o := range cfgo { o(testConfig) } - + //TODO: web3signer does not currently support validator registration signing so evaluator will break code + if !testConfig.UseWeb3RemoteSigner { + testConfig.Evaluators = append(testConfig.Evaluators, ev.FeeRecipientIsPresent) + } return newTestRunner(t, testConfig) } From 9f057d795a4ce18d719e422cc3227786834878f2 Mon Sep 17 00:00:00 2001 From: James He Date: Tue, 21 Jun 2022 15:05:40 -0500 Subject: [PATCH 39/70] current version uses wrong flag name --- testing/endtoend/components/validator.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/testing/endtoend/components/validator.go b/testing/endtoend/components/validator.go index 5ec4d1926245..2fe3f216b7a3 100644 --- a/testing/endtoend/components/validator.go +++ b/testing/endtoend/components/validator.go @@ -252,7 +252,12 @@ func (v *ValidatorNode) Start(ctx context.Context) error { args = append(args, fmt.Sprintf("--%s=%d", flags.InteropNumValidators.Name, validatorNum), fmt.Sprintf("--%s=%d", flags.InteropStartIndex.Name, offset), - fmt.Sprintf("--%s=%s", flags.ProposerSettingsFlag.Name, proposerSettingsPathPath)) //TODO: web3signer does not support validator registration signing currently, move this when support is there. + ) + } + //TODO: web3signer does not support validator registration signing currently, move this when support is there. + //TODO: current version of prysmsh still uses wrong flag name. + if !v.config.UsePrysmShValidator && !v.config.UseWeb3RemoteSigner { + args = append(args, fmt.Sprintf("--%s=%s", flags.ProposerSettingsFlag.Name, proposerSettingsPathPath)) } args = append(args, config.ValidatorFlags...) From 970626679a0b41dd6a6dfe0dce47d7e81868046e Mon Sep 17 00:00:00 2001 From: James He Date: Tue, 21 Jun 2022 21:50:20 -0500 Subject: [PATCH 40/70] optimizing key usage --- testing/endtoend/components/validator.go | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/testing/endtoend/components/validator.go b/testing/endtoend/components/validator.go index 2fe3f216b7a3..38c2dc5458ee 100644 --- a/testing/endtoend/components/validator.go +++ b/testing/endtoend/components/validator.go @@ -213,10 +213,7 @@ func (v *ValidatorNode) Start(ctx context.Context) error { for _, pub := range pubs { ValidatorHexPubKeys = append(ValidatorHexPubKeys, hexutil.Encode(pub.Marshal())) } - proposerSettingsPathPath, err := createProposerSettingsPath(ValidatorHexPubKeys) - if err != nil { - return err - } + args := []string{ fmt.Sprintf("--%s=%s/eth2-val-%d", cmdshared.DataDirFlag.Name, e2e.TestParams.TestPath, index), fmt.Sprintf("--%s=%s", cmdshared.LogFileName.Name, file.Name()), @@ -238,15 +235,7 @@ func (v *ValidatorNode) Start(ctx context.Context) error { args = append(args, fmt.Sprintf("--%s=http://localhost:%d", flags.Web3SignerURLFlag.Name, Web3RemoteSignerPort)) // Write the pubkeys as comma seperated hex strings with 0x prefix. // See: https://docs.teku.consensys.net/en/latest/HowTo/External-Signer/Use-External-Signer/ - _, pubs, err := interop.DeterministicallyGenerateKeys(uint64(offset), uint64(validatorNum)) - if err != nil { - return err - } - var hexPubs []string - for _, pub := range pubs { - hexPubs = append(hexPubs, hexutil.Encode(pub.Marshal())) - } - args = append(args, fmt.Sprintf("--%s=%s", flags.Web3SignerPublicValidatorKeysFlag.Name, strings.Join(hexPubs, ","))) + args = append(args, fmt.Sprintf("--%s=%s", flags.Web3SignerPublicValidatorKeysFlag.Name, strings.Join(ValidatorHexPubKeys, ","))) } else { // When not using remote key signer, use interop keys. args = append(args, @@ -257,6 +246,10 @@ func (v *ValidatorNode) Start(ctx context.Context) error { //TODO: web3signer does not support validator registration signing currently, move this when support is there. //TODO: current version of prysmsh still uses wrong flag name. if !v.config.UsePrysmShValidator && !v.config.UseWeb3RemoteSigner { + proposerSettingsPathPath, err := createProposerSettingsPath(ValidatorHexPubKeys) + if err != nil { + return err + } args = append(args, fmt.Sprintf("--%s=%s", flags.ProposerSettingsFlag.Name, proposerSettingsPathPath)) } args = append(args, config.ValidatorFlags...) From 1284c5c5ce1bf00919136ad4ddd87e7dc589f75c Mon Sep 17 00:00:00 2001 From: James He Date: Wed, 22 Jun 2022 10:09:31 -0500 Subject: [PATCH 41/70] making mining address a variable --- testing/endtoend/components/eth1/miner.go | 2 +- testing/endtoend/components/eth1/node.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/testing/endtoend/components/eth1/miner.go b/testing/endtoend/components/eth1/miner.go index f7d57dd3cb3d..f8b91d724a0a 100644 --- a/testing/endtoend/components/eth1/miner.go +++ b/testing/endtoend/components/eth1/miner.go @@ -133,7 +133,7 @@ func (m *Miner) Start(ctx context.Context) error { "--mine", fmt.Sprintf("--unlock=%s", EthAddress), "--allow-insecure-unlock", - "--txpool.locals=0x878705ba3f8bc32fcf7f4caa1a35e72af65cf766", + fmt.Sprintf("--txpool.locals=%s", EthAddress), fmt.Sprintf("--password=%s", eth1Path+"/keystore/"+minerPasswordFile), } diff --git a/testing/endtoend/components/eth1/node.go b/testing/endtoend/components/eth1/node.go index bc768d7af3b5..fa9bbf7932ae 100644 --- a/testing/endtoend/components/eth1/node.go +++ b/testing/endtoend/components/eth1/node.go @@ -90,7 +90,7 @@ func (node *Node) Start(ctx context.Context) error { "--ws.origins=\"*\"", "--ipcdisable", "--verbosity=4", - "--txpool.locals=0x878705ba3f8bc32fcf7f4caa1a35e72af65cf766", + fmt.Sprintf("--txpool.locals=%s", EthAddress), } // If we are testing sync, geth needs to be run via full sync as snap sync does not // work in our setup. From 4cd240819d8190df5f4b8366acf2462e2315e9d7 Mon Sep 17 00:00:00 2001 From: James He Date: Wed, 22 Jun 2022 10:41:57 -0500 Subject: [PATCH 42/70] moving from global to local variable --- testing/endtoend/components/validator.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/testing/endtoend/components/validator.go b/testing/endtoend/components/validator.go index 38c2dc5458ee..24fe160efa9c 100644 --- a/testing/endtoend/components/validator.go +++ b/testing/endtoend/components/validator.go @@ -40,7 +40,6 @@ const depositGasLimit = 4000000 const FeeRecipientAddress = "0x055FB65722e7B2455043BfeBf6177f1d2e9738d9" const DefaultFeeRecipientAddress = "0x099FB65722e7b2455043bfebF6177f1D2E9738d9" -var ValidatorHexPubKeys []string = make([]string, 0) var _ e2etypes.ComponentRunner = (*ValidatorNode)(nil) var _ e2etypes.ComponentRunner = (*ValidatorNodeSet)(nil) var _ e2etypes.MultipleComponentRunners = (*ValidatorNodeSet)(nil) @@ -177,6 +176,7 @@ func NewValidatorNode(config *e2etypes.E2EConfig, validatorNum, index, offset in // Start starts a validator client. func (v *ValidatorNode) Start(ctx context.Context) error { + validatorHexPubKeys := make([]string, 0) var pkg, target string if v.config.UsePrysmShValidator { pkg = "" @@ -211,7 +211,7 @@ func (v *ValidatorNode) Start(ctx context.Context) error { return err } for _, pub := range pubs { - ValidatorHexPubKeys = append(ValidatorHexPubKeys, hexutil.Encode(pub.Marshal())) + validatorHexPubKeys = append(validatorHexPubKeys, hexutil.Encode(pub.Marshal())) } args := []string{ @@ -235,7 +235,7 @@ func (v *ValidatorNode) Start(ctx context.Context) error { args = append(args, fmt.Sprintf("--%s=http://localhost:%d", flags.Web3SignerURLFlag.Name, Web3RemoteSignerPort)) // Write the pubkeys as comma seperated hex strings with 0x prefix. // See: https://docs.teku.consensys.net/en/latest/HowTo/External-Signer/Use-External-Signer/ - args = append(args, fmt.Sprintf("--%s=%s", flags.Web3SignerPublicValidatorKeysFlag.Name, strings.Join(ValidatorHexPubKeys, ","))) + args = append(args, fmt.Sprintf("--%s=%s", flags.Web3SignerPublicValidatorKeysFlag.Name, strings.Join(validatorHexPubKeys, ","))) } else { // When not using remote key signer, use interop keys. args = append(args, @@ -246,7 +246,7 @@ func (v *ValidatorNode) Start(ctx context.Context) error { //TODO: web3signer does not support validator registration signing currently, move this when support is there. //TODO: current version of prysmsh still uses wrong flag name. if !v.config.UsePrysmShValidator && !v.config.UseWeb3RemoteSigner { - proposerSettingsPathPath, err := createProposerSettingsPath(ValidatorHexPubKeys) + proposerSettingsPathPath, err := createProposerSettingsPath(validatorHexPubKeys) if err != nil { return err } @@ -400,11 +400,11 @@ func sendDeposits(web3 *ethclient.Client, keystoreBytes []byte, num, offset int, func createProposerSettingsPath(pubkeys []string) (string, error) { testNetDir := e2e.TestParams.TestPath + "/proposer-settings" configPath := filepath.Join(testNetDir, "config.json") - if len(ValidatorHexPubKeys) == 0 { + if len(pubkeys) == 0 { return "", errors.New("number of validators must be greater than 0") } var proposerSettingsPayload validator_service_config.ProposerSettingsPayload - if len(ValidatorHexPubKeys) == 1 { + if len(pubkeys) == 1 { proposerSettingsPayload = validator_service_config.ProposerSettingsPayload{ DefaultConfig: &validator_service_config.ProposerOptionPayload{ FeeRecipient: DefaultFeeRecipientAddress, From 71c08a03d13b969de1ebb731f88fdee09a8d2542 Mon Sep 17 00:00:00 2001 From: James He Date: Thu, 23 Jun 2022 08:33:56 -0500 Subject: [PATCH 43/70] removing unneeded log --- testing/endtoend/evaluators/fee_recipient.go | 1 - 1 file changed, 1 deletion(-) diff --git a/testing/endtoend/evaluators/fee_recipient.go b/testing/endtoend/evaluators/fee_recipient.go index 2f56c9baaa1d..3cf0fa592b6d 100644 --- a/testing/endtoend/evaluators/fee_recipient.go +++ b/testing/endtoend/evaluators/fee_recipient.go @@ -59,7 +59,6 @@ func feeRecipientIsPresent(conns ...*grpc.ClientConn) error { if len(fr) != 0 && hexutil.Encode(fr) != params.BeaconConfig().EthBurnAddressHex { isFeeRecipientPresent = true account = common.BytesToAddress(fr) - log.Infof("fee recipient %s", hexutil.Encode(fr)) } } if isFeeRecipientPresent { From 861da859eb2b38280277187113e81e4e8d06f25a Mon Sep 17 00:00:00 2001 From: James He Date: Mon, 27 Jun 2022 08:46:36 -0500 Subject: [PATCH 44/70] removing redundant check --- testing/endtoend/evaluators/fee_recipient.go | 35 +++++++++----------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/testing/endtoend/evaluators/fee_recipient.go b/testing/endtoend/evaluators/fee_recipient.go index 3cf0fa592b6d..5742d43fded0 100644 --- a/testing/endtoend/evaluators/fee_recipient.go +++ b/testing/endtoend/evaluators/fee_recipient.go @@ -11,7 +11,6 @@ import ( "github.com/ethereum/go-ethereum/rpc" "github.com/pkg/errors" "github.com/prysmaticlabs/prysm/config/params" - "github.com/prysmaticlabs/prysm/encoding/bytesutil" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/testing/endtoend/helpers" e2e "github.com/prysmaticlabs/prysm/testing/endtoend/params" @@ -69,24 +68,22 @@ func feeRecipientIsPresent(conns ...*grpc.ClientConn) error { return errors.New("fee recipient is not set") } - if !bytesutil.ZeroRoot(account.Bytes()) { - latestBlockNum, err := web3.BlockNumber(ctx) - if err != nil { - return err - } - accountBalance, err := web3.BalanceAt(ctx, account, big.NewInt(0).SetUint64(latestBlockNum)) - if err != nil { - return err - } - prevAccountBalance, err := web3.BalanceAt(ctx, account, big.NewInt(0).SetUint64(latestBlockNum-1)) - if err != nil { - return err - } - if accountBalance.Uint64() <= prevAccountBalance.Uint64() { - return errors.Errorf("account balance didn't change after applying fee recipient for account: %s", account.Hex()) - } else { - log.Infof("current account balance %v ,increased from previous account balance %v ", accountBalance, prevAccountBalance) - } + latestBlockNum, err := web3.BlockNumber(ctx) + if err != nil { + return err + } + accountBalance, err := web3.BalanceAt(ctx, account, big.NewInt(0).SetUint64(latestBlockNum)) + if err != nil { + return err + } + prevAccountBalance, err := web3.BalanceAt(ctx, account, big.NewInt(0).SetUint64(latestBlockNum-1)) + if err != nil { + return err + } + if accountBalance.Uint64() <= prevAccountBalance.Uint64() { + return errors.Errorf("account balance didn't change after applying fee recipient for account: %s", account.Hex()) + } else { + log.Infof("current account balance %v ,increased from previous account balance %v ", accountBalance, prevAccountBalance) } return nil From c8e14c3507ea14da2219531a11c678946a4fa338 Mon Sep 17 00:00:00 2001 From: James He Date: Mon, 27 Jun 2022 14:35:31 -0500 Subject: [PATCH 45/70] make proposer settings mroe deterministic and also have the evaluator compare the wanting values --- config/validator/service/proposer-settings.go | 6 +-- testing/endtoend/components/validator.go | 9 ++-- testing/endtoend/evaluators/fee_recipient.go | 47 +++++++++++++++---- validator/node/node.go | 6 +-- 4 files changed, 49 insertions(+), 19 deletions(-) diff --git a/config/validator/service/proposer-settings.go b/config/validator/service/proposer-settings.go index 626a3bd1b245..99fe9db604db 100644 --- a/config/validator/service/proposer-settings.go +++ b/config/validator/service/proposer-settings.go @@ -7,11 +7,11 @@ import ( ) // ProposerSettingsPayload is the struct representation of the JSON or YAML payload set in the validator through the CLI. -// ProposeConfig is the map of validator address to fee recipient options all in hex format. +// ProposerConfig is the map of validator address to fee recipient options all in hex format. // DefaultConfig is the default fee recipient address for all validators unless otherwise specified in the propose config.required. type ProposerSettingsPayload struct { - ProposeConfig map[string]*ProposerOptionPayload `json:"proposer_config" yaml:"proposer_config"` - DefaultConfig *ProposerOptionPayload `json:"default_config" yaml:"default_config"` + ProposerConfig map[string]*ProposerOptionPayload `json:"proposer_config" yaml:"proposer_config"` + DefaultConfig *ProposerOptionPayload `json:"default_config" yaml:"default_config"` } // ProposerOptionPayload is the struct representation of the JSON config file set in the validator through the CLI. diff --git a/testing/endtoend/components/validator.go b/testing/endtoend/components/validator.go index 24fe160efa9c..6ad76ceb5dea 100644 --- a/testing/endtoend/components/validator.go +++ b/testing/endtoend/components/validator.go @@ -37,7 +37,6 @@ import ( ) const depositGasLimit = 4000000 -const FeeRecipientAddress = "0x055FB65722e7B2455043BfeBf6177f1d2e9738d9" const DefaultFeeRecipientAddress = "0x099FB65722e7b2455043bfebF6177f1D2E9738d9" var _ e2etypes.ComponentRunner = (*ValidatorNode)(nil) @@ -412,11 +411,13 @@ func createProposerSettingsPath(pubkeys []string) (string, error) { } } else { config := make(map[string]*validator_service_config.ProposerOptionPayload) - config[pubkeys[0]] = &validator_service_config.ProposerOptionPayload{ - FeeRecipient: FeeRecipientAddress, + for index, pubkey := range pubkeys { + config[pubkey] = &validator_service_config.ProposerOptionPayload{ + FeeRecipient: fmt.Sprintf("0x%40d", 1+index), + } } proposerSettingsPayload = validator_service_config.ProposerSettingsPayload{ - ProposeConfig: config, + ProposerConfig: config, DefaultConfig: &validator_service_config.ProposerOptionPayload{ FeeRecipient: DefaultFeeRecipientAddress, }, diff --git a/testing/endtoend/evaluators/fee_recipient.go b/testing/endtoend/evaluators/fee_recipient.go index 5742d43fded0..6beae013cf9e 100644 --- a/testing/endtoend/evaluators/fee_recipient.go +++ b/testing/endtoend/evaluators/fee_recipient.go @@ -2,8 +2,11 @@ package evaluators import ( "context" + "encoding/json" "fmt" "math/big" + "os" + "path/filepath" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" @@ -11,6 +14,7 @@ import ( "github.com/ethereum/go-ethereum/rpc" "github.com/pkg/errors" "github.com/prysmaticlabs/prysm/config/params" + validator_service_config "github.com/prysmaticlabs/prysm/config/validator/service" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/testing/endtoend/helpers" e2e "github.com/prysmaticlabs/prysm/testing/endtoend/params" @@ -49,23 +53,48 @@ func feeRecipientIsPresent(conns ...*grpc.ClientConn) error { ctx := context.Background() var account common.Address - // check if fee recipient is set - isFeeRecipientPresent := false for _, ctr := range blks.BlockContainers { switch ctr.Block.(type) { case *ethpb.BeaconBlockContainer_BellatrixBlock: fr := ctr.GetBellatrixBlock().Block.Body.ExecutionPayload.FeeRecipient if len(fr) != 0 && hexutil.Encode(fr) != params.BeaconConfig().EthBurnAddressHex { - isFeeRecipientPresent = true account = common.BytesToAddress(fr) + } else { + return errors.New("fee recipient is not set") + } + validatorRequest := ðpb.GetValidatorRequest{ + QueryFilter: ðpb.GetValidatorRequest_Index{ + Index: ctr.GetBellatrixBlock().Block.ProposerIndex, + }, + } + validator, err := client.GetValidator(context.Background(), validatorRequest) + if err != nil { + return errors.Wrap(err, "failed to get validators") + } + publickey := validator.GetPublicKey() + // find + testNetDir := e2e.TestParams.TestPath + "/proposer-settings" + configPath := filepath.Join(testNetDir, "config.json") + jsonFile, err := os.Open(configPath) + if err != nil { + fmt.Println(err) + } + var configFile validator_service_config.ProposerSettingsPayload + if err := json.NewDecoder(jsonFile).Decode(&configFile); err != nil { + return err + } + + option, ok := configFile.ProposerConfig[hexutil.Encode(publickey)] + if !ok { + if configFile.DefaultConfig.FeeRecipient != account.Hex() { + return fmt.Errorf("fee recipient %s does not match the default fee recipient %s", account.Hex(), configFile.DefaultConfig.FeeRecipient) + } + } + if option.FeeRecipient != account.Hex() { + return fmt.Errorf("fee recipient %s does not match the proposer settings fee recipient %s", account.Hex(), option.FeeRecipient) } } - if isFeeRecipientPresent { - break - } - } - if !isFeeRecipientPresent { - return errors.New("fee recipient is not set") + } latestBlockNum, err := web3.BlockNumber(ctx) diff --git a/validator/node/node.go b/validator/node/node.go index d74589fe4d10..34b719f63427 100644 --- a/validator/node/node.go +++ b/validator/node/node.go @@ -489,7 +489,7 @@ func proposerSettings(cliCtx *cli.Context) (*validatorServiceConfig.ProposerSett if cliCtx.IsSet(flags.SuggestedFeeRecipientFlag.Name) { suggestedFee := cliCtx.String(flags.SuggestedFeeRecipientFlag.Name) fileConfig = &validatorServiceConfig.ProposerSettingsPayload{ - ProposeConfig: nil, + ProposerConfig: nil, DefaultConfig: &validatorServiceConfig.ProposerOptionPayload{ FeeRecipient: suggestedFee, GasLimit: params.BeaconConfig().DefaultBuilderGasLimit, @@ -538,9 +538,9 @@ func proposerSettings(cliCtx *cli.Context) (*validatorServiceConfig.ProposerSett GasLimit: reviewGasLimit(fileConfig.DefaultConfig.GasLimit), } - if fileConfig.ProposeConfig != nil { + if fileConfig.ProposerConfig != nil { vpSettings.ProposeConfig = make(map[[fieldparams.BLSPubkeyLength]byte]*validatorServiceConfig.ProposerOption) - for key, option := range fileConfig.ProposeConfig { + for key, option := range fileConfig.ProposerConfig { decodedKey, err := hexutil.Decode(key) if err != nil { return nil, errors.Wrapf(err, "could not decode public key %s", key) From e90afaf1b1f2c5f6efa747605e5db5d8146eb25e Mon Sep 17 00:00:00 2001 From: James He Date: Mon, 27 Jun 2022 14:46:30 -0500 Subject: [PATCH 46/70] fixing err return --- testing/endtoend/evaluators/fee_recipient.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/endtoend/evaluators/fee_recipient.go b/testing/endtoend/evaluators/fee_recipient.go index 6beae013cf9e..f17516e60436 100644 --- a/testing/endtoend/evaluators/fee_recipient.go +++ b/testing/endtoend/evaluators/fee_recipient.go @@ -77,7 +77,7 @@ func feeRecipientIsPresent(conns ...*grpc.ClientConn) error { configPath := filepath.Join(testNetDir, "config.json") jsonFile, err := os.Open(configPath) if err != nil { - fmt.Println(err) + return err } var configFile validator_service_config.ProposerSettingsPayload if err := json.NewDecoder(jsonFile).Decode(&configFile); err != nil { From 925a9f9fc54a288dbdf428afa5fa1d495d40a308 Mon Sep 17 00:00:00 2001 From: James He Date: Mon, 27 Jun 2022 14:49:27 -0500 Subject: [PATCH 47/70] fixing bazel --- testing/endtoend/evaluators/BUILD.bazel | 1 + 1 file changed, 1 insertion(+) diff --git a/testing/endtoend/evaluators/BUILD.bazel b/testing/endtoend/evaluators/BUILD.bazel index d648ab28da1e..13e75e71ec2d 100644 --- a/testing/endtoend/evaluators/BUILD.bazel +++ b/testing/endtoend/evaluators/BUILD.bazel @@ -27,6 +27,7 @@ go_library( "//beacon-chain/p2p:go_default_library", "//config/fieldparams:go_default_library", "//config/params:go_default_library", + "//config/validator/service:go_default_library", "//consensus-types/interfaces:go_default_library", "//consensus-types/primitives:go_default_library", "//consensus-types/wrapper:go_default_library", From 272ff125d84ce72ef072c5cb09cd1e76156dd779 Mon Sep 17 00:00:00 2001 From: James He Date: Mon, 27 Jun 2022 15:08:36 -0500 Subject: [PATCH 48/70] checking file too much moving it out --- testing/endtoend/evaluators/fee_recipient.go | 22 ++++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/testing/endtoend/evaluators/fee_recipient.go b/testing/endtoend/evaluators/fee_recipient.go index f17516e60436..dbde19a6ec61 100644 --- a/testing/endtoend/evaluators/fee_recipient.go +++ b/testing/endtoend/evaluators/fee_recipient.go @@ -52,6 +52,17 @@ func feeRecipientIsPresent(conns ...*grpc.ClientConn) error { web3 := ethclient.NewClient(rpcclient) ctx := context.Background() + testNetDir := e2e.TestParams.TestPath + "/proposer-settings" + configPath := filepath.Join(testNetDir, "config.json") + jsonFile, err := os.Open(configPath) + if err != nil { + return err + } + var configFile validator_service_config.ProposerSettingsPayload + if err := json.NewDecoder(jsonFile).Decode(&configFile); err != nil { + return err + } + var account common.Address for _, ctr := range blks.BlockContainers { switch ctr.Block.(type) { @@ -72,17 +83,6 @@ func feeRecipientIsPresent(conns ...*grpc.ClientConn) error { return errors.Wrap(err, "failed to get validators") } publickey := validator.GetPublicKey() - // find - testNetDir := e2e.TestParams.TestPath + "/proposer-settings" - configPath := filepath.Join(testNetDir, "config.json") - jsonFile, err := os.Open(configPath) - if err != nil { - return err - } - var configFile validator_service_config.ProposerSettingsPayload - if err := json.NewDecoder(jsonFile).Decode(&configFile); err != nil { - return err - } option, ok := configFile.ProposerConfig[hexutil.Encode(publickey)] if !ok { From 3b36b6ae199d5d0d2f6a8cba03327b9026775202 Mon Sep 17 00:00:00 2001 From: James He Date: Mon, 27 Jun 2022 15:17:52 -0500 Subject: [PATCH 49/70] fixing gosec --- testing/endtoend/evaluators/fee_recipient.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/endtoend/evaluators/fee_recipient.go b/testing/endtoend/evaluators/fee_recipient.go index dbde19a6ec61..5cc03fce8ce9 100644 --- a/testing/endtoend/evaluators/fee_recipient.go +++ b/testing/endtoend/evaluators/fee_recipient.go @@ -53,7 +53,7 @@ func feeRecipientIsPresent(conns ...*grpc.ClientConn) error { ctx := context.Background() testNetDir := e2e.TestParams.TestPath + "/proposer-settings" - configPath := filepath.Join(testNetDir, "config.json") + configPath := filepath.Join(testNetDir, filepath.Clean("config.json")) jsonFile, err := os.Open(configPath) if err != nil { return err From b8e166e1ce30c97cc3c12aebee9a6834e1cb622c Mon Sep 17 00:00:00 2001 From: James He Date: Mon, 27 Jun 2022 15:28:50 -0500 Subject: [PATCH 50/70] trying to fix gosec error --- testing/endtoend/evaluators/fee_recipient.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/endtoend/evaluators/fee_recipient.go b/testing/endtoend/evaluators/fee_recipient.go index 5cc03fce8ce9..8cbefd500d98 100644 --- a/testing/endtoend/evaluators/fee_recipient.go +++ b/testing/endtoend/evaluators/fee_recipient.go @@ -54,7 +54,7 @@ func feeRecipientIsPresent(conns ...*grpc.ClientConn) error { testNetDir := e2e.TestParams.TestPath + "/proposer-settings" configPath := filepath.Join(testNetDir, filepath.Clean("config.json")) - jsonFile, err := os.Open(configPath) + jsonFile, err := os.Open(filepath.Clean(configPath)) if err != nil { return err } From 310e956af47f8e17e77d6ce7404cff2dd441cc2f Mon Sep 17 00:00:00 2001 From: James He Date: Mon, 27 Jun 2022 16:24:44 -0500 Subject: [PATCH 51/70] trying to fix address --- testing/endtoend/components/validator.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/testing/endtoend/components/validator.go b/testing/endtoend/components/validator.go index 6ad76ceb5dea..01b475161953 100644 --- a/testing/endtoend/components/validator.go +++ b/testing/endtoend/components/validator.go @@ -16,6 +16,7 @@ import ( "github.com/bazelbuild/rules_go/go/tools/bazel" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/accounts/keystore" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/rpc" @@ -411,9 +412,14 @@ func createProposerSettingsPath(pubkeys []string) (string, error) { } } else { config := make(map[string]*validator_service_config.ProposerOptionPayload) + for index, pubkey := range pubkeys { + mixedAddress, err := common.NewMixedcaseAddressFromString(fmt.Sprintf("0x%40d", 1+index)) + if err != nil { + return "", err + } config[pubkey] = &validator_service_config.ProposerOptionPayload{ - FeeRecipient: fmt.Sprintf("0x%40d", 1+index), + FeeRecipient: mixedAddress.Address().Hex(), } } proposerSettingsPayload = validator_service_config.ProposerSettingsPayload{ From 363d989859128e0d3b30a6025cc00aa5c70d90b3 Mon Sep 17 00:00:00 2001 From: James He Date: Mon, 27 Jun 2022 16:27:50 -0500 Subject: [PATCH 52/70] fixing linting --- testing/endtoend/components/BUILD.bazel | 1 + 1 file changed, 1 insertion(+) diff --git a/testing/endtoend/components/BUILD.bazel b/testing/endtoend/components/BUILD.bazel index 48c11a30e7bf..241c72e9b222 100644 --- a/testing/endtoend/components/BUILD.bazel +++ b/testing/endtoend/components/BUILD.bazel @@ -39,6 +39,7 @@ go_library( "//validator/keymanager: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//common:go_default_library", "@com_github_ethereum_go_ethereum//common/hexutil:go_default_library", "@com_github_ethereum_go_ethereum//ethclient:go_default_library", "@com_github_ethereum_go_ethereum//rpc:go_default_library", From 935d0ffb1c18c67a5006a67faf652383f07a38b1 Mon Sep 17 00:00:00 2001 From: James He Date: Mon, 27 Jun 2022 16:42:58 -0500 Subject: [PATCH 53/70] trying to gerenate key and random address --- testing/endtoend/components/validator.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/testing/endtoend/components/validator.go b/testing/endtoend/components/validator.go index 01b475161953..3509ca232577 100644 --- a/testing/endtoend/components/validator.go +++ b/testing/endtoend/components/validator.go @@ -16,8 +16,8 @@ import ( "github.com/bazelbuild/rules_go/go/tools/bazel" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/accounts/keystore" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/rpc" "github.com/pkg/errors" @@ -413,13 +413,14 @@ func createProposerSettingsPath(pubkeys []string) (string, error) { } else { config := make(map[string]*validator_service_config.ProposerOptionPayload) - for index, pubkey := range pubkeys { - mixedAddress, err := common.NewMixedcaseAddressFromString(fmt.Sprintf("0x%40d", 1+index)) + for _, pubkey := range pubkeys { + // Create an account + key, err := crypto.GenerateKey() if err != nil { return "", err } config[pubkey] = &validator_service_config.ProposerOptionPayload{ - FeeRecipient: mixedAddress.Address().Hex(), + FeeRecipient: crypto.PubkeyToAddress(key.PublicKey).Hex(), } } proposerSettingsPayload = validator_service_config.ProposerSettingsPayload{ From 44e1ab0f3c7686727a41d38ec69f7a538cf0c386 Mon Sep 17 00:00:00 2001 From: James He Date: Mon, 27 Jun 2022 16:43:26 -0500 Subject: [PATCH 54/70] fixing linting --- testing/endtoend/components/BUILD.bazel | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/endtoend/components/BUILD.bazel b/testing/endtoend/components/BUILD.bazel index 241c72e9b222..2f131e02033e 100644 --- a/testing/endtoend/components/BUILD.bazel +++ b/testing/endtoend/components/BUILD.bazel @@ -39,8 +39,8 @@ go_library( "//validator/keymanager: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//common:go_default_library", "@com_github_ethereum_go_ethereum//common/hexutil:go_default_library", + "@com_github_ethereum_go_ethereum//crypto:go_default_library", "@com_github_ethereum_go_ethereum//ethclient:go_default_library", "@com_github_ethereum_go_ethereum//rpc:go_default_library", "@com_github_google_uuid//:go_default_library", From d86532a5d614b3b98fa56b0204b2be4cb2e5ca03 Mon Sep 17 00:00:00 2001 From: James He Date: Mon, 27 Jun 2022 17:09:35 -0500 Subject: [PATCH 55/70] fixing check for proposer config --- testing/endtoend/evaluators/fee_recipient.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/testing/endtoend/evaluators/fee_recipient.go b/testing/endtoend/evaluators/fee_recipient.go index 8cbefd500d98..beedfaa633cc 100644 --- a/testing/endtoend/evaluators/fee_recipient.go +++ b/testing/endtoend/evaluators/fee_recipient.go @@ -85,14 +85,16 @@ func feeRecipientIsPresent(conns ...*grpc.ClientConn) error { publickey := validator.GetPublicKey() option, ok := configFile.ProposerConfig[hexutil.Encode(publickey)] - if !ok { + if ok { + if option.FeeRecipient != account.Hex() { + return fmt.Errorf("fee recipient %s does not match the proposer settings fee recipient %s", account.Hex(), option.FeeRecipient) + } + } else { if configFile.DefaultConfig.FeeRecipient != account.Hex() { return fmt.Errorf("fee recipient %s does not match the default fee recipient %s", account.Hex(), configFile.DefaultConfig.FeeRecipient) } } - if option.FeeRecipient != account.Hex() { - return fmt.Errorf("fee recipient %s does not match the proposer settings fee recipient %s", account.Hex(), option.FeeRecipient) - } + } } From 0d4d9fbde19af9600a293cb8a2e47c5ec35ff5c3 Mon Sep 17 00:00:00 2001 From: James He Date: Mon, 27 Jun 2022 22:42:23 -0500 Subject: [PATCH 56/70] trying with multi config files --- testing/endtoend/components/validator.go | 6 +-- testing/endtoend/evaluators/fee_recipient.go | 41 +++++++++++++------- 2 files changed, 31 insertions(+), 16 deletions(-) diff --git a/testing/endtoend/components/validator.go b/testing/endtoend/components/validator.go index 3509ca232577..35b1b4d9c2c9 100644 --- a/testing/endtoend/components/validator.go +++ b/testing/endtoend/components/validator.go @@ -246,7 +246,7 @@ func (v *ValidatorNode) Start(ctx context.Context) error { //TODO: web3signer does not support validator registration signing currently, move this when support is there. //TODO: current version of prysmsh still uses wrong flag name. if !v.config.UsePrysmShValidator && !v.config.UseWeb3RemoteSigner { - proposerSettingsPathPath, err := createProposerSettingsPath(validatorHexPubKeys) + proposerSettingsPathPath, err := createProposerSettingsPath(validatorHexPubKeys, index) if err != nil { return err } @@ -397,8 +397,8 @@ func sendDeposits(web3 *ethclient.Client, keystoreBytes []byte, num, offset int, return nil } -func createProposerSettingsPath(pubkeys []string) (string, error) { - testNetDir := e2e.TestParams.TestPath + "/proposer-settings" +func createProposerSettingsPath(pubkeys []string, validatorIndex int) (string, error) { + testNetDir := e2e.TestParams.TestPath + fmt.Sprintf("/proposer-settings/validator_%d", validatorIndex) configPath := filepath.Join(testNetDir, "config.json") if len(pubkeys) == 0 { return "", errors.New("number of validators must be greater than 0") diff --git a/testing/endtoend/evaluators/fee_recipient.go b/testing/endtoend/evaluators/fee_recipient.go index beedfaa633cc..6e0aedd16747 100644 --- a/testing/endtoend/evaluators/fee_recipient.go +++ b/testing/endtoend/evaluators/fee_recipient.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "io/ioutil" "math/big" "os" "path/filepath" @@ -52,15 +53,25 @@ func feeRecipientIsPresent(conns ...*grpc.ClientConn) error { web3 := ethclient.NewClient(rpcclient) ctx := context.Background() + var configFiles []*validator_service_config.ProposerSettingsPayload testNetDir := e2e.TestParams.TestPath + "/proposer-settings" - configPath := filepath.Join(testNetDir, filepath.Clean("config.json")) - jsonFile, err := os.Open(filepath.Clean(configPath)) + dirs, err := ioutil.ReadDir(filepath.Clean(testNetDir)) if err != nil { return err } - var configFile validator_service_config.ProposerSettingsPayload - if err := json.NewDecoder(jsonFile).Decode(&configFile); err != nil { - return err + for _, f := range dirs { + if !f.IsDir() { + configPath := filepath.Join(testNetDir, filepath.Clean(f.Name()+"/config.json")) + jsonFile, err := os.Open(filepath.Clean(configPath)) + if err != nil { + return err + } + var configFile validator_service_config.ProposerSettingsPayload + if err := json.NewDecoder(jsonFile).Decode(&configFile); err != nil { + return err + } + configFiles = append(configFiles, &configFile) + } } var account common.Address @@ -83,15 +94,19 @@ func feeRecipientIsPresent(conns ...*grpc.ClientConn) error { return errors.Wrap(err, "failed to get validators") } publickey := validator.GetPublicKey() - - option, ok := configFile.ProposerConfig[hexutil.Encode(publickey)] - if ok { - if option.FeeRecipient != account.Hex() { - return fmt.Errorf("fee recipient %s does not match the proposer settings fee recipient %s", account.Hex(), option.FeeRecipient) + usesDefaultFeeRecipient := false + for _, config := range configFiles { + option, ok := config.ProposerConfig[hexutil.Encode(publickey)] + if ok { + if option.FeeRecipient != account.Hex() { + return fmt.Errorf("fee recipient %s does not match the proposer settings fee recipient %s", account.Hex(), option.FeeRecipient) + } + usesDefaultFeeRecipient = true } - } else { - if configFile.DefaultConfig.FeeRecipient != account.Hex() { - return fmt.Errorf("fee recipient %s does not match the default fee recipient %s", account.Hex(), configFile.DefaultConfig.FeeRecipient) + } + if !usesDefaultFeeRecipient { + if configFiles[0].DefaultConfig.FeeRecipient != account.Hex() { + return fmt.Errorf("fee recipient %s does not match the default fee recipient %s", account.Hex(), configFiles[0].DefaultConfig.FeeRecipient) } } From 8e57abd91d476091532b72ae7b410dafa81836d1 Mon Sep 17 00:00:00 2001 From: James He Date: Mon, 27 Jun 2022 23:20:42 -0500 Subject: [PATCH 57/70] fixing is dir check --- testing/endtoend/evaluators/fee_recipient.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/endtoend/evaluators/fee_recipient.go b/testing/endtoend/evaluators/fee_recipient.go index 6e0aedd16747..92853fe0eaa4 100644 --- a/testing/endtoend/evaluators/fee_recipient.go +++ b/testing/endtoend/evaluators/fee_recipient.go @@ -60,7 +60,7 @@ func feeRecipientIsPresent(conns ...*grpc.ClientConn) error { return err } for _, f := range dirs { - if !f.IsDir() { + if f.IsDir() { configPath := filepath.Join(testNetDir, filepath.Clean(f.Name()+"/config.json")) jsonFile, err := os.Open(filepath.Clean(configPath)) if err != nil { From fe7f2485a3ff5249f8459c0fe09e5e6ff19abdb2 Mon Sep 17 00:00:00 2001 From: James He Date: Mon, 27 Jun 2022 23:52:58 -0500 Subject: [PATCH 58/70] testing for older previous balance --- testing/endtoend/evaluators/fee_recipient.go | 38 ++++++++++---------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/testing/endtoend/evaluators/fee_recipient.go b/testing/endtoend/evaluators/fee_recipient.go index 92853fe0eaa4..d70fd7ae4202 100644 --- a/testing/endtoend/evaluators/fee_recipient.go +++ b/testing/endtoend/evaluators/fee_recipient.go @@ -74,10 +74,10 @@ func feeRecipientIsPresent(conns ...*grpc.ClientConn) error { } } - var account common.Address for _, ctr := range blks.BlockContainers { switch ctr.Block.(type) { case *ethpb.BeaconBlockContainer_BellatrixBlock: + var account common.Address fr := ctr.GetBellatrixBlock().Block.Body.ExecutionPayload.FeeRecipient if len(fr) != 0 && hexutil.Encode(fr) != params.BeaconConfig().EthBurnAddressHex { account = common.BytesToAddress(fr) @@ -109,28 +109,26 @@ func feeRecipientIsPresent(conns ...*grpc.ClientConn) error { return fmt.Errorf("fee recipient %s does not match the default fee recipient %s", account.Hex(), configFiles[0].DefaultConfig.FeeRecipient) } } - + latestBlockNum, err := web3.BlockNumber(ctx) + if err != nil { + return err + } + accountBalance, err := web3.BalanceAt(ctx, account, big.NewInt(0).SetUint64(latestBlockNum)) + if err != nil { + return err + } + prevAccountBalance, err := web3.BalanceAt(ctx, account, big.NewInt(0).SetUint64(latestBlockNum-uint64(params.BeaconConfig().SlotsPerEpoch))) + if err != nil { + return err + } + if accountBalance.Uint64() <= prevAccountBalance.Uint64() { + return errors.Errorf("account balance didn't change after applying fee recipient for account: %s", account.Hex()) + } else { + log.Infof("current account balance %v ,increased from previous account balance %v ", accountBalance, prevAccountBalance) + } } } - latestBlockNum, err := web3.BlockNumber(ctx) - if err != nil { - return err - } - accountBalance, err := web3.BalanceAt(ctx, account, big.NewInt(0).SetUint64(latestBlockNum)) - if err != nil { - return err - } - prevAccountBalance, err := web3.BalanceAt(ctx, account, big.NewInt(0).SetUint64(latestBlockNum-1)) - if err != nil { - return err - } - if accountBalance.Uint64() <= prevAccountBalance.Uint64() { - return errors.Errorf("account balance didn't change after applying fee recipient for account: %s", account.Hex()) - } else { - log.Infof("current account balance %v ,increased from previous account balance %v ", accountBalance, prevAccountBalance) - } - return nil } From b5512834b7b6d89a6c80fdd33a5b837bb8ea5326 Mon Sep 17 00:00:00 2001 From: James He Date: Tue, 28 Jun 2022 08:58:01 -0500 Subject: [PATCH 59/70] adding logging to help debug --- testing/endtoend/evaluators/fee_recipient.go | 1 + 1 file changed, 1 insertion(+) diff --git a/testing/endtoend/evaluators/fee_recipient.go b/testing/endtoend/evaluators/fee_recipient.go index d70fd7ae4202..f050f71dd5f4 100644 --- a/testing/endtoend/evaluators/fee_recipient.go +++ b/testing/endtoend/evaluators/fee_recipient.go @@ -122,6 +122,7 @@ func feeRecipientIsPresent(conns ...*grpc.ClientConn) error { return err } if accountBalance.Uint64() <= prevAccountBalance.Uint64() { + log.Infof("block num: %d account balance: %d pre account balance %d", latestBlockNum, accountBalance, prevAccountBalance) return errors.Errorf("account balance didn't change after applying fee recipient for account: %s", account.Hex()) } else { log.Infof("current account balance %v ,increased from previous account balance %v ", accountBalance, prevAccountBalance) From 2bdd1dd733515c3fef58f54045b075bf3c703b70 Mon Sep 17 00:00:00 2001 From: James He Date: Tue, 28 Jun 2022 11:10:55 -0500 Subject: [PATCH 60/70] changing how i get the block numbers --- testing/endtoend/evaluators/fee_recipient.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/testing/endtoend/evaluators/fee_recipient.go b/testing/endtoend/evaluators/fee_recipient.go index f050f71dd5f4..0222830675df 100644 --- a/testing/endtoend/evaluators/fee_recipient.go +++ b/testing/endtoend/evaluators/fee_recipient.go @@ -5,7 +5,6 @@ import ( "encoding/json" "fmt" "io/ioutil" - "math/big" "os" "path/filepath" @@ -78,6 +77,7 @@ func feeRecipientIsPresent(conns ...*grpc.ClientConn) error { switch ctr.Block.(type) { case *ethpb.BeaconBlockContainer_BellatrixBlock: var account common.Address + fr := ctr.GetBellatrixBlock().Block.Body.ExecutionPayload.FeeRecipient if len(fr) != 0 && hexutil.Encode(fr) != params.BeaconConfig().EthBurnAddressHex { account = common.BytesToAddress(fr) @@ -109,20 +109,21 @@ func feeRecipientIsPresent(conns ...*grpc.ClientConn) error { return fmt.Errorf("fee recipient %s does not match the default fee recipient %s", account.Hex(), configFiles[0].DefaultConfig.FeeRecipient) } } - latestBlockNum, err := web3.BlockNumber(ctx) + currentBlock, err := web3.BlockByHash(ctx, common.BytesToHash(ctr.GetBellatrixBlock().GetBlock().GetBody().GetExecutionPayload().BlockHash)) if err != nil { return err } - accountBalance, err := web3.BalanceAt(ctx, account, big.NewInt(0).SetUint64(latestBlockNum)) + accountBalance, err := web3.BalanceAt(ctx, account, currentBlock.Number()) if err != nil { return err } - prevAccountBalance, err := web3.BalanceAt(ctx, account, big.NewInt(0).SetUint64(latestBlockNum-uint64(params.BeaconConfig().SlotsPerEpoch))) + previousBlock, err := web3.BlockByHash(ctx, common.BytesToHash(ctr.GetBellatrixBlock().GetBlock().GetBody().GetExecutionPayload().ParentHash)) + prevAccountBalance, err := web3.BalanceAt(ctx, account, previousBlock.Number()) if err != nil { return err } if accountBalance.Uint64() <= prevAccountBalance.Uint64() { - log.Infof("block num: %d account balance: %d pre account balance %d", latestBlockNum, accountBalance, prevAccountBalance) + log.Infof("current block num: %d , previous block num: %d , account balance: %d, pre account balance %d", currentBlock.Number(), previousBlock.Number(), accountBalance, prevAccountBalance) return errors.Errorf("account balance didn't change after applying fee recipient for account: %s", account.Hex()) } else { log.Infof("current account balance %v ,increased from previous account balance %v ", accountBalance, prevAccountBalance) From 518e6d5e0364d6238c1d3a413b8610f6d6c5ca15 Mon Sep 17 00:00:00 2001 From: James He Date: Tue, 28 Jun 2022 11:11:33 -0500 Subject: [PATCH 61/70] fixing missed error check --- testing/endtoend/evaluators/fee_recipient.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/testing/endtoend/evaluators/fee_recipient.go b/testing/endtoend/evaluators/fee_recipient.go index 0222830675df..d62d4b912fca 100644 --- a/testing/endtoend/evaluators/fee_recipient.go +++ b/testing/endtoend/evaluators/fee_recipient.go @@ -118,6 +118,9 @@ func feeRecipientIsPresent(conns ...*grpc.ClientConn) error { return err } previousBlock, err := web3.BlockByHash(ctx, common.BytesToHash(ctr.GetBellatrixBlock().GetBlock().GetBody().GetExecutionPayload().ParentHash)) + if err != nil { + return err + } prevAccountBalance, err := web3.BalanceAt(ctx, account, previousBlock.Number()) if err != nil { return err From 575d4ac63a94894e515a769cbc8a55103e00b461 Mon Sep 17 00:00:00 2001 From: James He Date: Tue, 28 Jun 2022 11:52:26 -0500 Subject: [PATCH 62/70] adding gasused check --- testing/endtoend/evaluators/fee_recipient.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/testing/endtoend/evaluators/fee_recipient.go b/testing/endtoend/evaluators/fee_recipient.go index d62d4b912fca..4da5f808662c 100644 --- a/testing/endtoend/evaluators/fee_recipient.go +++ b/testing/endtoend/evaluators/fee_recipient.go @@ -113,6 +113,7 @@ func feeRecipientIsPresent(conns ...*grpc.ClientConn) error { if err != nil { return err } + accountBalance, err := web3.BalanceAt(ctx, account, currentBlock.Number()) if err != nil { return err @@ -125,7 +126,7 @@ func feeRecipientIsPresent(conns ...*grpc.ClientConn) error { if err != nil { return err } - if accountBalance.Uint64() <= prevAccountBalance.Uint64() { + if currentBlock.GasUsed() > 0 && accountBalance.Uint64() <= prevAccountBalance.Uint64() { log.Infof("current block num: %d , previous block num: %d , account balance: %d, pre account balance %d", currentBlock.Number(), previousBlock.Number(), accountBalance, prevAccountBalance) return errors.Errorf("account balance didn't change after applying fee recipient for account: %s", account.Hex()) } else { From 5237a6b14b4658687705bfc137e776db79c5bcce Mon Sep 17 00:00:00 2001 From: James He Date: Tue, 28 Jun 2022 13:11:07 -0500 Subject: [PATCH 63/70] adding log for current gas used --- testing/endtoend/evaluators/fee_recipient.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/endtoend/evaluators/fee_recipient.go b/testing/endtoend/evaluators/fee_recipient.go index 4da5f808662c..e94609a8039c 100644 --- a/testing/endtoend/evaluators/fee_recipient.go +++ b/testing/endtoend/evaluators/fee_recipient.go @@ -130,7 +130,7 @@ func feeRecipientIsPresent(conns ...*grpc.ClientConn) error { log.Infof("current block num: %d , previous block num: %d , account balance: %d, pre account balance %d", currentBlock.Number(), previousBlock.Number(), accountBalance, prevAccountBalance) return errors.Errorf("account balance didn't change after applying fee recipient for account: %s", account.Hex()) } else { - log.Infof("current account balance %v ,increased from previous account balance %v ", accountBalance, prevAccountBalance) + log.Infof("current gas used: %v current account balance %v ,increased from previous account balance %v ", currentBlock.GasUsed(), accountBalance, prevAccountBalance) } } From cce3b4fe9061f6c11c5682e002c9f7bbc55fe4b7 Mon Sep 17 00:00:00 2001 From: James He Date: Tue, 28 Jun 2022 21:06:18 -0500 Subject: [PATCH 64/70] taking suggestion to make fee recipient more deterministic --- testing/endtoend/components/validator.go | 8 ++-- testing/endtoend/evaluators/fee_recipient.go | 49 ++++---------------- 2 files changed, 15 insertions(+), 42 deletions(-) diff --git a/testing/endtoend/components/validator.go b/testing/endtoend/components/validator.go index 35b1b4d9c2c9..954786aa5238 100644 --- a/testing/endtoend/components/validator.go +++ b/testing/endtoend/components/validator.go @@ -16,14 +16,15 @@ import ( "github.com/bazelbuild/rules_go/go/tools/bazel" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/accounts/keystore" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/rpc" "github.com/pkg/errors" cmdshared "github.com/prysmaticlabs/prysm/cmd" "github.com/prysmaticlabs/prysm/cmd/validator/flags" "github.com/prysmaticlabs/prysm/config/features" + fieldparams "github.com/prysmaticlabs/prysm/config/fieldparams" "github.com/prysmaticlabs/prysm/config/params" validator_service_config "github.com/prysmaticlabs/prysm/config/validator/service" contracts "github.com/prysmaticlabs/prysm/contracts/deposit" @@ -415,12 +416,13 @@ func createProposerSettingsPath(pubkeys []string, validatorIndex int) (string, e for _, pubkey := range pubkeys { // Create an account - key, err := crypto.GenerateKey() + byteval, err := hexutil.Decode(pubkey) if err != nil { return "", err } + deterministicFeeRecipient := common.HexToAddress(hexutil.Encode(byteval[:fieldparams.FeeRecipientLength])).Hex() config[pubkey] = &validator_service_config.ProposerOptionPayload{ - FeeRecipient: crypto.PubkeyToAddress(key.PublicKey).Hex(), + FeeRecipient: deterministicFeeRecipient, } } proposerSettingsPayload = validator_service_config.ProposerSettingsPayload{ diff --git a/testing/endtoend/evaluators/fee_recipient.go b/testing/endtoend/evaluators/fee_recipient.go index e94609a8039c..6c29439cd68b 100644 --- a/testing/endtoend/evaluators/fee_recipient.go +++ b/testing/endtoend/evaluators/fee_recipient.go @@ -2,20 +2,17 @@ package evaluators import ( "context" - "encoding/json" "fmt" - "io/ioutil" - "os" - "path/filepath" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/rpc" "github.com/pkg/errors" + fieldparams "github.com/prysmaticlabs/prysm/config/fieldparams" "github.com/prysmaticlabs/prysm/config/params" - validator_service_config "github.com/prysmaticlabs/prysm/config/validator/service" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + "github.com/prysmaticlabs/prysm/testing/endtoend/components" "github.com/prysmaticlabs/prysm/testing/endtoend/helpers" e2e "github.com/prysmaticlabs/prysm/testing/endtoend/params" "github.com/prysmaticlabs/prysm/testing/endtoend/policies" @@ -52,27 +49,6 @@ func feeRecipientIsPresent(conns ...*grpc.ClientConn) error { web3 := ethclient.NewClient(rpcclient) ctx := context.Background() - var configFiles []*validator_service_config.ProposerSettingsPayload - testNetDir := e2e.TestParams.TestPath + "/proposer-settings" - dirs, err := ioutil.ReadDir(filepath.Clean(testNetDir)) - if err != nil { - return err - } - for _, f := range dirs { - if f.IsDir() { - configPath := filepath.Join(testNetDir, filepath.Clean(f.Name()+"/config.json")) - jsonFile, err := os.Open(filepath.Clean(configPath)) - if err != nil { - return err - } - var configFile validator_service_config.ProposerSettingsPayload - if err := json.NewDecoder(jsonFile).Decode(&configFile); err != nil { - return err - } - configFiles = append(configFiles, &configFile) - } - } - for _, ctr := range blks.BlockContainers { switch ctr.Block.(type) { case *ethpb.BeaconBlockContainer_BellatrixBlock: @@ -94,19 +70,14 @@ func feeRecipientIsPresent(conns ...*grpc.ClientConn) error { return errors.Wrap(err, "failed to get validators") } publickey := validator.GetPublicKey() - usesDefaultFeeRecipient := false - for _, config := range configFiles { - option, ok := config.ProposerConfig[hexutil.Encode(publickey)] - if ok { - if option.FeeRecipient != account.Hex() { - return fmt.Errorf("fee recipient %s does not match the proposer settings fee recipient %s", account.Hex(), option.FeeRecipient) - } - usesDefaultFeeRecipient = true - } - } - if !usesDefaultFeeRecipient { - if configFiles[0].DefaultConfig.FeeRecipient != account.Hex() { - return fmt.Errorf("fee recipient %s does not match the default fee recipient %s", account.Hex(), configFiles[0].DefaultConfig.FeeRecipient) + // calculate deterministic fee recipient using first 20 bytes of public key + deterministicFeeRecipient := common.HexToAddress(hexutil.Encode(publickey[:fieldparams.FeeRecipientLength])).Hex() + if deterministicFeeRecipient == account.Hex() { + return fmt.Errorf("fee recipient %s does not match the proposer settings fee recipient %s", account.Hex(), deterministicFeeRecipient) + } else { + + if components.DefaultFeeRecipientAddress != account.Hex() { + return fmt.Errorf("fee recipient %s does not match the default fee recipient %s", account.Hex(), components.DefaultFeeRecipientAddress) } } currentBlock, err := web3.BlockByHash(ctx, common.BytesToHash(ctr.GetBellatrixBlock().GetBlock().GetBody().GetExecutionPayload().BlockHash)) From dbeb8af3ad55197417bb85d75ec6753fc9b5aa94 Mon Sep 17 00:00:00 2001 From: James He Date: Tue, 28 Jun 2022 21:07:20 -0500 Subject: [PATCH 65/70] fixing linting --- testing/endtoend/components/BUILD.bazel | 3 ++- testing/endtoend/evaluators/BUILD.bazel | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/testing/endtoend/components/BUILD.bazel b/testing/endtoend/components/BUILD.bazel index 2f131e02033e..3df767334461 100644 --- a/testing/endtoend/components/BUILD.bazel +++ b/testing/endtoend/components/BUILD.bazel @@ -24,6 +24,7 @@ go_library( "//cmd/beacon-chain/flags:go_default_library", "//cmd/validator/flags:go_default_library", "//config/features:go_default_library", + "//config/fieldparams:go_default_library", "//config/params:go_default_library", "//config/validator/service:go_default_library", "//contracts/deposit:go_default_library", @@ -39,8 +40,8 @@ go_library( "//validator/keymanager: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//common:go_default_library", "@com_github_ethereum_go_ethereum//common/hexutil:go_default_library", - "@com_github_ethereum_go_ethereum//crypto:go_default_library", "@com_github_ethereum_go_ethereum//ethclient:go_default_library", "@com_github_ethereum_go_ethereum//rpc:go_default_library", "@com_github_google_uuid//:go_default_library", diff --git a/testing/endtoend/evaluators/BUILD.bazel b/testing/endtoend/evaluators/BUILD.bazel index 13e75e71ec2d..df953f5cb796 100644 --- a/testing/endtoend/evaluators/BUILD.bazel +++ b/testing/endtoend/evaluators/BUILD.bazel @@ -27,7 +27,6 @@ go_library( "//beacon-chain/p2p:go_default_library", "//config/fieldparams:go_default_library", "//config/params:go_default_library", - "//config/validator/service:go_default_library", "//consensus-types/interfaces:go_default_library", "//consensus-types/primitives:go_default_library", "//consensus-types/wrapper:go_default_library", @@ -39,6 +38,7 @@ go_library( "//proto/eth/v1:go_default_library", "//proto/eth/v2:go_default_library", "//proto/prysm/v1alpha1:go_default_library", + "//testing/endtoend/components:go_default_library", "//testing/endtoend/helpers:go_default_library", "//testing/endtoend/params:go_default_library", "//testing/endtoend/policies:go_default_library", From 43d03fbe45f689eb2d546b995e60b91d66358cb9 Mon Sep 17 00:00:00 2001 From: James He Date: Tue, 28 Jun 2022 21:56:01 -0500 Subject: [PATCH 66/70] fixing check --- testing/endtoend/evaluators/fee_recipient.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/endtoend/evaluators/fee_recipient.go b/testing/endtoend/evaluators/fee_recipient.go index 6c29439cd68b..cd30772fd359 100644 --- a/testing/endtoend/evaluators/fee_recipient.go +++ b/testing/endtoend/evaluators/fee_recipient.go @@ -72,7 +72,7 @@ func feeRecipientIsPresent(conns ...*grpc.ClientConn) error { publickey := validator.GetPublicKey() // calculate deterministic fee recipient using first 20 bytes of public key deterministicFeeRecipient := common.HexToAddress(hexutil.Encode(publickey[:fieldparams.FeeRecipientLength])).Hex() - if deterministicFeeRecipient == account.Hex() { + if deterministicFeeRecipient != account.Hex() { return fmt.Errorf("fee recipient %s does not match the proposer settings fee recipient %s", account.Hex(), deterministicFeeRecipient) } else { From 5bd896c2c19bbdc9147059e2b419e2cf72c3c8e9 Mon Sep 17 00:00:00 2001 From: James He Date: Tue, 28 Jun 2022 22:34:21 -0500 Subject: [PATCH 67/70] fixing the address check --- testing/endtoend/components/validator.go | 4 ++-- testing/endtoend/evaluators/fee_recipient.go | 10 ++-------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/testing/endtoend/components/validator.go b/testing/endtoend/components/validator.go index 954786aa5238..6b333f55b047 100644 --- a/testing/endtoend/components/validator.go +++ b/testing/endtoend/components/validator.go @@ -414,14 +414,14 @@ func createProposerSettingsPath(pubkeys []string, validatorIndex int) (string, e } else { config := make(map[string]*validator_service_config.ProposerOptionPayload) - for _, pubkey := range pubkeys { + for i, pubkey := range pubkeys { // Create an account byteval, err := hexutil.Decode(pubkey) if err != nil { return "", err } deterministicFeeRecipient := common.HexToAddress(hexutil.Encode(byteval[:fieldparams.FeeRecipientLength])).Hex() - config[pubkey] = &validator_service_config.ProposerOptionPayload{ + config[pubkeys[i]] = &validator_service_config.ProposerOptionPayload{ FeeRecipient: deterministicFeeRecipient, } } diff --git a/testing/endtoend/evaluators/fee_recipient.go b/testing/endtoend/evaluators/fee_recipient.go index cd30772fd359..4fb0b9af10d0 100644 --- a/testing/endtoend/evaluators/fee_recipient.go +++ b/testing/endtoend/evaluators/fee_recipient.go @@ -72,13 +72,8 @@ func feeRecipientIsPresent(conns ...*grpc.ClientConn) error { publickey := validator.GetPublicKey() // calculate deterministic fee recipient using first 20 bytes of public key deterministicFeeRecipient := common.HexToAddress(hexutil.Encode(publickey[:fieldparams.FeeRecipientLength])).Hex() - if deterministicFeeRecipient != account.Hex() { - return fmt.Errorf("fee recipient %s does not match the proposer settings fee recipient %s", account.Hex(), deterministicFeeRecipient) - } else { - - if components.DefaultFeeRecipientAddress != account.Hex() { - return fmt.Errorf("fee recipient %s does not match the default fee recipient %s", account.Hex(), components.DefaultFeeRecipientAddress) - } + if deterministicFeeRecipient != account.Hex() && components.DefaultFeeRecipientAddress != account.Hex() { + return fmt.Errorf("publickey %s, fee recipient %s does not match the proposer settings fee recipient %s nor the default fee recipient %s", account.Hex(), deterministicFeeRecipient, components.DefaultFeeRecipientAddress) } currentBlock, err := web3.BlockByHash(ctx, common.BytesToHash(ctr.GetBellatrixBlock().GetBlock().GetBody().GetExecutionPayload().BlockHash)) if err != nil { @@ -104,7 +99,6 @@ func feeRecipientIsPresent(conns ...*grpc.ClientConn) error { log.Infof("current gas used: %v current account balance %v ,increased from previous account balance %v ", currentBlock.GasUsed(), accountBalance, prevAccountBalance) } } - } return nil From 0a2d85e6ae7c04b63331115091e684e0a9f2b6df Mon Sep 17 00:00:00 2001 From: James He Date: Tue, 28 Jun 2022 23:16:11 -0500 Subject: [PATCH 68/70] fixing format error --- testing/endtoend/evaluators/fee_recipient.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/testing/endtoend/evaluators/fee_recipient.go b/testing/endtoend/evaluators/fee_recipient.go index 4fb0b9af10d0..d7a4d407e383 100644 --- a/testing/endtoend/evaluators/fee_recipient.go +++ b/testing/endtoend/evaluators/fee_recipient.go @@ -73,7 +73,8 @@ func feeRecipientIsPresent(conns ...*grpc.ClientConn) error { // calculate deterministic fee recipient using first 20 bytes of public key deterministicFeeRecipient := common.HexToAddress(hexutil.Encode(publickey[:fieldparams.FeeRecipientLength])).Hex() if deterministicFeeRecipient != account.Hex() && components.DefaultFeeRecipientAddress != account.Hex() { - return fmt.Errorf("publickey %s, fee recipient %s does not match the proposer settings fee recipient %s nor the default fee recipient %s", account.Hex(), deterministicFeeRecipient, components.DefaultFeeRecipientAddress) + return fmt.Errorf("publickey %s, fee recipient %s does not match the proposer settings fee recipient %s nor the default fee recipient %s", + hexutil.Encode(publickey), account.Hex(), deterministicFeeRecipient, components.DefaultFeeRecipientAddress) } currentBlock, err := web3.BlockByHash(ctx, common.BytesToHash(ctr.GetBellatrixBlock().GetBlock().GetBody().GetExecutionPayload().BlockHash)) if err != nil { From 92e6904fbff3fcd2e62feda9e76f1664796629ed Mon Sep 17 00:00:00 2001 From: James He Date: Wed, 29 Jun 2022 09:59:02 -0500 Subject: [PATCH 69/70] logic to differentiate recipients --- testing/endtoend/evaluators/fee_recipient.go | 23 +++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/testing/endtoend/evaluators/fee_recipient.go b/testing/endtoend/evaluators/fee_recipient.go index d7a4d407e383..0e89a6b42dc9 100644 --- a/testing/endtoend/evaluators/fee_recipient.go +++ b/testing/endtoend/evaluators/fee_recipient.go @@ -12,6 +12,7 @@ import ( fieldparams "github.com/prysmaticlabs/prysm/config/fieldparams" "github.com/prysmaticlabs/prysm/config/params" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + "github.com/prysmaticlabs/prysm/runtime/interop" "github.com/prysmaticlabs/prysm/testing/endtoend/components" "github.com/prysmaticlabs/prysm/testing/endtoend/helpers" e2e "github.com/prysmaticlabs/prysm/testing/endtoend/params" @@ -70,11 +71,27 @@ func feeRecipientIsPresent(conns ...*grpc.ClientConn) error { return errors.Wrap(err, "failed to get validators") } publickey := validator.GetPublicKey() + isDeterministicKey := false + validatorNum := int(params.BeaconConfig().MinGenesisActiveValidatorCount) // matches validator start in validator component + _, pubs, err := interop.DeterministicallyGenerateKeys(uint64(0), uint64(validatorNum)) + if err != nil { + return err + } + for _, pub := range pubs { + if hexutil.Encode(publickey) == hexutil.Encode(pub.Marshal()) { + isDeterministicKey = true + break + } + } // calculate deterministic fee recipient using first 20 bytes of public key deterministicFeeRecipient := common.HexToAddress(hexutil.Encode(publickey[:fieldparams.FeeRecipientLength])).Hex() - if deterministicFeeRecipient != account.Hex() && components.DefaultFeeRecipientAddress != account.Hex() { - return fmt.Errorf("publickey %s, fee recipient %s does not match the proposer settings fee recipient %s nor the default fee recipient %s", - hexutil.Encode(publickey), account.Hex(), deterministicFeeRecipient, components.DefaultFeeRecipientAddress) + if isDeterministicKey && deterministicFeeRecipient != account.Hex() { + return fmt.Errorf("publickey %s, fee recipient %s does not match the proposer settings fee recipient %s", + hexutil.Encode(publickey), account.Hex(), deterministicFeeRecipient) + } + if !isDeterministicKey && components.DefaultFeeRecipientAddress != account.Hex() { + return fmt.Errorf("publickey %s, fee recipient %s does not match the default fee recipient %s", + hexutil.Encode(publickey), account.Hex(), components.DefaultFeeRecipientAddress) } currentBlock, err := web3.BlockByHash(ctx, common.BytesToHash(ctr.GetBellatrixBlock().GetBlock().GetBody().GetExecutionPayload().BlockHash)) if err != nil { From 9a4c7e59fc77d97b8b948f40951041e57923ecef Mon Sep 17 00:00:00 2001 From: James He Date: Wed, 29 Jun 2022 10:00:52 -0500 Subject: [PATCH 70/70] fixing linting --- testing/endtoend/evaluators/BUILD.bazel | 1 + 1 file changed, 1 insertion(+) diff --git a/testing/endtoend/evaluators/BUILD.bazel b/testing/endtoend/evaluators/BUILD.bazel index df953f5cb796..6bd1a571feab 100644 --- a/testing/endtoend/evaluators/BUILD.bazel +++ b/testing/endtoend/evaluators/BUILD.bazel @@ -38,6 +38,7 @@ go_library( "//proto/eth/v1:go_default_library", "//proto/eth/v2:go_default_library", "//proto/prysm/v1alpha1:go_default_library", + "//runtime/interop:go_default_library", "//testing/endtoend/components:go_default_library", "//testing/endtoend/helpers:go_default_library", "//testing/endtoend/params:go_default_library",