Skip to content

Commit 3ffbbdb

Browse files
authored
Deserialize state machine from string in Substrate and Evm configs (#271)
1 parent e3b8a8e commit 3ffbbdb

File tree

9 files changed

+43
-21
lines changed

9 files changed

+43
-21
lines changed

Cargo.lock

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/pages/developers/network/relayer.mdx

+16-16
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ The configuration file is a toml file that at the moment, that expects the follo
155155
```toml
156156
# Hyperbridge config, required
157157
[hyperbridge]
158-
state_machine = { Kusama = 4009 }
158+
state_machine = "KUSAMA-4009"
159159
# Hyperbridge node ws rpc endpoint.
160160
rpc_ws = "ws://127.0.0.1:9944" # example endpoint
161161
# Sets the maximum size of an rpc request or response in bytes defaults to 150mb
@@ -176,11 +176,11 @@ minimum_withdrawal_amount = 100
176176
unprofitable_retry_frequency = 600
177177
# (Optional) If not empty, tesseract will only deliver requests to the specified state-machines
178178
delivery_endpoints = [
179-
{ Ethereum = "ExecutionLayer" },
180-
{ Ethereum = "Arbitrum" },
181-
{ Ethereum = "Optimism" },
182-
{ Ethereum = "Base" },
183-
"Bsc"
179+
"ETH-EXEC",
180+
"ETH-ARBI",
181+
"ETH-OPTI",
182+
"ETH-BASE",
183+
"BSC"
184184
]
185185

186186
# Here you'll declare a new chain entry for every chain you want to support.
@@ -189,12 +189,12 @@ delivery_endpoints = [
189189
# configuration type can be either "evm" or "substrate"
190190
type = "evm"
191191
# State machine identifier for the this evm chain. The possible values:
192-
# state_machine = { Ethereum = "ExecutionLayer" } # Ethereum L1
193-
# state_machine = { Ethereum = "Arbitrum" }
194-
# state_machine = { Ethereum = "Optimism" }
195-
# state_machine = { Ethereum = "Base" }
196-
# state_machine = "Bsc" # Binance smart chain
197-
state_machine = { Ethereum = "ExecutionLayer" }
192+
# state_machine = "ETH-EXEC" # Ethereum L1
193+
# state_machine = "ETH-ARBI" # Arbitrum
194+
# state_machine = "ETH-OPTI" # Optimism
195+
# state_machine = "ETH-BASE" # Base
196+
# state_machine = "BSC" # Binance smart chain
197+
state_machine = "ETH-EXEC"
198198
# http(s) rpc urls for evm based chains
199199
# Multiple rpc endpoints supported for increased reliability
200200
rpc_urls = ["http://127.0.0.1:8545", ""]
@@ -236,15 +236,15 @@ gas_price_buffer = 1
236236
# client_type = Geth
237237
# client_type = Erigon
238238
# If this field is not set, the default is Geth
239-
client_type = "Erigon"
239+
client_type = "Geth"
240240

241241
[substrate]
242242
type = "substrate"
243243
# The state machine identifier for this substrate based chain.
244244
# must be one of:
245-
# - { Polkadot = paraId }
246-
# - { Kusama = paraId }
247-
state_machine = { Kusama = 4009 }
245+
# - "POLKADOT-{paraId}"
246+
# - "KUSAMA-{paraId}"
247+
state_machine = "KUSAMA-4009"
248248
# substrate node ws(s) rpc endpoint.
249249
rpc_ws = "ws://127.0.0.1:9944" # example endpoint
250250
# Configures the maximum size of an rpc request/response in bytes

tesseract/evm/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ ismp-testsuite = { workspace = true, default-features = true }
5353
reconnecting-jsonrpsee-ws-client = { workspace = true, default-features = true }
5454
jsonrpsee = { version = "0.21", features = ["ws-client"]}
5555
pallet-ismp-host-executive = { workspace = true, default-features = true }
56+
serde-utils = { workspace = true, default-features = false }
5657

5758
[dev-dependencies]
5859
alloy-rlp = { workspace = true, default-features = true }

tesseract/evm/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ pub struct EvmConfig {
5959
/// RPC urls for the execution client
6060
pub rpc_urls: Vec<String>,
6161
/// State machine Identifier for this client on it's counterparties.
62+
#[serde(with = "serde_utils::as_string")]
6263
pub state_machine: StateMachine,
6364
/// Consensus state id for the consensus client on counterparty chain
6465
pub consensus_state_id: String,

tesseract/primitives/src/config.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
//! Relayer configuration options
1717
18-
use ismp::host::StateMachine;
1918
use serde::{Deserialize, Serialize};
2019

2120
/// Configuration options for the relayer.
@@ -33,7 +32,7 @@ pub struct RelayerConfig {
3332
/// If this is value not supplied retries will not be enabled
3433
pub unprofitable_retry_frequency: Option<u64>,
3534
/// Delivery endpoints: chains you intend to deliver messages to
36-
pub delivery_endpoints: Vec<StateMachine>,
35+
pub delivery_endpoints: Vec<String>,
3736
/// Flag to tell the messsaging process to deliver failed transactions
3837
pub deliver_failed: Option<bool>,
3938
}

tesseract/relayer/src/cli.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ impl Cli {
8686
// If the delivery endpoint is not empty then we only spawn tasks for chains
8787
// explicitly mentioned in the config
8888
if !config.relayer.delivery_endpoints.is_empty() &&
89-
!config.relayer.delivery_endpoints.contains(&state_machine)
89+
!config.relayer.delivery_endpoints.contains(&state_machine.to_string())
9090
{
9191
continue;
9292
}

tesseract/substrate/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ subxt-utils = { workspace = true, default-features = true }
3131
pallet-ismp-host-executive = { workspace = true, default-features = true }
3232
substrate-state-machine = { workspace = true, default-features = true }
3333
pallet-hyperbridge = { workspace = true, default-features = true }
34+
serde-utils = { workspace = true, default-features = false }
3435

3536
[features]
3637
testing = []

tesseract/substrate/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ mod testing;
4646
#[derive(Debug, Clone, Serialize, Deserialize)]
4747
pub struct SubstrateConfig {
4848
/// Hyperbridge network
49+
#[serde(with = "serde_utils::as_string")]
4950
pub state_machine: StateMachine,
5051
/// The hashing algorithm that substrate chain uses.
5152
pub hashing: Option<HashAlgorithm>,

tesseract/test-config.toml

+19-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Required
22
[hyperbridge]
3-
state_machine = { Kusama = 4009 }
3+
state_machine = "KUSAMA-4009"
44
hashing = "Keccak"
55
rpc_ws = "ws://127.0.0.1:9933"
66
signer = ""
@@ -13,4 +13,21 @@ fisherman = false
1313
router = { Kusama = 4296 }
1414
module_filter = []
1515
minimum_profit_percentage = 0
16-
delivery_endpoints = []
16+
delivery_endpoints = [
17+
"ETH-ARBI",
18+
"ETH-BASE"
19+
]
20+
21+
[optimism]
22+
type = "evm"
23+
state_machine = "ETH-ARBI"
24+
rpc_urls = [
25+
"http://127.0.0.1:8345"
26+
]
27+
etherscan_api_key = "CP3H4MAT8UU5KDYY5ZXH3E8UDV5V74B7R8"
28+
ismp_host = "0x8Ac39DfC1F2616e5e19B93420C6d008a8a8EE65f"
29+
consensus_state_id = "ETH0"
30+
signer = "0x8Ac39DfC1F2616e5e19B93420C6d008a8a8EE65f008a8a8EE65f"
31+
tracing_batch_size = 5
32+
query_batch_size = 10000
33+
gas_price_buffer = 5

0 commit comments

Comments
 (0)