Skip to content

Commit

Permalink
Fix relayer config, use correct relayer client + skip on testnet types
Browse files Browse the repository at this point in the history
  • Loading branch information
gjermundgaraba committed Dec 29, 2024
1 parent a9e9e3c commit c83ab1f
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 28 deletions.
8 changes: 8 additions & 0 deletions e2e/interchaintestv8/e2esuite/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,11 @@ func (s *TestSuite) SetupSuite(ctx context.Context) {
s.proposalIDs[chain.Config().ChainID] = 1
}
}

// TODO: Remove when we have removed manual relaying and moved to
// common relaying methods that can choose the correct methods
func (s *TestSuite) SkipIfEthTestnetType(testnetType string) {
if os.Getenv(testvalues.EnvKeyEthTestnetType) == testnetType {
s.T().Skipf("Skipping test because Ethereum testnet type is %s", testnetType)
}
}
9 changes: 7 additions & 2 deletions e2e/interchaintestv8/relayer/config.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
package relayer

import (
"fmt"
"os"
"text/template"
)

type EthCosmosConfigInfo struct {
// gRPC port for the Eth to Cosmos relayer module
EthToCosmosPort uint64
// gRPC port for the Cosmos to Eth relayer module
CosmosToEthPort uint64
// Tendermint RPC URL
TmRPC string
// ICS26 Router address
Expand Down Expand Up @@ -37,12 +42,12 @@ func (c *EthCosmosConfigInfo) GenerateEthCosmosConfigFile(path string) error {

// EthToCosmosGRPCAddress returns the address for the eth to cosmos relayer gRPC server.
func (c *EthCosmosConfigInfo) EthToCosmosGRPCAddress() string {
return "127.0.0.1:3001"
return fmt.Sprintf("127.0.0.1:%d", c.EthToCosmosPort)
}

// CosmosToEthGRPCAddress returns the address for the eth to cosmos relayer gRPC server.
func (c *EthCosmosConfigInfo) CosmosToEthGRPCAddress() string {
return "127.0.0.1:3000"
return fmt.Sprintf("127.0.0.1:%d", c.CosmosToEthPort)
}

// CosmosToCosmosConfigInfo is a struct that holds the configuration information for the Cosmos to Cosmos config template
Expand Down
14 changes: 7 additions & 7 deletions e2e/interchaintestv8/relayer/config.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,24 @@
},
"modules": [
{
"name": "cosmos_to_eth",
"port": 3000,
"name": "eth_to_cosmos",
"port": {{ .EthToCosmosPort }},
"config": {
"tm_rpc_url": "{{ .TmRPC }}",
"ics26_address": "{{ .ICS26Address }}",
"eth_rpc_url": "{{ .EthRPC }}",
"sp1_private_key": "{{ .SP1PrivateKey }}"
"eth_beacon_api_url": "{{ .BeaconAPI }}",
"signer_address": "{{ .SignerAddress }}"
}
},
{
"name": "eth_to_cosmos",
"port": 3001,
"name": "cosmos_to_eth",
"port": {{ .CosmosToEthPort }},
"config": {
"tm_rpc_url": "{{ .TmRPC }}",
"ics26_address": "{{ .ICS26Address }}",
"eth_rpc_url": "{{ .EthRPC }}",
"eth_beacon_api_url": "{{ .BeaconAPI }}",
"signer_address": "{{ .SignerAddress }}"
"sp1_private_key": "{{ .SP1PrivateKey }}"
}
}
]
Expand Down
41 changes: 22 additions & 19 deletions e2e/interchaintestv8/relayer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,14 @@ func (s *RelayerTestSuite) SetupSuite(ctx context.Context, proofType operator.Su
}

configInfo = relayer.EthCosmosConfigInfo{
TmRPC: simd.GetHostRPCAddress(),
ICS26Address: s.contractAddresses.Ics26Router,
EthRPC: eth.RPC,
BeaconAPI: beaconAPI,
SP1PrivateKey: os.Getenv(testvalues.EnvKeySp1PrivateKey),
SignerAddress: s.SimdSubmitter.FormattedAddress(),
EthToCosmosPort: 3000,
CosmosToEthPort: 3001,
TmRPC: simd.GetHostRPCAddress(),
ICS26Address: s.contractAddresses.Ics26Router,
EthRPC: eth.RPC,
BeaconAPI: beaconAPI,
SP1PrivateKey: os.Getenv(testvalues.EnvKeySp1PrivateKey),
SignerAddress: s.SimdSubmitter.FormattedAddress(),
}

err := configInfo.GenerateEthCosmosConfigFile(testvalues.RelayerConfigFilePath)
Expand Down Expand Up @@ -120,26 +122,26 @@ func (s *RelayerTestSuite) TestRelayerInfo() {

eth, simd := s.EthChain, s.CosmosChains[0]

s.Run("Eth to Cosmos Relayer Info", func() {
info, err := s.EthToCosmosRelayerClient.Info(context.Background(), &relayertypes.InfoRequest{})
s.Run("Cosmos to Eth Relayer Info", func() {
info, err := s.CosmosToEthRelayerClient.Info(context.Background(), &relayertypes.InfoRequest{})
s.Require().NoError(err)
s.Require().NotNil(info)

s.T().Logf("Relayer Info: %+v", info)

s.Require().Equal(eth.ChainID.String(), info.SourceChain.ChainId)
s.Require().Equal(simd.Config().ChainID, info.TargetChain.ChainId)
s.Require().Equal(simd.Config().ChainID, info.SourceChain.ChainId)
s.Require().Equal(eth.ChainID.String(), info.TargetChain.ChainId)
})

s.Run("Cosmos to Eth Relayer Info", func() {
info, err := s.CosmosToEthRelayerClient.Info(context.Background(), &relayertypes.InfoRequest{})
s.Run("Eth to Cosmos Relayer Info", func() {
info, err := s.EthToCosmosRelayerClient.Info(context.Background(), &relayertypes.InfoRequest{})
s.Require().NoError(err)
s.Require().NotNil(info)

s.T().Logf("Relayer Info: %+v", info)

s.Require().Equal(simd.Config().ChainID, info.SourceChain.ChainId)
s.Require().Equal(eth.ChainID.String(), info.TargetChain.ChainId)
s.Require().Equal(eth.ChainID.String(), info.SourceChain.ChainId)
s.Require().Equal(simd.Config().ChainID, info.TargetChain.ChainId)
})
}

Expand Down Expand Up @@ -242,7 +244,7 @@ func (s *RelayerTestSuite) RecvPacketToEthTest(

var multicallTx []byte
s.Require().True(s.Run("Retrieve relay tx to Ethereum", func() {
resp, err := s.EthToCosmosRelayerClient.RelayByTx(context.Background(), &relayertypes.RelayByTxRequest{
resp, err := s.CosmosToEthRelayerClient.RelayByTx(context.Background(), &relayertypes.RelayByTxRequest{
SourceTxIds: txHashes,
TargetChannelId: s.TendermintLightClientID,
})
Expand Down Expand Up @@ -329,6 +331,7 @@ func (s *RelayerTestSuite) Test_5_BatchedAckPacketToEth_Plonk() {
func (s *RelayerTestSuite) ICS20TransferERC20TokenBatchedAckTest(
ctx context.Context, proofType operator.SupportedProofType, numOfTransfers int,
) {
s.SkipIfEthTestnetType(testvalues.EthTestnetTypePoS)
s.SetupSuite(ctx, proofType)

eth, simd := s.EthChain, s.CosmosChains[0]
Expand Down Expand Up @@ -464,7 +467,7 @@ func (s *RelayerTestSuite) ICS20TransferERC20TokenBatchedAckTest(
s.Require().True(s.Run("Acknowledge packets on Ethereum", func() {
var multicallTx []byte
s.Require().True(s.Run("Retrieve relay tx to Ethereum", func() {
resp, err := s.EthToCosmosRelayerClient.RelayByTx(context.Background(), &relayertypes.RelayByTxRequest{
resp, err := s.CosmosToEthRelayerClient.RelayByTx(context.Background(), &relayertypes.RelayByTxRequest{
SourceTxIds: [][]byte{txHash},
TargetChannelId: s.TendermintLightClientID,
})
Expand Down Expand Up @@ -612,7 +615,7 @@ func (s *RelayerTestSuite) ICS20TimeoutFromEthereumToTimeoutTest(
s.True(s.Run("Timeout packet on Ethereum", func() {
var multicallTx []byte
s.Require().True(s.Run("Retrieve timeout tx to Ethereum", func() {
resp, err := s.EthToCosmosRelayerClient.RelayByTx(context.Background(), &relayertypes.RelayByTxRequest{
resp, err := s.CosmosToEthRelayerClient.RelayByTx(context.Background(), &relayertypes.RelayByTxRequest{
TimeoutTxIds: txHashes,
TargetChannelId: s.TendermintLightClientID,
})
Expand Down Expand Up @@ -666,7 +669,7 @@ func (s *RelayerTestSuite) ICS20TimeoutFromEthereumToTimeoutTest(
}

func (s *RelayerTestSuite) TestRecvPacketToCosmos_Groth16() {
// TODO: Skip if not PoS?
s.SkipIfEthTestnetType(testvalues.EthTestnetTypePoW)
ctx := context.Background()
s.RecvPacketCosmosTest(ctx, operator.ProofTypeGroth16, 1)
}
Expand Down Expand Up @@ -758,7 +761,7 @@ func (s *RelayerTestSuite) RecvPacketCosmosTest(ctx context.Context, proofType o

var txBodyBz []byte
s.Require().True(s.Run("Retrieve relay tx to Cosmos chain", func() {
resp, err := s.EthToCosmosRelayerClient.RelayByTx(context.Background(), &relayertypes.RelayByTxRequest{
resp, err := s.CosmosToEthRelayerClient.RelayByTx(context.Background(), &relayertypes.RelayByTxRequest{
SourceTxIds: txHashes,
TargetChannelId: ibctesting.FirstChannelID,
})
Expand Down

0 comments on commit c83ab1f

Please sign in to comment.