Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

E2E: fee-recipient evaluator #10528

Merged
merged 118 commits into from
Jun 30, 2022
Merged
Show file tree
Hide file tree
Changes from 106 commits
Commits
Show all changes
118 commits
Select commit Hold shift + click to select a range
28234cf
testing out fee-recipient evaluator
james-prysm Apr 14, 2022
16ebb53
fixing bazel linter
james-prysm Apr 14, 2022
f3c15a6
Merge branch 'develop' into fee-recipient-e2e
james-prysm Apr 14, 2022
bc26e25
adjusting comparison
james-prysm Apr 14, 2022
f01c7a2
typo on file rolling back
james-prysm Apr 14, 2022
0058de0
adding fee recipient is present to minimal e2e
james-prysm Apr 14, 2022
9ce5f5c
fixing gofmt
james-prysm Apr 14, 2022
cde4eae
fixing gofmt
james-prysm Apr 14, 2022
5bd0a72
fixing flag usage name
james-prysm Apr 14, 2022
c8e6a11
Merge branch 'develop' into fee-recipient-e2e
james-prysm Apr 15, 2022
028d3b5
Merge branch 'develop' into fee-recipient-e2e
james-prysm Apr 15, 2022
8a9e9cc
adding in log to help debug
james-prysm Apr 15, 2022
465bc68
fixing log build
james-prysm Apr 15, 2022
fc0ece8
trying to figure out why suggested fee recipient isn't working in e2…
james-prysm Apr 19, 2022
934695e
Merge branch 'develop' into fee-recipient-e2e
james-prysm Apr 21, 2022
aa8b073
rolling back logs
james-prysm Apr 21, 2022
db27abd
making e2e test more dynamic
james-prysm Apr 21, 2022
351d3ed
Merge branch 'develop' into fee-recipient-e2e
james-prysm Apr 21, 2022
30b9b7b
fixing deepsource issue
james-prysm Apr 21, 2022
41a59d7
fixing bazel
james-prysm Apr 21, 2022
dd8b44c
Merge branch 'develop' into fee-recipient-e2e
james-prysm Apr 22, 2022
76513a6
adding in condition for latest release
james-prysm Apr 22, 2022
ec240d5
duplicate condtion check.
james-prysm Apr 22, 2022
1c33814
Merge branch 'develop' into fee-recipient-e2e
james-prysm Apr 25, 2022
5b8e22e
Merge branch 'develop' into fee-recipient-e2e
james-prysm Apr 25, 2022
d245a6d
Merge branch 'develop' into fee-recipient-e2e
james-prysm Apr 26, 2022
4d98016
Merge branch 'develop' into fee-recipient-e2e
james-prysm Apr 28, 2022
7d18427
Merge branch 'develop' into fee-recipient-e2e
james-prysm Apr 28, 2022
2379454
Merge branch 'develop' into fee-recipient-e2e
james-prysm Apr 28, 2022
6ce66bb
Merge branch 'develop' into fee-recipient-e2e
james-prysm Apr 29, 2022
00edc3f
Merge branch 'develop' into fee-recipient-e2e
james-prysm Apr 29, 2022
4c9facf
Merge branch 'develop' into fee-recipient-e2e
james-prysm May 2, 2022
5d74382
Merge branch 'develop' into fee-recipient-e2e
james-prysm May 2, 2022
5d5c269
Merge branch 'develop' into fee-recipient-e2e
james-prysm Jun 15, 2022
58e7662
fixing gofmt
james-prysm Jun 15, 2022
7091a12
rolling back changes
james-prysm Jun 15, 2022
6ae653b
adding fee recipient evaluator in new file
james-prysm Jun 15, 2022
7ff6609
fixing validator component logic
james-prysm Jun 15, 2022
c082a0f
Merge branch 'develop' into fee-recipient-e2e
james-prysm Jun 15, 2022
a970511
Merge branch 'develop' into fee-recipient-e2e
james-prysm Jun 15, 2022
d7eb33a
Merge branch 'develop' into fee-recipient-e2e
james-prysm Jun 15, 2022
6482ab6
testing rpc client addition
james-prysm Jun 15, 2022
db324b9
testing fee recipient evaluator
james-prysm Jun 15, 2022
23a38a2
fixing bazel:
james-prysm Jun 15, 2022
e40e4d2
testing casting
james-prysm Jun 15, 2022
e97b43e
test casting
james-prysm Jun 15, 2022
185d08d
Merge branch 'develop' into fee-recipient-e2e
james-prysm Jun 15, 2022
441e40a
reverting
james-prysm Jun 15, 2022
47fc71c
testing casting
james-prysm Jun 15, 2022
03c84a2
testing casting
james-prysm Jun 15, 2022
fd74a6c
testing log
james-prysm Jun 16, 2022
640e1d7
adding bazel fix
james-prysm Jun 16, 2022
7d21f89
Merge branch 'develop' into fee-recipient-e2e
james-prysm Jun 16, 2022
6f8b168
Merge branch 'develop' into fee-recipient-e2e
james-prysm Jun 16, 2022
377dd1a
switching mixed case and adding temp logging
james-prysm Jun 16, 2022
92cb73c
Merge branch 'develop' into fee-recipient-e2e
james-prysm Jun 16, 2022
cd552b6
fixing gofmt
james-prysm Jun 16, 2022
b10dd54
Merge branch 'develop' into fee-recipient-e2e
james-prysm Jun 16, 2022
9c1baf8
Merge branch 'develop' into fee-recipient-e2e
james-prysm Jun 17, 2022
901727c
rolling back changes
james-prysm Jun 17, 2022
c5d1de2
removing fee recipient evaluator when web3signer is used
james-prysm Jun 17, 2022
fe23974
Merge branch 'develop' into fee-recipient-e2e
james-prysm Jun 17, 2022
1e65326
test only minimal config
james-prysm Jun 17, 2022
5b1f67c
Merge branch 'develop' into fee-recipient-e2e
james-prysm Jun 21, 2022
d8d05af
reverting changes
james-prysm Jun 21, 2022
99fdefd
Merge branch 'develop' into fee-recipient-e2e
james-prysm Jun 21, 2022
a3ac174
adding fee recipient evaluator to mainnet
james-prysm Jun 21, 2022
9c9f543
Merge branch 'develop' into fee-recipient-e2e
james-prysm Jun 21, 2022
9f057d7
current version uses wrong flag name
james-prysm Jun 21, 2022
846af79
Merge branch 'develop' into fee-recipient-e2e
james-prysm Jun 22, 2022
9706266
optimizing key usage
james-prysm Jun 22, 2022
1284c5c
making mining address a variable
james-prysm Jun 22, 2022
4cd2408
moving from global to local variable
james-prysm Jun 22, 2022
b024423
Merge branch 'develop' into fee-recipient-e2e
james-prysm Jun 22, 2022
71c08a0
removing unneeded log
james-prysm Jun 23, 2022
385f350
Merge branch 'develop' into fee-recipient-e2e
james-prysm Jun 23, 2022
4a2fa03
Merge branch 'develop' into fee-recipient-e2e
james-prysm Jun 24, 2022
cda7bfe
Merge branch 'develop' into fee-recipient-e2e
james-prysm Jun 24, 2022
117126e
Merge branch 'develop' into fee-recipient-e2e
james-prysm Jun 24, 2022
861da85
removing redundant check
james-prysm Jun 27, 2022
b090e96
Merge branch 'develop' into fee-recipient-e2e
james-prysm Jun 27, 2022
39fd16f
Merge branch 'develop' into fee-recipient-e2e
james-prysm Jun 27, 2022
c8e14c3
make proposer settings mroe deterministic and also have the evaluator…
james-prysm Jun 27, 2022
28af9e1
Merge branch 'develop' into fee-recipient-e2e
james-prysm Jun 27, 2022
e90afaf
fixing err return
james-prysm Jun 27, 2022
925a9f9
fixing bazel
james-prysm Jun 27, 2022
635ee1b
Merge branch 'develop' into fee-recipient-e2e
james-prysm Jun 27, 2022
272ff12
checking file too much moving it out
james-prysm Jun 27, 2022
3b36b6a
fixing gosec
james-prysm Jun 27, 2022
b8e166e
trying to fix gosec error
james-prysm Jun 27, 2022
310e956
trying to fix address
james-prysm Jun 27, 2022
363d989
fixing linting
james-prysm Jun 27, 2022
935d0ff
trying to gerenate key and random address
james-prysm Jun 27, 2022
44e1ab0
fixing linting
james-prysm Jun 27, 2022
d86532a
fixing check for proposer config
james-prysm Jun 27, 2022
32efcb3
Merge branch 'develop' into fee-recipient-e2e
james-prysm Jun 27, 2022
0d4d9fb
trying with multi config files
james-prysm Jun 28, 2022
ca736e6
Merge branch 'develop' into fee-recipient-e2e
james-prysm Jun 28, 2022
8e57abd
fixing is dir check
james-prysm Jun 28, 2022
fe7f248
testing for older previous balance
james-prysm Jun 28, 2022
b551283
adding logging to help debug
james-prysm Jun 28, 2022
40c5eaa
Merge branch 'develop' into fee-recipient-e2e
james-prysm Jun 28, 2022
2bdd1dd
changing how i get the block numbers
james-prysm Jun 28, 2022
518e6d5
fixing missed error check
james-prysm Jun 28, 2022
575d4ac
adding gasused check
james-prysm Jun 28, 2022
5237a6b
adding log for current gas used
james-prysm Jun 28, 2022
cce3b4f
taking suggestion to make fee recipient more deterministic
james-prysm Jun 29, 2022
dbeb8af
fixing linting
james-prysm Jun 29, 2022
43d03fb
fixing check
james-prysm Jun 29, 2022
5bd896c
fixing the address check
james-prysm Jun 29, 2022
0a2d85e
fixing format error
james-prysm Jun 29, 2022
b24c9ff
Merge branch 'develop' into fee-recipient-e2e
james-prysm Jun 29, 2022
7a6de08
Merge branch 'develop' into fee-recipient-e2e
james-prysm Jun 29, 2022
92e6904
logic to differentiate recipients
james-prysm Jun 29, 2022
9a4c7e5
fixing linting
james-prysm Jun 29, 2022
c1003ff
Merge branch 'develop' into fee-recipient-e2e
james-prysm Jun 29, 2022
4aefa0f
Merge branch 'develop' into fee-recipient-e2e
james-prysm Jun 29, 2022
a2147e5
Merge branch 'develop' into fee-recipient-e2e
james-prysm Jun 29, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions config/validator/service/proposer-settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions testing/endtoend/components/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -39,6 +40,7 @@ go_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/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",
Expand Down
8 changes: 6 additions & 2 deletions testing/endtoend/components/eth1/miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ import (
log "github.com/sirupsen/logrus"
)

const (
EthAddress = "0x878705ba3f8bc32fcf7f4caa1a35e72af65cf766"
)

// Miner represents an ETH1 node which mines blocks.
type Miner struct {
e2etypes.ComponentRunner
Expand Down Expand Up @@ -127,9 +131,9 @@ func (m *Miner) Start(ctx context.Context) error {
"--ipcdisable",
"--verbosity=4",
"--mine",
"--unlock=0x878705ba3f8bc32fcf7f4caa1a35e72af65cf766",
fmt.Sprintf("--unlock=%s", EthAddress),
"--allow-insecure-unlock",
"--txpool.locals=0x878705ba3f8bc32fcf7f4caa1a35e72af65cf766",
fmt.Sprintf("--txpool.locals=%s", EthAddress),
fmt.Sprintf("--password=%s", eth1Path+"/keystore/"+minerPasswordFile),
}

Expand Down
2 changes: 1 addition & 1 deletion testing/endtoend/components/eth1/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
84 changes: 74 additions & 10 deletions testing/endtoend/components/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,32 @@ package components
import (
"bytes"
"context"
"encoding/json"
"fmt"
"math/big"
"os"
"os/exec"
"path"
"path/filepath"
"strings"
"syscall"

"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/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"
"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"
Expand All @@ -33,6 +38,7 @@ import (
)

const depositGasLimit = 4000000
const DefaultFeeRecipientAddress = "0x099FB65722e7b2455043bfebF6177f1D2E9738d9"

var _ e2etypes.ComponentRunner = (*ValidatorNode)(nil)
var _ e2etypes.ComponentRunner = (*ValidatorNodeSet)(nil)
Expand Down Expand Up @@ -170,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 = ""
Expand Down Expand Up @@ -198,6 +205,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()),
Expand All @@ -219,20 +235,22 @@ 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,
fmt.Sprintf("--%s=%d", flags.InteropNumValidators.Name, validatorNum),
fmt.Sprintf("--%s=%d", flags.InteropStartIndex.Name, offset))
fmt.Sprintf("--%s=%d", flags.InteropStartIndex.Name, offset),
)
}
//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, index)
if err != nil {
return err
}
args = append(args, fmt.Sprintf("--%s=%s", flags.ProposerSettingsFlag.Name, proposerSettingsPathPath))
}
args = append(args, config.ValidatorFlags...)

Expand Down Expand Up @@ -378,3 +396,49 @@ func sendDeposits(web3 *ethclient.Client, keystoreBytes []byte, num, offset int,
}
return nil
}

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")
}
var proposerSettingsPayload validator_service_config.ProposerSettingsPayload
if len(pubkeys) == 1 {
proposerSettingsPayload = validator_service_config.ProposerSettingsPayload{
DefaultConfig: &validator_service_config.ProposerOptionPayload{
FeeRecipient: DefaultFeeRecipientAddress,
},
}
} else {
config := make(map[string]*validator_service_config.ProposerOptionPayload)

for _, pubkey := range pubkeys {
// Create an account
key, err := crypto.GenerateKey()
james-prysm marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
return "", err
}
config[pubkey] = &validator_service_config.ProposerOptionPayload{
FeeRecipient: crypto.PubkeyToAddress(key.PublicKey).Hex(),
}
}
proposerSettingsPayload = validator_service_config.ProposerSettingsPayload{
ProposerConfig: config,
DefaultConfig: &validator_service_config.ProposerOptionPayload{
FeeRecipient: DefaultFeeRecipientAddress,
},
}
}
jsonBytes, err := json.Marshal(proposerSettingsPayload)
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
}
9 changes: 8 additions & 1 deletion testing/endtoend/endtoend_setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,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 {
james-prysm marked this conversation as resolved.
Show resolved Hide resolved
testConfig.Evaluators = append(testConfig.Evaluators, ev.FeeRecipientIsPresent)
}

return newTestRunner(t, testConfig)
}
Expand Down Expand Up @@ -158,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)
}

Expand Down
6 changes: 6 additions & 0 deletions testing/endtoend/evaluators/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ go_library(
"api_middleware.go",
"data.go",
"execution_engine.go",
"fee_recipient.go",
"finality.go",
"fork.go",
"metrics.go",
Expand All @@ -26,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",
Expand All @@ -43,9 +45,13 @@ 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",
"@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",
Expand Down
Loading