-
Notifications
You must be signed in to change notification settings - Fork 126
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
Add support for the Hermes relayer #396
Changes from all commits
0072f44
fedafd6
a35487e
a18bf66
19930b0
e78de86
3def8eb
be8adbf
7a5160e
f7ca984
5bbefaa
a1e091e
5ce3a8d
5f573c9
5326b10
48d8562
791b8f0
47af05d
6783734
1976b22
a40eff6
8194b65
cde37cb
4dfd2a1
9adbf3b
83b0c5a
5ad0cec
b26c8c2
0c9e8f8
385369d
136f35f
5366e6f
e066e90
b7797b1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
# Don't commit the interchaintest.test file, | ||
# regardless of where it was built. | ||
interchaintest.test | ||
|
||
/bin | ||
.idea | ||
/bin | ||
vendor |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"Relayers": ["rly"], | ||
"Relayers": ["rly", "hermes"], | ||
|
||
"ChainSets": [ | ||
[ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,6 @@ import ( | |
"bytes" | ||
"context" | ||
"fmt" | ||
"path" | ||
"time" | ||
|
||
"github.com/docker/docker/api/types" | ||
|
@@ -48,10 +47,10 @@ func (w *FileWriter) WriteFile(ctx context.Context, volumeName, relPath string, | |
Cmd: []string{ | ||
// Take the uid and gid of the mount path, | ||
// and set that as the owner of the new relative path. | ||
`chown "$(stat -c '%u:%g' "$1")" "$2"`, | ||
`chown -R "$(stat -c '%u:%g' "$1")" "$2"`, | ||
"_", // Meaningless arg0 for sh -c with positional args. | ||
mountPath, | ||
path.Join(mountPath, relPath), | ||
mountPath, | ||
Comment on lines
+50
to
+53
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I made this change as the hermes relayer ended up making several files in other places in the home directory and was running into permissions issues. I thought it might be fine if we just set the home directory to be owned by the relayer user. If this is a problem we can figure something else out! |
||
}, | ||
|
||
// Use root user to avoid permission issues when reading files from the volume. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,10 @@ import ( | |
"go.uber.org/zap" | ||
) | ||
|
||
const ( | ||
defaultRlyHomeDirectory = "/home/relayer" | ||
) | ||
|
||
// DockerRelayer provides a common base for relayer implementations | ||
// that run on Docker. | ||
type DockerRelayer struct { | ||
|
@@ -42,6 +46,8 @@ type DockerRelayer struct { | |
|
||
// wallets contains a mapping of chainID to relayer wallet | ||
wallets map[string]ibc.Wallet | ||
|
||
homeDir string | ||
} | ||
|
||
var _ ibc.Relayer = (*DockerRelayer)(nil) | ||
|
@@ -64,12 +70,16 @@ func NewDockerRelayer(ctx context.Context, log *zap.Logger, testName string, cli | |
wallets: map[string]ibc.Wallet{}, | ||
} | ||
|
||
r.homeDir = defaultRlyHomeDirectory | ||
|
||
for _, opt := range options { | ||
switch o := opt.(type) { | ||
case RelayerOptionDockerImage: | ||
r.customImage = &o.DockerImage | ||
case RelayerOptionImagePull: | ||
r.pullImage = o.Pull | ||
case RelayerOptionHomeDir: | ||
r.homeDir = o.HomeDir | ||
} | ||
} | ||
|
||
|
@@ -122,6 +132,21 @@ func NewDockerRelayer(ctx context.Context, log *zap.Logger, testName string, cli | |
return &r, nil | ||
} | ||
|
||
// WriteFileToHomeDir writes the given contents to a file at the relative path specified. The file is relative | ||
// to the home directory in the relayer container. | ||
func (r *DockerRelayer) WriteFileToHomeDir(ctx context.Context, relativePath string, contents []byte) error { | ||
fw := dockerutil.NewFileWriter(r.log, r.client, r.testName) | ||
if err := fw.WriteFile(ctx, r.volumeName, relativePath, contents); err != nil { | ||
return fmt.Errorf("failed to write file: %w", err) | ||
} | ||
return nil | ||
} | ||
Comment on lines
+137
to
+143
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added this helper function as the hermes relayer required a few different files to be created. |
||
|
||
// AddWallet adds a stores a wallet for the given chain ID. | ||
func (r *DockerRelayer) AddWallet(chainID string, wallet ibc.Wallet) { | ||
r.wallets[chainID] = wallet | ||
} | ||
|
||
func (r *DockerRelayer) AddChainConfiguration(ctx context.Context, rep ibc.RelayerExecReporter, chainConfig ibc.ChainConfig, keyName, rpcAddr, grpcAddr string) error { | ||
// For rly this file is json, but the file extension should not matter. | ||
// Using .config to avoid implying any particular format. | ||
|
@@ -469,7 +494,7 @@ func (r *DockerRelayer) Bind() []string { | |
|
||
// HomeDir returns the home directory of the relayer on the underlying Docker container's filesystem. | ||
func (r *DockerRelayer) HomeDir() string { | ||
return "/home/relayer" | ||
return r.homeDir | ||
} | ||
|
||
func (r *DockerRelayer) HostName(pathName string) string { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed the go relayer and the hermes relayer return different states, this just accounts for either of them