Skip to content

Commit

Permalink
Add Optimistic Sync Scenario Testing (#10836)
Browse files Browse the repository at this point in the history
* add latest changes

* fix it

* add multiclient support

* fix tests

* Apply suggestions from code review

* fix test

Co-authored-by: Raul Jordan <[email protected]>
Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Jun 9, 2022
1 parent 18fc17c commit 7f443e8
Show file tree
Hide file tree
Showing 18 changed files with 362 additions and 71 deletions.
10 changes: 6 additions & 4 deletions testing/endtoend/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ common_deps = [
"//io/file:go_default_library",
"//proto/eth/service:go_default_library",
"//proto/eth/v1:go_default_library",
"//math:go_default_library",
"//proto/engine/v1:go_default_library",
"//proto/prysm/v1alpha1:go_default_library",
"//testing/assert:go_default_library",
"//testing/endtoend/components:go_default_library",
Expand Down Expand Up @@ -64,6 +66,7 @@ go_test(
"@web3signer",
],
eth_network = "minimal",
flaky = True,
shard_count = 2,
tags = [
"e2e",
Expand All @@ -72,7 +75,6 @@ go_test(
"requires-network",
],
deps = common_deps,
flaky = True,
)

go_test(
Expand All @@ -96,6 +98,7 @@ go_test(
"@web3signer",
],
eth_network = "mainnet",
flaky = True,
shard_count = 2,
tags = [
"e2e",
Expand All @@ -105,7 +108,6 @@ go_test(
"requires-network",
],
deps = common_deps,
flaky = True,
)

go_test(
Expand All @@ -129,6 +131,7 @@ go_test(
"@web3signer",
],
eth_network = "mainnet",
flaky = True,
shard_count = 2,
tags = [
"exclusive",
Expand All @@ -138,7 +141,6 @@ go_test(
"scenario",
],
deps = common_deps,
flaky = True,
)

go_test(
Expand All @@ -162,6 +164,7 @@ go_test(
"@web3signer",
],
eth_network = "minimal",
flaky = True,
shard_count = 2,
tags = [
"exclusive",
Expand All @@ -171,5 +174,4 @@ go_test(
"scenario",
],
deps = common_deps,
flaky = True,
)
2 changes: 1 addition & 1 deletion testing/endtoend/component_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type componentHandler struct {
web3Signer e2etypes.ComponentRunner
bootnode e2etypes.ComponentRunner
eth1Miner e2etypes.ComponentRunner
eth1Proxy e2etypes.ComponentRunner
eth1Proxy e2etypes.MultipleComponentRunners
eth1Nodes e2etypes.MultipleComponentRunners
beaconNodes e2etypes.MultipleComponentRunners
validatorNodes e2etypes.MultipleComponentRunners
Expand Down
8 changes: 8 additions & 0 deletions testing/endtoend/components/beacon_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,14 @@ func (s *BeaconNodeSet) StopAtIndex(i int) error {
return s.nodes[i].Stop()
}

// ComponentAtIndex returns the component at the provided index.
func (s *BeaconNodeSet) ComponentAtIndex(i int) (e2etypes.ComponentRunner, error) {
if i >= len(s.nodes) {
return nil, errors.Errorf("provided index exceeds slice size: %d >= %d", i, len(s.nodes))
}
return s.nodes[i], nil
}

// BeaconNode represents beacon node.
type BeaconNode struct {
e2etypes.ComponentRunner
Expand Down
2 changes: 1 addition & 1 deletion testing/endtoend/components/eth1/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var _ e2etypes.MultipleComponentRunners = (*NodeSet)(nil)
var _ e2etypes.MultipleComponentRunners = (*ProxySet)(nil)
var _ e2etypes.ComponentRunner = (*Miner)(nil)
var _ e2etypes.ComponentRunner = (*Node)(nil)
var _ e2etypes.ComponentRunner = (*Proxy)(nil)
var _ e2etypes.EngineProxy = (*Proxy)(nil)

// WaitForBlocks waits for a certain amount of blocks to be mined by the ETH1 chain before returning.
func WaitForBlocks(web3 *ethclient.Client, keystore *keystore.Key, blocksToWait uint64) error {
Expand Down
8 changes: 8 additions & 0 deletions testing/endtoend/components/eth1/node_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,11 @@ func (s *NodeSet) StopAtIndex(i int) error {
}
return s.nodes[i].Stop()
}

// ComponentAtIndex returns the component at the provided index.
func (s *NodeSet) ComponentAtIndex(i int) (e2etypes.ComponentRunner, error) {
if i >= len(s.nodes) {
return nil, errors.Errorf("provided index exceeds slice size: %d >= %d", i, len(s.nodes))
}
return s.nodes[i], nil
}
32 changes: 29 additions & 3 deletions testing/endtoend/components/eth1/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,21 @@ func (s *ProxySet) StopAtIndex(i int) error {
return s.proxies[i].Stop()
}

// ComponentAtIndex returns the component at the provided index.
func (s *ProxySet) ComponentAtIndex(i int) (e2etypes.ComponentRunner, error) {
if i >= len(s.proxies) {
return nil, errors.Errorf("provided index exceeds slice size: %d >= %d", i, len(s.proxies))
}
return s.proxies[i], nil
}

// Proxy represents an engine-api proxy.
type Proxy struct {
e2etypes.ComponentRunner
started chan struct{}
index int
cancel func()
started chan struct{}
index int
engineProxy *proxy.Proxy
cancel func()
}

// NewProxy creates and returns an engine-api proxy.
Expand Down Expand Up @@ -157,6 +166,7 @@ func (node *Proxy) Start(ctx context.Context) error {
// Set cancel into context.
ctx, cancel := context.WithCancel(ctx)
node.cancel = cancel
node.engineProxy = nProxy
// Mark node as ready.
close(node.started)
return nProxy.Start(ctx)
Expand Down Expand Up @@ -185,6 +195,22 @@ func (node *Proxy) Stop() error {
return nil
}

// AddRequestInterceptor adds in a json-rpc request interceptor.
func (node *Proxy) AddRequestInterceptor(rpcMethodName string, responseGen func() interface{}, trigger func() bool) {
node.engineProxy.AddRequestInterceptor(rpcMethodName, responseGen, trigger)
}

// RemoveRequestInterceptor removes the request interceptor for the provided method.
func (node *Proxy) RemoveRequestInterceptor(rpcMethodName string) {
node.engineProxy.RemoveRequestInterceptor(rpcMethodName)
}

// ReleaseBackedUpRequests releases backed up http requests which
// were previously ignored due to our interceptors.
func (node *Proxy) ReleaseBackedUpRequests(rpcMethodName string) {
node.engineProxy.ReleaseBackedUpRequests(rpcMethodName)
}

func parseJWTSecretFromFile(jwtSecretFile string) ([]byte, error) {
enc, err := file.ReadFileAsBytes(jwtSecretFile)
if err != nil {
Expand Down
8 changes: 8 additions & 0 deletions testing/endtoend/components/lighthouse_beacon.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,14 @@ func (s *LighthouseBeaconNodeSet) StopAtIndex(i int) error {
return s.nodes[i].Stop()
}

// ComponentAtIndex returns the component at the provided index.
func (s *LighthouseBeaconNodeSet) ComponentAtIndex(i int) (e2etypes.ComponentRunner, error) {
if i >= len(s.nodes) {
return nil, errors.Errorf("provided index exceeds slice size: %d >= %d", i, len(s.nodes))
}
return s.nodes[i], nil
}

// LighthouseBeaconNode represents a lighthouse beacon node.
type LighthouseBeaconNode struct {
e2etypes.ComponentRunner
Expand Down
8 changes: 8 additions & 0 deletions testing/endtoend/components/lighthouse_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,14 @@ func (s *LighthouseValidatorNodeSet) StopAtIndex(i int) error {
return s.nodes[i].Stop()
}

// ComponentAtIndex returns the component at the provided index.
func (s *LighthouseValidatorNodeSet) ComponentAtIndex(i int) (e2etypes.ComponentRunner, error) {
if i >= len(s.nodes) {
return nil, errors.Errorf("provided index exceeds slice size: %d >= %d", i, len(s.nodes))
}
return s.nodes[i], nil
}

// LighthouseValidatorNode represents a lighthouse validator node.
type LighthouseValidatorNode struct {
e2etypes.ComponentRunner
Expand Down
8 changes: 8 additions & 0 deletions testing/endtoend/components/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,14 @@ func (s *ValidatorNodeSet) StopAtIndex(i int) error {
return s.nodes[i].Stop()
}

// ComponentAtIndex returns the component at the provided index.
func (s *ValidatorNodeSet) ComponentAtIndex(i int) (e2etypes.ComponentRunner, error) {
if i >= len(s.nodes) {
return nil, errors.Errorf("provided index exceeds slice size: %d >= %d", i, len(s.nodes))
}
return s.nodes[i], nil
}

// ValidatorNode represents a validator node.
type ValidatorNode struct {
e2etypes.ComponentRunner
Expand Down
11 changes: 3 additions & 8 deletions testing/endtoend/deps.bzl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") # gazelle:keep

lighthouse_version = "v2.1.4"
lighthouse_version = "v2.3.0"
lighthouse_archive_name = "lighthouse-%s-x86_64-unknown-linux-gnu-portable.tar.gz" % lighthouse_version

def e2e_deps():
Expand All @@ -14,12 +14,7 @@ def e2e_deps():

http_archive(
name = "lighthouse",
sha256 = "236883a4827037d96636aa259eef8cf3abc54c795adc18c4c2880842e09c743c",
sha256 = "6029acd211f269bcf41f86fd72fe540703a167ff96dfd952ff95b1693e3b5495",
build_file = "@prysm//testing/endtoend:lighthouse.BUILD",
# url = ("https://github.com/sigp/lighthouse/releases/download/%s/" + lighthouse_archive_name) % lighthouse_version,
# This is a compiled version of lighthouse from their `unstable` branch at this commit
# https://github.com/sigp/lighthouse/commit/99bb55472c278a1050f7679b2e018546ad3a28bf. Lighthouse does not have support
# for all the merge features as of their latest release, so this is a temporary compromise to allow multiclient test
# runs till their official release includes the required merge features in.
url = "https://prysmaticlabs.com/uploads/misc/lighthouse-99bb5547.tar.xz",
url = ("https://github.com/sigp/lighthouse/releases/download/%s/" + lighthouse_archive_name) % lighthouse_version,
)
Loading

0 comments on commit 7f443e8

Please sign in to comment.