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

[WIP] hermes relayer #115

Closed
wants to merge 2 commits into from
Closed
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
11 changes: 11 additions & 0 deletions chain/cosmos/cosmos_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ func (c *CosmosChain) GetGRPCAddress() string {
return fmt.Sprintf("%s:9090", c.getFullNode().HostName())
}

// Implements Chain interface
func (c *CosmosChain) GetWebsocketAddress() string {
return fmt.Sprintf("ws://%s:26657/websocket", c.getFullNode().HostName())
}

// GetHostRPCAddress returns the address of the RPC server accessible by the host.
// This will not return a valid address until the chain has been started.
func (c *CosmosChain) GetHostRPCAddress() string {
Expand All @@ -119,6 +124,12 @@ func (c *CosmosChain) GetHostGRPCAddress() string {
return dockerutil.GetHostPort(c.getFullNode().Container, grpcPort)
}

// GetHostWebsocketAddress returns the address of the websocket stream accessible by the host.
// This will not return a valid address until the chain has been started.
func (c *CosmosChain) GetHostWebsocketAddress() string {
return "ws://" + dockerutil.GetHostPort(c.getFullNode().Container, rpcPort) + "/websocket"
}

// Implements Chain interface
func (c *CosmosChain) CreateKey(ctx context.Context, keyName string) error {
return c.getFullNode().CreateKey(ctx, keyName)
Expand Down
11 changes: 11 additions & 0 deletions chain/penumbra/penumbra_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ func (c *PenumbraChain) GetGRPCAddress() string {
return fmt.Sprintf("%s:9090", c.getRelayerNode().TendermintNode.HostName())
}

// Implements Chain interface
func (c *PenumbraChain) GetWebsocketAddress() string {
return fmt.Sprintf("ws://%s:26657/websocket", c.getRelayerNode().TendermintNode.HostName())
}

// GetHostRPCAddress returns the address of the RPC server accessible by the host.
// This will not return a valid address until the chain has been started.
func (c *PenumbraChain) GetHostRPCAddress() string {
Expand All @@ -135,6 +140,12 @@ func (c *PenumbraChain) GetHostGRPCAddress() string {
return dockerutil.GetHostPort(c.getRelayerNode().TendermintNode.Container, grpcPort)
}

// GetHostWebsocketAddress returns the address of the websocket stream accessible by the host.
// This will not return a valid address until the chain has been started.
func (c *PenumbraChain) GetHostWebsocketAddress() string {
return "ws://" + dockerutil.GetHostPort(c.getRelayerNode().TendermintNode.Container, rpcPort) + "/websocket"
}

// Implements Chain interface
func (c *PenumbraChain) CreateKey(ctx context.Context, keyName string) error {
return c.getRelayerNode().PenumbraAppNode.CreateKey(ctx, keyName)
Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ require (
github.com/davecgh/go-spew v1.1.1
github.com/google/go-cmp v0.5.7
github.com/ory/dockertest/v3 v3.8.1
github.com/stretchr/testify v1.7.0
github.com/pelletier/go-toml/v2 v2.0.1
github.com/stretchr/testify v1.7.1
github.com/tendermint/tendermint v0.34.14
go.uber.org/multierr v1.6.0
go.uber.org/zap v1.21.0
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,8 @@ github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/9
github.com/pelletier/go-toml v1.9.3/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
github.com/pelletier/go-toml v1.9.4 h1:tjENF6MfZAg8e4ZmZTeWaWiT2vXtsoO6+iuOjFhECwM=
github.com/pelletier/go-toml v1.9.4/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
github.com/pelletier/go-toml/v2 v2.0.1 h1:8e3L2cCQzLFi2CR4g7vGFuFxX7Jl1kKX8gW+iV0GUKU=
github.com/pelletier/go-toml/v2 v2.0.1/go.mod h1:r9LEWfGN8R5k0VXJ+0BkIe7MYkRdwZOjgMj2KwnJFUo=
github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac=
github.com/peterh/liner v1.1.1-0.20190123174540-a2c9a5303de7/go.mod h1:CRroGNssyjTd/qIG2FyxByd2S8JEAZXBl4qUrZf8GS0=
github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 h1:q2e307iGHPdTGp0hoxKjt1H5pDo6utceo3dQVK3I5XQ=
Expand Down Expand Up @@ -900,6 +902,8 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww=
Expand Down
2 changes: 1 addition & 1 deletion ibc/Relayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type Relayer interface {
AddKey(ctx context.Context, rep RelayerExecReporter, chainID, keyName string) (RelayerWallet, error)

// add relayer configuration for a chain
AddChainConfiguration(ctx context.Context, rep RelayerExecReporter, chainConfig ChainConfig, keyName, rpcAddr, grpcAddr string) error
AddChainConfiguration(ctx context.Context, rep RelayerExecReporter, chainConfig ChainConfig, keyName, rpcAddr, grpcAddr, websocketAddr string) error

// generate new path between two chains
GeneratePath(ctx context.Context, rep RelayerExecReporter, srcChainID, dstChainID, pathName string) error
Expand Down
7 changes: 7 additions & 0 deletions ibc/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,17 @@ type Chain interface {
// retrieves grpc address that can be reached by other containers in the docker network
GetGRPCAddress() string

// retrieves websocket address that can be reached by other containers in the docker network
GetWebsocketAddress() string

// GetHostRPCAddress returns the rpc address that can be reached by processes on the host machine.
// Note that this will not return a valid value until after Start returns.
GetHostRPCAddress() string

// GetHostWebsocketAddress returns the websocket endpoint that can be reached by processes on the host machine.
// Note that this will not return a valid value until after Start returns.
GetHostWebsocketAddress() string

// GetHostGRPCAddress returns the grpc address that can be reached by processes on the host machine.
// Note that this will not return a valid value until after Start returns.
GetHostGRPCAddress() string
Expand Down
6 changes: 3 additions & 3 deletions interchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,16 +266,16 @@ func (ic *Interchain) configureRelayerKeys(ctx context.Context, rep *testreporte

for r, chains := range ic.relayerChains() {
for _, c := range chains {
rpcAddr, grpcAddr := c.GetRPCAddress(), c.GetGRPCAddress()
rpcAddr, grpcAddr, websocket := c.GetRPCAddress(), c.GetGRPCAddress(), c.GetWebsocketAddress()
if !r.UseDockerNetwork() {
rpcAddr, grpcAddr = c.GetHostRPCAddress(), c.GetHostGRPCAddress()
rpcAddr, grpcAddr, websocket = c.GetHostRPCAddress(), c.GetHostGRPCAddress(), c.GetHostWebsocketAddress()
}

chainName := ic.chains[c]
if err := r.AddChainConfiguration(ctx,
rep,
c.Config(), chainName,
rpcAddr, grpcAddr,
rpcAddr, grpcAddr, websocket,
); err != nil {
return fmt.Errorf("failed to configure relayer %s for chain %s: %w", ic.relayers[r], chainName, err)
}
Expand Down
6 changes: 3 additions & 3 deletions relayer/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func NewDockerRelayer(log *zap.Logger, testName, home string, pool *dockertest.P
}
}

func (r *DockerRelayer) AddChainConfiguration(ctx context.Context, rep ibc.RelayerExecReporter, chainConfig ibc.ChainConfig, keyName, rpcAddr, grpcAddr string) error {
func (r *DockerRelayer) AddChainConfiguration(ctx context.Context, rep ibc.RelayerExecReporter, chainConfig ibc.ChainConfig, keyName, rpcAddr, grpcAddr, websocketAddr string) error {
// rly needs to run "rly config init", and AddChainConfiguration should be the first call where it's needed.
// This might be a better fit for NewDockerRelayer, but that would considerably change the function signature.
if !r.didInit {
Expand All @@ -75,7 +75,7 @@ func (r *DockerRelayer) AddChainConfiguration(ctx context.Context, rep ibc.Relay
chainConfigLocalFilePath := filepath.Join(r.Dir(), chainConfigFile)
chainConfigContainerFilePath := fmt.Sprintf("%s/%s", r.NodeHome(), chainConfigFile)

configContent, err := r.c.ConfigContent(ctx, chainConfig, keyName, rpcAddr, grpcAddr)
configContent, err := r.c.ConfigContent(ctx, chainConfig, keyName, rpcAddr, "", grpcAddr)
if err != nil {
return fmt.Errorf("failed to generate config content: %w", err)
}
Expand Down Expand Up @@ -370,7 +370,7 @@ type RelayerCommander interface {
ContainerVersion() string

// ConfigContent generates the content of the config file that will be passed to AddChainConfiguration.
ConfigContent(ctx context.Context, cfg ibc.ChainConfig, keyName, rpcAddr, grpcAddr string) ([]byte, error)
ConfigContent(ctx context.Context, cfg ibc.ChainConfig, keyName, rpcAddr, grpcAddr, websocketAddr string) ([]byte, error)

// ParseAddKeyOutput processes the output of AddKey
// to produce the wallet that was created.
Expand Down
99 changes: 99 additions & 0 deletions relayer/hermes/hermes_config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
package hermes

type HermesGlobalConfig struct {
LogLevel string `toml:"log_level"`
}

type HermesModeConfig struct {
Clients HermesClientsConfig
Connections HermesConnectionsConfig
Channels HermesChannelsConfig
Packets HermesPacketsConfig
}

type HermesClientsConfig struct {
Enabled bool
Refresh bool
Misbehavior bool
}

type HermesConnectionsConfig struct {
Enabled bool
}

type HermesChannelsConfig struct {
Enabled bool
}

type HermesPacketsConfig struct {
Enabled bool
ClearInterval uint64 `toml:"clear_interval"`
ClearOnStart bool `toml:"clear_on_start"`
TxConfirmation bool `toml:"tx_confirmation"`
}

type HermesRESTConfig struct {
Enabled bool
Host string
Port uint16
}

type HermesTelemetryConfig struct {
Enabled bool
Host string
Port uint16
}

type HermesGasPriceConfig struct {
Price float64
Denom string
}

type HermesPacketFilterConfig struct {
Policy string
List [][]string
}

type HermesTrustThresholdConfig struct {
Numerator string
Denominator string
}

type HermesAddressTypeConfig struct {
Derivation string
}

type HermesChainConfig struct {
ID string
RpcAddr string `toml:"rpc_addr"`
WebSocketAddr string `toml:"websocket_addr"`
GRPCAddr string `toml:"grpc_addr"`
RPCTimeout string `toml:"rpc_timeout"`
AccountPrefix string `toml:"account_prefix"`
KeyName string `toml:"key_name"`
KeyStoreType string `toml:"key_store_type"`
StorePrefix string `toml:"store_prefix"`
DefaultGas uint64 `toml:"default_gas,omitempty"`
MaxGas uint64 `toml:"max_gas,omitempty"`
GasAdjustment float64 `toml:"gas_adjustment,omitempty"`
FeeGranter string `toml:"fee_granter,omitempty"`
MaxMsgNum int `toml:"max_msg_num"`
MaxTxSize int `toml:"max_tx_size"`
ClockDrift string `toml:"clock_drift"`
MaxBlockTime string `toml:"proof_specs"`
TrustingPeriod string `toml:"trusting_period,omitempty"`
MemoPrefix string `toml:"memo_prefix"`
ProofSpecs string `toml:"proof_specs"`
TrustThreshold HermesTrustThresholdConfig `toml:"trust_threshold"`
GasPrice HermesGasPriceConfig `toml:"gas_price"`
PacketFilter HermesPacketFilterConfig `toml:"packet_filter"`
AddressType HermesAddressTypeConfig `toml:"address_type"`
}

type HermesConfig struct {
Global HermesGlobalConfig
Mode HermesModeConfig
REST HermesRESTConfig
Telemetry HermesTelemetryConfig
Chains []HermesChainConfig
}
Loading