mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 22:11:02 +00:00
Update Substrate/Polkadot/Cumulus references (#1353)
* cumulus: 4e95228291
polkadot: 975e780ae0d988dc033f400ba822d14b326ee5b9
substrate: 89fcb3e4f62d221d4e161a437768e77d6265889e
* fix refs
* sync changes from https://github.com/paritytech/polkadot/pull/3828
* sync changes from https://github.com/paritytech/polkadot/pull/4387
* sync changes from https://github.com/paritytech/polkadot/pull/3940
* sync with changes from https://github.com/paritytech/polkadot/pull/4493
* sync with changes from https://github.com/paritytech/polkadot/pull/4958
* sync with changes from https://github.com/paritytech/polkadot/pull/3889
* sync with changes from https://github.com/paritytech/polkadot/pull/5033
* sync with changes from https://github.com/paritytech/polkadot/pull/5065
* compilation fixes
* fixed prometheus endpoint startup (it now requires to be spawned within tokio context)
This commit is contained in:
committed by
Bastian Köcher
parent
ed2a3082ef
commit
65c2c0ccce
@@ -9,7 +9,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
||||
anyhow = "1.0"
|
||||
async-std = "1.9.0"
|
||||
async-trait = "0.1.42"
|
||||
codec = { package = "parity-scale-codec", version = "2.2.0" }
|
||||
codec = { package = "parity-scale-codec", version = "3.0.0" }
|
||||
futures = "0.3.12"
|
||||
hex = "0.4"
|
||||
log = "0.4.14"
|
||||
@@ -79,4 +79,4 @@ hex-literal = "0.3"
|
||||
pallet-bridge-grandpa = { path = "../../modules/grandpa" }
|
||||
sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
tempfile = "3.2"
|
||||
finality-grandpa = { version = "0.14.0" }
|
||||
finality-grandpa = { version = "0.15.0" }
|
||||
|
||||
@@ -107,8 +107,8 @@ impl RegisterParachain {
|
||||
let para_id: ParaId = relay_client
|
||||
.storage_value(StorageKey(para_id_key.to_vec()), None)
|
||||
.await?
|
||||
.unwrap_or(polkadot_primitives::v1::LOWEST_PUBLIC_ID)
|
||||
.max(polkadot_primitives::v1::LOWEST_PUBLIC_ID);
|
||||
.unwrap_or(polkadot_primitives::v2::LOWEST_PUBLIC_ID)
|
||||
.max(polkadot_primitives::v2::LOWEST_PUBLIC_ID);
|
||||
log::info!(target: "bridge", "Going to reserve parachain id: {:?}", para_id);
|
||||
|
||||
// step 1: reserve a parachain id
|
||||
|
||||
@@ -6,10 +6,10 @@ edition = "2021"
|
||||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
||||
|
||||
[dependencies]
|
||||
codec = { package = "parity-scale-codec", version = "2.2.0" }
|
||||
codec = { package = "parity-scale-codec", version = "3.0.0" }
|
||||
relay-substrate-client = { path = "../client-substrate" }
|
||||
relay-utils = { path = "../utils" }
|
||||
scale-info = { version = "1.0", features = ["derive"] }
|
||||
scale-info = { version = "2.0.1", features = ["derive"] }
|
||||
|
||||
# Bridge dependencies
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ edition = "2021"
|
||||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
||||
|
||||
[dependencies]
|
||||
codec = { package = "parity-scale-codec", version = "2.2.0" }
|
||||
codec = { package = "parity-scale-codec", version = "3.0.0" }
|
||||
relay-substrate-client = { path = "../client-substrate" }
|
||||
relay-utils = { path = "../utils" }
|
||||
|
||||
|
||||
@@ -105,6 +105,7 @@ impl TransactionSignScheme for Millau {
|
||||
let raw_payload = SignedPayload::from_raw(
|
||||
param.unsigned.call.clone(),
|
||||
(
|
||||
frame_system::CheckNonZeroSender::<millau_runtime::Runtime>::new(),
|
||||
frame_system::CheckSpecVersion::<millau_runtime::Runtime>::new(),
|
||||
frame_system::CheckTxVersion::<millau_runtime::Runtime>::new(),
|
||||
frame_system::CheckGenesis::<millau_runtime::Runtime>::new(),
|
||||
@@ -114,6 +115,7 @@ impl TransactionSignScheme for Millau {
|
||||
pallet_transaction_payment::ChargeTransactionPayment::<millau_runtime::Runtime>::from(param.unsigned.tip),
|
||||
),
|
||||
(
|
||||
(),
|
||||
param.spec_version,
|
||||
param.transaction_version,
|
||||
param.genesis_hash,
|
||||
|
||||
@@ -6,10 +6,10 @@ edition = "2021"
|
||||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
||||
|
||||
[dependencies]
|
||||
codec = { package = "parity-scale-codec", version = "2.2.0" }
|
||||
codec = { package = "parity-scale-codec", version = "3.0.0" }
|
||||
relay-substrate-client = { path = "../client-substrate" }
|
||||
relay-utils = { path = "../utils" }
|
||||
scale-info = { version = "1.0", features = ["derive"] }
|
||||
scale-info = { version = "2.0.1", features = ["derive"] }
|
||||
|
||||
# Bridge dependencies
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ edition = "2021"
|
||||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
||||
|
||||
[dependencies]
|
||||
codec = { package = "parity-scale-codec", version = "2.2.0" }
|
||||
codec = { package = "parity-scale-codec", version = "3.0.0" }
|
||||
relay-substrate-client = { path = "../client-substrate" }
|
||||
relay-utils = { path = "../utils" }
|
||||
|
||||
|
||||
@@ -105,6 +105,7 @@ impl TransactionSignScheme for Rialto {
|
||||
let raw_payload = SignedPayload::from_raw(
|
||||
param.unsigned.call.clone(),
|
||||
(
|
||||
frame_system::CheckNonZeroSender::<rialto_runtime::Runtime>::new(),
|
||||
frame_system::CheckSpecVersion::<rialto_runtime::Runtime>::new(),
|
||||
frame_system::CheckTxVersion::<rialto_runtime::Runtime>::new(),
|
||||
frame_system::CheckGenesis::<rialto_runtime::Runtime>::new(),
|
||||
@@ -114,6 +115,7 @@ impl TransactionSignScheme for Rialto {
|
||||
pallet_transaction_payment::ChargeTransactionPayment::<rialto_runtime::Runtime>::from(param.unsigned.tip),
|
||||
),
|
||||
(
|
||||
(),
|
||||
param.spec_version,
|
||||
param.transaction_version,
|
||||
param.genesis_hash,
|
||||
|
||||
@@ -6,10 +6,10 @@ edition = "2021"
|
||||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
||||
|
||||
[dependencies]
|
||||
codec = { package = "parity-scale-codec", version = "2.2.0" }
|
||||
codec = { package = "parity-scale-codec", version = "3.0.0" }
|
||||
relay-substrate-client = { path = "../client-substrate" }
|
||||
relay-utils = { path = "../utils" }
|
||||
scale-info = { version = "1.0", features = ["derive"] }
|
||||
scale-info = { version = "2.0.1", features = ["derive"] }
|
||||
|
||||
# Bridge dependencies
|
||||
|
||||
|
||||
@@ -8,13 +8,13 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
||||
[dependencies]
|
||||
async-std = { version = "1.6.5", features = ["attributes"] }
|
||||
async-trait = "0.1.40"
|
||||
codec = { package = "parity-scale-codec", version = "2.2.0" }
|
||||
jsonrpsee-proc-macros = "0.3.1"
|
||||
jsonrpsee-ws-client = "0.3.1"
|
||||
codec = { package = "parity-scale-codec", version = "3.0.0" }
|
||||
jsonrpsee = { version = "0.8", features = ["macros", "ws-client"] }
|
||||
log = "0.4.11"
|
||||
num-traits = "0.2"
|
||||
rand = "0.7"
|
||||
tokio = "1.8"
|
||||
serde = { version = "1.0" }
|
||||
tokio = { version = "1.8", features = ["rt-multi-thread"] }
|
||||
thiserror = "1.0.26"
|
||||
|
||||
# Bridge dependencies
|
||||
|
||||
@@ -18,7 +18,7 @@ use bp_messages::MessageNonce;
|
||||
use bp_runtime::{Chain as ChainBase, EncodedOrDecodedCall, HashOf, TransactionEraOf};
|
||||
use codec::{Codec, Encode};
|
||||
use frame_support::weights::{Weight, WeightToFeePolynomial};
|
||||
use jsonrpsee_ws_client::types::{DeserializeOwned, Serialize};
|
||||
use jsonrpsee::core::{DeserializeOwned, Serialize};
|
||||
use num_traits::Zero;
|
||||
use sc_transaction_pool_api::TransactionStatus;
|
||||
use sp_core::{storage::StorageKey, Pair};
|
||||
|
||||
@@ -18,8 +18,9 @@
|
||||
|
||||
use crate::{
|
||||
chain::{Chain, ChainWithBalances, TransactionStatusOf},
|
||||
rpc::Substrate,
|
||||
ConnectionParams, Error, HashOf, HeaderIdOf, Result,
|
||||
rpc::SubstrateClient,
|
||||
AccountIdOf, BlockNumberOf, ConnectionParams, Error, HashOf, HeaderIdOf, HeaderOf, IndexOf,
|
||||
Result,
|
||||
};
|
||||
|
||||
use async_std::sync::{Arc, Mutex};
|
||||
@@ -27,12 +28,10 @@ use async_trait::async_trait;
|
||||
use codec::{Decode, Encode};
|
||||
use frame_system::AccountInfo;
|
||||
use futures::{SinkExt, StreamExt};
|
||||
use jsonrpsee_ws_client::{
|
||||
types::{
|
||||
self as jsonrpsee_types, traits::SubscriptionClient, v2::params::JsonRpcParams,
|
||||
DeserializeOwned,
|
||||
},
|
||||
WsClient as RpcClient, WsClientBuilder as RpcClientBuilder,
|
||||
use jsonrpsee::{
|
||||
core::{client::SubscriptionClientT, DeserializeOwned},
|
||||
types::params::ParamsSer,
|
||||
ws_client::{WsClient as RpcClient, WsClientBuilder as RpcClientBuilder},
|
||||
};
|
||||
use num_traits::{Bounded, CheckedSub, One, Zero};
|
||||
use pallet_balances::AccountData;
|
||||
@@ -154,7 +153,15 @@ impl<C: Chain> Client<C> {
|
||||
let genesis_hash_client = client.clone();
|
||||
let genesis_hash = tokio
|
||||
.spawn(async move {
|
||||
Substrate::<C>::chain_get_block_hash(&*genesis_hash_client, number).await
|
||||
SubstrateClient::<
|
||||
AccountIdOf<C>,
|
||||
BlockNumberOf<C>,
|
||||
HashOf<C>,
|
||||
HeaderOf<C>,
|
||||
IndexOf<C>,
|
||||
C::SignedBlock,
|
||||
>::chain_get_block_hash(&*genesis_hash_client, Some(number))
|
||||
.await
|
||||
})
|
||||
.await??;
|
||||
|
||||
@@ -210,7 +217,15 @@ impl<C: Chain> Client<C> {
|
||||
/// Returns true if client is connected to at least one peer and is in synced state.
|
||||
pub async fn ensure_synced(&self) -> Result<()> {
|
||||
self.jsonrpsee_execute(|client| async move {
|
||||
let health = Substrate::<C>::system_health(&*client).await?;
|
||||
let health = SubstrateClient::<
|
||||
AccountIdOf<C>,
|
||||
BlockNumberOf<C>,
|
||||
HashOf<C>,
|
||||
HeaderOf<C>,
|
||||
IndexOf<C>,
|
||||
C::SignedBlock,
|
||||
>::system_health(&*client)
|
||||
.await?;
|
||||
let is_synced = !health.is_syncing && (!health.should_have_peers || health.peers > 0);
|
||||
if is_synced {
|
||||
Ok(())
|
||||
@@ -229,7 +244,15 @@ impl<C: Chain> Client<C> {
|
||||
/// Return hash of the best finalized block.
|
||||
pub async fn best_finalized_header_hash(&self) -> Result<C::Hash> {
|
||||
self.jsonrpsee_execute(|client| async move {
|
||||
Ok(Substrate::<C>::chain_get_finalized_head(&*client).await?)
|
||||
Ok(SubstrateClient::<
|
||||
AccountIdOf<C>,
|
||||
BlockNumberOf<C>,
|
||||
HashOf<C>,
|
||||
HeaderOf<C>,
|
||||
IndexOf<C>,
|
||||
C::SignedBlock,
|
||||
>::chain_get_finalized_head(&*client)
|
||||
.await?)
|
||||
})
|
||||
.await
|
||||
}
|
||||
@@ -245,7 +268,15 @@ impl<C: Chain> Client<C> {
|
||||
C::Header: DeserializeOwned,
|
||||
{
|
||||
self.jsonrpsee_execute(|client| async move {
|
||||
Ok(Substrate::<C>::chain_get_header(&*client, None).await?)
|
||||
Ok(SubstrateClient::<
|
||||
AccountIdOf<C>,
|
||||
BlockNumberOf<C>,
|
||||
HashOf<C>,
|
||||
HeaderOf<C>,
|
||||
IndexOf<C>,
|
||||
C::SignedBlock,
|
||||
>::chain_get_header(&*client, None)
|
||||
.await?)
|
||||
})
|
||||
.await
|
||||
}
|
||||
@@ -253,7 +284,15 @@ impl<C: Chain> Client<C> {
|
||||
/// Get a Substrate block from its hash.
|
||||
pub async fn get_block(&self, block_hash: Option<C::Hash>) -> Result<C::SignedBlock> {
|
||||
self.jsonrpsee_execute(move |client| async move {
|
||||
Ok(Substrate::<C>::chain_get_block(&*client, block_hash).await?)
|
||||
Ok(SubstrateClient::<
|
||||
AccountIdOf<C>,
|
||||
BlockNumberOf<C>,
|
||||
HashOf<C>,
|
||||
HeaderOf<C>,
|
||||
IndexOf<C>,
|
||||
C::SignedBlock,
|
||||
>::chain_get_block(&*client, block_hash)
|
||||
.await?)
|
||||
})
|
||||
.await
|
||||
}
|
||||
@@ -264,7 +303,15 @@ impl<C: Chain> Client<C> {
|
||||
C::Header: DeserializeOwned,
|
||||
{
|
||||
self.jsonrpsee_execute(move |client| async move {
|
||||
Ok(Substrate::<C>::chain_get_header(&*client, block_hash).await?)
|
||||
Ok(SubstrateClient::<
|
||||
AccountIdOf<C>,
|
||||
BlockNumberOf<C>,
|
||||
HashOf<C>,
|
||||
HeaderOf<C>,
|
||||
IndexOf<C>,
|
||||
C::SignedBlock,
|
||||
>::chain_get_header(&*client, Some(block_hash))
|
||||
.await?)
|
||||
})
|
||||
.await
|
||||
}
|
||||
@@ -272,7 +319,15 @@ impl<C: Chain> Client<C> {
|
||||
/// Get a Substrate block hash by its number.
|
||||
pub async fn block_hash_by_number(&self, number: C::BlockNumber) -> Result<C::Hash> {
|
||||
self.jsonrpsee_execute(move |client| async move {
|
||||
Ok(Substrate::<C>::chain_get_block_hash(&*client, number).await?)
|
||||
Ok(SubstrateClient::<
|
||||
AccountIdOf<C>,
|
||||
BlockNumberOf<C>,
|
||||
HashOf<C>,
|
||||
HeaderOf<C>,
|
||||
IndexOf<C>,
|
||||
C::SignedBlock,
|
||||
>::chain_get_block_hash(&*client, Some(number))
|
||||
.await?)
|
||||
})
|
||||
.await
|
||||
}
|
||||
@@ -290,7 +345,15 @@ impl<C: Chain> Client<C> {
|
||||
/// Return runtime version.
|
||||
pub async fn runtime_version(&self) -> Result<RuntimeVersion> {
|
||||
self.jsonrpsee_execute(move |client| async move {
|
||||
Ok(Substrate::<C>::state_runtime_version(&*client).await?)
|
||||
Ok(SubstrateClient::<
|
||||
AccountIdOf<C>,
|
||||
BlockNumberOf<C>,
|
||||
HashOf<C>,
|
||||
HeaderOf<C>,
|
||||
IndexOf<C>,
|
||||
C::SignedBlock,
|
||||
>::state_runtime_version(&*client)
|
||||
.await?)
|
||||
})
|
||||
.await
|
||||
}
|
||||
@@ -316,7 +379,15 @@ impl<C: Chain> Client<C> {
|
||||
block_hash: Option<C::Hash>,
|
||||
) -> Result<Option<StorageData>> {
|
||||
self.jsonrpsee_execute(move |client| async move {
|
||||
Ok(Substrate::<C>::state_get_storage(&*client, storage_key, block_hash).await?)
|
||||
Ok(SubstrateClient::<
|
||||
AccountIdOf<C>,
|
||||
BlockNumberOf<C>,
|
||||
HashOf<C>,
|
||||
HeaderOf<C>,
|
||||
IndexOf<C>,
|
||||
C::SignedBlock,
|
||||
>::state_get_storage(&*client, storage_key, block_hash)
|
||||
.await?)
|
||||
})
|
||||
.await
|
||||
}
|
||||
@@ -328,10 +399,16 @@ impl<C: Chain> Client<C> {
|
||||
{
|
||||
self.jsonrpsee_execute(move |client| async move {
|
||||
let storage_key = C::account_info_storage_key(&account);
|
||||
let encoded_account_data =
|
||||
Substrate::<C>::state_get_storage(&*client, storage_key, None)
|
||||
.await?
|
||||
.ok_or(Error::AccountDoesNotExist)?;
|
||||
let encoded_account_data = SubstrateClient::<
|
||||
AccountIdOf<C>,
|
||||
BlockNumberOf<C>,
|
||||
HashOf<C>,
|
||||
HeaderOf<C>,
|
||||
IndexOf<C>,
|
||||
C::SignedBlock,
|
||||
>::state_get_storage(&*client, storage_key, None)
|
||||
.await?
|
||||
.ok_or(Error::AccountDoesNotExist)?;
|
||||
let decoded_account_data = AccountInfo::<C::Index, AccountData<C::Balance>>::decode(
|
||||
&mut &encoded_account_data.0[..],
|
||||
)
|
||||
@@ -346,7 +423,15 @@ impl<C: Chain> Client<C> {
|
||||
/// Note: It's the caller's responsibility to make sure `account` is a valid SS58 address.
|
||||
pub async fn next_account_index(&self, account: C::AccountId) -> Result<C::Index> {
|
||||
self.jsonrpsee_execute(move |client| async move {
|
||||
Ok(Substrate::<C>::system_account_next_index(&*client, account).await?)
|
||||
Ok(SubstrateClient::<
|
||||
AccountIdOf<C>,
|
||||
BlockNumberOf<C>,
|
||||
HashOf<C>,
|
||||
HeaderOf<C>,
|
||||
IndexOf<C>,
|
||||
C::SignedBlock,
|
||||
>::system_account_next_index(&*client, account)
|
||||
.await?)
|
||||
})
|
||||
.await
|
||||
}
|
||||
@@ -356,7 +441,15 @@ impl<C: Chain> Client<C> {
|
||||
/// Note: The given transaction needs to be SCALE encoded beforehand.
|
||||
pub async fn submit_unsigned_extrinsic(&self, transaction: Bytes) -> Result<C::Hash> {
|
||||
self.jsonrpsee_execute(move |client| async move {
|
||||
let tx_hash = Substrate::<C>::author_submit_extrinsic(&*client, transaction).await?;
|
||||
let tx_hash = SubstrateClient::<
|
||||
AccountIdOf<C>,
|
||||
BlockNumberOf<C>,
|
||||
HashOf<C>,
|
||||
HeaderOf<C>,
|
||||
IndexOf<C>,
|
||||
C::SignedBlock,
|
||||
>::author_submit_extrinsic(&*client, transaction)
|
||||
.await?;
|
||||
log::trace!(target: "bridge", "Sent transaction to Substrate node: {:?}", tx_hash);
|
||||
Ok(tx_hash)
|
||||
})
|
||||
@@ -391,7 +484,15 @@ impl<C: Chain> Client<C> {
|
||||
|
||||
self.jsonrpsee_execute(move |client| async move {
|
||||
let extrinsic = prepare_extrinsic(best_header_id, transaction_nonce)?;
|
||||
let tx_hash = Substrate::<C>::author_submit_extrinsic(&*client, extrinsic).await?;
|
||||
let tx_hash = SubstrateClient::<
|
||||
AccountIdOf<C>,
|
||||
BlockNumberOf<C>,
|
||||
HashOf<C>,
|
||||
HeaderOf<C>,
|
||||
IndexOf<C>,
|
||||
C::SignedBlock,
|
||||
>::author_submit_extrinsic(&*client, extrinsic)
|
||||
.await?;
|
||||
log::trace!(target: "bridge", "Sent transaction to {} node: {:?}", C::NAME, tx_hash);
|
||||
Ok(tx_hash)
|
||||
})
|
||||
@@ -416,8 +517,8 @@ impl<C: Chain> Client<C> {
|
||||
let subscription = client
|
||||
.subscribe(
|
||||
"author_submitAndWatchExtrinsic",
|
||||
JsonRpcParams::Array(vec![jsonrpsee_types::to_json_value(extrinsic)
|
||||
.map_err(|e| Error::RpcError(e.into()))?]),
|
||||
Some(ParamsSer::Array(vec![jsonrpsee::core::to_json_value(extrinsic)
|
||||
.map_err(|e| Error::RpcError(e.into()))?])),
|
||||
"author_unwatchExtrinsic",
|
||||
)
|
||||
.await?;
|
||||
@@ -438,7 +539,15 @@ impl<C: Chain> Client<C> {
|
||||
/// Returns pending extrinsics from transaction pool.
|
||||
pub async fn pending_extrinsics(&self) -> Result<Vec<Bytes>> {
|
||||
self.jsonrpsee_execute(move |client| async move {
|
||||
Ok(Substrate::<C>::author_pending_extrinsics(&*client).await?)
|
||||
Ok(SubstrateClient::<
|
||||
AccountIdOf<C>,
|
||||
BlockNumberOf<C>,
|
||||
HashOf<C>,
|
||||
HeaderOf<C>,
|
||||
IndexOf<C>,
|
||||
C::SignedBlock,
|
||||
>::author_pending_extrinsics(&*client)
|
||||
.await?)
|
||||
})
|
||||
.await
|
||||
}
|
||||
@@ -453,8 +562,15 @@ impl<C: Chain> Client<C> {
|
||||
let call = SUB_API_TXPOOL_VALIDATE_TRANSACTION.to_string();
|
||||
let data = Bytes((TransactionSource::External, transaction, at_block).encode());
|
||||
|
||||
let encoded_response =
|
||||
Substrate::<C>::state_call(&*client, call, data, Some(at_block)).await?;
|
||||
let encoded_response = SubstrateClient::<
|
||||
AccountIdOf<C>,
|
||||
BlockNumberOf<C>,
|
||||
HashOf<C>,
|
||||
HeaderOf<C>,
|
||||
IndexOf<C>,
|
||||
C::SignedBlock,
|
||||
>::state_call(&*client, call, data, Some(at_block))
|
||||
.await?;
|
||||
let validity = TransactionValidity::decode(&mut &encoded_response.0[..])
|
||||
.map_err(Error::ResponseParseFailed)?;
|
||||
|
||||
@@ -469,8 +585,15 @@ impl<C: Chain> Client<C> {
|
||||
transaction: Bytes,
|
||||
) -> Result<InclusionFee<C::Balance>> {
|
||||
self.jsonrpsee_execute(move |client| async move {
|
||||
let fee_details =
|
||||
Substrate::<C>::payment_query_fee_details(&*client, transaction, None).await?;
|
||||
let fee_details = SubstrateClient::<
|
||||
AccountIdOf<C>,
|
||||
BlockNumberOf<C>,
|
||||
HashOf<C>,
|
||||
HeaderOf<C>,
|
||||
IndexOf<C>,
|
||||
C::SignedBlock,
|
||||
>::payment_query_fee_details(&*client, transaction, None)
|
||||
.await?;
|
||||
let inclusion_fee = fee_details
|
||||
.inclusion_fee
|
||||
.map(|inclusion_fee| InclusionFee {
|
||||
@@ -502,8 +625,15 @@ impl<C: Chain> Client<C> {
|
||||
let call = SUB_API_GRANDPA_AUTHORITIES.to_string();
|
||||
let data = Bytes(Vec::new());
|
||||
|
||||
let encoded_response =
|
||||
Substrate::<C>::state_call(&*client, call, data, Some(block)).await?;
|
||||
let encoded_response = SubstrateClient::<
|
||||
AccountIdOf<C>,
|
||||
BlockNumberOf<C>,
|
||||
HashOf<C>,
|
||||
HeaderOf<C>,
|
||||
IndexOf<C>,
|
||||
C::SignedBlock,
|
||||
>::state_call(&*client, call, data, Some(block))
|
||||
.await?;
|
||||
let authority_list = encoded_response.0;
|
||||
|
||||
Ok(authority_list)
|
||||
@@ -519,9 +649,16 @@ impl<C: Chain> Client<C> {
|
||||
at_block: Option<C::Hash>,
|
||||
) -> Result<Bytes> {
|
||||
self.jsonrpsee_execute(move |client| async move {
|
||||
Substrate::<C>::state_call(&*client, method, data, at_block)
|
||||
.await
|
||||
.map_err(Into::into)
|
||||
SubstrateClient::<
|
||||
AccountIdOf<C>,
|
||||
BlockNumberOf<C>,
|
||||
HashOf<C>,
|
||||
HeaderOf<C>,
|
||||
IndexOf<C>,
|
||||
C::SignedBlock,
|
||||
>::state_call(&*client, method, data, at_block)
|
||||
.await
|
||||
.map_err(Into::into)
|
||||
})
|
||||
.await
|
||||
}
|
||||
@@ -533,10 +670,19 @@ impl<C: Chain> Client<C> {
|
||||
at_block: C::Hash,
|
||||
) -> Result<StorageProof> {
|
||||
self.jsonrpsee_execute(move |client| async move {
|
||||
Substrate::<C>::state_prove_storage(&*client, keys, Some(at_block))
|
||||
.await
|
||||
.map(|proof| StorageProof::new(proof.proof.into_iter().map(|b| b.0).collect()))
|
||||
.map_err(Into::into)
|
||||
SubstrateClient::<
|
||||
AccountIdOf<C>,
|
||||
BlockNumberOf<C>,
|
||||
HashOf<C>,
|
||||
HeaderOf<C>,
|
||||
IndexOf<C>,
|
||||
C::SignedBlock,
|
||||
>::state_prove_storage(&*client, keys, Some(at_block))
|
||||
.await
|
||||
.map(|proof| {
|
||||
StorageProof::new(proof.proof.into_iter().map(|b| b.0).collect::<Vec<_>>())
|
||||
})
|
||||
.map_err(Into::into)
|
||||
})
|
||||
.await
|
||||
}
|
||||
@@ -544,7 +690,15 @@ impl<C: Chain> Client<C> {
|
||||
/// Return `tokenDecimals` property from the set of chain properties.
|
||||
pub async fn token_decimals(&self) -> Result<Option<u64>> {
|
||||
self.jsonrpsee_execute(move |client| async move {
|
||||
let system_properties = Substrate::<C>::system_properties(&*client).await?;
|
||||
let system_properties = SubstrateClient::<
|
||||
AccountIdOf<C>,
|
||||
BlockNumberOf<C>,
|
||||
HashOf<C>,
|
||||
HeaderOf<C>,
|
||||
IndexOf<C>,
|
||||
C::SignedBlock,
|
||||
>::system_properties(&*client)
|
||||
.await?;
|
||||
Ok(system_properties.get("tokenDecimals").and_then(|v| v.as_u64()))
|
||||
})
|
||||
.await
|
||||
@@ -557,7 +711,7 @@ impl<C: Chain> Client<C> {
|
||||
Ok(client
|
||||
.subscribe(
|
||||
"grandpa_subscribeJustifications",
|
||||
JsonRpcParams::NoParams,
|
||||
None,
|
||||
"grandpa_unsubscribeJustifications",
|
||||
)
|
||||
.await?)
|
||||
@@ -597,26 +751,16 @@ impl<T: DeserializeOwned> Subscription<T> {
|
||||
async fn background_worker(
|
||||
chain_name: String,
|
||||
item_type: String,
|
||||
mut subscription: jsonrpsee_types::Subscription<T>,
|
||||
mut subscription: jsonrpsee::core::client::Subscription<T>,
|
||||
mut sender: futures::channel::mpsc::Sender<Option<T>>,
|
||||
) {
|
||||
loop {
|
||||
match subscription.next().await {
|
||||
Ok(Some(item)) =>
|
||||
Some(Ok(item)) =>
|
||||
if sender.send(Some(item)).await.is_err() {
|
||||
break
|
||||
},
|
||||
Ok(None) => {
|
||||
log::trace!(
|
||||
target: "bridge",
|
||||
"{} {} subscription stream has returned None. Stream needs to be restarted.",
|
||||
chain_name,
|
||||
item_type,
|
||||
);
|
||||
let _ = sender.send(None).await;
|
||||
break
|
||||
},
|
||||
Err(e) => {
|
||||
Some(Err(e)) => {
|
||||
log::trace!(
|
||||
target: "bridge",
|
||||
"{} {} subscription stream has returned '{:?}'. Stream needs to be restarted.",
|
||||
@@ -627,6 +771,16 @@ impl<T: DeserializeOwned> Subscription<T> {
|
||||
let _ = sender.send(None).await;
|
||||
break
|
||||
},
|
||||
None => {
|
||||
log::trace!(
|
||||
target: "bridge",
|
||||
"{} {} subscription stream has returned None. Stream needs to be restarted.",
|
||||
chain_name,
|
||||
item_type,
|
||||
);
|
||||
let _ = sender.send(None).await;
|
||||
break
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
//! Substrate node RPC errors.
|
||||
|
||||
use jsonrpsee_ws_client::types::Error as RpcError;
|
||||
use jsonrpsee::core::Error as RpcError;
|
||||
use relay_utils::MaybeConnectionError;
|
||||
use sc_rpc_api::system::Health;
|
||||
use sp_runtime::transaction_validity::TransactionValidityError;
|
||||
|
||||
@@ -16,8 +16,7 @@
|
||||
|
||||
//! The most generic Substrate node RPC interface.
|
||||
|
||||
use crate::chain::Chain;
|
||||
|
||||
use jsonrpsee::{core::RpcResult, proc_macros::rpc};
|
||||
use pallet_transaction_payment_rpc_runtime_api::FeeDetails;
|
||||
use sc_rpc_api::{state::ReadProof, system::Health};
|
||||
use sp_core::{
|
||||
@@ -27,35 +26,51 @@ use sp_core::{
|
||||
use sp_rpc::number::NumberOrHex;
|
||||
use sp_version::RuntimeVersion;
|
||||
|
||||
jsonrpsee_proc_macros::rpc_client_api! {
|
||||
pub(crate) Substrate<C: Chain> {
|
||||
#[rpc(method = "system_health", positional_params)]
|
||||
fn system_health() -> Health;
|
||||
#[rpc(method = "system_properties", positional_params)]
|
||||
fn system_properties() -> sc_chain_spec::Properties;
|
||||
#[rpc(method = "chain_getHeader", positional_params)]
|
||||
fn chain_get_header(block_hash: Option<C::Hash>) -> C::Header;
|
||||
#[rpc(method = "chain_getFinalizedHead", positional_params)]
|
||||
fn chain_get_finalized_head() -> C::Hash;
|
||||
#[rpc(method = "chain_getBlock", positional_params)]
|
||||
fn chain_get_block(block_hash: Option<C::Hash>) -> C::SignedBlock;
|
||||
#[rpc(method = "chain_getBlockHash", positional_params)]
|
||||
fn chain_get_block_hash(block_number: Option<C::BlockNumber>) -> C::Hash;
|
||||
#[rpc(method = "system_accountNextIndex", positional_params)]
|
||||
fn system_account_next_index(account_id: C::AccountId) -> C::Index;
|
||||
#[rpc(method = "author_submitExtrinsic", positional_params)]
|
||||
fn author_submit_extrinsic(extrinsic: Bytes) -> C::Hash;
|
||||
#[rpc(method = "author_pendingExtrinsics", positional_params)]
|
||||
fn author_pending_extrinsics() -> Vec<Bytes>;
|
||||
#[rpc(method = "state_call", positional_params)]
|
||||
fn state_call(method: String, data: Bytes, at_block: Option<C::Hash>) -> Bytes;
|
||||
#[rpc(method = "state_getStorage", positional_params)]
|
||||
fn state_get_storage(key: StorageKey, at_block: Option<C::Hash>) -> Option<StorageData>;
|
||||
#[rpc(method = "state_getReadProof", positional_params)]
|
||||
fn state_prove_storage(keys: Vec<StorageKey>, hash: Option<C::Hash>) -> ReadProof<C::Hash>;
|
||||
#[rpc(method = "state_getRuntimeVersion", positional_params)]
|
||||
fn state_runtime_version() -> RuntimeVersion;
|
||||
#[rpc(method = "payment_queryFeeDetails", positional_params)]
|
||||
fn payment_query_fee_details(extrinsic: Bytes, at_block: Option<C::Hash>) -> FeeDetails<NumberOrHex>;
|
||||
}
|
||||
#[rpc(client)]
|
||||
pub(crate) trait Substrate<AccountId, BlockNumber, Hash, Header, Index, SignedBlock> {
|
||||
#[method(name = "system_health", param_kind = array)]
|
||||
async fn system_health(&self) -> RpcResult<Health>;
|
||||
#[method(name = "system_properties", param_kind = array)]
|
||||
async fn system_properties(&self) -> RpcResult<sc_chain_spec::Properties>;
|
||||
#[method(name = "chain_getHeader", param_kind = array)]
|
||||
async fn chain_get_header(&self, block_hash: Option<Hash>) -> RpcResult<Header>;
|
||||
#[method(name = "chain_getFinalizedHead", param_kind = array)]
|
||||
async fn chain_get_finalized_head(&self) -> RpcResult<Hash>;
|
||||
#[method(name = "chain_getBlock", param_kind = array)]
|
||||
async fn chain_get_block(&self, block_hash: Option<Hash>) -> RpcResult<SignedBlock>;
|
||||
#[method(name = "chain_getBlockHash", param_kind = array)]
|
||||
async fn chain_get_block_hash(&self, block_number: Option<BlockNumber>) -> RpcResult<Hash>;
|
||||
#[method(name = "system_accountNextIndex", param_kind = array)]
|
||||
async fn system_account_next_index(&self, account_id: AccountId) -> RpcResult<Index>;
|
||||
#[method(name = "author_submitExtrinsic", param_kind = array)]
|
||||
async fn author_submit_extrinsic(&self, extrinsic: Bytes) -> RpcResult<Hash>;
|
||||
#[method(name = "author_pendingExtrinsics", param_kind = array)]
|
||||
async fn author_pending_extrinsics(&self) -> RpcResult<Vec<Bytes>>;
|
||||
#[method(name = "state_call", param_kind = array)]
|
||||
async fn state_call(
|
||||
&self,
|
||||
method: String,
|
||||
data: Bytes,
|
||||
at_block: Option<Hash>,
|
||||
) -> RpcResult<Bytes>;
|
||||
#[method(name = "state_getStorage", param_kind = array)]
|
||||
async fn state_get_storage(
|
||||
&self,
|
||||
key: StorageKey,
|
||||
at_block: Option<Hash>,
|
||||
) -> RpcResult<Option<StorageData>>;
|
||||
#[method(name = "state_getReadProof", param_kind = array)]
|
||||
async fn state_prove_storage(
|
||||
&self,
|
||||
keys: Vec<StorageKey>,
|
||||
hash: Option<Hash>,
|
||||
) -> RpcResult<ReadProof<Hash>>;
|
||||
#[method(name = "state_getRuntimeVersion", param_kind = array)]
|
||||
async fn state_runtime_version(&self) -> RpcResult<RuntimeVersion>;
|
||||
#[method(name = "payment_queryFeeDetails", param_kind = array)]
|
||||
async fn payment_query_fee_details(
|
||||
&self,
|
||||
extrinsic: Bytes,
|
||||
at_block: Option<Hash>,
|
||||
) -> RpcResult<FeeDetails<NumberOrHex>>;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ edition = "2021"
|
||||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
||||
|
||||
[dependencies]
|
||||
codec = { package = "parity-scale-codec", version = "2.2.0" }
|
||||
codec = { package = "parity-scale-codec", version = "3.0.0" }
|
||||
relay-substrate-client = { path = "../client-substrate" }
|
||||
relay-utils = { path = "../utils" }
|
||||
|
||||
|
||||
@@ -6,10 +6,10 @@ edition = "2021"
|
||||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
||||
|
||||
[dependencies]
|
||||
codec = { package = "parity-scale-codec", version = "2.2.0" }
|
||||
codec = { package = "parity-scale-codec", version = "3.0.0" }
|
||||
relay-substrate-client = { path = "../client-substrate" }
|
||||
relay-utils = { path = "../utils" }
|
||||
scale-info = { version = "1.0", default-features = false, features = ["derive"] }
|
||||
scale-info = { version = "2.0.1", default-features = false, features = ["derive"] }
|
||||
|
||||
# Bridge dependencies
|
||||
bridge-runtime-common = { path = "../../bin/runtime-common" }
|
||||
|
||||
@@ -10,18 +10,17 @@ anyhow = "1.0"
|
||||
thiserror = "1.0.26"
|
||||
async-std = "1.9.0"
|
||||
async-trait = "0.1.42"
|
||||
codec = { package = "parity-scale-codec", version = "2.2.0" }
|
||||
codec = { package = "parity-scale-codec", version = "3.0.0" }
|
||||
futures = "0.3.12"
|
||||
num-traits = "0.2"
|
||||
log = "0.4.14"
|
||||
|
||||
|
||||
# Bridge dependencies
|
||||
|
||||
bp-header-chain = { path = "../../primitives/header-chain" }
|
||||
bridge-runtime-common = { path = "../../bin/runtime-common" }
|
||||
|
||||
finality-grandpa = { version = "0.14.0" }
|
||||
finality-grandpa = { version = "0.15.0" }
|
||||
finality-relay = { path = "../finality" }
|
||||
relay-utils = { path = "../utils" }
|
||||
messages-relay = { path = "../messages" }
|
||||
|
||||
@@ -20,6 +20,7 @@ num-traits = "0.2"
|
||||
serde_json = "1.0"
|
||||
sysinfo = "0.15"
|
||||
time = { version = "0.3", features = ["formatting", "local-offset", "std"] }
|
||||
tokio = { version = "1.8", features = ["rt"] }
|
||||
thiserror = "1.0.26"
|
||||
|
||||
# Bridge dependencies
|
||||
|
||||
@@ -187,12 +187,32 @@ impl<SC, TC, LM> LoopMetrics<SC, TC, LM> {
|
||||
|
||||
let registry = self.registry;
|
||||
async_std::task::spawn(async move {
|
||||
let result = init_prometheus(socket_addr, registry).await;
|
||||
log::trace!(
|
||||
target: "bridge-metrics",
|
||||
"Prometheus endpoint has exited with result: {:?}",
|
||||
result,
|
||||
);
|
||||
let runtime =
|
||||
match tokio::runtime::Builder::new_current_thread().enable_all().build() {
|
||||
Ok(runtime) => runtime,
|
||||
Err(err) => {
|
||||
log::trace!(
|
||||
target: "bridge-metrics",
|
||||
"Failed to create tokio runtime. Prometheus meterics are not available: {:?}",
|
||||
err,
|
||||
);
|
||||
return
|
||||
},
|
||||
};
|
||||
|
||||
let _ = runtime.block_on(async move {
|
||||
log::trace!(
|
||||
target: "bridge-metrics",
|
||||
"Starting prometheus endpoint at: {:?}",
|
||||
socket_addr,
|
||||
);
|
||||
let result = init_prometheus(socket_addr, registry).await;
|
||||
log::trace!(
|
||||
target: "bridge-metrics",
|
||||
"Prometheus endpoint has exited with result: {:?}",
|
||||
result,
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user