Skip to content
Snippets Groups Projects
Unverified Commit 152675fb authored by bgallois's avatar bgallois
Browse files

fix distance_oracle NEED VALID METADATA TO FINISH

parent c14015ab
No related branches found
No related tags found
No related merge requests found
Pipeline #35466 failed
This commit is part of merge request !229. Comments created here will be created in the context of that merge request.
This diff is collapsed.
...@@ -9,21 +9,22 @@ edition = "2021" ...@@ -9,21 +9,22 @@ edition = "2021"
[dependencies] [dependencies]
sp-distance = { path = "../primitives/distance" } sp-distance = { path = "../primitives/distance" }
codec = { package = "parity-scale-codec", version = "3.6.5" } codec = { package = "parity-scale-codec", version = "3.6.9" }
fnv = "1.0.7" fnv = "1.0.7"
log = "0.4.17" log = "0.4.20"
num-traits = "0.2.15" num-traits = "0.2.17"
rayon = "1.7.0" rayon = "1.8.1"
simple_logger = "4.2.0" simple_logger = "4.3.3"
sp-core = { git = "https://github.com/bgallois/duniter-polkadot-sdk.git", branch = "duniter-v1.6.0" } sp-core = { git = "https://github.com/bgallois/duniter-polkadot-sdk.git", branch = "duniter-v1.6.0" }
sp-runtime = { git = "https://github.com/bgallois/duniter-polkadot-sdk.git", branch = "duniter-v1.6.0" } sp-runtime = { git = "https://github.com/bgallois/duniter-polkadot-sdk.git", branch = "duniter-v1.6.0" }
subxt = { git = 'https://github.com/duniter/subxt.git', branch = 'duniter-substrate-v0.9.42', default-features = false, features = ["substrate-compat", "jsonrpsee-ws"] } subxt = { git = 'https://github.com/paritytech/subxt.git', tag = 'v0.33.0', default-features = false, features = ["substrate-compat", "native"] }
time = "<=0.3.23"# required for MSRV time = "0.3.31"
time-macros = "=0.2.10" time-macros = "0.2.16"
# standalone only # standalone only
clap = { version = "4.0", features = ["derive"], optional = true } clap = { version = "4.4.18", features = ["derive"], optional = true }
tokio = { version = "1.15.0", features = [ tokio = { version = "1.35.1", features = [
"rt-multi-thread", "rt-multi-thread",
"macros", "macros",
], optional = true } ], optional = true }
...@@ -31,7 +32,7 @@ tokio = { version = "1.15.0", features = [ ...@@ -31,7 +32,7 @@ tokio = { version = "1.15.0", features = [
[dev-dependencies] [dev-dependencies]
bincode = "1.3.3" bincode = "1.3.3"
dubp-wot = "0.11.1" dubp-wot = "0.11.1"
flate2 = { version = "1.0", features = [ flate2 = { version = "1.0.28", features = [
"zlib-ng-compat", "zlib-ng-compat",
], default-features = false } ], default-features = false }
......
...@@ -18,7 +18,7 @@ use crate::runtime; ...@@ -18,7 +18,7 @@ use crate::runtime;
use log::debug; use log::debug;
use sp_core::H256; use sp_core::H256;
use subxt::storage::StorageKey; use subxt::storage::Storage;
pub type Client = subxt::OnlineClient<crate::RuntimeConfig>; pub type Client = subxt::OnlineClient<crate::RuntimeConfig>;
pub type AccountId = subxt::utils::AccountId32; pub type AccountId = subxt::utils::AccountId32;
...@@ -31,7 +31,12 @@ pub async fn client(rpc_url: String) -> Client { ...@@ -31,7 +31,12 @@ pub async fn client(rpc_url: String) -> Client {
} }
pub async fn parent_hash(client: &Client) -> H256 { pub async fn parent_hash(client: &Client) -> H256 {
client.rpc().block_hash(None).await.unwrap().unwrap() client
.blocks()
.at_latest()
.await
.expect("Cannot fetch latest block hash")
.hash()
} }
pub async fn current_session(client: &Client, parent_hash: H256) -> u32 { pub async fn current_session(client: &Client, parent_hash: H256) -> u32 {
...@@ -93,18 +98,17 @@ pub async fn member_iter(client: &Client, evaluation_block: H256) -> MemberIter ...@@ -93,18 +98,17 @@ pub async fn member_iter(client: &Client, evaluation_block: H256) -> MemberIter
client client
.storage() .storage()
.at(evaluation_block) .at(evaluation_block)
.iter(runtime::storage().membership().membership(0), 100) .iter(runtime::storage().membership().membership(0))
.await .await
.expect("Cannot fetch memberships"), .expect("Cannot fetch memberships"),
) )
} }
pub struct MemberIter( pub struct MemberIter(
subxt::storage::KeyIter< subxt::backend::StreamOfResults<(
crate::RuntimeConfig, Vec<u8>,
Client,
runtime::runtime_types::sp_membership::MembershipData<u32>, runtime::runtime_types::sp_membership::MembershipData<u32>,
>, )>,
); );
impl MemberIter { impl MemberIter {
...@@ -128,7 +132,7 @@ pub async fn cert_iter(client: &Client, evaluation_block: H256) -> CertIter { ...@@ -128,7 +132,7 @@ pub async fn cert_iter(client: &Client, evaluation_block: H256) -> CertIter {
) )
} }
pub struct CertIter(subxt::storage::KeyIter<crate::RuntimeConfig, Client, Vec<(IdtyIndex, u32)>>); pub struct CertIter(subxt::backend::StreamOfResults<(Vec<u8>, Vec<(IdtyIndex, u32)>)>);
impl CertIter { impl CertIter {
pub async fn next( pub async fn next(
...@@ -142,6 +146,6 @@ impl CertIter { ...@@ -142,6 +146,6 @@ impl CertIter {
} }
} }
fn idty_id_from_storage_key(storage_key: &StorageKey) -> IdtyIndex { fn idty_id_from_storage_key<T: subxt::Config>(storage_key: &Storage<T, Client>) -> IdtyIndex {
u32::from_le_bytes(storage_key.as_ref()[40..44].try_into().unwrap()) u32::from_le_bytes(storage_key.as_ref()[40..44].try_into().unwrap())
} }
...@@ -40,8 +40,6 @@ pub mod runtime {} ...@@ -40,8 +40,6 @@ pub mod runtime {}
pub enum RuntimeConfig {} pub enum RuntimeConfig {}
impl subxt::config::Config for RuntimeConfig { impl subxt::config::Config for RuntimeConfig {
type Index = u32;
// type BlockNumber = u32;
type Hash = sp_core::H256; type Hash = sp_core::H256;
type Hasher = subxt::config::substrate::BlakeTwo256; type Hasher = subxt::config::substrate::BlakeTwo256;
type AccountId = AccountId; type AccountId = AccountId;
...@@ -49,7 +47,8 @@ impl subxt::config::Config for RuntimeConfig { ...@@ -49,7 +47,8 @@ impl subxt::config::Config for RuntimeConfig {
type Header = type Header =
subxt::config::substrate::SubstrateHeader<u32, subxt::config::substrate::BlakeTwo256>; subxt::config::substrate::SubstrateHeader<u32, subxt::config::substrate::BlakeTwo256>;
type Signature = subxt::ext::sp_runtime::MultiSignature; type Signature = subxt::ext::sp_runtime::MultiSignature;
type ExtrinsicParams = subxt::config::extrinsic_params::BaseExtrinsicParams<Self, Tip>; type ExtrinsicParams = subxt::config::substrate::SubstrateExtrinsicParams<Self>;
type AssetId = ();
} }
#[derive(Copy, Clone, Debug, Default, Encode)] #[derive(Copy, Clone, Debug, Default, Encode)]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment