Skip to content
Draft
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
3 changes: 2 additions & 1 deletion e2e/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ require (
github.com/go-kit/log v0.2.1 // indirect
github.com/go-logfmt/logfmt v0.6.1 // indirect
github.com/go-viper/mapstructure/v2 v2.5.0 // indirect
github.com/goccy/go-yaml v1.19.2 // indirect
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect
github.com/gofrs/flock v0.12.1 // indirect
github.com/gogo/googleapis v1.4.1 // indirect
Expand Down Expand Up @@ -343,7 +344,7 @@ require (
golang.org/x/net v0.56.0 // indirect
golang.org/x/sys v0.47.0 // indirect
google.golang.org/protobuf v1.36.12-0.20260120151049-f2248ac996af // indirect
gopkg.in/yaml.v3 v3.0.1
gopkg.in/yaml.v3 v3.0.1 // indirect
)

replace github.com/cosmos/ibc/link => ../link
2 changes: 2 additions & 0 deletions e2e/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,8 @@ github.com/go-viper/mapstructure/v2 v2.5.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlnd
github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo=
github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw=
github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM=
github.com/goccy/go-yaml v1.19.2 h1:PmFC1S6h8ljIz6gMRBopkjP1TVT7xuwrButHID66PoM=
github.com/goccy/go-yaml v1.19.2/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA=
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 h1:ZpnhV/YsD2/4cESfV5+Hoeu/iUR3ruzNvZ+yQfO03a0=
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2/go.mod h1:bBOAhwG1umN6/6ZUMtDFBMQR8jRg9O75tm9K00oMsK4=
github.com/gofrs/flock v0.12.1 h1:MTLVXXHf8ekldpJk3AKicLij9MdwOWkZ+a/jHHZby9E=
Expand Down
5 changes: 3 additions & 2 deletions e2e/internal/e2etest/traffic_setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/cosmos/ibc/e2e/internal/harness/environment/solidityibc/iftsendcallconstructor"
"github.com/cosmos/ibc/e2e/internal/harness/environment/solidityibc/testerc20"
"github.com/cosmos/ibc/e2e/internal/harness/ibclink"
linkconfig "github.com/cosmos/ibc/link/config"
)

var testERC20Transactor = mustBinding(testerc20.NewTestERC20Transactor(common.Address{}, nil))
Expand Down Expand Up @@ -154,7 +155,7 @@ func DeployWithRelayerConfig(
if configure != nil {
configure(&config)
}
if config.SignerType == "" || config.SignerType == ibclink.RelayerSignerLocal {
if config.SignerType == "" || config.SignerType == linkconfig.SignerLocal {
require.NoError(t, relayer.storeKey(config.SignerKeyFile), "e2etest: store relayer signer key")
}
require.NoError(t, ibclink.WriteRelayerConfig(configPath, config), "e2etest: write config")
Expand Down Expand Up @@ -384,7 +385,7 @@ func buildConfig(
t.Fatalf("e2etest: resolve Attestor %q: %v", id, err)
}
config.Attestors = append(config.Attestors, ibclink.RelayerAttestor{
Name: string(attestor.ID()), Type: ibclink.RelayerAttestorRemote, GRPC: attestor.Endpoint(),
Name: string(attestor.ID()), Type: linkconfig.AttestorTypeRemote, GRPC: attestor.Endpoint(),
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (

"github.com/cosmos/ibc/e2e/internal/harness/environment"
"github.com/cosmos/ibc/e2e/internal/harness/ibclink"
linkconfig "github.com/cosmos/ibc/link/config"
"github.com/cosmos/ibc/link/keyfile"
)

Expand Down Expand Up @@ -130,12 +131,12 @@ func TestStartFailsWhenConfiguredAttestorsDoNotSatisfyOnChainQuorum(t *testing.T
require.NoError(t, err)

attestors := []ibclink.RelayerAttestor{
{Name: string(attestorA1), Type: ibclink.RelayerAttestorRemote, GRPC: resolvedA1.Endpoint()},
{Name: string(attestorB), Type: ibclink.RelayerAttestorRemote, GRPC: resolvedB.Endpoint()},
{Name: string(attestorA1), Type: linkconfig.AttestorTypeRemote, GRPC: resolvedA1.Endpoint()},
{Name: string(attestorB), Type: linkconfig.AttestorTypeRemote, GRPC: resolvedB.Endpoint()},
}
if includeSecondAttestorA {
attestors = append(attestors, ibclink.RelayerAttestor{
Name: string(attestorA2), Type: ibclink.RelayerAttestorRemote, GRPC: resolvedA2.Endpoint(),
Name: string(attestorA2), Type: linkconfig.AttestorTypeRemote, GRPC: resolvedA2.Endpoint(),
})
}

Expand Down
82 changes: 15 additions & 67 deletions e2e/internal/harness/ibclink/attestor.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ import (
"github.com/ethereum/go-ethereum/crypto"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
"gopkg.in/yaml.v3"

attestorv2 "github.com/cosmos/ibc/link/api/v2/attestor"
linkconfig "github.com/cosmos/ibc/link/config"
"github.com/cosmos/ibc/link/keyfile"
)

Expand Down Expand Up @@ -394,42 +394,42 @@ func prepareAttestorWorkspace(
return workspacePaths{}, fmt.Errorf("start IBC Link attestor: create private work dir %q: %w", dir, mkdirErr)
}

signer := signerConfig{Alias: signerAlias, Type: RelayerSignerRemote}
signer := linkconfig.SignerConfig{Alias: signerAlias, Type: linkconfig.SignerRemote}
if key != nil {
keyPath := filepath.Join(dir, "keys", keyFilename)
if writeErr := keyfile.Store(keyPath, keyfile.ECDSA, crypto.FromECDSA(key)); writeErr != nil {
return workspacePaths{}, fmt.Errorf("start IBC Link attestor: write private key file: %w", writeErr)
}
signer.Type = RelayerSignerLocal
signer.Type = linkconfig.SignerLocal
signer.File = keyPath
} else {
signer.GRPC = spec.SignerGRPC
signer.RemoteKeyID = spec.SignerRemoteKeyID
}

config := fileConfig{
Server: serverConfig{ListenAddress: listenAddress},
DB: dbConfig{
Type: dbTypeSQLite,
config := linkconfig.Config{
Server: linkconfig.ServerConfig{ListenAddress: listenAddress},
DB: linkconfig.DBConfig{
Type: linkconfig.DBTypeSQLite,
URL: filepath.Join(dir, "ibc.db"),
},
Chains: []chainConfig{{
Chains: []linkconfig.ChainConfig{{
ChainID: spec.ChainID,
EVM: evmChainConfig{
EVM: &linkconfig.EVMChainConfig{
RPC: spec.RPCURL,
ICS26Router: spec.ICS26Router,
},
}},
Attestors: []attestorFileConfig{{
Attestors: linkconfig.Attestors{{
Name: spec.Name,
ChainID: spec.ChainID,
Type: RelayerAttestorLocal,
Type: linkconfig.AttestorTypeLocal,
Signer: signerAlias,
FinalityOffset: HarnessFinalityOffset,
}},
Signers: []signerConfig{signer},
Signers: linkconfig.Signers{signer},
}
configData, err := yaml.Marshal(config)
configData, err := linkconfig.MarshalYAML(config)
if err != nil {
return workspacePaths{}, fmt.Errorf("start IBC Link attestor: encode config: %w", err)
}
Expand Down Expand Up @@ -527,57 +527,5 @@ func (w *logWriter) close() {
}
}

// Shared config-literal defaults for harness-written Link config files.
const (
loopbackAnyPort = "127.0.0.1:0"
dbTypeSQLite = "sqlite"
)

type fileConfig struct {
Server serverConfig `yaml:"server"`
DB dbConfig `yaml:"db"`
Chains []chainConfig `yaml:"chains"`
Relayer *relayerFileConfig `yaml:"relayer,omitempty"`
Attestors []attestorFileConfig `yaml:"attestors"`
Signers []signerConfig `yaml:"signers"`
}

type chainConfig struct {
ChainID string `yaml:"chainId"`
EVM evmChainConfig `yaml:"evm"`
Deployer string `yaml:"deployer,omitempty"`
}

type evmChainConfig struct {
RPC string `yaml:"rpc"`
ICS26Router string `yaml:"ics26Router"`
}

type serverConfig struct {
ListenAddress string `yaml:"listenAddr"`
}

type dbConfig struct {
Type string `yaml:"type"`
URL string `yaml:"url"`
}

type attestorFileConfig struct {
Name string `yaml:"name"`
ChainID string `yaml:"chainId"`
Type string `yaml:"type"`
Signer string `yaml:"signer,omitempty"`

// FinalityOffset is kept at 1 ("latest" minus one block) because the dev
// chains behind the harness do not expose the "finalized" block tag.
FinalityOffset uint `yaml:"finalityOffset,omitempty"`
GRPC string `yaml:"grpc,omitempty"`
}

type signerConfig struct {
Alias string `yaml:"alias"`
Type string `yaml:"type"`
File string `yaml:"file,omitempty"`
GRPC string `yaml:"grpc,omitempty"`
RemoteKeyID string `yaml:"remoteKeyId,omitempty"`
}
// Shared config-literal default for harness-written Link config files.
const loopbackAnyPort = "127.0.0.1:0"
26 changes: 13 additions & 13 deletions e2e/internal/harness/ibclink/attestor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ import (
"github.com/ethereum/go-ethereum/crypto"
"github.com/stretchr/testify/require"
"google.golang.org/grpc"
"gopkg.in/yaml.v3"

attestorv2 "github.com/cosmos/ibc/link/api/v2/attestor"
linkconfig "github.com/cosmos/ibc/link/config"
"github.com/cosmos/ibc/link/keyfile"
)

Expand Down Expand Up @@ -113,13 +113,14 @@ func TestStartWritesRemoteSignerWithoutLocalKey(t *testing.T) {
common.HexToAddress("0xE57bFE9F44b819898F47BF37E5AF72a0783e1141"),
process.SignerAddress())

configData, err := os.ReadFile(filepath.Join(workDir, configFilename))
config, err := linkconfig.LoadFile(
filepath.Join(workDir, configFilename),
linkconfig.LoadOptions{SkipValidation: true},
)
require.NoError(t, err)
var config fileConfig
require.NoError(t, yaml.Unmarshal(configData, &config))
require.Equal(t, []signerConfig{{
require.Equal(t, linkconfig.Signers{{
Alias: signerAlias,
Type: RelayerSignerRemote,
Type: linkconfig.SignerRemote,
GRPC: remoteSignerEndpoint,
RemoteKeyID: "attestor-key",
}}, config.Signers)
Expand Down Expand Up @@ -265,13 +266,12 @@ func runAttestorHelper() error {
if err != nil {
return err
}
configData, err := os.ReadFile(filepath.Join(home, configName))
config, err := linkconfig.LoadFile(
filepath.Join(home, configName),
linkconfig.LoadOptions{SkipValidation: true},
)
if err != nil {
return fmt.Errorf("helper read config: %w", err)
}
var config fileConfig
if decodeErr := yaml.Unmarshal(configData, &config); decodeErr != nil {
return fmt.Errorf("helper decode config: %w", decodeErr)
return fmt.Errorf("helper load config: %w", err)
}
if len(config.Attestors) != 1 || config.Attestors[0].Name != "attestor-a" {
return fmt.Errorf("helper received unexpected attestor config: %+v", config.Attestors)
Expand All @@ -284,7 +284,7 @@ func runAttestorHelper() error {
return fmt.Errorf("helper received unexpected signer config: %+v", config.Signers)
}
signer := config.Signers[0]
if signer.Type == RelayerSignerLocal {
if signer.Type == linkconfig.SignerLocal {
if _, readErr := os.ReadFile(signer.File); readErr != nil {
return fmt.Errorf("helper read signer key: %w", readErr)
}
Expand Down
18 changes: 9 additions & 9 deletions e2e/internal/harness/ibclink/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"strings"
"time"

"gopkg.in/yaml.v3"
linkconfig "github.com/cosmos/ibc/link/config"
)

// deployCommandTimeout bounds the sequential deployment transactions a
Expand Down Expand Up @@ -53,24 +53,24 @@ func WriteDeployConfig(path string, cfg DeployConfig) error {
return errors.New("ibclink: deploy config: at least one chain is required")
}

file := fileConfig{
Server: serverConfig{ListenAddress: loopbackAnyPort},
DB: dbConfig{Type: dbTypeSQLite, URL: cfg.DBPath},
Signers: []signerConfig{{
file := linkconfig.Config{
Server: linkconfig.ServerConfig{ListenAddress: loopbackAnyPort},
DB: linkconfig.DBConfig{Type: linkconfig.DBTypeSQLite, URL: cfg.DBPath},
Signers: linkconfig.Signers{{
Alias: cfg.SignerAlias,
Type: RelayerSignerLocal,
Type: linkconfig.SignerLocal,
File: cfg.SignerKeyFile,
}},
}
for _, chain := range cfg.Chains {
file.Chains = append(file.Chains, chainConfig{
file.Chains = append(file.Chains, linkconfig.ChainConfig{
ChainID: chain.ChainID,
EVM: evmChainConfig{RPC: chain.RPC, ICS26Router: placeholderRouter},
EVM: &linkconfig.EVMChainConfig{RPC: chain.RPC, ICS26Router: placeholderRouter},
Deployer: cfg.SignerAlias,
})
}

data, err := yaml.Marshal(file)
data, err := linkconfig.MarshalYAML(file)
if err != nil {
return fmt.Errorf("ibclink: encode deploy config: %w", err)
}
Expand Down
Loading