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

imp(relayer): align config as toml for better parse error #333

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ bacon.toml
.bacon-locations

# Config files and test artifacts
programs/relayer/config.json
programs/relayer/config.toml
scripts/genesis.json
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

61 changes: 28 additions & 33 deletions e2e/interchaintestv8/relayer/config.tmpl
Original file line number Diff line number Diff line change
@@ -1,33 +1,28 @@
{
"server": {
"log_level": "info",
"address": "127.0.0.1",
"port": 3000
},
"modules": [
{
"name": "eth_to_cosmos",
"src_chain": "{{ .EthChainID }}",
"dst_chain": "{{ .CosmosChainID }}",
"config": {
"tm_rpc_url": "{{ .TmRPC }}",
"ics26_address": "{{ .ICS26Address }}",
"eth_rpc_url": "{{ .EthRPC }}",
"eth_beacon_api_url": "{{ .BeaconAPI }}",
"signer_address": "{{ .SignerAddress }}",
"mock": {{ .MockWasmClient }}
}
},
{
"name": "cosmos_to_eth",
"src_chain": "{{ .CosmosChainID }}",
"dst_chain": "{{ .EthChainID }}",
"config": {
"tm_rpc_url": "{{ .TmRPC }}",
"ics26_address": "{{ .ICS26Address }}",
"eth_rpc_url": "{{ .EthRPC }}",
"sp1_config": "{{ .SP1Config }}"
}
}
]
}
[server]
log_level = "info"
address = "127.0.0.1"
port = 3_000

[[modules]]
name = "eth_to_cosmos"
src_chain = "{{ .EthChainID }}"
dst_chain = "{{ .CosmosChainID }}"

[modules.config]
tm_rpc_url = "{{ .TmRPC }}"
ics26_address = "{{ .ICS26Address }}"
eth_rpc_url = "{{ .EthRPC }}"
eth_beacon_api_url = "{{ .BeaconAPI }}"
signer_address = "{{ .SignerAddress }}"
mock = {{ .MockWasmClient }}

[[modules]]
name = "cosmos_to_eth"
src_chain = "{{ .CosmosChainID }}"
dst_chain = "{{ .EthChainID }}"

[modules.config]
tm_rpc_url = "{{ .TmRPC }}"
ics26_address = "{{ .ICS26Address }}"
eth_rpc_url = "{{ .EthRPC }}"
sp1_config = "{{ .SP1Config }}"
53 changes: 24 additions & 29 deletions e2e/interchaintestv8/relayer/cosmos_to_cosmos_config.tmpl
Original file line number Diff line number Diff line change
@@ -1,29 +1,24 @@
{
"server": {
"log_level": "info",
"port": 3000,
"address": "127.0.0.1"
},
"modules": [
{
"name": "cosmos_to_cosmos",
"src_chain": "{{ .ChainAID }}",
"dst_chain": "{{ .ChainBID }}",
"config": {
"src_rpc_url": "{{ .ChainATmRPC }}",
"target_rpc_url": "{{ .ChainBTmRPC }}",
"signer_address": "{{ .ChainBUser }}"
}
},
{
"name": "cosmos_to_cosmos",
"src_chain": "{{ .ChainBID }}",
"dst_chain": "{{ .ChainAID }}",
"config": {
"src_rpc_url": "{{ .ChainBTmRPC }}",
"target_rpc_url": "{{ .ChainATmRPC }}",
"signer_address": "{{ .ChainAUser }}"
}
}
]
}
[server]
log_level = "info"
port = 3_000
address = "127.0.0.1"

[[modules]]
name = "cosmos_to_cosmos"
src_chain = "{{ .ChainAID }}"
dst_chain = "{{ .ChainBID }}"

[modules.config]
src_rpc_url = "{{ .ChainATmRPC }}"
target_rpc_url = "{{ .ChainBTmRPC }}"
signer_address = "{{ .ChainBUser }}"

[[modules]]
name = "cosmos_to_cosmos"
src_chain = "{{ .ChainBID }}"
dst_chain = "{{ .ChainAID }}"

[modules.config]
src_rpc_url = "{{ .ChainBTmRPC }}"
target_rpc_url = "{{ .ChainATmRPC }}"
signer_address = "{{ .ChainAUser }}"
149 changes: 72 additions & 77 deletions e2e/interchaintestv8/relayer/multichain_config.tmpl
Original file line number Diff line number Diff line change
@@ -1,77 +1,72 @@
{
"server": {
"log_level": "info",
"address": "127.0.0.1",
"port": 3000
},
"modules": [
{
"name": "eth_to_cosmos",
"src_chain": "{{ .EthChainID }}",
"dst_chain": "{{ .ChainAID }}",
"config": {
"tm_rpc_url": "{{ .ChainATmRPC }}",
"ics26_address": "{{ .ICS26Address }}",
"eth_rpc_url": "{{ .EthRPC }}",
"eth_beacon_api_url": "{{ .BeaconAPI }}",
"signer_address": "{{ .ChainASignerAddress }}",
"mock": {{ .MockWasmClient }}
}
},
{
"name": "cosmos_to_eth",
"src_chain": "{{ .ChainAID }}",
"dst_chain": "{{ .EthChainID }}",
"config": {
"tm_rpc_url": "{{ .ChainATmRPC }}",
"ics26_address": "{{ .ICS26Address }}",
"eth_rpc_url": "{{ .EthRPC }}",
"sp1_config": "{{ .SP1Config }}"
}
},
{
"name": "eth_to_cosmos",
"src_chain": "{{ .EthChainID }}",
"dst_chain": "{{ .ChainBID }}",
"config": {
"tm_rpc_url": "{{ .ChainBTmRPC }}",
"ics26_address": "{{ .ICS26Address }}",
"eth_rpc_url": "{{ .EthRPC }}",
"eth_beacon_api_url": "{{ .BeaconAPI }}",
"signer_address": "{{ .ChainBSignerAddress }}",
"mock": {{ .MockWasmClient }}
}
},
{
"name": "cosmos_to_eth",
"src_chain": "{{ .ChainBID }}",
"dst_chain": "{{ .EthChainID }}",
"config": {
"tm_rpc_url": "{{ .ChainBTmRPC }}",
"ics26_address": "{{ .ICS26Address }}",
"eth_rpc_url": "{{ .EthRPC }}",
"sp1_config": "{{ .SP1Config }}"
}
},
{
"name": "cosmos_to_cosmos",
"src_chain": "{{ .ChainAID }}",
"dst_chain": "{{ .ChainBID }}",
"config": {
"src_rpc_url": "{{ .ChainATmRPC }}",
"target_rpc_url": "{{ .ChainBTmRPC }}",
"signer_address": "{{ .ChainBSignerAddress }}"
}
},
{
"name": "cosmos_to_cosmos",
"src_chain": "{{ .ChainBID }}",
"dst_chain": "{{ .ChainAID }}",
"config": {
"src_rpc_url": "{{ .ChainBTmRPC }}",
"target_rpc_url": "{{ .ChainATmRPC }}",
"signer_address": "{{ .ChainASignerAddress }}"
}
}
]
}
[server]
log_level = "info"
address = "127.0.0.1"
port = 3_000

[[modules]]
name = "eth_to_cosmos"
src_chain = "{{ .EthChainID }}"
dst_chain = "{{ .ChainAID }}"

[modules.config]
tm_rpc_url = "{{ .ChainATmRPC }}"
ics26_address = "{{ .ICS26Address }}"
eth_rpc_url = "{{ .EthRPC }}"
eth_beacon_api_url = "{{ .BeaconAPI }}"
signer_address = "{{ .ChainASignerAddress }}"
mock = {{ .MockWasmClient }}

[[modules]]
name = "cosmos_to_eth"
src_chain = "{{ .ChainAID }}"
dst_chain = "{{ .EthChainID }}"

[modules.config]
tm_rpc_url = "{{ .ChainATmRPC }}"
ics26_address = "{{ .ICS26Address }}"
eth_rpc_url = "{{ .EthRPC }}"
sp1_config = "{{ .SP1Config }}"

[[modules]]
name = "eth_to_cosmos"
src_chain = "{{ .EthChainID }}"
dst_chain = "{{ .ChainBID }}"

[modules.config]
tm_rpc_url = "{{ .ChainBTmRPC }}"
ics26_address = "{{ .ICS26Address }}"
eth_rpc_url = "{{ .EthRPC }}"
eth_beacon_api_url = "{{ .BeaconAPI }}"
signer_address = "{{ .ChainBSignerAddress }}"
mock = {{ .MockWasmClient }}

[[modules]]
name = "cosmos_to_eth"
src_chain = "{{ .ChainBID }}"
dst_chain = "{{ .EthChainID }}"

[modules.config]
tm_rpc_url = "{{ .ChainBTmRPC }}"
ics26_address = "{{ .ICS26Address }}"
eth_rpc_url = "{{ .EthRPC }}"
sp1_config = "{{ .SP1Config }}"

[[modules]]
name = "cosmos_to_cosmos"
src_chain = "{{ .ChainAID }}"
dst_chain = "{{ .ChainBID }}"

[modules.config]
src_rpc_url = "{{ .ChainATmRPC }}"
target_rpc_url = "{{ .ChainBTmRPC }}"
signer_address = "{{ .ChainBSignerAddress }}"

[[modules]]
name = "cosmos_to_cosmos"
src_chain = "{{ .ChainBID }}"
dst_chain = "{{ .ChainAID }}"

[modules.config]
src_rpc_url = "{{ .ChainBTmRPC }}"
target_rpc_url = "{{ .ChainATmRPC }}"
signer_address = "{{ .ChainASignerAddress }}"
2 changes: 1 addition & 1 deletion e2e/interchaintestv8/testvalues/values.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const (
// RustFixturesDir is the directory where the Rust fixtures are stored.
RustFixturesDir = "packages/ethereum-light-client/src/test_utils/fixtures"
// RelayerConfigFilePath is the path to generate the relayer config file.
RelayerConfigFilePath = "programs/relayer/config.json"
RelayerConfigFilePath = "programs/relayer/config.toml"
// E2EDeployScriptPath is the path to the E2E deploy script.
E2EDeployScriptPath = "scripts/E2ETestDeploy.s.sol:E2ETestDeploy"
// SP1ICS07DeployScriptPath is the path to the SP1ICS07 deploy script.
Expand Down
1 change: 1 addition & 0 deletions programs/relayer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ tendermint-rpc = { workspace = true }

sp1-sdk = { workspace = true, default-features = true }
sp1-prover = { workspace = true }
toml = "0.8.20"

[build-dependencies]
tonic-build = { workspace = true, default-features = true }
2 changes: 1 addition & 1 deletion programs/relayer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ This is a work-in-progress implementation, and the relayer is not yet usable. Th

## Usage

To run the relayer binary, you need to write a configuration file. At the moment, there is a working example configuration file at [`config.example.json`](./config.example.json). You can copy this file and modify it to suit your needs.
To run the relayer binary, you need to write a configuration file. At the moment, there is a working example configuration file at [`config.example.toml`](./config.example.toml). You can copy this file and modify it to suit your needs.

After building/installing the relayer binary, you can run the relayer with the following command:

Expand Down
42 changes: 0 additions & 42 deletions programs/relayer/config.example.json

This file was deleted.

37 changes: 37 additions & 0 deletions programs/relayer/config.example.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[server]
log_level = "info"
address = "127.0.0.1"
port = 3_000

[[modules]]
name = "cosmos_to_eth"
src_chain = "cosmoshub-4"
dst_chain = "0x1"

[modules.config]
tm_rpc_url = "http://public-celestia-mocha4-consensus.numia.xyz/"
ics26_address = "0x4242424242424242424242424242424242424242"
eth_rpc_url = "https://ethereum-holesky-rpc.publicnode.com"
sp1_config = "env"

[[modules]]
name = "eth_to_cosmos"
src_chain = "0x1"
dst_chain = "cosmoshub-4"

[modules.config]
tm_rpc_url = "http://public-celestia-mocha4-consensus.numia.xyz/"
ics26_address = "0x4242424242424242424242424242424242424242"
eth_rpc_url = "https://ethereum-holesky-rpc.publicnode.com"
eth_beacon_api_url = "https://ethereum-holesky-beacon-api.publicnode.com"
signer_address = "cosmos1abcdef1234567890abcdef1234567890"

[[modules]]
name = "cosmos_to_cosmos"
src_chain = "cosmoshub-4"
dst_chain = "osmosis-1"

[modules.config]
src_rpc_url = "https://noble-testnet-rpc.polkachu.com:443"
target_rpc_url = "http://public-celestia-mocha5-consensus.numia.xyz/"
signer_address = "cosmos1abcdef1234567890abcdef1234567890"
4 changes: 2 additions & 2 deletions programs/relayer/src/bin/relayer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ async fn main() -> anyhow::Result<()> {
match cli.command {
Commands::Start(args) => {
let config_path = PathBuf::from(args.config);
let config_bz = std::fs::read(config_path)?;
let config: RelayerConfig = serde_json::from_slice(&config_bz)?;
let config_bz = std::fs::read_to_string(config_path)?;
let config: RelayerConfig = toml::from_str(config_bz.as_ref())?;

// Initialize the logger with log level.
tracing_subscriber::fmt::fmt()
Expand Down
Loading
Loading