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

*: cherry pick 2685 and 2673 #2689

Merged
merged 2 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 3 additions & 2 deletions app/obolapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,10 @@ func (c Client) url() *url.URL {
return baseURL
}

// PublishLock posts the lockfile to obol-api.
// PublishLock posts the lockfile to obol-api. It has a 30s timeout.
func (c Client) PublishLock(ctx context.Context, lock cluster.Lock) error {
ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
// TODO(xenowits): Reduce the timeout once the obol-api is optimised for publishing large lock files.
ctx, cancel := context.WithTimeout(ctx, 30*time.Second)
defer cancel()

addr := c.url()
Expand Down
2 changes: 1 addition & 1 deletion cmd/createcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ func runCreateCluster(ctx context.Context, w io.Writer, conf clusterConfig) erro
return err
}

valRegs, err := createValidatorRegistrations(def.WithdrawalAddresses(), secrets, def.ForkVersion)
valRegs, err := createValidatorRegistrations(def.FeeRecipientAddresses(), secrets, def.ForkVersion)
if err != nil {
return err
}
Expand Down
30 changes: 24 additions & 6 deletions cmd/createcluster_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,24 @@ func TestCreateCluster(t *testing.T) {
return data
},
},
{
Name: "test with fee recipient and withdrawal addresses",
Config: clusterConfig{
Name: "test_cluster",
NumNodes: 3,
Threshold: 4,
NumDVs: 5,
Network: "goerli",
},
Prep: func(t *testing.T, config clusterConfig) clusterConfig {
t.Helper()

config.FeeRecipientAddrs = []string{testutil.RandomChecksummedETHAddress(t, 1)}
config.WithdrawalAddrs = []string{testutil.RandomChecksummedETHAddress(t, 2)}

return config
},
},
}
for _, test := range tests {
t.Run(test.Name, func(t *testing.T) {
Expand All @@ -203,14 +221,14 @@ func TestCreateCluster(t *testing.T) {

test.Config.DefFile = srv.URL
}
if test.Prep != nil {
test.Config = test.Prep(t, test.Config)
}

test.Config.InsecureKeys = true
test.Config.WithdrawalAddrs = []string{zeroAddress}
test.Config.FeeRecipientAddrs = []string{zeroAddress}

if test.Prep != nil {
test.Config = test.Prep(t, test.Config)
}

testCreateCluster(t, test.Config, def, test.expectedErr)
})
}
Expand Down Expand Up @@ -413,9 +431,9 @@ func TestSplitKeys(t *testing.T) {
}{
{
name: "split keys from local definition",
numSplitKeys: 1,
numSplitKeys: 2,
conf: clusterConfig{
DefFile: "../cluster/examples/cluster-definition-002.json",
DefFile: "../cluster/examples/cluster-definition-004.json",
ClusterDir: t.TempDir(),
NumNodes: 4,
Network: defaultNetwork,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[
"node0",
"node1",
"node2",
"node0/charon-enr-private-key",
"node0/cluster-lock.json",
"node0/deposit-data.json",
"node0/validator_keys",
"node1/charon-enr-private-key",
"node1/cluster-lock.json",
"node1/deposit-data.json",
"node1/validator_keys",
"node2/charon-enr-private-key",
"node2/cluster-lock.json",
"node2/deposit-data.json",
"node2/validator_keys"
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Created charon cluster:
--split-existing-keys=false

charon/
├─ node[0-2]/ Directory for each node
│ ├─ charon-enr-private-key Charon networking private key for node authentication
│ ├─ cluster-lock.json Cluster lock defines the cluster lock file which is signed by all nodes
│ ├─ deposit-data.json Deposit data file is used to activate a Distributed Validator on DV Launchpad
│ ├─ validator_keys Validator keystores and password
│ │ ├─ keystore-*.json Validator private share key for duty signing
│ │ ├─ keystore-*.txt Keystore password files for keystore-*.json
13 changes: 13 additions & 0 deletions testutil/random.go
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,19 @@ func RandomETHAddress() string {
return fmt.Sprintf("%#x", RandomBytes32()[:20])
}

func RandomChecksummedETHAddress(t *testing.T, seed int) string {
t.Helper()

// Generate a new random private key
privatekey := GenerateInsecureK1Key(t, seed)

// Get the corresponding public key
publicKey := privatekey.PubKey()

// Derive the Ethereum address from the public key
return eth2util.PublicKeyToAddress(publicKey)
}

func RandomBytes96() []byte {
var resp [96]byte
_, _ = rand.Read(resp[:])
Expand Down
Loading