Compare commits

...

3 Commits

Author SHA1 Message Date
Raul Jordan
06e0ee1677 Merge branch 'develop' into optimistic-sync-e2e 2022-05-02 14:31:41 +00:00
Raul Jordan
8a54ae89af gaz 2022-05-02 00:26:23 -04:00
Raul Jordan
3248128e6c use the engine API proxy middleware to simulate SYNCING responses and test optimistic sync in e2e 2022-05-02 00:22:56 -04:00
4 changed files with 30 additions and 1 deletions

View File

@@ -49,6 +49,7 @@ go_test(
"//testing/endtoend/helpers:go_default_library",
"//testing/endtoend/params:go_default_library",
"//testing/endtoend/types:go_default_library",
"//testing/middleware/engine-api-proxy:go_default_library",
"//testing/require:go_default_library",
"//testing/slasher/simulator:go_default_library",
"//testing/util:go_default_library",

View File

@@ -117,8 +117,12 @@ func (node *BeaconNode) Start(ctx context.Context) error {
expectedNumOfPeers += 1
}
jwtPath := path.Join(e2e.TestParams.TestPath, "eth1data/"+strconv.Itoa(node.index)+"/")
eth1Port := e2e.TestParams.Ports.Eth1AuthRPCPort
// The first beacon node should be connecting to an execution client with authentication
// via a proxy middleware we can use to test SYNCING responses in the engine API.
if index == 0 {
jwtPath = path.Join(e2e.TestParams.TestPath, "eth1data/miner/")
eth1Port = e2e.TestParams.Ports.Eth1ProxyPort
}
jwtPath = path.Join(jwtPath, "geth/jwtsecret")
args := []string{
@@ -126,7 +130,7 @@ func (node *BeaconNode) Start(ctx context.Context) error {
fmt.Sprintf("--%s=%s", cmdshared.LogFileName.Name, stdOutFile.Name()),
fmt.Sprintf("--%s=%s", flags.DepositContractFlag.Name, e2e.TestParams.ContractAddress.Hex()),
fmt.Sprintf("--%s=%d", flags.RPCPort.Name, e2e.TestParams.Ports.PrysmBeaconNodeRPCPort+index),
fmt.Sprintf("--%s=http://127.0.0.1:%d", flags.HTTPWeb3ProviderFlag.Name, e2e.TestParams.Ports.Eth1AuthRPCPort+index),
fmt.Sprintf("--%s=http://127.0.0.1:%d", flags.HTTPWeb3ProviderFlag.Name, eth1Port+index),
fmt.Sprintf("--%s=%s", flags.ExecutionJWTSecretFlag.Name, jwtPath),
fmt.Sprintf("--%s=%d", flags.MinSyncPeers.Name, 1),
fmt.Sprintf("--%s=%d", cmdshared.P2PUDPPort.Name, e2e.TestParams.Ports.PrysmBeaconNodeUDPPort+index),

View File

@@ -9,6 +9,7 @@ import (
"fmt"
"os"
"path"
"strconv"
"strings"
"sync"
"testing"
@@ -26,6 +27,7 @@ import (
"github.com/prysmaticlabs/prysm/testing/endtoend/helpers"
e2e "github.com/prysmaticlabs/prysm/testing/endtoend/params"
e2etypes "github.com/prysmaticlabs/prysm/testing/endtoend/types"
proxy "github.com/prysmaticlabs/prysm/testing/middleware/engine-api-proxy"
"github.com/prysmaticlabs/prysm/testing/require"
log "github.com/sirupsen/logrus"
"golang.org/x/sync/errgroup"
@@ -80,6 +82,21 @@ func (r *testRunner) run() {
return tracingSink.Start(ctx)
})
// Creates an engine API proxy middleware for mocking certain responses between
// the beacon node and the execution client. This helps us simulate scenarios such as
// the execution client signaling Prysm that it is SYNCING, and therefore triggering optimistic sync
// in our end-to-end test suite.
engineProxyMiddleware, err := proxy.New(
proxy.WithHost("127.0.0.1"),
proxy.WithPort(e2e.TestParams.Ports.Eth1ProxyPort),
proxy.WithDestinationAddress("127.0.0.1:"+strconv.Itoa(e2e.TestParams.Ports.Eth1RPCPort)),
)
if err != nil {
t.Fatal(err)
}
g.Go(func() error {
return engineProxyMiddleware.Start(ctx)
})
if multiClientActive {
keyGen = components.NewKeystoreGenerator()

View File

@@ -29,6 +29,7 @@ type ports struct {
BootNodeMetricsPort int
Eth1Port int
Eth1RPCPort int
Eth1ProxyPort int
Eth1AuthRPCPort int
Eth1WSPort int
PrysmBeaconNodeRPCPort int
@@ -86,6 +87,7 @@ const (
Eth1RPCPort = Eth1Port + portSpan
Eth1WSPort = Eth1Port + 2*portSpan
Eth1AuthRPCPort = Eth1Port + 3*portSpan
Eth1ProxyPort = Eth1Port + 4*portSpan
PrysmBeaconNodeRPCPort = 4150
PrysmBeaconNodeUDPPort = PrysmBeaconNodeRPCPort + portSpan
@@ -233,6 +235,10 @@ func initializeStandardPorts(shardCount, shardIndex int, ports *ports, existingR
if err != nil {
return err
}
eth1ProxyPort, err := port(Eth1ProxyPort, shardCount, shardIndex, existingRegistrations)
if err != nil {
return err
}
beaconNodeRPCPort, err := port(PrysmBeaconNodeRPCPort, shardCount, shardIndex, existingRegistrations)
if err != nil {
return err
@@ -274,6 +280,7 @@ func initializeStandardPorts(shardCount, shardIndex int, ports *ports, existingR
ports.Eth1Port = eth1Port
ports.Eth1RPCPort = eth1RPCPort
ports.Eth1AuthRPCPort = eth1AuthPort
ports.Eth1ProxyPort = eth1ProxyPort
ports.Eth1WSPort = eth1WSPort
ports.PrysmBeaconNodeRPCPort = beaconNodeRPCPort
ports.PrysmBeaconNodeUDPPort = beaconNodeUDPPort