-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support different Parentchain configs for Integritee, TargetA, Target…
…B and default to AssetTip for TargetB (aka support Asset Hub) (#1652) * trying to use a supertrait to make ParentchainApi generic * introduce ParentchainRuntimeConfig for simpler generic parentchain support * [onchain_bridge] worker_request compiles * [onchain_bridge] send_to_parentchain compiles * [onchain_bridge] stuck at prometheus metrics * prometheus metrics wip * finish metrics * worker builds * fix unused warnings * wip splitting up extrinsic factory * cleanup * remove unnecessary alias * remove core * some cleanup * cleanup and remove naming ambiguities * fix test build * clippy * fix teeracle build * fix attesteer build * Fix typo in `AdditionalParamsOf` * remove parentchainapi trait * fmt * re-activate check for rarenewal period to derive account funding * log error for init target chain * add trace! logs for signed extra and additional signed * [enclave-runtime] try_runtime now takes the parentchain as arg. Sending xt to asset hub works * [enclave-runtime] implement parentchain event handler * more verbose logs and wait for proxy creation inclusion * some log pimp * use per-parentchain block type * WIP: trait jungle untangle * Revert "WIP: trait jungle untangle" This reverts commit f9bc9df. * Revert "use per-parentchain block type" This reverts commit 344da8e. * [aura] improve logging around block import * [aura] implement debug on SlotInfo to get Header info * [stf-executor] fix updating the target_b block * fix clippy * fix log * minor logging improvement --------- Co-authored-by: Alain Brenzikofer <[email protected]>
- Loading branch information
Showing
55 changed files
with
1,562 additions
and
581 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
app-libs/parentchain-interface/src/integritee/api_client_types.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
Copyright 2021 Integritee AG and Supercomputing Systems AG | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
//! Contains semi-generic type definitions to talk to the node without depending on an implementation of Runtime. | ||
//! | ||
//! You need to update this if you have a signed extension in your node that | ||
//! is different from the integritee-node, e.g., if you use the `pallet_asset_tx_payment`. | ||
use crate::{ | ||
GenericAdditionalParams, GenericExtrinsicParams, GenericSignedExtra, ParentchainRuntimeConfig, | ||
PlainTip, UncheckedExtrinsicV4, | ||
}; | ||
use itp_types::parentchain::Header; | ||
pub use itp_types::parentchain::{ | ||
AccountData, AccountId, AccountInfo, Address, Balance, Hash, Index, Signature as PairSignature, | ||
}; | ||
use sp_runtime::generic; | ||
|
||
pub type IntegriteeRuntimeConfig = ParentchainRuntimeConfig<IntegriteeTip>; | ||
|
||
// Configuration for the ExtrinsicParams. | ||
pub type IntegriteeTip = PlainTip<Balance>; | ||
pub type IntegriteeExtrinsicParams = GenericExtrinsicParams<IntegriteeRuntimeConfig, IntegriteeTip>; | ||
pub type IntegriteeAdditionalParams = GenericAdditionalParams<IntegriteeRuntimeConfig, Hash>; | ||
|
||
pub type IntegriteeSignedExtra = GenericSignedExtra<IntegriteeTip, Index>; | ||
pub type IntegriteeSignature = Signature<IntegriteeSignedExtra>; | ||
|
||
pub type IntegriteeUncheckedExtrinsic<Call> = | ||
UncheckedExtrinsicV4<Address, Call, PairSignature, IntegriteeSignedExtra>; | ||
|
||
/// Signature type of the [UncheckedExtrinsicV4]. | ||
pub type Signature<SignedExtra> = Option<(Address, PairSignature, SignedExtra)>; | ||
|
||
pub type Block = generic::Block<Header, IntegriteeUncheckedExtrinsic<([u8; 2])>>; | ||
|
||
#[cfg(feature = "std")] | ||
pub use api::*; | ||
|
||
#[cfg(feature = "std")] | ||
mod api { | ||
use crate::ParentchainRuntimeConfig; | ||
use itp_api_client_types::PlainTip; | ||
use itp_types::parentchain::Balance; | ||
pub use substrate_api_client::{ | ||
api::Error as ApiClientError, | ||
rpc::{tungstenite_client::TungsteniteRpcClient, Error as RpcClientError}, | ||
Api, | ||
}; | ||
|
||
pub type IntegriteeApi = Api<ParentchainRuntimeConfig<PlainTip<Balance>>, TungsteniteRpcClient>; | ||
} |
49 changes: 49 additions & 0 deletions
49
app-libs/parentchain-interface/src/integritee/api_factory.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
Copyright 2021 Integritee AG and Supercomputing Systems AG | ||
Copyright (C) 2017-2019 Baidu, Inc. All Rights Reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
use super::api_client_types::IntegriteeTip; | ||
use crate::ParentchainRuntimeConfig; | ||
use itp_api_client_types::{Api, TungsteniteRpcClient}; | ||
use itp_node_api::node_api_factory::{CreateNodeApi, NodeApiFactoryError, Result}; | ||
use sp_core::sr25519; | ||
|
||
/// Node API factory implementation. | ||
pub struct IntegriteeNodeApiFactory { | ||
node_url: String, | ||
signer: sr25519::Pair, | ||
} | ||
|
||
impl IntegriteeNodeApiFactory { | ||
pub fn new(url: String, signer: sr25519::Pair) -> Self { | ||
Self { node_url: url, signer } | ||
} | ||
} | ||
|
||
impl CreateNodeApi<ParentchainRuntimeConfig<IntegriteeTip>, TungsteniteRpcClient> | ||
for IntegriteeNodeApiFactory | ||
{ | ||
fn create_api( | ||
&self, | ||
) -> Result<Api<ParentchainRuntimeConfig<IntegriteeTip>, TungsteniteRpcClient>> { | ||
let rpc_client = TungsteniteRpcClient::new(self.node_url.as_str(), 5) | ||
.map_err(NodeApiFactoryError::FailedToCreateRpcClient)?; | ||
let mut api = Api::new(rpc_client).map_err(NodeApiFactoryError::FailedToCreateNodeApi)?; | ||
api.set_signer(self.signer.clone().into()); | ||
Ok(api) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
app-libs/parentchain-interface/src/target_a/api_client_types.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
Copyright 2021 Integritee AG and Supercomputing Systems AG | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
//! Contains semi-generic type definitions to talk to the node without depending on an implementation of Runtime. | ||
//! | ||
//! You need to update this if you have a signed extension in your node that | ||
//! is different from the integritee-node, e.g., if you use the `pallet_asset_tx_payment`. | ||
use crate::{ | ||
GenericAdditionalParams, GenericExtrinsicParams, GenericSignedExtra, ParentchainRuntimeConfig, | ||
PlainTip, UncheckedExtrinsicV4, | ||
}; | ||
pub use itp_types::parentchain::{ | ||
AccountData, AccountId, AccountInfo, Address, Balance, Hash, Index, Signature as PairSignature, | ||
}; | ||
|
||
pub type TargetARuntimeConfig = ParentchainRuntimeConfig<TargetATip>; | ||
|
||
// Configuration for the ExtrinsicParams. | ||
|
||
pub type TargetATip = PlainTip<Balance>; | ||
pub type TargetAExtrinsicParams = GenericExtrinsicParams<TargetARuntimeConfig, TargetATip>; | ||
pub type TargetAAdditionalParams = GenericAdditionalParams<TargetARuntimeConfig, Hash>; | ||
|
||
pub type TargetASignedExtra = GenericSignedExtra<TargetATip, Index>; | ||
pub type TargetASignature = Signature<TargetASignedExtra>; | ||
|
||
pub type TargetAUncheckedExtrinsic<Call> = | ||
UncheckedExtrinsicV4<Address, Call, PairSignature, TargetASignedExtra>; | ||
|
||
/// Signature type of the [UncheckedExtrinsicV4]. | ||
pub type Signature<SignedExtra> = Option<(Address, PairSignature, SignedExtra)>; | ||
|
||
#[cfg(feature = "std")] | ||
pub use api::*; | ||
|
||
#[cfg(feature = "std")] | ||
mod api { | ||
use crate::ParentchainRuntimeConfig; | ||
use itp_api_client_types::PlainTip; | ||
use itp_types::parentchain::Balance; | ||
pub use substrate_api_client::{ | ||
api::Error as ApiClientError, | ||
rpc::{tungstenite_client::TungsteniteRpcClient, Error as RpcClientError}, | ||
Api, | ||
}; | ||
|
||
pub type TargetANodeConfig = ParentchainRuntimeConfig<PlainTip<Balance>>; | ||
pub type TargetAApi = Api<TargetANodeConfig, TungsteniteRpcClient>; | ||
} |
49 changes: 49 additions & 0 deletions
49
app-libs/parentchain-interface/src/target_a/api_factory.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
Copyright 2021 Integritee AG and Supercomputing Systems AG | ||
Copyright (C) 2017-2019 Baidu, Inc. All Rights Reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
use super::api_client_types::TargetATip; | ||
use crate::ParentchainRuntimeConfig; | ||
use itp_api_client_types::{Api, TungsteniteRpcClient}; | ||
use itp_node_api::node_api_factory::{CreateNodeApi, NodeApiFactoryError, Result}; | ||
use sp_core::sr25519; | ||
|
||
/// Node API factory implementation. | ||
pub struct TargetANodeApiFactory { | ||
node_url: String, | ||
signer: sr25519::Pair, | ||
} | ||
|
||
impl TargetANodeApiFactory { | ||
pub fn new(url: String, signer: sr25519::Pair) -> Self { | ||
Self { node_url: url, signer } | ||
} | ||
} | ||
|
||
impl CreateNodeApi<ParentchainRuntimeConfig<TargetATip>, TungsteniteRpcClient> | ||
for TargetANodeApiFactory | ||
{ | ||
fn create_api( | ||
&self, | ||
) -> Result<Api<ParentchainRuntimeConfig<TargetATip>, TungsteniteRpcClient>> { | ||
let rpc_client = TungsteniteRpcClient::new(self.node_url.as_str(), 5) | ||
.map_err(NodeApiFactoryError::FailedToCreateRpcClient)?; | ||
let mut api = Api::new(rpc_client).map_err(NodeApiFactoryError::FailedToCreateNodeApi)?; | ||
api.set_signer(self.signer.clone().into()); | ||
Ok(api) | ||
} | ||
} |
Oops, something went wrong.