Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

Commit

Permalink
handle subxt error and update lighthouse (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
salman01zp authored Sep 12, 2023
1 parent ffcf4ea commit f9e77b5
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 20 deletions.
4 changes: 2 additions & 2 deletions crates/eth-rpc-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ edition = "2021"
[dependencies]
eth-types = { path = "../eth-types", default-features = false, features = ["eth2", "arbitrary"] }
finality-update-verify = { package = "webb-finality-update-verify", path = "../finality-update-verify", features = ["arbitrary"] }
types = { git = "https://github.com/webb-tools/lighthouse.git" }
merkle_proof = { git = "https://github.com/webb-tools/lighthouse.git", features = ["arbitrary"] }
types = { git = "https://github.com/webb-tools/lighthouse.git", rev="ef72e752eaf45f4b7eb64dd8dbb0fe088f955df8" }
merkle_proof = { git = "https://github.com/webb-tools/lighthouse.git", features = ["arbitrary"], rev="ef72e752eaf45f4b7eb64dd8dbb0fe088f955df8" }
tree_hash = { version = "0.5.0", features = ["arbitrary"] }
ethereum_hashing = { version = "1.0.0-beta.2" }
ethereum_ssz = { version = "0.5.0", features = ["arbitrary"] }
Expand Down
2 changes: 1 addition & 1 deletion crates/eth2-pallet-init/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2021"

[dependencies]
types = { git = "https://github.com/webb-tools/lighthouse.git" }
types = { git = "https://github.com/webb-tools/lighthouse.git", rev="ef72e752eaf45f4b7eb64dd8dbb0fe088f955df8" }
tree-hash = { package = "webb-tree-hash", path = "../tree-hash", default-features = false }
merkle-proof = { package = "webb-merkle-proof", path = "../merkle-proof", default-features = false }

Expand Down
Binary file not shown.
Binary file modified crates/eth2-pallet-init/metadata/tangle-runtime.scale
Binary file not shown.
10 changes: 6 additions & 4 deletions crates/eth2-pallet-init/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
use clap::Parser;
use std::string::String;
use subxt::{OnlineClient, PolkadotConfig};
use webb_eth2_pallet_init::{
config::Config,
init_pallet::init_pallet,
substrate_pallet_client::{setup_api, EthClientPallet},
config::Config, init_pallet::init_pallet, substrate_pallet_client::EthClientPallet,
};
use webb_proposals::TypedChainId;

Expand All @@ -25,7 +24,10 @@ async fn main() -> anyhow::Result<()> {
let config =
Config::load_from_toml(args.config.clone().try_into().expect("Incorrect config path"));

let api = setup_api().await.unwrap();
let api = OnlineClient::<PolkadotConfig>::from_url(config.substrate_endpoint.clone())
.await
.expect("failed to connect to substrate node");

let mut eth_client_contract = EthClientPallet::new(api, TypedChainId::None);
init_pallet(&config, &mut eth_client_contract)
.await
Expand Down
19 changes: 15 additions & 4 deletions crates/eth2-pallet-init/src/substrate_pallet_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use eth_types::{
BlockHeader, H256,
};

use subxt::utils::AccountId32;
use subxt::{error::DispatchError, utils::AccountId32};
use webb::substrate::{
scale::{Decode, Encode},
subxt::{
Expand Down Expand Up @@ -44,7 +44,7 @@ pub fn convert_typed_chain_ids(
tangle::runtime_types::webb_proposals::header::TypedChainId::Solana(id),
TypedChainId::Ink(id) =>
tangle::runtime_types::webb_proposals::header::TypedChainId::Ink(id),
_ => panic!("Unsupported chain id"),
_ => unimplemented!("Unsupported chain id"),
}
}

Expand Down Expand Up @@ -218,10 +218,21 @@ impl EthClientPallet {
return Ok(hash.0.into())
},
Err(err) => {
log::error!("tx failed {err:?}");
let error_msg = match err {
subxt::Error::Runtime(DispatchError::Module(error)) => {
let details = error.details()?;
let pallet = details.pallet.name();
let error = &details.variant;
format!("Extrinsic failed with an error: {pallet}::{error:?}")
},
_ => {
format!("Extrinsic failed with an error: {}", err)
},
};

return Err(std::io::Error::new(
std::io::ErrorKind::Other,
format!("Failed to get hash storage value: {err:?}"),
format!("Tx failed : {error_msg}"),
)
.into())
},
Expand Down
2 changes: 1 addition & 1 deletion eth2substrate-block-relay-rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2021"

[dependencies]
types = { git = "https://github.com/webb-tools/lighthouse.git" }
types = { git = "https://github.com/webb-tools/lighthouse.git", rev="ef72e752eaf45f4b7eb64dd8dbb0fe088f955df8" }
eth2_hashing = { package = "ethereum_hashing", version = "1.0.0-beta.2" }
eth2_ssz = { package = "ethereum_ssz", version = "0.5.0", features = ["arbitrary"] }

Expand Down
2 changes: 1 addition & 1 deletion gadget/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ eth2-to-substrate-relay = { path = "../eth2substrate-block-relay-rs" }
eth2-pallet-init = { package = "webb-eth2-pallet-init", path = "../crates/eth2-pallet-init" }

# DKG
dkg-runtime-primitives = { git = "https://github.com/webb-tools/dkg-substrate.git", tag = "v0.4.3", default-features = false }
dkg-runtime-primitives = { git = "https://github.com/webb-tools/dkg-substrate.git", tag = "v0.4.4", default-features = false }

# Webb
webb-proposals = { git = "https://github.com/webb-tools/webb-rs", rev="a960eaf", features = ["scale", "evm"] }
7 changes: 4 additions & 3 deletions gadget/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,10 @@ pub async fn start_gadget(relayer_params: Eth2LightClientParams) {
},
};

let api = OnlineClient::from_url(lc_relay_config.substrate_endpoint.clone())
.await
.expect("failed to connect to substrate node");
let api =
OnlineClient::<subxt::PolkadotConfig>::from_url(lc_relay_config.substrate_endpoint.clone())
.await
.expect("failed to connect to substrate node");

let mut eth_pallet =
EthClientPallet::new(api, lc_relay_config.ethereum_network.as_typed_chain_id());
Expand Down
8 changes: 4 additions & 4 deletions runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ pallet-eth2-light-client = { path = "../pallets/eth2-light-client", default-feat
pallet-eth2-light-client-runtime-api = { path = "../pallets/eth2-light-client/runtime-api", default-features = false }

# DKG Substrate Dependencies
dkg-runtime-primitives = { git = "https://github.com/webb-tools/dkg-substrate.git", tag = "v0.4.3", default-features = false }
pallet-dkg-metadata = { git = "https://github.com/webb-tools/dkg-substrate.git", tag = "v0.4.3", default-features = false }
pallet-dkg-proposal-handler = { git = "https://github.com/webb-tools/dkg-substrate.git", tag = "v0.4.3", default-features = false }
pallet-dkg-proposals = { git = "https://github.com/webb-tools/dkg-substrate.git", tag = "v0.4.3", default-features = false }
dkg-runtime-primitives = { git = "https://github.com/webb-tools/dkg-substrate.git", tag = "v0.4.4", default-features = false }
pallet-dkg-metadata = { git = "https://github.com/webb-tools/dkg-substrate.git", tag = "v0.4.4", default-features = false }
pallet-dkg-proposal-handler = { git = "https://github.com/webb-tools/dkg-substrate.git", tag = "v0.4.4", default-features = false }
pallet-dkg-proposals = { git = "https://github.com/webb-tools/dkg-substrate.git", tag = "v0.4.4", default-features = false }

[build-dependencies]
substrate-wasm-builder = { version = "5.0.0-dev", git = "https://github.com/paritytech/substrate.git", optional = true , branch = "polkadot-v1.0.0" }
Expand Down

0 comments on commit f9e77b5

Please sign in to comment.