Skip to content

Commit

Permalink
Deserialize state machine from string in Substrate and Evm configs (#271
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Wizdave97 authored Jul 26, 2024
1 parent e3b8a8e commit 3ffbbdb
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 21 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

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

32 changes: 16 additions & 16 deletions docs/pages/developers/network/relayer.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ The configuration file is a toml file that at the moment, that expects the follo
```toml
# Hyperbridge config, required
[hyperbridge]
state_machine = { Kusama = 4009 }
state_machine = "KUSAMA-4009"
# Hyperbridge node ws rpc endpoint.
rpc_ws = "ws://127.0.0.1:9944" # example endpoint
# Sets the maximum size of an rpc request or response in bytes defaults to 150mb
Expand All @@ -176,11 +176,11 @@ minimum_withdrawal_amount = 100
unprofitable_retry_frequency = 600
# (Optional) If not empty, tesseract will only deliver requests to the specified state-machines
delivery_endpoints = [
{ Ethereum = "ExecutionLayer" },
{ Ethereum = "Arbitrum" },
{ Ethereum = "Optimism" },
{ Ethereum = "Base" },
"Bsc"
"ETH-EXEC",
"ETH-ARBI",
"ETH-OPTI",
"ETH-BASE",
"BSC"
]

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

[substrate]
type = "substrate"
# The state machine identifier for this substrate based chain.
# must be one of:
# - { Polkadot = paraId }
# - { Kusama = paraId }
state_machine = { Kusama = 4009 }
# - "POLKADOT-{paraId}"
# - "KUSAMA-{paraId}"
state_machine = "KUSAMA-4009"
# substrate node ws(s) rpc endpoint.
rpc_ws = "ws://127.0.0.1:9944" # example endpoint
# Configures the maximum size of an rpc request/response in bytes
Expand Down
1 change: 1 addition & 0 deletions tesseract/evm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ ismp-testsuite = { workspace = true, default-features = true }
reconnecting-jsonrpsee-ws-client = { workspace = true, default-features = true }
jsonrpsee = { version = "0.21", features = ["ws-client"]}
pallet-ismp-host-executive = { workspace = true, default-features = true }
serde-utils = { workspace = true, default-features = false }

[dev-dependencies]
alloy-rlp = { workspace = true, default-features = true }
Expand Down
1 change: 1 addition & 0 deletions tesseract/evm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ pub struct EvmConfig {
/// RPC urls for the execution client
pub rpc_urls: Vec<String>,
/// State machine Identifier for this client on it's counterparties.
#[serde(with = "serde_utils::as_string")]
pub state_machine: StateMachine,
/// Consensus state id for the consensus client on counterparty chain
pub consensus_state_id: String,
Expand Down
3 changes: 1 addition & 2 deletions tesseract/primitives/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

//! Relayer configuration options
use ismp::host::StateMachine;
use serde::{Deserialize, Serialize};

/// Configuration options for the relayer.
Expand All @@ -33,7 +32,7 @@ pub struct RelayerConfig {
/// If this is value not supplied retries will not be enabled
pub unprofitable_retry_frequency: Option<u64>,
/// Delivery endpoints: chains you intend to deliver messages to
pub delivery_endpoints: Vec<StateMachine>,
pub delivery_endpoints: Vec<String>,
/// Flag to tell the messsaging process to deliver failed transactions
pub deliver_failed: Option<bool>,
}
2 changes: 1 addition & 1 deletion tesseract/relayer/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl Cli {
// If the delivery endpoint is not empty then we only spawn tasks for chains
// explicitly mentioned in the config
if !config.relayer.delivery_endpoints.is_empty() &&
!config.relayer.delivery_endpoints.contains(&state_machine)
!config.relayer.delivery_endpoints.contains(&state_machine.to_string())
{
continue;
}
Expand Down
1 change: 1 addition & 0 deletions tesseract/substrate/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ subxt-utils = { workspace = true, default-features = true }
pallet-ismp-host-executive = { workspace = true, default-features = true }
substrate-state-machine = { workspace = true, default-features = true }
pallet-hyperbridge = { workspace = true, default-features = true }
serde-utils = { workspace = true, default-features = false }

[features]
testing = []
1 change: 1 addition & 0 deletions tesseract/substrate/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ mod testing;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SubstrateConfig {
/// Hyperbridge network
#[serde(with = "serde_utils::as_string")]
pub state_machine: StateMachine,
/// The hashing algorithm that substrate chain uses.
pub hashing: Option<HashAlgorithm>,
Expand Down
21 changes: 19 additions & 2 deletions tesseract/test-config.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Required
[hyperbridge]
state_machine = { Kusama = 4009 }
state_machine = "KUSAMA-4009"
hashing = "Keccak"
rpc_ws = "ws://127.0.0.1:9933"
signer = ""
Expand All @@ -13,4 +13,21 @@ fisherman = false
router = { Kusama = 4296 }
module_filter = []
minimum_profit_percentage = 0
delivery_endpoints = []
delivery_endpoints = [
"ETH-ARBI",
"ETH-BASE"
]

[optimism]
type = "evm"
state_machine = "ETH-ARBI"
rpc_urls = [
"http://127.0.0.1:8345"
]
etherscan_api_key = "CP3H4MAT8UU5KDYY5ZXH3E8UDV5V74B7R8"
ismp_host = "0x8Ac39DfC1F2616e5e19B93420C6d008a8a8EE65f"
consensus_state_id = "ETH0"
signer = "0x8Ac39DfC1F2616e5e19B93420C6d008a8a8EE65f008a8a8EE65f"
tracing_batch_size = 5
query_batch_size = 10000
gas_price_buffer = 5

0 comments on commit 3ffbbdb

Please sign in to comment.