From 9357614d1301e2f6354adf0c559791f61b374a03 Mon Sep 17 00:00:00 2001 From: corver Date: Wed, 24 Jul 2024 23:21:18 +0200 Subject: [PATCH] ci(e2e): populate p2p with advertised addrs (#1576) Cherry picks #1560 from `main` to `release/v0.2`. This is required to improve joining omega. issue: none --- e2e/app/definition.go | 6 ++-- e2e/app/setup.go | 36 ++++++++----------- halo/cmd/cometconfig.go | 2 ++ halo/cmd/testdata/TestRunCmd_defaults.golden | 4 +-- halo/cmd/testdata/TestRunCmd_flags.golden | 4 +-- .../cmd/testdata/TestRunCmd_json_files.golden | 4 +-- .../cmd/testdata/TestRunCmd_toml_files.golden | 4 +-- 7 files changed, 28 insertions(+), 32 deletions(-) diff --git a/e2e/app/definition.go b/e2e/app/definition.go index 51fa5c0fd..9ffa1565f 100644 --- a/e2e/app/definition.go +++ b/e2e/app/definition.go @@ -342,7 +342,9 @@ func TestnetFromManifest(ctx context.Context, manifest types.Manifest, infd type return types.Testnet{}, err } - en := enode.NewV4(&nodeKey.PublicKey, inst.IPAddress, 30303, 30303) + ip := advertisedIP(manifest.Network, mode, inst.IPAddress, inst.ExtIPAddress) + + en := enode.NewV4(&nodeKey.PublicKey, ip, 30303, 30303) internalIP := inst.IPAddress.String() if infd.Provider == docker.ProviderName { @@ -352,7 +354,7 @@ func TestnetFromManifest(ctx context.Context, manifest types.Manifest, infd type omniEVMS = append(omniEVMS, types.OmniEVM{ Chain: types.OmniEVMByNetwork(manifest.Network), InstanceName: name, - AdvertisedIP: advertisedIP(manifest.Network, mode, inst.IPAddress, inst.ExtIPAddress), + AdvertisedIP: ip, ProxyPort: inst.Port, InternalRPC: fmt.Sprintf("http://%s:8545", internalIP), ExternalRPC: fmt.Sprintf("http://%s:%d", inst.ExtIPAddress.String(), inst.Port), diff --git a/e2e/app/setup.go b/e2e/app/setup.go index 396002102..707140621 100644 --- a/e2e/app/setup.go +++ b/e2e/app/setup.go @@ -231,12 +231,13 @@ func writeAnvilState(testnet types.Testnet) error { } // MakeConfig generates a CometBFT config for a node. -// -//nolint:lll // CometBFT super long names :( func MakeConfig(network netconf.ID, node *e2e.Node, nodeDir string) (*config.Config, error) { + if node.ABCIProtocol != e2e.ProtocolBuiltin { + return nil, errors.New("only Builtin ABCI is supported") + } + cfg := halocmd.DefaultCometConfig(nodeDir) cfg.Moniker = node.Name - cfg.ProxyApp = AppAddressTCP cfg.RPC.ListenAddress = "tcp://0.0.0.0:26657" cfg.RPC.PprofListenAddress = ":6060" cfg.P2P.ExternalAddress = fmt.Sprintf("tcp://%v:26656", advertisedIP(network, node.Mode, node.InternalIP, node.ExternalIP)) @@ -244,23 +245,6 @@ func MakeConfig(network netconf.ID, node *e2e.Node, nodeDir string) (*config.Con cfg.DBBackend = node.Database cfg.StateSync.DiscoveryTime = 5 * time.Second cfg.BlockSync.Version = node.BlockSyncVersion - cfg.Mempool.ExperimentalMaxGossipConnectionsToNonPersistentPeers = int(node.Testnet.ExperimentalMaxGossipConnectionsToNonPersistentPeers) - cfg.Mempool.ExperimentalMaxGossipConnectionsToPersistentPeers = int(node.Testnet.ExperimentalMaxGossipConnectionsToPersistentPeers) - - switch node.ABCIProtocol { - case e2e.ProtocolUNIX: - cfg.ProxyApp = AppAddressUNIX - case e2e.ProtocolTCP: - cfg.ProxyApp = AppAddressTCP - case e2e.ProtocolGRPC: - cfg.ProxyApp = AppAddressTCP - cfg.ABCI = "grpc" - case e2e.ProtocolBuiltin, e2e.ProtocolBuiltinConnSync: - cfg.ProxyApp = "" - cfg.ABCI = "" - default: - return nil, errors.New("unexpected ABCI protocol") - } // CometBFT errors if it does not have a privval key set up, regardless of whether // it's actually needed (e.g. for remote KMS or non-validators). We set up a dummy @@ -298,14 +282,14 @@ func MakeConfig(network netconf.ID, node *e2e.Node, nodeDir string) (*config.Con if len(cfg.P2P.Seeds) > 0 { cfg.P2P.Seeds += "," } - cfg.P2P.Seeds += seed.AddressP2P(true) + cfg.P2P.Seeds += advertisedP2PAddr(network, seed) } cfg.P2P.PersistentPeers = "" for _, peer := range node.PersistentPeers { if len(cfg.P2P.PersistentPeers) > 0 { cfg.P2P.PersistentPeers += "," } - cfg.P2P.PersistentPeers += peer.AddressP2P(true) + cfg.P2P.PersistentPeers += advertisedP2PAddr(network, peer) } if node.Prometheus { @@ -315,6 +299,14 @@ func MakeConfig(network netconf.ID, node *e2e.Node, nodeDir string) (*config.Con return &cfg, nil } +// advertisedP2PAddr returns the cometBFT network address to advertise for a node. +func advertisedP2PAddr(network netconf.ID, node *e2e.Node) string { + id := node.NodeKey.PubKey().Address().Bytes() + ip := advertisedIP(network, node.Mode, node.InternalIP, node.ExternalIP) + + return fmt.Sprintf("%x@%s:26656", id, ip) +} + // advertisedIP returns the IP address to advertise for a node on a network. func advertisedIP(network netconf.ID, mode types.Mode, internal, external net.IP) net.IP { if network.IsEphemeral() { diff --git a/halo/cmd/cometconfig.go b/halo/cmd/cometconfig.go index ac4f44c57..f6b23309a 100644 --- a/halo/cmd/cometconfig.go +++ b/halo/cmd/cometconfig.go @@ -42,6 +42,8 @@ func DefaultCometConfig(homeDir string) cfg.Config { conf.StateSync.DiscoveryTime = time.Second * 10 // Increase discovery time conf.StateSync.ChunkRequestTimeout = time.Minute // Increase timeout conf.Mempool.Type = cfg.MempoolTypeNop // Disable cometBFT mempool + conf.ProxyApp = "" // Only support built-in ABCI app supported. + conf.ABCI = "" // Only support built-in ABCI app supported. return *conf } diff --git a/halo/cmd/testdata/TestRunCmd_defaults.golden b/halo/cmd/testdata/TestRunCmd_defaults.golden index 4b65060ad..d06b6b01e 100644 --- a/halo/cmd/testdata/TestRunCmd_defaults.golden +++ b/halo/cmd/testdata/TestRunCmd_defaults.golden @@ -18,7 +18,7 @@ "Comet": { "Version": "0.38.10", "RootDir": "./halo", - "ProxyApp": "tcp://127.0.0.1:26658", + "ProxyApp": "", "Moniker": "testmoniker", "DBBackend": "goleveldb", "DBPath": "data", @@ -29,7 +29,7 @@ "PrivValidatorState": "data/priv_validator_state.json", "PrivValidatorListenAddr": "", "NodeKey": "config/node_key.json", - "ABCI": "socket", + "ABCI": "", "FilterPeers": false, "RPC": { "RootDir": "./halo", diff --git a/halo/cmd/testdata/TestRunCmd_flags.golden b/halo/cmd/testdata/TestRunCmd_flags.golden index d615d12b9..ad0d3a515 100644 --- a/halo/cmd/testdata/TestRunCmd_flags.golden +++ b/halo/cmd/testdata/TestRunCmd_flags.golden @@ -18,7 +18,7 @@ "Comet": { "Version": "0.38.10", "RootDir": "foo", - "ProxyApp": "tcp://127.0.0.1:26658", + "ProxyApp": "", "Moniker": "testmoniker", "DBBackend": "goleveldb", "DBPath": "data", @@ -29,7 +29,7 @@ "PrivValidatorState": "data/priv_validator_state.json", "PrivValidatorListenAddr": "", "NodeKey": "config/node_key.json", - "ABCI": "socket", + "ABCI": "", "FilterPeers": false, "RPC": { "RootDir": "foo", diff --git a/halo/cmd/testdata/TestRunCmd_json_files.golden b/halo/cmd/testdata/TestRunCmd_json_files.golden index bfc1a4e27..edccbc2ee 100644 --- a/halo/cmd/testdata/TestRunCmd_json_files.golden +++ b/halo/cmd/testdata/TestRunCmd_json_files.golden @@ -18,7 +18,7 @@ "Comet": { "Version": "0.38.10", "RootDir": "testinput/input2", - "ProxyApp": "tcp://127.0.0.1:26658", + "ProxyApp": "", "Moniker": "testmoniker", "DBBackend": "goleveldb", "DBPath": "data", @@ -29,7 +29,7 @@ "PrivValidatorState": "data/priv_validator_state.json", "PrivValidatorListenAddr": "", "NodeKey": "config/node_key.json", - "ABCI": "socket", + "ABCI": "", "FilterPeers": false, "RPC": { "RootDir": "testinput/input2", diff --git a/halo/cmd/testdata/TestRunCmd_toml_files.golden b/halo/cmd/testdata/TestRunCmd_toml_files.golden index 91cc76685..e04f5d9f7 100644 --- a/halo/cmd/testdata/TestRunCmd_toml_files.golden +++ b/halo/cmd/testdata/TestRunCmd_toml_files.golden @@ -21,7 +21,7 @@ "Comet": { "Version": "0.38.10", "RootDir": "testinput/input1", - "ProxyApp": "tcp://127.0.0.1:26658", + "ProxyApp": "", "Moniker": "config.toml", "DBBackend": "goleveldb", "DBPath": "data", @@ -32,7 +32,7 @@ "PrivValidatorState": "data/priv_validator_state.json", "PrivValidatorListenAddr": "", "NodeKey": "config/node_key.json", - "ABCI": "socket", + "ABCI": "", "FilterPeers": false, "RPC": { "RootDir": "testinput/input1",