Skip to content

Commit

Permalink
Fix issues with metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
vovac12 committed Dec 12, 2023
1 parent fb44457 commit 3a67a34
Show file tree
Hide file tree
Showing 12 changed files with 49 additions and 232 deletions.
3 changes: 0 additions & 3 deletions .cargo/config.toml

This file was deleted.

2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,3 @@
# will have compiled files and executables
debug/
target/
parachain-gen/bytes/*
substrate-gen/bytes/*
99 changes: 0 additions & 99 deletions Cargo.lock

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

8 changes: 2 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,5 @@ eth-bridge = { git = "https://github.com/sora-xor//sora2-network.git" }
common = { git = "https://github.com/sora-xor//sora2-network.git" }

[workspace]
members = [
"substrate-gen",
"ethereum-gen",
"parachain-gen",
"relayer",
]
members = ["substrate-gen", "ethereum-gen", "parachain-gen", "relayer"]
resolver = "2"
5 changes: 0 additions & 5 deletions parachain-gen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
name = "parachain-gen"
version = "0.1.0"
edition = "2021"
build = "build.rs"

[build-dependencies]
reqwest = { version = "0.11.2", features = ["blocking"] }

[dependencies]
common = { git = "https://github.com/sora-xor/sora2-network.git" }
Expand All @@ -25,4 +21,3 @@ async-trait = "0.1.49"
serde = { version = "1.0.193", features = ["derive"] }
bridge-types = { git = "https://github.com/sora-xor/sora2-common.git" }
beefy-light-client = { git = "https://github.com/sora-xor/sora2-common.git", default-features = false }

53 changes: 0 additions & 53 deletions parachain-gen/build.rs

This file was deleted.

Binary file added parachain-gen/bytes/metadata.scale
Binary file not shown.
13 changes: 8 additions & 5 deletions relayer/src/substrate/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,10 +376,11 @@ impl<T: ConfigExt> UnsignedClient<T> {
address.entry_name(),
hash
);
let address = Unvalidated(address);
let res = self
.api()
.storage()
.fetch(address, Some(hash.into()))
.fetch(&address, Some(hash.into()))
.await
.context(format!(
"Fetch storage {}::{} at hash {:?}",
Expand All @@ -406,10 +407,11 @@ impl<T: ConfigExt> UnsignedClient<T> {
address.entry_name(),
hash
);
let address = Unvalidated(address);
let res = self
.api()
.storage()
.fetch_or_default(address, Some(hash.into()))
.fetch_or_default(&address, Some(hash.into()))
.await
.context(format!(
"Fetch storage {}::{} at hash {:?}",
Expand All @@ -427,7 +429,8 @@ impl<T: ConfigExt> UnsignedClient<T> {
where
Address: ConstantAddress,
{
let res = self.api().constants().at(address)?;
let address = Unvalidated(address);
let res = self.api().constants().at(&address)?;
Ok(res)
}

Expand All @@ -447,7 +450,7 @@ impl<T: ConfigExt> UnsignedClient<T> {
} else {
debug!("Submitting extrinsic without validation data");
}
let xt = UnvalidatedTxPayload(xt);
let xt = Unvalidated(xt);
let res = self
.api()
.tx()
Expand Down Expand Up @@ -516,7 +519,7 @@ impl<T: ConfigExt> SignedClient<T> {
debug!("Submitting extrinsic without validation data");
}
// Metadata validation often works incorrectly, so we turn it off for now
let xt = UnvalidatedTxPayload(xt);
let xt = Unvalidated(xt);
let res = self
.api()
.tx()
Expand Down
41 changes: 39 additions & 2 deletions relayer/src/substrate/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ use sp_mmr_primitives::Proof;
pub use substrate_gen::{
runtime as mainnet_runtime, SoraExtrinsicParams as MainnetExtrinsicParams,
};
use subxt::constants::ConstantAddress;
pub use subxt::rpc::ChainBlock;
pub use subxt::rpc::Subscription;
use subxt::storage::StorageAddress;
use subxt::tx::TxPayload;
use subxt::Config as SubxtConfig;
use subxt::OnlineClient;
Expand Down Expand Up @@ -119,9 +121,9 @@ impl From<H256> for BlockNumberOrHash {
}
}

pub struct UnvalidatedTxPayload<'a, P: TxPayload>(pub &'a P);
pub struct Unvalidated<'a, P>(pub &'a P);

impl<'a, P: TxPayload> TxPayload for UnvalidatedTxPayload<'a, P> {
impl<'a, P: TxPayload> TxPayload for Unvalidated<'a, P> {
fn encode_call_data_to(
&self,
metadata: &subxt::Metadata,
Expand All @@ -130,3 +132,38 @@ impl<'a, P: TxPayload> TxPayload for UnvalidatedTxPayload<'a, P> {
self.0.encode_call_data_to(metadata, out)
}
}

impl<'a, P: StorageAddress> StorageAddress for Unvalidated<'a, P> {
type Target = P::Target;
type IsFetchable = P::IsFetchable;
type IsDefaultable = P::IsDefaultable;
type IsIterable = P::IsIterable;

fn pallet_name(&self) -> &str {
self.0.pallet_name()
}

fn entry_name(&self) -> &str {
self.0.entry_name()
}

fn append_entry_bytes(
&self,
metadata: &subxt::Metadata,
bytes: &mut Vec<u8>,
) -> Result<(), subxt::Error> {
self.0.append_entry_bytes(metadata, bytes)
}
}

impl<'a, P: ConstantAddress> ConstantAddress for Unvalidated<'a, P> {
type Target = P::Target;

fn pallet_name(&self) -> &str {
self.0.pallet_name()
}

fn constant_name(&self) -> &str {
self.0.constant_name()
}
}
4 changes: 0 additions & 4 deletions substrate-gen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
name = "substrate-gen"
version = "0.1.0"
edition = "2021"
build = "build.rs"

[build-dependencies]
reqwest = { version = "0.11.2", features = ["blocking"] }

[dependencies]
common = { git = "https://github.com/sora-xor/sora2-network.git" }
Expand Down
Loading

0 comments on commit 3a67a34

Please sign in to comment.