Companion for #8615: enrich metadata with type information (#3336)

* Use beefy branch with scale-info

* Add patches

* Sprinkle some TypeInfo derives

* Add some TypeInfo deriv

* Cargo.lock

* Derive TypeInfo and skip type params for Xcm types

* Cargo.lock

* Fix up scale_info bounds attributes

* Fix up dependencies

* Use my own beefy-primitives branch

* Bump BEEFY

* Update patches

* Add some scale-info dependencies and TypeInfo derives

* More TypeInfo decoration

* Update scale-info

* Some TypeInfos and remove more Event pallet::metadata

* Moar TypeInfos

* TypeInfos galore, fix up metadata runtime API

* TypeInfo

* TypeInfos, update other runtime metadata APIs

* Fix up Kusama, comment out some `usize` QueueSize parameter types

* Remove local diener patches

* Cargo.lock

* Cargo.lock

* Update to scale-info crates.io release

* Update primitive-types branch

* Update pallet-beefy to use custom branch

* Update other parity-common deps

* Update parity-common patches

* bump a bunch of deps in parity-common

* Remove parity-common patches

* Bump finality-grandpa version

* Cargo.lock

* Update scale-info to 0.9.1

* Add recursion_limit for runtime-parachains

* Add some scale_info attributes

* Cargo.lock

* Revert finality-grandpa bump

* Cargo.lock, scale-info update

* cargo update

* Make sure using patched version of finality-grandpa

* Use patched scale-info

* Update to scale-info 0.10.0

* Update finality-grandpa

* Cargo.lock

* Update beefy deps

* Update beefy deps again

* Add scale-info dependency

* Remove deprecated pallet::metadata attributes.

* Add some missing scale-info deps and derives

* Use some variant struct call syntax

* Add missing TypeInfo impl

* Add some more TypeInfo impls

* Convert some call enum struct variant constructors

* More scale-info deps and derives

* Call enum struct variants

* TypeInfo derives

* Call enum variant structs

* scale-info deps and derives

* Call enum variant struct constructors

* Use beefy-primitives scale-info feature

* Use grandpa-bridge-gadget master branch

* Remove finality-grandpa patch

* Add missing scale_info dependency and derive

* Fix up some call variant constructors

* Add missing scale_info dependency

* Fix some test errors

* More TypeInfo derives

* More call variant structs

* Call variant structs in tests

* Cargo.lock

* Fmt

* Fix more call struct variants

* Another call struct variant

* add scale-info/std features explicitly

* More call struct variants

* Add missing scale-info dependency

* Fmt

* review: activate scale-info/std where missing

* Remove some duplicate std feature activation

* review: add scale_info bounds() attr

* More call variant structs

* Remove recursion limit

* Update beefy-primitives

* Update beefy-primitives

* Fix simnet call variant struct errors

* Fmt

* cargo update -p beefy-primitives

* Add some missing TypeInfo derives

* Fix some call variants

* Fix some call variant underscores

* Cargo.lock

* Cargo.lock

* Add missing TypeInfo derive

* Add some more missing TypeInfo derives

* Even more missing TypeInfo derives

* Add TypeInfo derives to new xcm types

* Fmt

* Cargo.lock

* Add missing TypeInfo impls

* Cargo.lock

* More missing TypeInfos

* Fixes

* Cargo.lock

* Cargo.lock

* Add TypeInfo impls to xcm v2

* Update to scale-info 1.0

* Update finality-grandpa 0.14.4, patch for now

* Update beefy

* Remove patched finality-grandpa

* Add TypeInfo impl to Outcome

* Fixes

* Call variant struct

* Call variant struct

* Fix test

* Add TypeInfo impl

* Cargo.lock

* Cargo.lock

* Cargo.lock

* git checkout master Cargo.lock

* update Substrate

* Add missing scale-info features for beefy-primitives

* Fmt

* Remove check for now

* Update beefy-primitives, removes scale-info feature

* Update beefy-primitives again

Co-authored-by: adoerr <0xad@gmx.net>
Co-authored-by: Andronik Ordian <write@reusable.software>
Co-authored-by: thiolliere <gui.thiolliere@gmail.com>
Co-authored-by: parity-processbot <>
Co-authored-by: Bastian Köcher <info@kchr.de>
This commit is contained in:
Andrew Jones
2021-09-15 21:38:45 +01:00
committed by GitHub
parent 44d2e9adbd
commit 4c7539cab5
95 changed files with 819 additions and 548 deletions
-16
View File
@@ -269,22 +269,6 @@ build-adder-collator:
#### stage: build
check-transaction-versions:
image: node:15
stage: build
<<: *rules-test
<<: *docker-env
<<: *vault-secrets
needs:
- job: test-build-linux-stable
artifacts: true
before_script:
- apt-get -y update; apt-get -y install jq lsof
- npm install --ignore-scripts -g @polkadot/metadata-cmp
- git fetch origin release
script:
- scripts/gitlab/check_extrinsics_ordering.sh
generate-impl-guide:
stage: build
<<: *rules-test
+252 -167
View File
File diff suppressed because it is too large Load Diff
@@ -465,7 +465,7 @@ impl_runtime_apis! {
impl sp_api::Metadata<Block> for Runtime {
fn metadata() -> OpaqueMetadata {
Runtime::metadata().into()
OpaqueMetadata::new(Runtime::metadata().into())
}
}
@@ -590,7 +590,7 @@ impl_runtime_apis! {
impl sp_api::Metadata<Block> for Runtime {
fn metadata() -> OpaqueMetadata {
Runtime::metadata().into()
OpaqueMetadata::new(Runtime::metadata().into())
}
}
@@ -11,6 +11,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false, features = ["derive"] }
ed25519-dalek = { version = "1.0", default-features = false, optional = true }
hash-db = { version = "0.15.2", default-features = false }
scale-info = { version = "1.0", default-features = false, features = ["derive"] }
# Bridge dependencies
@@ -40,10 +41,12 @@ std = [
"codec/std",
"frame-support/std",
"hash-db/std",
"scale-info/std",
"pallet-bridge-dispatch/std",
"pallet-bridge-grandpa/std",
"pallet-bridge-messages/std",
"pallet-transaction-payment/std",
"scale-info/std",
"sp-core/std",
"sp-runtime/std",
"sp-state-machine/std",
@@ -37,6 +37,7 @@ use frame_support::{
RuntimeDebug,
};
use hash_db::Hasher;
use scale_info::TypeInfo;
use sp_runtime::{
traits::{AtLeast32BitUnsigned, CheckedAdd, CheckedDiv, CheckedMul},
FixedPointNumber, FixedPointOperand, FixedU128,
@@ -200,7 +201,7 @@ pub mod source {
/// - hash of finalized header;
/// - storage proof of inbound lane state;
/// - lane id.
#[derive(Clone, Decode, Encode, Eq, PartialEq, RuntimeDebug)]
#[derive(Clone, Decode, Encode, Eq, PartialEq, RuntimeDebug, TypeInfo)]
pub struct FromBridgedChainMessagesDeliveryProof<BridgedHeaderHash> {
/// Hash of the bridge header the proof is for.
pub bridged_header_hash: BridgedHeaderHash,
@@ -431,7 +432,7 @@ pub mod target {
/// - storage proof of messages and (optionally) outbound lane state;
/// - lane id;
/// - nonces (inclusive range) of messages which are included in this proof.
#[derive(Clone, Decode, Encode, Eq, PartialEq, RuntimeDebug)]
#[derive(Clone, Decode, Encode, Eq, PartialEq, RuntimeDebug, TypeInfo)]
pub struct FromBridgedChainMessagesProof<BridgedHeaderHash> {
/// Hash of the finalized bridged header the proof is for.
pub bridged_header_hash: BridgedHeaderHash,
@@ -9,7 +9,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
[dependencies]
codec = { package = "parity-scale-codec", version = "2.0.0" }
finality-grandpa = "0.14.0"
finality-grandpa = "0.14.4"
hash-db = "0.15.2"
honggfuzz = "0.5.54"
log = "0.4.0"
@@ -8,6 +8,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
[dependencies]
codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false }
scale-info = { version = "1.0", default-features = false, features = ["derive"] }
log = { version = "0.4.14", default-features = false }
# Bridge dependencies
@@ -32,9 +33,11 @@ default = ["std"]
std = [
"bp-message-dispatch/std",
"bp-runtime/std",
"codec/std",
"frame-support/std",
"frame-system/std",
"log/std",
"scale-info/std",
"sp-core/std",
"sp-runtime/std",
"sp-std/std",
+30 -21
View File
@@ -399,6 +399,7 @@ mod tests {
use super::*;
use frame_support::{dispatch::GetDispatchInfo, parameter_types, weights::Weight};
use frame_system::{EventRecord, Phase};
use scale_info::TypeInfo;
use sp_core::H256;
use sp_runtime::{
testing::Header,
@@ -412,7 +413,7 @@ mod tests {
const SOURCE_CHAIN_ID: ChainId = *b"srce";
const TARGET_CHAIN_ID: ChainId = *b"trgt";
#[derive(Debug, Encode, Decode, Clone, PartialEq, Eq)]
#[derive(Debug, Encode, Decode, Clone, PartialEq, Eq, TypeInfo)]
pub struct TestAccountPublic(AccountId);
impl IdentifyAccount for TestAccountPublic {
@@ -423,7 +424,7 @@ mod tests {
}
}
#[derive(Debug, Encode, Decode, Clone, PartialEq, Eq)]
#[derive(Debug, Encode, Decode, Clone, PartialEq, Eq, TypeInfo)]
pub struct TestSignature(AccountId);
impl Verify for TestSignature {
@@ -516,7 +517,7 @@ mod tests {
impl Contains<Call> for TestCallFilter {
fn contains(call: &Call) -> bool {
!matches!(*call, Call::System(frame_system::Call::fill_block(_)))
!matches!(*call, Call::System(frame_system::Call::fill_block { .. }))
}
}
@@ -569,8 +570,9 @@ mod tests {
let id = [0; 4];
const BAD_SPEC_VERSION: SpecVersion = 99;
let mut message =
prepare_root_message(Call::System(<frame_system::Call<TestRuntime>>::remark(vec![1, 2, 3])));
let mut message = prepare_root_message(Call::System(frame_system::Call::<TestRuntime>::remark {
remark: vec![1, 2, 3],
}));
let weight = message.weight;
message.spec_version = BAD_SPEC_VERSION;
@@ -599,7 +601,7 @@ mod tests {
fn should_fail_on_weight_mismatch() {
new_test_ext().execute_with(|| {
let id = [0; 4];
let call = Call::System(<frame_system::Call<TestRuntime>>::remark(vec![1, 2, 3]));
let call = Call::System(frame_system::Call::<TestRuntime>::remark { remark: vec![1, 2, 3] });
let call_weight = call.get_dispatch_info().weight;
let mut message = prepare_root_message(call);
message.weight = 7;
@@ -637,7 +639,7 @@ mod tests {
let call_origin = CallOrigin::TargetAccount(1, TestAccountPublic(1), TestSignature(99));
let message = prepare_message(
call_origin,
Call::System(<frame_system::Call<TestRuntime>>::remark(vec![1, 2, 3])),
Call::System(frame_system::Call::<TestRuntime>::remark { remark: vec![1, 2, 3] }),
);
let weight = message.weight;
@@ -687,8 +689,9 @@ mod tests {
new_test_ext().execute_with(|| {
let id = [0; 4];
let mut message =
prepare_root_message(Call::System(<frame_system::Call<TestRuntime>>::remark(vec![1, 2, 3])));
let mut message = prepare_root_message(Call::System(frame_system::Call::<TestRuntime>::remark {
remark: vec![1, 2, 3],
}));
let weight = message.weight;
message.call.0 = vec![];
@@ -716,7 +719,9 @@ mod tests {
new_test_ext().execute_with(|| {
let id = [0; 4];
let call = Call::System(<frame_system::Call<TestRuntime>>::fill_block(Perbill::from_percent(75)));
let call = Call::System(frame_system::Call::<TestRuntime>::fill_block {
ratio: Perbill::from_percent(75),
});
let weight = call.get_dispatch_info().weight;
let mut message = prepare_root_message(call);
message.weight = weight;
@@ -745,8 +750,9 @@ mod tests {
new_test_ext().execute_with(|| {
let id = [0; 4];
let mut message =
prepare_root_message(Call::System(<frame_system::Call<TestRuntime>>::remark(vec![1, 2, 3])));
let mut message = prepare_root_message(Call::System(frame_system::Call::<TestRuntime>::remark {
remark: vec![1, 2, 3],
}));
let weight = message.weight;
message.dispatch_fee_payment = DispatchFeePayment::AtTargetChain;
@@ -779,8 +785,9 @@ mod tests {
new_test_ext().execute_with(|| {
let id = [0; 4];
let mut message =
prepare_root_message(Call::System(<frame_system::Call<TestRuntime>>::remark(vec![1, 2, 3])));
let mut message = prepare_root_message(Call::System(frame_system::Call::<TestRuntime>::remark {
remark: vec![1, 2, 3],
}));
message.dispatch_fee_payment = DispatchFeePayment::AtTargetChain;
System::set_block_number(1);
@@ -808,7 +815,7 @@ mod tests {
new_test_ext().execute_with(|| {
let id = [0; 4];
let call = Call::System(<frame_system::Call<TestRuntime>>::set_heap_pages(1));
let call = Call::System(frame_system::Call::<TestRuntime>::set_heap_pages { pages: 1 });
let message = prepare_target_message(call);
System::set_block_number(1);
@@ -835,7 +842,9 @@ mod tests {
fn should_dispatch_bridge_message_from_root_origin() {
new_test_ext().execute_with(|| {
let id = [0; 4];
let message = prepare_root_message(Call::System(<frame_system::Call<TestRuntime>>::remark(vec![1, 2, 3])));
let message = prepare_root_message(Call::System(frame_system::Call::<TestRuntime>::remark {
remark: vec![1, 2, 3],
}));
System::set_block_number(1);
let result = Dispatch::dispatch(SOURCE_CHAIN_ID, TARGET_CHAIN_ID, id, Ok(message), |_, _| unreachable!());
@@ -862,7 +871,7 @@ mod tests {
new_test_ext().execute_with(|| {
let id = [0; 4];
let call = Call::System(<frame_system::Call<TestRuntime>>::remark(vec![]));
let call = Call::System(frame_system::Call::<TestRuntime>::remark { remark: vec![] });
let message = prepare_target_message(call);
System::set_block_number(1);
@@ -890,7 +899,7 @@ mod tests {
new_test_ext().execute_with(|| {
let id = [0; 4];
let call = Call::System(<frame_system::Call<TestRuntime>>::remark(vec![]));
let call = Call::System(frame_system::Call::<TestRuntime>::remark { remark: vec![] });
let message = prepare_source_message(call);
System::set_block_number(1);
@@ -915,7 +924,7 @@ mod tests {
#[test]
fn origin_is_checked_when_verifying_sending_message_using_source_root_account() {
let call = Call::System(<frame_system::Call<TestRuntime>>::remark(vec![]));
let call = Call::System(frame_system::Call::<TestRuntime>::remark { remark: vec![] });
let message = prepare_root_message(call);
// When message is sent by Root, CallOrigin::SourceRoot is allowed
@@ -930,7 +939,7 @@ mod tests {
#[test]
fn origin_is_checked_when_verifying_sending_message_using_target_account() {
let call = Call::System(<frame_system::Call<TestRuntime>>::remark(vec![]));
let call = Call::System(frame_system::Call::<TestRuntime>::remark { remark: vec![] });
let message = prepare_target_message(call);
// When message is sent by Root, CallOrigin::TargetAccount is not allowed
@@ -955,7 +964,7 @@ mod tests {
#[test]
fn origin_is_checked_when_verifying_sending_message_using_source_account() {
let call = Call::System(<frame_system::Call<TestRuntime>>::remark(vec![]));
let call = Call::System(frame_system::Call::<TestRuntime>::remark { remark: vec![] });
let message = prepare_source_message(call);
// Sending a message from the expected origin account works
@@ -9,7 +9,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
[dependencies]
codec = { package = "parity-scale-codec", version = "2.0.0" }
ethereum-types = "0.11.0"
finality-grandpa = "0.14.1"
finality-grandpa = "0.14.4"
hex = "0.4"
log = "0.4.14"
+3 -1
View File
@@ -9,9 +9,10 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
[dependencies]
codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false }
finality-grandpa = { version = "0.14.1", default-features = false }
finality-grandpa = { version = "0.14.4", default-features = false }
log = { version = "0.4.14", default-features = false }
num-traits = { version = "0.2", default-features = false }
scale-info = { version = "1.0", default-features = false, features = ["derive"] }
serde = { version = "1.0", optional = true }
# Bridge Dependencies
@@ -47,6 +48,7 @@ std = [
"frame-system/std",
"log/std",
"num-traits/std",
"scale-info/std",
"serde",
"sp-finality-grandpa/std",
"sp-runtime/std",
@@ -11,6 +11,7 @@ bitvec = { version = "0.20", default-features = false, features = ["alloc"] }
codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false }
log = { version = "0.4.14", default-features = false }
num-traits = { version = "0.2", default-features = false }
scale-info = { version = "1.0", default-features = false, features = ["derive"] }
serde = { version = "1.0.101", optional = true, features = ["derive"] }
# Bridge dependencies
@@ -47,6 +48,7 @@ std = [
"frame-system/std",
"log/std",
"num-traits/std",
"scale-info/std",
"serde",
"sp-core/std",
"sp-runtime/std",
@@ -32,6 +32,7 @@ use bp_messages::{
use bp_runtime::{messages::MessageDispatchResult, Size};
use codec::{Decode, Encode};
use frame_support::{parameter_types, weights::Weight};
use scale_info::TypeInfo;
use sp_core::H256;
use sp_runtime::{
testing::Header as SubstrateHeader,
@@ -42,7 +43,7 @@ use std::collections::BTreeMap;
pub type AccountId = u64;
pub type Balance = u64;
#[derive(Decode, Encode, Clone, Debug, PartialEq, Eq)]
#[derive(Decode, Encode, Clone, Debug, PartialEq, Eq, TypeInfo)]
pub struct TestPayload {
/// Field that may be used to identify messages.
pub id: u64,
@@ -138,7 +139,7 @@ parameter_types! {
pub storage TokenConversionRate: FixedU128 = 1.into();
}
#[derive(Debug, Clone, Encode, Decode, PartialEq, Eq)]
#[derive(Debug, Clone, Encode, Decode, PartialEq, Eq, TypeInfo)]
pub enum TestMessagesParameter {
TokenConversionRate(FixedU128),
}
@@ -211,7 +212,7 @@ pub const PAYLOAD_REJECTED_BY_TARGET_CHAIN: TestPayload = message_payload(1, 50)
pub type MessagesByLaneVec = Vec<(LaneId, ProvedLaneMessages<Message<TestMessageFee>>)>;
/// Test messages proof.
#[derive(Debug, Encode, Decode, Clone, PartialEq, Eq)]
#[derive(Debug, Encode, Decode, Clone, PartialEq, Eq, TypeInfo)]
pub struct TestMessagesProof {
pub result: Result<MessagesByLaneVec, ()>,
}
@@ -242,7 +243,7 @@ impl From<Result<Vec<Message<TestMessageFee>>, ()>> for TestMessagesProof {
}
/// Messages delivery proof used in tests.
#[derive(Debug, Encode, Decode, Eq, Clone, PartialEq)]
#[derive(Debug, Encode, Decode, Eq, Clone, PartialEq, TypeInfo)]
pub struct TestMessagesDeliveryProof(pub Result<(LaneId, InboundLaneData<TestRelayer>), ()>);
impl Size for TestMessagesDeliveryProof {
@@ -16,7 +16,7 @@ fixed-hash = { version = "0.7.0", default-features = false }
hash256-std-hasher = { version = "0.15.2", default-features = false }
impl-codec = { version = "0.5.1", default-features = false }
impl-serde = { version = "0.3.1", optional = true }
parity-util-mem = { version = "0.9.0", default-features = false, features = ["primitive-types"] }
parity-util-mem = { version = "0.10.0", default-features = false, features = ["primitive-types"] }
serde = { version = "1.0.101", optional = true, features = ["derive"] }
# Substrate Based Dependencies
@@ -8,7 +8,8 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
[dependencies]
codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false }
finality-grandpa = { version = "0.14.1", default-features = false }
finality-grandpa = { version = "0.14.4", default-features = false }
scale-info = { version = "1.0", default-features = false, features = ["derive"] }
serde = { version = "1.0", optional = true }
# Substrate Dependencies
@@ -28,6 +29,7 @@ default = ["std"]
std = [
"codec/std",
"finality-grandpa/std",
"scale-info/std",
"serde/std",
"frame-support/std",
"sp-core/std",
@@ -22,6 +22,7 @@
use codec::{Decode, Encode};
use finality_grandpa::voter_set::VoterSet;
use frame_support::RuntimeDebug;
use scale_info::TypeInfo;
use sp_finality_grandpa::{AuthorityId, AuthoritySignature, SetId};
use sp_runtime::traits::Header as HeaderT;
use sp_std::collections::{btree_map::BTreeMap, btree_set::BTreeSet};
@@ -32,7 +33,7 @@ use sp_std::prelude::*;
///
/// This particular proof is used to prove that headers on a bridged chain
/// (so not our chain) have been finalized correctly.
#[derive(Encode, Decode, RuntimeDebug, Clone, PartialEq, Eq)]
#[derive(Encode, Decode, RuntimeDebug, Clone, PartialEq, Eq, TypeInfo)]
pub struct GrandpaJustification<Header: HeaderT> {
/// The round (voting period) this justification is valid for.
pub round: u64,
@@ -24,6 +24,7 @@ use core::clone::Clone;
use core::cmp::Eq;
use core::default::Default;
use core::fmt::Debug;
use scale_info::TypeInfo;
#[cfg(feature = "std")]
use serde::{Deserialize, Serialize};
use sp_finality_grandpa::{AuthorityList, ConsensusLog, SetId, GRANDPA_ENGINE_ID};
@@ -39,7 +40,7 @@ pub trait Parameter: Codec + EncodeLike + Clone + Eq + Debug {}
impl<T> Parameter for T where T: Codec + EncodeLike + Clone + Eq + Debug {}
/// A GRANDPA Authority List and ID.
#[derive(Default, Encode, Decode, RuntimeDebug, PartialEq, Clone)]
#[derive(Default, Encode, Decode, RuntimeDebug, PartialEq, Clone, TypeInfo)]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
pub struct AuthoritySet {
/// List of GRANDPA authorities for the current round.
@@ -58,7 +59,7 @@ impl AuthoritySet {
/// Data required for initializing the bridge pallet.
///
/// The bridge needs to know where to start its sync from, and this provides that initial context.
#[derive(Default, Encode, Decode, RuntimeDebug, PartialEq, Eq, Clone)]
#[derive(Default, Encode, Decode, RuntimeDebug, PartialEq, Eq, Clone, TypeInfo)]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
pub struct InitializationData<H: HeaderT> {
/// The header from which we should start syncing.
@@ -9,6 +9,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
[dependencies]
bp-runtime = { path = "../runtime", default-features = false }
codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false }
scale-info = { version = "1.0", default-features = false, features = ["derive"] }
# Substrate Dependencies
@@ -21,5 +22,6 @@ std = [
"bp-runtime/std",
"codec/std",
"frame-support/std",
"scale-info/std",
"sp-std/std",
]
@@ -25,6 +25,7 @@ use bp_runtime::{
};
use codec::{Decode, Encode};
use frame_support::RuntimeDebug;
use scale_info::TypeInfo;
use sp_std::prelude::*;
/// Message dispatch weight.
@@ -71,7 +72,7 @@ pub trait MessageDispatch<AccountId, MessageId> {
/// The source chain can (and should) verify that the message can be dispatched on the target chain
/// with a particular origin given the source chain's origin. This can be done with the
/// `verify_message_origin()` function.
#[derive(RuntimeDebug, Encode, Decode, Clone, PartialEq, Eq)]
#[derive(RuntimeDebug, Encode, Decode, Clone, PartialEq, Eq, TypeInfo)]
pub enum CallOrigin<SourceChainAccountId, TargetChainAccountPublic, TargetChainSignature> {
/// Call is sent by the Root origin on the source chain. On the target chain it is dispatched
/// from a derived account.
@@ -111,7 +112,7 @@ pub enum CallOrigin<SourceChainAccountId, TargetChainAccountPublic, TargetChainS
}
/// Message payload type used by dispatch module.
#[derive(RuntimeDebug, Encode, Decode, Clone, PartialEq, Eq)]
#[derive(RuntimeDebug, Encode, Decode, Clone, PartialEq, Eq, TypeInfo)]
pub struct MessagePayload<SourceChainAccountId, TargetChainAccountPublic, TargetChainSignature, Call> {
/// Runtime specification version. We only dispatch messages that have the same
/// runtime version. Otherwise we risk to misinterpret encoded calls.
@@ -10,6 +10,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
bitvec = { version = "0.20", default-features = false, features = ["alloc"] }
codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false, features = ["derive", "bit-vec"] }
impl-trait-for-tuples = "0.2"
scale-info = { version = "1.0", default-features = false, features = ["derive"] }
serde = { version = "1.0.101", optional = true, features = ["derive"] }
# Bridge dependencies
@@ -29,6 +30,7 @@ std = [
"codec/std",
"frame-support/std",
"frame-system/std",
"scale-info/std",
"serde",
"sp-std/std"
"sp-std/std",
]
@@ -26,6 +26,7 @@ use bitvec::prelude::*;
use bp_runtime::messages::DispatchFeePayment;
use codec::{Decode, Encode};
use frame_support::RuntimeDebug;
use scale_info::TypeInfo;
use sp_std::{collections::vec_deque::VecDeque, prelude::*};
pub mod source_chain;
@@ -35,7 +36,7 @@ pub mod target_chain;
pub use frame_support::weights::Weight;
/// Messages pallet operating mode.
#[derive(Encode, Decode, Clone, Copy, PartialEq, Eq, RuntimeDebug)]
#[derive(Encode, Decode, Clone, Copy, PartialEq, Eq, RuntimeDebug, TypeInfo)]
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))]
pub enum OperatingMode {
/// Normal mode, when all operations are allowed.
@@ -81,7 +82,7 @@ pub type MessageId = (LaneId, MessageNonce);
pub type MessagePayload = Vec<u8>;
/// Message key (unique message identifier) as it is stored in the storage.
#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug)]
#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo)]
pub struct MessageKey {
/// ID of the message lane.
pub lane_id: LaneId,
@@ -90,7 +91,7 @@ pub struct MessageKey {
}
/// Message data as it is stored in the storage.
#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug)]
#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo)]
pub struct MessageData<Fee> {
/// Message payload.
pub payload: MessagePayload,
@@ -99,7 +100,7 @@ pub struct MessageData<Fee> {
}
/// Message as it is stored in the storage.
#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug)]
#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo)]
pub struct Message<Fee> {
/// Message key.
pub key: MessageKey,
@@ -108,7 +109,7 @@ pub struct Message<Fee> {
}
/// Inbound lane data.
#[derive(Encode, Decode, Clone, RuntimeDebug, PartialEq, Eq)]
#[derive(Encode, Decode, Clone, RuntimeDebug, PartialEq, Eq, TypeInfo)]
pub struct InboundLaneData<RelayerId> {
/// Identifiers of relayers and messages that they have delivered to this lane (ordered by message nonce).
///
@@ -195,7 +196,7 @@ pub type DispatchResultsBitVec = BitVec<Msb0, u8>;
///
/// This struct represents a continuous range of messages that have been delivered by the same relayer
/// and whose confirmations are still pending.
#[derive(Encode, Decode, Clone, RuntimeDebug, PartialEq, Eq)]
#[derive(Encode, Decode, Clone, RuntimeDebug, PartialEq, Eq, TypeInfo)]
pub struct UnrewardedRelayer<RelayerId> {
/// Identifier of the relayer.
pub relayer: RelayerId,
@@ -204,7 +205,7 @@ pub struct UnrewardedRelayer<RelayerId> {
}
/// Delivered messages with their dispatch result.
#[derive(Clone, Default, Encode, Decode, RuntimeDebug, PartialEq, Eq)]
#[derive(Clone, Default, Encode, Decode, RuntimeDebug, PartialEq, Eq, TypeInfo)]
pub struct DeliveredMessages {
/// Nonce of the first message that has been delivered (inclusive).
pub begin: MessageNonce,
@@ -254,7 +255,7 @@ impl DeliveredMessages {
}
/// Gist of `InboundLaneData::relayers` field used by runtime APIs.
#[derive(Clone, Default, Encode, Decode, RuntimeDebug, PartialEq, Eq)]
#[derive(Clone, Default, Encode, Decode, RuntimeDebug, PartialEq, Eq, TypeInfo)]
pub struct UnrewardedRelayersState {
/// Number of entries in the `InboundLaneData::relayers` set.
pub unrewarded_relayer_entries: MessageNonce,
@@ -266,7 +267,7 @@ pub struct UnrewardedRelayersState {
}
/// Outbound lane data.
#[derive(Encode, Decode, Clone, RuntimeDebug, PartialEq, Eq)]
#[derive(Encode, Decode, Clone, RuntimeDebug, PartialEq, Eq, TypeInfo)]
pub struct OutboundLaneData {
/// Nonce of oldest message that we haven't yet pruned. May point to not-yet-generated message if
/// all sent messages are already pruned.
@@ -21,13 +21,14 @@ use crate::{LaneId, Message, MessageData, MessageKey, OutboundLaneData};
use bp_runtime::{messages::MessageDispatchResult, Size};
use codec::{Decode, Encode, Error as CodecError};
use frame_support::{weights::Weight, Parameter, RuntimeDebug};
use scale_info::TypeInfo;
use sp_std::{collections::btree_map::BTreeMap, fmt::Debug, prelude::*};
/// Proved messages from the source chain.
pub type ProvedMessages<Message> = BTreeMap<LaneId, ProvedLaneMessages<Message>>;
/// Proved messages from single lane of the source chain.
#[derive(RuntimeDebug, Encode, Decode, Clone, PartialEq, Eq)]
#[derive(RuntimeDebug, Encode, Decode, Clone, PartialEq, Eq, TypeInfo)]
pub struct ProvedLaneMessages<Message> {
/// Optional outbound lane state.
pub lane_state: Option<OutboundLaneData>,
@@ -8,6 +8,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
[dependencies]
parity-scale-codec = { version = "2.0.0", default-features = false, features = ["derive"] }
scale-info = { version = "1.0", default-features = false, features = ["derive"] }
# Bridge Dependencies
@@ -35,6 +36,7 @@ std = [
"frame-support/std",
"frame-system/std",
"parity-scale-codec/std",
"scale-info/std",
"sp-api/std",
"sp-core/std",
"sp-runtime/std",
@@ -213,7 +213,7 @@ pub type AdditionalSigned = (u32, u32, Hash, Hash, (), (), ());
/// A simplified version of signed extensions meant for producing signed transactions
/// and signed payload in the client code.
#[derive(PartialEq, Eq, Clone, RuntimeDebug)]
#[derive(PartialEq, Eq, Clone, RuntimeDebug, scale_info::TypeInfo)]
pub struct SignedExtensions<Call> {
encode_payload: SignedExtra,
additional_signed: AdditionalSigned,
@@ -266,7 +266,14 @@ impl<Call> SignedExtensions<Call> {
impl<Call> sp_runtime::traits::SignedExtension for SignedExtensions<Call>
where
Call: parity_scale_codec::Codec + sp_std::fmt::Debug + Sync + Send + Clone + Eq + PartialEq,
Call: parity_scale_codec::Codec
+ sp_std::fmt::Debug
+ Sync
+ Send
+ Clone
+ Eq
+ PartialEq
+ scale_info::StaticTypeInfo,
Call: Dispatchable,
{
const IDENTIFIER: &'static str = "Not needed.";
@@ -10,6 +10,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false }
hash-db = { version = "0.15.2", default-features = false }
num-traits = { version = "0.2", default-features = false }
scale-info = { version = "1.0", default-features = false, features = ["derive"] }
# Substrate Dependencies
@@ -32,6 +33,7 @@ std = [
"frame-support/std",
"hash-db/std",
"num-traits/std",
"scale-info/std",
"sp-core/std",
"sp-io/std",
"sp-runtime/std",
@@ -18,9 +18,10 @@
use codec::{Decode, Encode};
use frame_support::{weights::Weight, RuntimeDebug};
use scale_info::TypeInfo;
/// Where message dispatch fee is paid?
#[derive(Encode, Decode, RuntimeDebug, Clone, Copy, PartialEq, Eq)]
#[derive(Encode, Decode, RuntimeDebug, Clone, Copy, PartialEq, Eq, TypeInfo)]
pub enum DispatchFeePayment {
/// The dispacth fee is paid at the source chain.
AtSourceChain,
@@ -34,7 +35,7 @@ pub enum DispatchFeePayment {
}
/// Message dispatch result.
#[derive(Encode, Decode, RuntimeDebug, Clone, PartialEq, Eq)]
#[derive(Encode, Decode, RuntimeDebug, Clone, PartialEq, Eq, TypeInfo)]
pub struct MessageDispatchResult {
/// Dispatch result flag. This flag is relayed back to the source chain and, generally
/// speaking, may bring any (that fits in single bit) information from the dispatcher at
@@ -9,7 +9,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
bp-header-chain = { path = "../header-chain", default-features = false }
codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false }
ed25519-dalek = { version = "1.0", default-features = false, features = ["u64_backend"] }
finality-grandpa = { version = "0.14.1", default-features = false }
finality-grandpa = { version = "0.14.4", default-features = false }
sp-application-crypto = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-finality-grandpa = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
@@ -32,7 +32,7 @@ bp-wococo = { path = "../../primitives/chain-wococo" }
bp-runtime = { path = "../../primitives/runtime" }
bp-westend = { path = "../../primitives/chain-westend" }
bridge-runtime-common = { path = "../../bin/runtime-common" }
finality-grandpa = { version = "0.14.1" }
finality-grandpa = { version = "0.14.1", }
finality-relay = { path = "../finality" }
headers-relay = { path = "../headers" }
messages-relay = { path = "../messages" }
+3
View File
@@ -8,15 +8,18 @@ edition = "2018"
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-std = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
scale-info = { version = "1.0", default-features = false, features = ["derive"] }
parity-scale-codec = { version = "2.0.0", default-features = false, features = [ "derive" ] }
parity-util-mem = { version = "0.10.0", default-features = false, optional = true }
[features]
default = [ "std" ]
std = [
"scale-info/std",
"sp-core/std",
"sp-runtime/std",
"sp-std/std",
"scale-info/std",
"parity-scale-codec/std",
"parity-util-mem",
]
+5 -4
View File
@@ -23,6 +23,7 @@
use parity_scale_codec::{Decode, Encode};
#[cfg(feature = "std")]
use parity_util_mem::MallocSizeOf;
use scale_info::TypeInfo;
use sp_runtime::{
generic,
traits::{IdentifyAccount, Verify},
@@ -64,7 +65,7 @@ pub type Hash = sp_core::H256;
/// This type is produced by [`CandidateReceipt::hash`].
///
/// This type makes it easy to enforce that a hash is a candidate hash on the type level.
#[derive(Clone, Copy, Encode, Decode, Hash, Eq, PartialEq, Default, PartialOrd, Ord)]
#[derive(Clone, Copy, Encode, Decode, Hash, Eq, PartialEq, Default, PartialOrd, Ord, TypeInfo)]
#[cfg_attr(feature = "std", derive(MallocSizeOf))]
pub struct CandidateHash(pub Hash);
@@ -117,7 +118,7 @@ pub type DownwardMessage = sp_std::vec::Vec<u8>;
/// A wrapped version of `DownwardMessage`. The difference is that it has attached the block number when
/// the message was sent.
#[derive(Encode, Decode, Clone, sp_runtime::RuntimeDebug, PartialEq)]
#[derive(Encode, Decode, Clone, sp_runtime::RuntimeDebug, PartialEq, TypeInfo)]
#[cfg_attr(feature = "std", derive(MallocSizeOf))]
pub struct InboundDownwardMessage<BlockNumber = crate::BlockNumber> {
/// The block number at which these messages were put into the downward message queue.
@@ -127,7 +128,7 @@ pub struct InboundDownwardMessage<BlockNumber = crate::BlockNumber> {
}
/// An HRMP message seen from the perspective of a recipient.
#[derive(Encode, Decode, Clone, sp_runtime::RuntimeDebug, PartialEq)]
#[derive(Encode, Decode, Clone, sp_runtime::RuntimeDebug, PartialEq, TypeInfo)]
#[cfg_attr(feature = "std", derive(MallocSizeOf))]
pub struct InboundHrmpMessage<BlockNumber = crate::BlockNumber> {
/// The block number at which this message was sent.
@@ -139,7 +140,7 @@ pub struct InboundHrmpMessage<BlockNumber = crate::BlockNumber> {
}
/// An HRMP message seen from the perspective of a sender.
#[derive(Encode, Decode, Clone, sp_runtime::RuntimeDebug, PartialEq, Eq, Hash)]
#[derive(Encode, Decode, Clone, sp_runtime::RuntimeDebug, PartialEq, Eq, Hash, TypeInfo)]
#[cfg_attr(feature = "std", derive(MallocSizeOf))]
pub struct OutboundHrmpMessage<Id> {
/// The para that will get this message in its downward message queue.
@@ -138,7 +138,7 @@ where
let proposal_hash = {
// note the call (pre-image?) of the call.
node.submit_extrinsic(
DemocracyCall::note_preimage(call.into().encode()),
DemocracyCall::note_preimage { encoded_proposal: call.into().encode() },
Some(whales[0].clone()),
)
.await?;
@@ -161,15 +161,16 @@ where
// submit external_propose call through council collective
{
let external_propose =
DemocracyCall::external_propose_majority(proposal_hash.clone().into());
let external_propose = DemocracyCall::external_propose_majority {
proposal_hash: proposal_hash.clone().into(),
};
let length = external_propose.using_encoded(|x| x.len()) as u32 + 1;
let weight = Weight::MAX / 100_000_000;
let proposal = CouncilCollectiveCall::propose(
council_collective.len() as u32,
Box::new(external_propose.clone().into()),
length,
);
let proposal = CouncilCollectiveCall::propose {
threshold: council_collective.len() as u32,
proposal: Box::new(external_propose.clone().into()),
length_bound: length,
};
node.submit_extrinsic(proposal.clone(), Some(council_collective[0].clone()))
.await?;
@@ -191,13 +192,18 @@ where
// vote
for member in &council_collective[1..] {
let call = CouncilCollectiveCall::vote(hash.clone(), index, true);
let call = CouncilCollectiveCall::vote { proposal: hash.clone(), index, approve: true };
node.submit_extrinsic(call, Some(member.clone())).await?;
}
node.seal_blocks(1).await;
// close vote
let call = CouncilCollectiveCall::close(hash, index, weight, length);
let call = CouncilCollectiveCall::close {
proposal_hash: hash,
index,
proposal_weight_bound: weight,
length_bound: length,
};
node.submit_extrinsic(call, Some(council_collective[0].clone())).await?;
node.seal_blocks(1).await;
@@ -227,15 +233,18 @@ where
// next technical collective must fast track the proposal.
{
let fast_track =
DemocracyCall::fast_track(proposal_hash.into(), FastTrackVotingPeriod::get(), 0);
let fast_track = DemocracyCall::fast_track {
proposal_hash: proposal_hash.into(),
voting_period: FastTrackVotingPeriod::get(),
delay: 0,
};
let weight = Weight::MAX / 100_000_000;
let length = fast_track.using_encoded(|x| x.len()) as u32 + 1;
let proposal = TechnicalCollectiveCall::propose(
technical_collective.len() as u32,
Box::new(fast_track.into()),
length,
);
let proposal = TechnicalCollectiveCall::propose {
threshold: technical_collective.len() as u32,
proposal: Box::new(fast_track.into()),
length_bound: length,
};
node.submit_extrinsic(proposal, Some(technical_collective[0].clone())).await?;
node.seal_blocks(1).await;
@@ -259,13 +268,19 @@ where
// vote
for member in &technical_collective[1..] {
let call = TechnicalCollectiveCall::vote(hash.clone(), index, true);
let call =
TechnicalCollectiveCall::vote { proposal: hash.clone(), index, approve: true };
node.submit_extrinsic(call, Some(member.clone())).await?;
}
node.seal_blocks(1).await;
// close vote
let call = TechnicalCollectiveCall::close(hash, index, weight, length);
let call = CouncilCollectiveCall::close {
proposal_hash: hash,
index,
proposal_weight_bound: weight,
length_bound: length,
};
node.submit_extrinsic(call, Some(technical_collective[0].clone())).await?;
node.seal_blocks(1).await;
@@ -309,14 +324,14 @@ where
format!("democracy::Event::Started not found in events: {:#?}", node.events())
})?;
let call = DemocracyCall::vote(
let call = DemocracyCall::vote {
ref_index,
AccountVote::Standard {
vote: AccountVote::Standard {
vote: Vote { aye: true, conviction: Conviction::Locked1x },
// 10 DOTS
balance: 10_000_000_000_000,
},
);
};
for whale in whales {
node.submit_extrinsic(call.clone(), Some(whale)).await?;
}
@@ -404,9 +419,12 @@ mod tests {
node.seal_blocks(1).await;
// submit extrinsics
let alice = MultiSigner::from(Alice.public()).into_account();
node.submit_extrinsic(system::Call::remark((b"hello world").to_vec()), Some(alice))
.await
.unwrap();
node.submit_extrinsic(
system::Call::remark { remark: (b"hello world").to_vec() },
Some(alice),
)
.await
.unwrap();
// look ma, I can read state.
let _events = node.with_state(|| system::Pallet::<Runtime>::events());
@@ -35,7 +35,7 @@ fn main() -> Result<(), Box<dyn Error>> {
.ok_or("Polkadot development wasm not available")?
.to_vec();
// upgrade runtime.
dispatch_with_root(system::Call::set_code(wasm_binary), &node).await?;
dispatch_with_root(system::Call::set_code { code: wasm_binary }, &node).await?;
// assert that the runtime has been updated by looking at events
let events = node
@@ -74,8 +74,11 @@ fn main() -> Result<(), Box<dyn Error>> {
);
// post upgrade tests, a simple balance transfer
node.submit_extrinsic(balances::Call::transfer(dest.into(), balance), Some(from))
.await?;
node.submit_extrinsic(
balances::Call::transfer { dest: dest.into(), value: balance },
Some(from),
)
.await?;
node.seal_blocks(1).await;
let events = node
+7 -7
View File
@@ -286,16 +286,16 @@ impl PolkadotTestNode {
validation_code: impl Into<ValidationCode>,
genesis_head: impl Into<HeadData>,
) -> Result<(), RpcTransactionError> {
let call = ParasSudoWrapperCall::sudo_schedule_para_initialize(
let call = ParasSudoWrapperCall::sudo_schedule_para_initialize {
id,
ParaGenesisArgs {
genesis: ParaGenesisArgs {
genesis_head: genesis_head.into(),
validation_code: validation_code.into(),
parachain: true,
},
);
};
self.send_extrinsic(SudoCall::sudo(Box::new(call.into())), Sr25519Keyring::Alice)
self.send_extrinsic(SudoCall::sudo { call: Box::new(call.into()) }, Sr25519Keyring::Alice)
.await
.map(drop)
}
@@ -377,10 +377,10 @@ pub fn construct_transfer_extrinsic(
dest: sp_keyring::AccountKeyring,
value: Balance,
) -> UncheckedExtrinsic {
let function = polkadot_test_runtime::Call::Balances(pallet_balances::Call::transfer(
MultiSigner::from(dest.public()).into_account().into(),
let function = polkadot_test_runtime::Call::Balances(pallet_balances::Call::transfer {
dest: MultiSigner::from(dest.public()).into_account().into(),
value,
));
});
construct_extrinsic(client, function, origin, 0)
}
@@ -22,10 +22,10 @@ async fn call_function_actually_work() {
let alice =
run_validator_node(tokio::runtime::Handle::current(), Alice, || {}, Vec::new(), None);
let function = polkadot_test_runtime::Call::Balances(pallet_balances::Call::transfer(
Default::default(),
1,
));
let function = polkadot_test_runtime::Call::Balances(pallet_balances::Call::transfer {
dest: Default::default(),
value: 1,
});
let output = alice.send_extrinsic(function, Bob).await.unwrap();
let res = output.result.expect("return value expected");
+2
View File
@@ -11,6 +11,7 @@ edition = "2018"
# various unnecessary Substrate-specific endpoints.
parity-scale-codec = { version = "2.0.0", default-features = false, features = [ "derive" ] }
parity-util-mem = { version = "0.10.0", optional = true }
scale-info = { version = "1.0", default-features = false, features = ["derive"] }
sp-std = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
@@ -26,6 +27,7 @@ default = ["std"]
wasm-api = []
std = [
"parity-scale-codec/std",
"scale-info/std",
"serde/std",
"sp-std/std",
"sp-runtime/std",
+13 -7
View File
@@ -21,6 +21,7 @@ use sp_std::vec::Vec;
use frame_support::weights::Weight;
use parity_scale_codec::{CompactAs, Decode, Encode};
use scale_info::TypeInfo;
use sp_core::{RuntimeDebug, TypeId};
use sp_runtime::traits::Hash as _;
@@ -40,7 +41,7 @@ pub use polkadot_core_primitives::BlockNumber as RelayChainBlockNumber;
/// Parachain head data included in the chain.
#[derive(
PartialEq, Eq, Clone, PartialOrd, Ord, Encode, Decode, RuntimeDebug, derive_more::From,
PartialEq, Eq, Clone, PartialOrd, Ord, Encode, Decode, RuntimeDebug, derive_more::From, TypeInfo,
)]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize, Default, Hash, MallocSizeOf))]
pub struct HeadData(#[cfg_attr(feature = "std", serde(with = "bytes"))] pub Vec<u8>);
@@ -53,7 +54,9 @@ impl HeadData {
}
/// Parachain validation code.
#[derive(Default, PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug, derive_more::From)]
#[derive(
Default, PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug, derive_more::From, TypeInfo,
)]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize, Hash, MallocSizeOf))]
pub struct ValidationCode(#[cfg_attr(feature = "std", serde(with = "bytes"))] pub Vec<u8>);
@@ -69,7 +72,7 @@ impl ValidationCode {
/// This type is produced by [`ValidationCode::hash`].
///
/// This type makes it easy to enforce that a hash is a validation code hash on the type level.
#[derive(Clone, Copy, Encode, Decode, Default, Hash, Eq, PartialEq, PartialOrd, Ord)]
#[derive(Clone, Copy, Encode, Decode, Default, Hash, Eq, PartialEq, PartialOrd, Ord, TypeInfo)]
#[cfg_attr(feature = "std", derive(MallocSizeOf))]
pub struct ValidationCodeHash(Hash);
@@ -112,7 +115,7 @@ impl sp_std::fmt::LowerHex for ValidationCodeHash {
/// Parachain block data.
///
/// Contains everything required to validate para-block, may contain block and witness data.
#[derive(PartialEq, Eq, Clone, Encode, Decode, derive_more::From)]
#[derive(PartialEq, Eq, Clone, Encode, Decode, derive_more::From, TypeInfo)]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize, Debug, MallocSizeOf))]
pub struct BlockData(#[cfg_attr(feature = "std", serde(with = "bytes"))] pub Vec<u8>);
@@ -130,6 +133,7 @@ pub struct BlockData(#[cfg_attr(feature = "std", serde(with = "bytes"))] pub Vec
PartialEq,
PartialOrd,
RuntimeDebug,
TypeInfo,
)]
#[cfg_attr(
feature = "std",
@@ -227,7 +231,9 @@ impl sp_std::ops::Sub<u32> for Id {
}
}
#[derive(Clone, Copy, Default, Encode, Decode, Eq, PartialEq, Ord, PartialOrd, RuntimeDebug)]
#[derive(
Clone, Copy, Default, Encode, Decode, Eq, PartialEq, Ord, PartialOrd, RuntimeDebug, TypeInfo,
)]
pub struct Sibling(pub Id);
impl From<Id> for Sibling {
@@ -330,7 +336,7 @@ impl<T: Encode + Decode + Default> AccountIdConversion<T> for Id {
/// is allowed between two participants in one direction, i.e. there cannot be 2 different channels
/// identified by `(A, B)`. A channel with the same para id in sender and recipient is invalid. That
/// is, however, not enforced.
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Encode, Decode, RuntimeDebug)]
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Encode, Decode, RuntimeDebug, TypeInfo)]
#[cfg_attr(feature = "std", derive(Hash))]
pub struct HrmpChannelId {
/// The para that acts as the sender in this channel.
@@ -370,7 +376,7 @@ impl DmpMessageHandler for () {
}
/// The aggregate XCMP message format.
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode)]
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, TypeInfo)]
pub enum XcmpMessageFormat {
/// Encoded `VersionedXcm` messages, all concatenated.
ConcatenatedVersionedXcm,
+2
View File
@@ -6,6 +6,7 @@ edition = "2018"
[dependencies]
serde = { version = "1.0.130", optional = true, features = ["derive"] }
scale-info = { version = "1.0", default-features = false, features = ["bit-vec", "derive"] }
parity-scale-codec = { version = "2.0.0", default-features = false, features = ["bit-vec", "derive"] }
primitives = { package = "sp-core", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
inherents = { package = "sp-inherents", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
@@ -34,6 +35,7 @@ default = ["std"]
std = [
"application-crypto/std",
"parity-scale-codec/std",
"scale-info/std",
"primitives/std",
"inherents/std",
"trie/std",
+19 -18
View File
@@ -23,6 +23,7 @@ use bitvec::vec::BitVec;
use parity_scale_codec::{Decode, Encode};
#[cfg(feature = "std")]
use parity_util_mem::{MallocSizeOf, MallocSizeOfOps};
use scale_info::TypeInfo;
#[cfg(feature = "std")]
use serde::{Deserialize, Serialize};
@@ -106,7 +107,7 @@ impl MallocSizeOf for ValidatorId {
}
/// Index of the validator is used as a lightweight replacement of the `ValidatorId` when appropriate.
#[derive(Eq, Ord, PartialEq, PartialOrd, Copy, Clone, Encode, Decode)]
#[derive(Eq, Ord, PartialEq, PartialOrd, Copy, Clone, Encode, Decode, TypeInfo)]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize, Debug, Hash, MallocSizeOf))]
pub struct ValidatorIndex(pub u32);
@@ -139,7 +140,7 @@ impl MallocSizeOf for ValidatorSignature {
}
/// Retriability for a given active para.
#[derive(Clone, Eq, PartialEq, Encode, Decode)]
#[derive(Clone, Eq, PartialEq, Encode, Decode, TypeInfo)]
#[cfg_attr(feature = "std", derive(Debug))]
pub enum Retriable {
/// Ineligible for retry. This means it's either a parachain that is always scheduled anyway or
@@ -205,7 +206,7 @@ impl SwapAux for () {
}
/// Identifier for a chain, either one of a number of parachains or the relay chain.
#[derive(Copy, Clone, PartialEq, Encode, Decode)]
#[derive(Copy, Clone, PartialEq, Encode, Decode, TypeInfo)]
#[cfg_attr(feature = "std", derive(Debug))]
pub enum Chain {
/// The relay chain.
@@ -215,7 +216,7 @@ pub enum Chain {
}
/// The duty roster specifying what jobs each validator must do.
#[derive(Clone, PartialEq, Encode, Decode)]
#[derive(Clone, PartialEq, Encode, Decode, TypeInfo)]
#[cfg_attr(feature = "std", derive(Default, Debug))]
pub struct DutyRoster {
/// Lookup from validator index to chain on which that validator has a duty to validate.
@@ -226,7 +227,7 @@ pub struct DutyRoster {
/// to fully validate the candidate.
///
/// These are global parameters that apply to all parachain candidates in a block.
#[derive(PartialEq, Eq, Clone, Encode, Decode)]
#[derive(PartialEq, Eq, Clone, Encode, Decode, TypeInfo)]
#[cfg_attr(feature = "std", derive(Debug, Default))]
pub struct GlobalValidationData<N = BlockNumber> {
/// The maximum code size permitted, in bytes.
@@ -239,7 +240,7 @@ pub struct GlobalValidationData<N = BlockNumber> {
/// Extra data that is needed along with the other fields in a `CandidateReceipt`
/// to fully validate the candidate. These fields are parachain-specific.
#[derive(PartialEq, Eq, Clone, Encode, Decode)]
#[derive(PartialEq, Eq, Clone, Encode, Decode, TypeInfo)]
#[cfg_attr(feature = "std", derive(Debug, Default))]
pub struct LocalValidationData<N = BlockNumber> {
/// The parent head-data.
@@ -261,7 +262,7 @@ pub struct LocalValidationData<N = BlockNumber> {
}
/// Commitments made in a `CandidateReceipt`. Many of these are outputs of validation.
#[derive(PartialEq, Eq, Clone, Encode, Decode)]
#[derive(PartialEq, Eq, Clone, Encode, Decode, TypeInfo)]
#[cfg_attr(feature = "std", derive(Debug, Default))]
pub struct CandidateCommitments<H = Hash> {
/// Fees paid from the chain to the relay chain validators.
@@ -310,7 +311,7 @@ fn check_collator_signature<H: AsRef<[u8]>>(
}
/// All data pertaining to the execution of a parachain candidate.
#[derive(PartialEq, Eq, Clone, Encode, Decode)]
#[derive(PartialEq, Eq, Clone, Encode, Decode, TypeInfo)]
#[cfg_attr(feature = "std", derive(Debug, Default))]
pub struct CandidateReceipt<H = Hash, N = BlockNumber> {
/// The ID of the parachain this is a candidate for.
@@ -395,7 +396,7 @@ impl Ord for CandidateReceipt {
/// All the data which is omitted in an `AbridgedCandidateReceipt`, but that
/// is necessary for validation of the parachain candidate.
#[derive(PartialEq, Eq, Clone, Encode, Decode)]
#[derive(PartialEq, Eq, Clone, Encode, Decode, TypeInfo)]
#[cfg_attr(feature = "std", derive(Debug, Default))]
pub struct OmittedValidationData<N = BlockNumber> {
/// The global validation schedule.
@@ -409,7 +410,7 @@ pub struct OmittedValidationData<N = BlockNumber> {
/// Much info in a candidate-receipt is duplicated from the relay-chain state.
/// When submitting to the relay-chain, this data should be omitted as it can
/// be re-generated from relay-chain state.
#[derive(PartialEq, Eq, Clone, Encode, Decode)]
#[derive(PartialEq, Eq, Clone, Encode, Decode, TypeInfo)]
#[cfg_attr(feature = "std", derive(Debug, Default))]
pub struct AbridgedCandidateReceipt<H = Hash> {
/// The ID of the parachain this is a candidate for.
@@ -544,7 +545,7 @@ impl Ord for AbridgedCandidateReceipt {
}
/// A unique descriptor of the candidate receipt, in a lightweight format.
#[derive(PartialEq, Eq, Clone, Encode, Decode)]
#[derive(PartialEq, Eq, Clone, Encode, Decode, TypeInfo)]
#[cfg_attr(feature = "std", derive(Debug, Default))]
pub struct CandidateDescriptor<H = Hash> {
/// The ID of the para this is a candidate for.
@@ -564,7 +565,7 @@ pub struct CandidateDescriptor<H = Hash> {
}
/// A collation sent by a collator.
#[derive(PartialEq, Eq, Clone, Encode, Decode)]
#[derive(PartialEq, Eq, Clone, Encode, Decode, TypeInfo)]
#[cfg_attr(feature = "std", derive(Debug, Default))]
pub struct CollationInfo {
/// The ID of the parachain this is a candidate for.
@@ -619,7 +620,7 @@ impl CollationInfo {
/// A full collation.
#[derive(PartialEq, Eq, Clone)]
#[cfg_attr(feature = "std", derive(Debug, Encode, Decode))]
#[cfg_attr(feature = "std", derive(Debug, Encode, Decode, TypeInfo))]
pub struct Collation {
/// Candidate receipt itself.
pub info: CollationInfo,
@@ -629,7 +630,7 @@ pub struct Collation {
/// A Proof-of-Validation block.
#[derive(PartialEq, Eq, Clone)]
#[cfg_attr(feature = "std", derive(Debug, Encode, Decode))]
#[cfg_attr(feature = "std", derive(Debug, Encode, Decode, TypeInfo))]
pub struct PoVBlock {
/// Block data.
pub block_data: BlockData,
@@ -645,7 +646,7 @@ impl PoVBlock {
/// The data that is kept available about a particular parachain block.
#[derive(PartialEq, Eq, Clone)]
#[cfg_attr(feature = "std", derive(Debug, Encode, Decode))]
#[cfg_attr(feature = "std", derive(Debug, Encode, Decode, TypeInfo))]
pub struct AvailableData {
/// The PoV block.
pub pov_block: PoVBlock,
@@ -677,7 +678,7 @@ impl CompactStatement {
}
// Inner helper for codec on `CompactStatement`.
#[derive(Encode, Decode)]
#[derive(Encode, Decode, TypeInfo)]
enum CompactStatementInner {
#[codec(index = 1)]
Seconded(CandidateHash),
@@ -733,7 +734,7 @@ impl CompactStatement {
/// An either implicit or explicit attestation to the validity of a parachain
/// candidate.
#[derive(Clone, Eq, PartialEq, Decode, Encode, RuntimeDebug)]
#[derive(Clone, Eq, PartialEq, Decode, Encode, RuntimeDebug, TypeInfo)]
pub enum ValidityAttestation {
/// Implicit validity attestation by issuing.
/// This corresponds to issuance of a `Candidate` statement.
@@ -804,7 +805,7 @@ impl AttestedCandidate {
}
/// A fee schedule for messages. This is a linear function in the number of bytes of a message.
#[derive(PartialEq, Eq, PartialOrd, Hash, Default, Clone, Copy, Encode, Decode)]
#[derive(PartialEq, Eq, PartialOrd, Hash, Default, Clone, Copy, Encode, Decode, TypeInfo)]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize, Debug))]
pub struct FeeSchedule {
/// The base fee charged for all messages.
+31 -30
View File
@@ -18,6 +18,7 @@
use bitvec::vec::BitVec;
use parity_scale_codec::{Decode, Encode};
use scale_info::TypeInfo;
use sp_std::{collections::btree_map::BTreeMap, prelude::*};
use application_crypto::KeyTypeId;
@@ -319,7 +320,7 @@ fn check_collator_signature<H: AsRef<[u8]>>(
}
/// A unique descriptor of the candidate receipt.
#[derive(PartialEq, Eq, Clone, Encode, Decode)]
#[derive(PartialEq, Eq, Clone, Encode, Decode, TypeInfo)]
#[cfg_attr(feature = "std", derive(Debug, Default, Hash, MallocSizeOf))]
pub struct CandidateDescriptor<H = Hash> {
/// The ID of the para this is a candidate for.
@@ -361,7 +362,7 @@ impl<H: AsRef<[u8]>> CandidateDescriptor<H> {
}
/// A candidate-receipt.
#[derive(PartialEq, Eq, Clone, Encode, Decode)]
#[derive(PartialEq, Eq, Clone, Encode, Decode, TypeInfo)]
#[cfg_attr(feature = "std", derive(Debug, Default, MallocSizeOf))]
pub struct CandidateReceipt<H = Hash> {
/// The descriptor of the candidate.
@@ -386,7 +387,7 @@ impl<H> CandidateReceipt<H> {
}
/// All data pertaining to the execution of a para candidate.
#[derive(PartialEq, Eq, Clone, Encode, Decode)]
#[derive(PartialEq, Eq, Clone, Encode, Decode, TypeInfo)]
#[cfg_attr(feature = "std", derive(Debug, Default))]
pub struct FullCandidateReceipt<H = Hash, N = BlockNumber> {
/// The inner candidate receipt.
@@ -399,7 +400,7 @@ pub struct FullCandidateReceipt<H = Hash, N = BlockNumber> {
}
/// A candidate-receipt with commitments directly included.
#[derive(PartialEq, Eq, Clone, Encode, Decode)]
#[derive(PartialEq, Eq, Clone, Encode, Decode, TypeInfo)]
#[cfg_attr(feature = "std", derive(Debug, Default, Hash, MallocSizeOf))]
pub struct CommittedCandidateReceipt<H = Hash> {
/// The descriptor of the candidate.
@@ -480,7 +481,7 @@ impl Ord for CommittedCandidateReceipt {
///
/// The `PersistedValidationData` should be relatively lightweight primarily because it is constructed
/// during inclusion for each candidate and therefore lies on the critical path of inclusion.
#[derive(PartialEq, Eq, Clone, Encode, Decode)]
#[derive(PartialEq, Eq, Clone, Encode, Decode, TypeInfo)]
#[cfg_attr(feature = "std", derive(Debug, Default, MallocSizeOf))]
pub struct PersistedValidationData<H = Hash, N = BlockNumber> {
/// The parent head-data.
@@ -501,7 +502,7 @@ impl<H: Encode, N: Encode> PersistedValidationData<H, N> {
}
/// Commitments made in a `CandidateReceipt`. Many of these are outputs of validation.
#[derive(PartialEq, Eq, Clone, Encode, Decode)]
#[derive(PartialEq, Eq, Clone, Encode, Decode, TypeInfo)]
#[cfg_attr(feature = "std", derive(Debug, Default, Hash, MallocSizeOf))]
pub struct CandidateCommitments<N = BlockNumber> {
/// Messages destined to be interpreted by the Relay chain itself.
@@ -526,7 +527,7 @@ impl CandidateCommitments {
}
/// A bitfield concerning availability of backed candidates.
#[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug)]
#[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug, TypeInfo)]
pub struct AvailabilityBitfield(pub BitVec<bitvec::order::Lsb0, u8>);
impl From<BitVec<bitvec::order::Lsb0, u8>> for AvailabilityBitfield {
@@ -549,7 +550,7 @@ pub type SignedAvailabilityBitfields = Vec<SignedAvailabilityBitfield>;
pub type UncheckedSignedAvailabilityBitfields = Vec<UncheckedSignedAvailabilityBitfield>;
/// A backed (or backable, depending on context) candidate.
#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug)]
#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo)]
#[cfg_attr(feature = "std", derive(Default))]
pub struct BackedCandidate<H = Hash> {
/// The candidate referred to.
@@ -637,7 +638,7 @@ pub fn check_candidate_backing<H: AsRef<[u8]> + Clone + Encode>(
}
/// The unique (during session) index of a core.
#[derive(Encode, Decode, Default, PartialOrd, Ord, Eq, PartialEq, Clone, Copy)]
#[derive(Encode, Decode, Default, PartialOrd, Ord, Eq, PartialEq, Clone, Copy, TypeInfo)]
#[cfg_attr(feature = "std", derive(Debug, Hash, MallocSizeOf))]
pub struct CoreIndex(pub u32);
@@ -648,7 +649,7 @@ impl From<u32> for CoreIndex {
}
/// The unique (during session) index of a validator group.
#[derive(Encode, Decode, Default, Clone, Copy, Debug, PartialEq, Eq)]
#[derive(Encode, Decode, Default, Clone, Copy, Debug, PartialEq, Eq, TypeInfo)]
#[cfg_attr(feature = "std", derive(Hash, MallocSizeOf))]
pub struct GroupIndex(pub u32);
@@ -659,12 +660,12 @@ impl From<u32> for GroupIndex {
}
/// A claim on authoring the next block for a given parathread.
#[derive(Clone, Encode, Decode, Default)]
#[derive(Clone, Encode, Decode, Default, TypeInfo)]
#[cfg_attr(feature = "std", derive(PartialEq, Debug))]
pub struct ParathreadClaim(pub Id, pub CollatorId);
/// An entry tracking a claim to ensure it does not pass the maximum number of retries.
#[derive(Clone, Encode, Decode, Default)]
#[derive(Clone, Encode, Decode, Default, TypeInfo)]
#[cfg_attr(feature = "std", derive(PartialEq, Debug))]
pub struct ParathreadEntry {
/// The claim.
@@ -674,7 +675,7 @@ pub struct ParathreadEntry {
}
/// What is occupying a specific availability core.
#[derive(Clone, Encode, Decode)]
#[derive(Clone, Encode, Decode, TypeInfo)]
#[cfg_attr(feature = "std", derive(PartialEq, Debug))]
pub enum CoreOccupied {
/// A parathread.
@@ -684,7 +685,7 @@ pub enum CoreOccupied {
}
/// A helper data-type for tracking validator-group rotations.
#[derive(Clone, Encode, Decode)]
#[derive(Clone, Encode, Decode, TypeInfo)]
#[cfg_attr(feature = "std", derive(PartialEq, Debug, MallocSizeOf))]
pub struct GroupRotationInfo<N = BlockNumber> {
/// The block number where the session started.
@@ -772,7 +773,7 @@ impl<N: Saturating + BaseArithmetic + Copy> GroupRotationInfo<N> {
}
/// Information about a core which is currently occupied.
#[derive(Clone, Encode, Decode)]
#[derive(Clone, Encode, Decode, TypeInfo)]
#[cfg_attr(feature = "std", derive(Debug, PartialEq, MallocSizeOf))]
pub struct OccupiedCore<H = Hash, N = BlockNumber> {
// NOTE: this has no ParaId as it can be deduced from the candidate descriptor.
@@ -808,7 +809,7 @@ impl<H, N> OccupiedCore<H, N> {
}
/// Information about a core which is currently occupied.
#[derive(Clone, Encode, Decode)]
#[derive(Clone, Encode, Decode, TypeInfo)]
#[cfg_attr(feature = "std", derive(Debug, PartialEq, Default, MallocSizeOf))]
pub struct ScheduledCore {
/// The ID of a para scheduled.
@@ -818,7 +819,7 @@ pub struct ScheduledCore {
}
/// The state of a particular availability core.
#[derive(Clone, Encode, Decode)]
#[derive(Clone, Encode, Decode, TypeInfo)]
#[cfg_attr(feature = "std", derive(Debug, PartialEq, MallocSizeOf))]
pub enum CoreState<H = Hash, N = BlockNumber> {
/// The core is currently occupied.
@@ -854,7 +855,7 @@ impl<N> CoreState<N> {
}
/// An assumption being made about the state of an occupied core.
#[derive(Clone, Copy, Encode, Decode)]
#[derive(Clone, Copy, Encode, Decode, TypeInfo)]
#[cfg_attr(feature = "std", derive(PartialEq, Eq, Hash, Debug))]
pub enum OccupiedCoreAssumption {
/// The candidate occupying the core was made available and included to free the core.
@@ -869,7 +870,7 @@ pub enum OccupiedCoreAssumption {
}
/// An even concerning a candidate.
#[derive(Clone, Encode, Decode)]
#[derive(Clone, Encode, Decode, TypeInfo)]
#[cfg_attr(feature = "std", derive(PartialEq, Debug, MallocSizeOf))]
pub enum CandidateEvent<H = Hash> {
/// This candidate receipt was backed in the most recent block.
@@ -888,7 +889,7 @@ pub enum CandidateEvent<H = Hash> {
}
/// Information about validator sets of a session.
#[derive(Clone, Encode, Decode, RuntimeDebug)]
#[derive(Clone, Encode, Decode, RuntimeDebug, TypeInfo)]
#[cfg_attr(feature = "std", derive(PartialEq, Default, MallocSizeOf))]
pub struct SessionInfo {
/// Validators in canonical ordering.
@@ -1033,7 +1034,7 @@ impl From<ValidityError> for u8 {
/// Abridged version of `HostConfiguration` (from the `Configuration` parachains host runtime module)
/// meant to be used by a parachain or PDK such as cumulus.
#[derive(Clone, Encode, Decode, RuntimeDebug)]
#[derive(Clone, Encode, Decode, RuntimeDebug, TypeInfo)]
#[cfg_attr(feature = "std", derive(PartialEq))]
pub struct AbridgedHostConfiguration {
/// The maximum validation code size, in bytes.
@@ -1066,7 +1067,7 @@ pub struct AbridgedHostConfiguration {
/// Abridged version of `HrmpChannel` (from the `Hrmp` parachains host runtime module) meant to be
/// used by a parachain or PDK such as cumulus.
#[derive(Clone, Encode, Decode, RuntimeDebug)]
#[derive(Clone, Encode, Decode, RuntimeDebug, TypeInfo)]
#[cfg_attr(feature = "std", derive(PartialEq))]
pub struct AbridgedHrmpChannel {
/// The maximum number of messages that can be pending in the channel at once.
@@ -1092,7 +1093,7 @@ pub struct AbridgedHrmpChannel {
}
/// A possible upgrade restriction that prevents a parachain from performing an upgrade.
#[derive(Encode, Decode, PartialEq, RuntimeDebug)]
#[derive(Encode, Decode, PartialEq, RuntimeDebug, TypeInfo)]
pub enum UpgradeRestriction {
/// There is an upgrade restriction and there are no details about its specifics nor how long
/// it could last.
@@ -1105,7 +1106,7 @@ pub enum UpgradeRestriction {
///
/// This data type appears in the last step of the upgrade process. After the parachain observes it
/// and reacts to it the upgrade process concludes.
#[derive(Encode, Decode, PartialEq, RuntimeDebug)]
#[derive(Encode, Decode, PartialEq, RuntimeDebug, TypeInfo)]
pub enum UpgradeGoAhead {
/// Abort the upgrade process. There is something wrong with the validation code previously
/// submitted by the parachain. This variant can also be used to prevent upgrades by the governance
@@ -1173,7 +1174,7 @@ impl<H> From<ConsensusLog> for runtime_primitives::DigestItem<H> {
/// A statement about a candidate, to be used within the dispute resolution process.
///
/// Statements are either in favor of the candidate's validity or against it.
#[derive(Encode, Decode, Clone, PartialEq, RuntimeDebug)]
#[derive(Encode, Decode, Clone, PartialEq, RuntimeDebug, TypeInfo)]
pub enum DisputeStatement {
/// A valid statement, of the given kind.
#[codec(index = 0)]
@@ -1242,7 +1243,7 @@ impl DisputeStatement {
}
/// Different kinds of statements of validity on a candidate.
#[derive(Encode, Decode, Clone, PartialEq, RuntimeDebug)]
#[derive(Encode, Decode, Clone, PartialEq, RuntimeDebug, TypeInfo)]
pub enum ValidDisputeStatementKind {
/// An explicit statement issued as part of a dispute.
#[codec(index = 0)]
@@ -1259,7 +1260,7 @@ pub enum ValidDisputeStatementKind {
}
/// Different kinds of statements of invalidity on a candidate.
#[derive(Encode, Decode, Clone, PartialEq, RuntimeDebug)]
#[derive(Encode, Decode, Clone, PartialEq, RuntimeDebug, TypeInfo)]
pub enum InvalidDisputeStatementKind {
/// An explicit statement issued as part of a dispute.
#[codec(index = 0)]
@@ -1287,7 +1288,7 @@ impl ExplicitDisputeStatement {
}
/// A set of statements about a specific candidate.
#[derive(Encode, Decode, Clone, PartialEq, RuntimeDebug)]
#[derive(Encode, Decode, Clone, PartialEq, RuntimeDebug, TypeInfo)]
pub struct DisputeStatementSet {
/// The candidate referenced by this set.
pub candidate_hash: CandidateHash,
@@ -1301,7 +1302,7 @@ pub struct DisputeStatementSet {
pub type MultiDisputeStatementSet = Vec<DisputeStatementSet>;
/// The entire state of a dispute.
#[derive(Encode, Decode, Clone, RuntimeDebug, PartialEq)]
#[derive(Encode, Decode, Clone, RuntimeDebug, PartialEq, TypeInfo)]
pub struct DisputeState<N = BlockNumber> {
/// A bitfield indicating all validators for the candidate.
pub validators_for: BitVec<bitvec::order::Lsb0, u8>, // one bit per validator.
@@ -1314,7 +1315,7 @@ pub struct DisputeState<N = BlockNumber> {
}
/// Parachains inherent-data passed into the runtime by a block author
#[derive(Encode, Decode, Clone, PartialEq, RuntimeDebug)]
#[derive(Encode, Decode, Clone, PartialEq, RuntimeDebug, TypeInfo)]
pub struct InherentData<HDR: HeaderT = Header> {
/// Signed bitfields by validators about availability.
pub bitfields: UncheckedSignedAvailabilityBitfields,
+2 -1
View File
@@ -15,6 +15,7 @@
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
use parity_scale_codec::{Decode, Encode};
use scale_info::TypeInfo;
#[cfg(feature = "std")]
use application_crypto::AppKey;
@@ -41,7 +42,7 @@ use crate::v0::{SigningContext, ValidatorId, ValidatorIndex, ValidatorSignature}
pub struct Signed<Payload, RealPayload = Payload>(UncheckedSigned<Payload, RealPayload>);
/// Unchecked signed data, can be converted to `Signed` by checking the signature.
#[derive(Clone, PartialEq, Eq, RuntimeDebug, Encode, Decode)]
#[derive(Clone, PartialEq, Eq, RuntimeDebug, Encode, Decode, TypeInfo)]
pub struct UncheckedSigned<Payload, RealPayload = Payload> {
/// The payload is part of the signed data. The rest is the signing context,
/// which is known both at signing and at validation.
+3
View File
@@ -10,10 +10,12 @@ bitvec = { version = "0.20.1", default-features = false, features = ["alloc"] }
parity-scale-codec = { version = "2.0.0", default-features = false, features = ["derive"] }
log = { version = "0.4.13", default-features = false }
rustc-hex = { version = "2.1.0", default-features = false }
scale-info = { version = "1.0", default-features = false, features = ["derive"] }
serde = { version = "1.0.130", default-features = false }
serde_derive = { version = "1.0.117", optional = true }
static_assertions = "1.1.0"
beefy-primitives = { git = "https://github.com/paritytech/grandpa-bridge-gadget", branch = "master", default-features = false }
sp-api = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
inherents = { package = "sp-inherents", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-std = { package = "sp-std", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
@@ -63,6 +65,7 @@ no_std = []
std = [
"bitvec/std",
"parity-scale-codec/std",
"scale-info/std",
"log/std",
"rustc-hex/std",
"serde_derive",
-6
View File
@@ -118,12 +118,6 @@ pub mod pallet {
#[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)]
#[pallet::metadata(
T::AccountId = "AccountId",
T::BlockNumber = "BlockNumber",
LeasePeriodOf<T> = "LeasePeriod",
BalanceOf<T> = "Balance",
)]
pub enum Event<T: Config> {
/// An auction started. Provides its index and the block number where it will begin to
/// close and the first lease period of the quadruplet that is auctioned.
+56 -27
View File
@@ -24,6 +24,7 @@ use frame_support::{
pub use pallet::*;
use parity_scale_codec::{Decode, Encode};
use primitives::v1::ValidityError;
use scale_info::TypeInfo;
#[cfg(feature = "std")]
use serde::{self, Deserialize, Deserializer, Serialize, Serializer};
use sp_io::{crypto::secp256k1_ecdsa_recover, hashing::keccak_256};
@@ -71,7 +72,7 @@ impl WeightInfo for TestWeightInfo {
}
/// The kind of statement an account needs to make for a claim to be valid.
#[derive(Encode, Decode, Clone, Copy, Eq, PartialEq, RuntimeDebug)]
#[derive(Encode, Decode, Clone, Copy, Eq, PartialEq, RuntimeDebug, TypeInfo)]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
pub enum StatementKind {
/// Statement required to be made by non-SAFT holders.
@@ -105,7 +106,7 @@ impl Default for StatementKind {
/// An Ethereum address (i.e. 20 bytes, used to represent an Ethereum account).
///
/// This gets serialized to the 0x-prefixed hex representation.
#[derive(Clone, Copy, PartialEq, Eq, Encode, Decode, Default, RuntimeDebug)]
#[derive(Clone, Copy, PartialEq, Eq, Encode, Decode, Default, RuntimeDebug, TypeInfo)]
pub struct EthereumAddress([u8; 20]);
#[cfg(feature = "std")]
@@ -141,7 +142,7 @@ impl<'de> Deserialize<'de> for EthereumAddress {
}
}
#[derive(Encode, Decode, Clone)]
#[derive(Encode, Decode, Clone, TypeInfo)]
pub struct EcdsaSignature(pub [u8; 65]);
impl PartialEq for EcdsaSignature {
@@ -180,7 +181,6 @@ pub mod pallet {
#[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)]
#[pallet::metadata(T::AccountId = "AccountId", BalanceOf<T> = "Balance")]
pub enum Event<T: Config> {
/// Someone claimed some DOTs. `[who, ethereum_address, amount]`
Claimed(T::AccountId, EthereumAddress, BalanceOf<T>),
@@ -473,14 +473,14 @@ pub mod pallet {
// <weight>
// The weight of this logic is included in the `claim` dispatchable.
// </weight>
Call::claim(account, ethereum_signature) => {
Call::claim { dest: account, ethereum_signature } => {
let data = account.using_encoded(to_ascii_hex);
(Self::eth_recover(&ethereum_signature, &data, &[][..]), None)
},
// <weight>
// The weight of this logic is included in the `claim_attest` dispatchable.
// </weight>
Call::claim_attest(account, ethereum_signature, statement) => {
Call::claim_attest { dest: account, ethereum_signature, statement } => {
let data = account.using_encoded(to_ascii_hex);
(
Self::eth_recover(&ethereum_signature, &data, &statement),
@@ -588,7 +588,8 @@ impl<T: Config> Pallet<T> {
/// Validate `attest` calls prior to execution. Needed to avoid a DoS attack since they are
/// otherwise free to place on chain.
#[derive(Encode, Decode, Clone, Eq, PartialEq)]
#[derive(Encode, Decode, Clone, Eq, PartialEq, TypeInfo)]
#[scale_info(skip_type_params(T))]
pub struct PrevalidateAttests<T: Config + Send + Sync>(sp_std::marker::PhantomData<T>)
where
<T as frame_system::Config>::Call: IsSubType<Call<T>>;
@@ -643,7 +644,7 @@ where
_len: usize,
) -> TransactionValidity {
if let Some(local_call) = call.is_sub_type() {
if let Call::attest(attested_statement) = local_call {
if let Call::attest { statement: attested_statement } = local_call {
let signer = Preclaims::<T>::get(who)
.ok_or(InvalidTransaction::Custom(ValidityError::SignerHasNoClaim.into()))?;
if let Some(s) = Signing::<T>::get(signer) {
@@ -1035,7 +1036,9 @@ mod tests {
fn valid_attest_transactions_are_free() {
new_test_ext().execute_with(|| {
let p = PrevalidateAttests::<Test>::new();
let c = Call::Claims(ClaimsCall::attest(StatementKind::Saft.to_text().to_vec()));
let c = Call::Claims(ClaimsCall::attest {
statement: StatementKind::Saft.to_text().to_vec(),
});
let di = c.get_dispatch_info();
assert_eq!(di.pays_fee, Pays::No);
let r = p.validate(&42, &c, &di, 20);
@@ -1047,11 +1050,15 @@ mod tests {
fn invalid_attest_transactions_are_recognized() {
new_test_ext().execute_with(|| {
let p = PrevalidateAttests::<Test>::new();
let c = Call::Claims(ClaimsCall::attest(StatementKind::Regular.to_text().to_vec()));
let c = Call::Claims(ClaimsCall::attest {
statement: StatementKind::Regular.to_text().to_vec(),
});
let di = c.get_dispatch_info();
let r = p.validate(&42, &c, &di, 20);
assert!(r.is_err());
let c = Call::Claims(ClaimsCall::attest(StatementKind::Saft.to_text().to_vec()));
let c = Call::Claims(ClaimsCall::attest {
statement: StatementKind::Saft.to_text().to_vec(),
});
let di = c.get_dispatch_info();
let r = p.validate(&69, &c, &di, 20);
assert!(r.is_err());
@@ -1282,7 +1289,10 @@ mod tests {
assert_eq!(
<Pallet<Test>>::validate_unsigned(
source,
&ClaimsCall::claim(1, sig::<Test>(&alice(), &1u64.encode(), &[][..]))
&ClaimsCall::claim {
dest: 1,
ethereum_signature: sig::<Test>(&alice(), &1u64.encode(), &[][..])
}
),
Ok(ValidTransaction {
priority: 100,
@@ -1295,19 +1305,26 @@ mod tests {
assert_eq!(
<Pallet<Test>>::validate_unsigned(
source,
&ClaimsCall::claim(0, EcdsaSignature([0; 65]))
&ClaimsCall::claim { dest: 0, ethereum_signature: EcdsaSignature([0; 65]) }
),
InvalidTransaction::Custom(ValidityError::InvalidEthereumSignature.into()).into(),
);
assert_eq!(
<Pallet<Test>>::validate_unsigned(
source,
&ClaimsCall::claim(1, sig::<Test>(&bob(), &1u64.encode(), &[][..]))
&ClaimsCall::claim {
dest: 1,
ethereum_signature: sig::<Test>(&bob(), &1u64.encode(), &[][..])
}
),
InvalidTransaction::Custom(ValidityError::SignerHasNoClaim.into()).into(),
);
let s = sig::<Test>(&dave(), &1u64.encode(), StatementKind::Regular.to_text());
let call = ClaimsCall::claim_attest(1, s, StatementKind::Regular.to_text().to_vec());
let call = ClaimsCall::claim_attest {
dest: 1,
ethereum_signature: s,
statement: StatementKind::Regular.to_text().to_vec(),
};
assert_eq!(
<Pallet<Test>>::validate_unsigned(source, &call),
Ok(ValidTransaction {
@@ -1321,31 +1338,43 @@ mod tests {
assert_eq!(
<Pallet<Test>>::validate_unsigned(
source,
&ClaimsCall::claim_attest(
1,
EcdsaSignature([0; 65]),
StatementKind::Regular.to_text().to_vec()
)
&ClaimsCall::claim_attest {
dest: 1,
ethereum_signature: EcdsaSignature([0; 65]),
statement: StatementKind::Regular.to_text().to_vec()
}
),
InvalidTransaction::Custom(ValidityError::InvalidEthereumSignature.into()).into(),
);
let s = sig::<Test>(&bob(), &1u64.encode(), StatementKind::Regular.to_text());
let call = ClaimsCall::claim_attest(1, s, StatementKind::Regular.to_text().to_vec());
let call = ClaimsCall::claim_attest {
dest: 1,
ethereum_signature: s,
statement: StatementKind::Regular.to_text().to_vec(),
};
assert_eq!(
<Pallet<Test>>::validate_unsigned(source, &call),
InvalidTransaction::Custom(ValidityError::SignerHasNoClaim.into()).into(),
);
let s = sig::<Test>(&dave(), &1u64.encode(), StatementKind::Saft.to_text());
let call = ClaimsCall::claim_attest(1, s, StatementKind::Regular.to_text().to_vec());
let call = ClaimsCall::claim_attest {
dest: 1,
ethereum_signature: s,
statement: StatementKind::Regular.to_text().to_vec(),
};
assert_eq!(
<Pallet<Test>>::validate_unsigned(source, &call),
InvalidTransaction::Custom(ValidityError::SignerHasNoClaim.into()).into(),
);
let s = sig::<Test>(&dave(), &1u64.encode(), StatementKind::Saft.to_text());
let call = ClaimsCall::claim_attest(1, s, StatementKind::Saft.to_text().to_vec());
let call = ClaimsCall::claim_attest {
dest: 1,
ethereum_signature: s,
statement: StatementKind::Saft.to_text().to_vec(),
};
assert_eq!(
<Pallet<Test>>::validate_unsigned(source, &call),
InvalidTransaction::Custom(ValidityError::InvalidStatement.into()).into(),
@@ -1414,7 +1443,7 @@ mod benchmarking {
super::Pallet::<T>::mint_claim(RawOrigin::Root.into(), eth_address, VALUE.into(), vesting, None)?;
assert_eq!(Claims::<T>::get(eth_address), Some(VALUE.into()));
let source = sp_runtime::transaction_validity::TransactionSource::External;
let call = Call::<T>::claim(account.clone(), signature.clone());
let call = Call::<T>::claim { dest: account.clone(), ethereum_signature: signature.clone() };
}: {
super::Pallet::<T>::validate_unsigned(source, &call).map_err(|e| -> &'static str { e.into() })?;
super::Pallet::<T>::claim(RawOrigin::None.into(), account, signature)?;
@@ -1459,7 +1488,7 @@ mod benchmarking {
let signature = sig::<T>(&secret_key, &account.encode(), statement.to_text());
super::Pallet::<T>::mint_claim(RawOrigin::Root.into(), eth_address, VALUE.into(), vesting, Some(statement))?;
assert_eq!(Claims::<T>::get(eth_address), Some(VALUE.into()));
let call = Call::<T>::claim_attest(account.clone(), signature.clone(), StatementKind::Regular.to_text().to_vec());
let call = Call::<T>::claim_attest { dest: account.clone(), ethereum_signature: signature.clone(), statement: StatementKind::Regular.to_text().to_vec() };
let source = sp_runtime::transaction_validity::TransactionSource::External;
}: {
super::Pallet::<T>::validate_unsigned(source, &call).map_err(|e| -> &'static str { e.into() })?;
@@ -1489,10 +1518,10 @@ mod benchmarking {
Preclaims::<T>::insert(&account, eth_address);
assert_eq!(Claims::<T>::get(eth_address), Some(VALUE.into()));
let call = super::Call::attest(StatementKind::Regular.to_text().to_vec());
let call = super::Call::attest { statement: StatementKind::Regular.to_text().to_vec() };
// We have to copy the validate statement here because of trait issues... :(
let validate = |who: &T::AccountId, call: &super::Call<T>| -> DispatchResult {
if let Call::attest(attested_statement) = call {
if let Call::attest{ statement: attested_statement } = call {
let signer = Preclaims::<T>::get(who).ok_or("signer has no claim")?;
if let Some(s) = Signing::<T>::get(signer) {
ensure!(&attested_statement[..] == s.to_text(), "invalid statement");
+3 -3
View File
@@ -63,6 +63,7 @@ use frame_support::{
pub use pallet::*;
use parity_scale_codec::{Decode, Encode};
use primitives::v1::Id as ParaId;
use scale_info::TypeInfo;
use sp_runtime::{
traits::{
AccountIdConversion, CheckedAdd, Hash, IdentifyAccount, One, Saturating, Verify, Zero,
@@ -124,7 +125,7 @@ impl WeightInfo for TestWeightInfo {
}
}
#[derive(Encode, Decode, Copy, Clone, PartialEq, Eq, RuntimeDebug)]
#[derive(Encode, Decode, Copy, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo)]
pub enum LastContribution<BlockNumber> {
Never,
PreEnding(u32),
@@ -133,7 +134,7 @@ pub enum LastContribution<BlockNumber> {
/// Information on a funding effort for a pre-existing parachain. We assume that the parachain ID
/// is known as it's used for the key of the storage item for which this is the value (`Funds`).
#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug)]
#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo)]
#[codec(dumb_trait_bound)]
pub struct FundInfo<AccountId, Balance, BlockNumber, LeasePeriod> {
/// The owning account who placed the deposit.
@@ -242,7 +243,6 @@ pub mod pallet {
#[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)]
#[pallet::metadata(T::AccountId = "AccountId", BalanceOf<T> = "Balance")]
pub enum Event<T: Config> {
/// Create a new crowdloaning campaign. `[fund_index]`
Created(ParaId),
@@ -35,12 +35,13 @@ use sp_std::{prelude::*, result};
use crate::traits::{OnSwap, Registrar};
pub use pallet::*;
use parity_scale_codec::{Decode, Encode};
use scale_info::TypeInfo;
use sp_runtime::{
traits::{CheckedSub, Saturating},
RuntimeDebug,
};
#[derive(Encode, Decode, Clone, PartialEq, Eq, Default, RuntimeDebug)]
#[derive(Encode, Decode, Clone, PartialEq, Eq, Default, RuntimeDebug, TypeInfo)]
pub struct ParaInfo<Account, Balance> {
/// The account that has placed a deposit for registering this para.
pub(crate) manager: Account,
@@ -124,7 +125,6 @@ pub mod pallet {
#[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)]
#[pallet::metadata(T::AccountId = "AccountId")]
pub enum Event<T: Config> {
Registered(ParaId, T::AccountId),
Deregistered(ParaId),
+4 -8
View File
@@ -23,6 +23,7 @@ use frame_support::{
use frame_system::pallet_prelude::*;
pub use pallet::*;
use parity_scale_codec::{Decode, Encode};
use scale_info::TypeInfo;
use sp_core::sr25519;
use sp_runtime::{
traits::{CheckedAdd, Saturating, Verify, Zero},
@@ -34,7 +35,7 @@ type BalanceOf<T> =
<<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance;
/// The kind of a statement an account needs to make for a claim to be valid.
#[derive(Encode, Decode, Clone, Copy, Eq, PartialEq, RuntimeDebug)]
#[derive(Encode, Decode, Clone, Copy, Eq, PartialEq, RuntimeDebug, TypeInfo)]
pub enum AccountValidity {
/// Account is not valid.
Invalid,
@@ -70,7 +71,7 @@ impl AccountValidity {
}
/// All information about an account regarding the purchase of DOTs.
#[derive(Encode, Decode, Default, Clone, Eq, PartialEq, RuntimeDebug)]
#[derive(Encode, Decode, Default, Clone, Eq, PartialEq, RuntimeDebug, TypeInfo)]
pub struct AccountStatus<Balance> {
/// The current validity status of the user. Will denote if the user has passed KYC,
/// how much they are able to purchase, and when their purchase process has completed.
@@ -129,11 +130,6 @@ pub mod pallet {
#[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)]
#[pallet::metadata(
T::AccountId = "AccountId",
T::BlockNumber = "BlockNumber",
BalanceOf<T> = "Balance",
)]
pub enum Event<T: Config> {
/// A [new] account was created.
AccountCreated(T::AccountId),
@@ -1071,7 +1067,7 @@ mod tests {
);
// Vesting lock is removed in whole on block 101 (100 blocks after block 1)
System::set_block_number(100);
let vest_call = Call::Vesting(pallet_vesting::Call::<Test>::vest());
let vest_call = Call::Vesting(pallet_vesting::Call::<Test>::vest {});
assert_ok!(vest_call.clone().dispatch(Origin::signed(alice())));
assert_ok!(vest_call.clone().dispatch(Origin::signed(bob())));
assert_eq!(<Test as Config>::VestingSchedule::vesting_balance(&alice()), Some(45));
-5
View File
@@ -110,11 +110,6 @@ pub mod pallet {
#[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)]
#[pallet::metadata(
T::AccountId = "AccountId",
LeasePeriodOf<T> = "LeasePeriod",
BalanceOf<T> = "Balance",
)]
pub enum Event<T: Config> {
/// A new `[lease_period]` is beginning.
NewLeasePeriod(LeasePeriodOf<T>),
+2
View File
@@ -8,6 +8,7 @@ build = "build.rs"
[dependencies]
bitvec = { version = "0.20.1", default-features = false, features = ["alloc"] }
parity-scale-codec = { version = "2.2.0", default-features = false, features = ["derive", "max-encoded-len"] }
scale-info = { version = "1.0", default-features = false, features = ["derive"] }
log = { version = "0.4.14", default-features = false }
rustc-hex = { version = "2.1.0", default-features = false }
serde = { version = "1.0.130", default-features = false }
@@ -109,6 +110,7 @@ std = [
"primitives/std",
"rustc-hex/std",
"parity-scale-codec/std",
"scale-info/std",
"inherents/std",
"sp-core/std",
"sp-api/std",
+29 -19
View File
@@ -141,7 +141,7 @@ pub fn native_version() -> NativeVersion {
pub struct BaseFilter;
impl Contains<Call> for BaseFilter {
fn contains(c: &Call) -> bool {
!matches!(c, Call::Registrar(paras_registrar::Call::swap(..)))
!matches!(c, Call::Registrar(paras_registrar::Call::swap { .. }))
}
}
@@ -972,7 +972,17 @@ parameter_types! {
/// The type used to represent the kinds of proxying allowed.
#[derive(
Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, RuntimeDebug, MaxEncodedLen,
Copy,
Clone,
Eq,
PartialEq,
Ord,
PartialOrd,
Encode,
Decode,
RuntimeDebug,
MaxEncodedLen,
scale_info::TypeInfo,
)]
pub enum ProxyType {
Any,
@@ -997,9 +1007,9 @@ impl InstanceFilter<Call> for ProxyType {
Call::System(..) |
Call::Babe(..) |
Call::Timestamp(..) |
Call::Indices(pallet_indices::Call::claim(..)) |
Call::Indices(pallet_indices::Call::free(..)) |
Call::Indices(pallet_indices::Call::freeze(..)) |
Call::Indices(pallet_indices::Call::claim {..}) |
Call::Indices(pallet_indices::Call::free {..}) |
Call::Indices(pallet_indices::Call::freeze {..}) |
// Specifically omitting Indices `transfer`, `force_transfer`
// Specifically omitting the entire Balances pallet
Call::Authorship(..) |
@@ -1019,24 +1029,24 @@ impl InstanceFilter<Call> for ProxyType {
Call::Utility(..) |
Call::Identity(..) |
Call::Society(..) |
Call::Recovery(pallet_recovery::Call::as_recovered(..)) |
Call::Recovery(pallet_recovery::Call::vouch_recovery(..)) |
Call::Recovery(pallet_recovery::Call::claim_recovery(..)) |
Call::Recovery(pallet_recovery::Call::close_recovery(..)) |
Call::Recovery(pallet_recovery::Call::remove_recovery(..)) |
Call::Recovery(pallet_recovery::Call::cancel_recovered(..)) |
Call::Recovery(pallet_recovery::Call::as_recovered {..}) |
Call::Recovery(pallet_recovery::Call::vouch_recovery {..}) |
Call::Recovery(pallet_recovery::Call::claim_recovery {..}) |
Call::Recovery(pallet_recovery::Call::close_recovery {..}) |
Call::Recovery(pallet_recovery::Call::remove_recovery {..}) |
Call::Recovery(pallet_recovery::Call::cancel_recovered {..}) |
// Specifically omitting Recovery `create_recovery`, `initiate_recovery`
Call::Vesting(pallet_vesting::Call::vest(..)) |
Call::Vesting(pallet_vesting::Call::vest_other(..)) |
Call::Vesting(pallet_vesting::Call::vest {..}) |
Call::Vesting(pallet_vesting::Call::vest_other {..}) |
// Specifically omitting Vesting `vested_transfer`, and `force_vested_transfer`
Call::Scheduler(..) |
Call::Proxy(..) |
Call::Multisig(..) |
Call::Gilt(..) |
Call::Registrar(paras_registrar::Call::register(..)) |
Call::Registrar(paras_registrar::Call::deregister(..)) |
Call::Registrar(paras_registrar::Call::register {..}) |
Call::Registrar(paras_registrar::Call::deregister {..}) |
// Specifically omitting Registrar `swap`
Call::Registrar(paras_registrar::Call::reserve(..)) |
Call::Registrar(paras_registrar::Call::reserve {..}) |
Call::Crowdloan(..) |
Call::Slots(..) |
Call::Auctions(..) // Specifically omitting the entire XCM Pallet
@@ -1054,10 +1064,10 @@ impl InstanceFilter<Call> for ProxyType {
},
ProxyType::IdentityJudgement => matches!(
c,
Call::Identity(pallet_identity::Call::provide_judgement(..)) | Call::Utility(..)
Call::Identity(pallet_identity::Call::provide_judgement { .. }) | Call::Utility(..)
),
ProxyType::CancelProxy => {
matches!(c, Call::Proxy(pallet_proxy::Call::reject_announcement(..)))
matches!(c, Call::Proxy(pallet_proxy::Call::reject_announcement { .. }))
},
ProxyType::Auction => matches!(
c,
@@ -1646,7 +1656,7 @@ sp_api::impl_runtime_apis! {
impl sp_api::Metadata<Block> for Runtime {
fn metadata() -> OpaqueMetadata {
Runtime::metadata().into()
OpaqueMetadata::new(Runtime::metadata().into())
}
}
+4 -4
View File
@@ -79,10 +79,10 @@ fn block_cost() {
#[ignore]
fn transfer_cost_min_multiplier() {
let min_multiplier = runtime_common::MinimumMultiplier::get();
let call = <pallet_balances::Call<Runtime>>::transfer_keep_alive(
Default::default(),
Default::default(),
);
let call = pallet_balances::Call::<Runtime>::transfer_keep_alive {
dest: Default::default(),
value: Default::default(),
};
let info = call.get_dispatch_info();
// convert to outer call.
let call = Call::Balances(call);
+3 -1
View File
@@ -9,7 +9,8 @@ bitvec = { version = "0.20.1", default-features = false, features = ["alloc"] }
parity-scale-codec = { version = "2.0.0", default-features = false, features = ["derive"] }
log = { version = "0.4.14", default-features = false }
rustc-hex = { version = "2.1.0", default-features = false }
serde = { version = "1.0.130", features = ["derive"], optional = true }
scale-info = { version = "1.0", default-features = false, features = ["derive"] }
serde = { version = "1.0.130", features = [ "derive" ], optional = true }
derive_more = "0.99.14"
bitflags = "1.3.2"
@@ -56,6 +57,7 @@ std = [
"bitvec/std",
"parity-scale-codec/std",
"rustc-hex/std",
"scale-info/std",
"serde",
"primitives/std",
"inherents/std",
@@ -33,7 +33,7 @@ pub mod migration;
const LOG_TARGET: &str = "runtime::configuration";
/// All configuration of the runtime with respect to parachains and parathreads.
#[derive(Clone, Encode, Decode, PartialEq, sp_core::RuntimeDebug)]
#[derive(Clone, Encode, Decode, PartialEq, sp_core::RuntimeDebug, scale_info::TypeInfo)]
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))]
pub struct HostConfiguration<BlockNumber> {
// NOTE: This structure is used by parachains via merkle proofs. Therefore, this struct requires
+3 -2
View File
@@ -30,6 +30,7 @@ use primitives::v1::{
InvalidDisputeStatementKind, MultiDisputeStatementSet, SessionIndex, SigningContext,
ValidDisputeStatementKind, ValidatorId, ValidatorIndex, ValidatorSignature,
};
use scale_info::TypeInfo;
use sp_runtime::{
traits::{AppVerify, One, Saturating, Zero},
DispatchError, RuntimeDebug, SaturatedConversion,
@@ -37,14 +38,14 @@ use sp_runtime::{
use sp_std::{collections::btree_set::BTreeSet, prelude::*};
/// Whether the dispute is local or remote.
#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug)]
#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo)]
pub enum DisputeLocation {
Local,
Remote,
}
/// The result of a dispute, whether the candidate is deemed valid (for) or invalid (against).
#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug)]
#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo)]
pub enum DisputeResult {
Valid,
Invalid,
+3 -2
View File
@@ -25,6 +25,7 @@ use primitives::v1::{
Balance, Hash, HrmpChannelId, Id as ParaId, InboundHrmpMessage, OutboundHrmpMessage,
SessionIndex,
};
use scale_info::TypeInfo;
use sp_runtime::traits::{AccountIdConversion, BlakeTwo256, Hash as HashT, UniqueSaturatedInto};
use sp_std::{
collections::{btree_map::BTreeMap, btree_set::BTreeSet},
@@ -35,7 +36,7 @@ use sp_std::{
pub use pallet::*;
/// A description of a request to open an HRMP channel.
#[derive(Encode, Decode)]
#[derive(Encode, Decode, TypeInfo)]
pub struct HrmpOpenChannelRequest {
/// Indicates if this request was confirmed by the recipient.
pub confirmed: bool,
@@ -53,7 +54,7 @@ pub struct HrmpOpenChannelRequest {
}
/// A metadata of an HRMP channel.
#[derive(Encode, Decode)]
#[derive(Encode, Decode, TypeInfo)]
#[cfg_attr(test, derive(Debug))]
pub struct HrmpChannel {
// NOTE: This structure is used by parachains via merkle proofs. Therefore, this struct requires
+3 -3
View File
@@ -28,6 +28,7 @@ use primitives::v1::{
CandidateHash, CandidateReceipt, CommittedCandidateReceipt, CoreIndex, GroupIndex, HeadData,
Id as ParaId, SigningContext, UncheckedSignedAvailabilityBitfields, ValidatorIndex,
};
use scale_info::TypeInfo;
use sp_runtime::{
traits::{One, Saturating},
DispatchError,
@@ -43,7 +44,7 @@ pub use pallet::*;
///
/// The bitfield's signature should be checked at the point of submission. Afterwards it can be
/// dropped.
#[derive(Encode, Decode)]
#[derive(Encode, Decode, TypeInfo)]
#[cfg_attr(test, derive(Debug))]
pub struct AvailabilityBitfieldRecord<N> {
bitfield: AvailabilityBitfield, // one bit per core.
@@ -51,7 +52,7 @@ pub struct AvailabilityBitfieldRecord<N> {
}
/// A backed candidate pending availability.
#[derive(Encode, Decode, PartialEq)]
#[derive(Encode, Decode, PartialEq, TypeInfo)]
#[cfg_attr(test, derive(Debug))]
pub struct CandidatePendingAvailability<H, N> {
/// The availability core this is assigned to.
@@ -134,7 +135,6 @@ pub mod pallet {
#[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)]
#[pallet::metadata(T::Hash = "Hash")]
pub enum Event<T: Config> {
/// A candidate was backed. `[candidate, head_data]`
CandidateBacked(CandidateReceipt<T::Hash>, HeadData, CoreIndex, GroupIndex),
@@ -27,6 +27,7 @@ use crate::{
use frame_support::traits::{OneSessionHandler, Randomness};
use parity_scale_codec::{Decode, Encode};
use primitives::v1::{BlockNumber, ConsensusLog, SessionIndex, ValidatorId};
use scale_info::TypeInfo;
use sp_std::prelude::*;
pub use pallet::*;
@@ -61,7 +62,7 @@ impl<BlockNumber: Default + From<u32>> Default for SessionChangeNotification<Blo
}
}
#[derive(Encode, Decode)]
#[derive(Encode, Decode, TypeInfo)]
struct BufferedSessionChange {
validators: Vec<ValidatorId>,
queued: Vec<ValidatorId>,
+1 -1
View File
@@ -54,7 +54,7 @@ pub mod pallet {
/// Origin for the parachains.
#[pallet::origin]
#[derive(PartialEq, Eq, Clone, Encode, Decode, sp_core::RuntimeDebug)]
#[derive(PartialEq, Eq, Clone, Encode, Decode, sp_core::RuntimeDebug, scale_info::TypeInfo)]
pub enum Origin {
/// It comes from a parachain.
Parachain(ParaId),
+5 -4
View File
@@ -31,6 +31,7 @@ use primitives::v1::{
ConsensusLog, HeadData, Id as ParaId, SessionIndex, UpgradeGoAhead, UpgradeRestriction,
ValidationCode, ValidationCodeHash,
};
use scale_info::TypeInfo;
use sp_core::RuntimeDebug;
use sp_runtime::{traits::One, DispatchResult, SaturatedConversion};
use sp_std::{prelude::*, result};
@@ -43,7 +44,7 @@ pub use crate::Origin as ParachainOrigin;
pub use pallet::*;
// the two key times necessary to track for every code replacement.
#[derive(Default, Encode, Decode)]
#[derive(Default, Encode, Decode, TypeInfo)]
#[cfg_attr(test, derive(Debug, Clone, PartialEq))]
pub struct ReplacementTimes<N> {
/// The relay-chain block number that the code upgrade was expected to be activated.
@@ -58,7 +59,7 @@ pub struct ReplacementTimes<N> {
/// Metadata used to track previous parachain validation code that we keep in
/// the state.
#[derive(Default, Encode, Decode)]
#[derive(Default, Encode, Decode, TypeInfo)]
#[cfg_attr(test, derive(Debug, Clone, PartialEq))]
pub struct ParaPastCodeMeta<N> {
/// Block numbers where the code was expected to be replaced and where the code
@@ -87,7 +88,7 @@ enum UseCodeAt<N> {
/// If the para is in a "transition state", it is expected that the parachain is
/// queued in the `ActionsQueue` to transition it into a stable state. Its lifecycle
/// state will be used to determine the state transition to apply to the para.
#[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug)]
#[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug, TypeInfo)]
pub enum ParaLifecycle {
/// Para is new and is onboarding as a Parathread or Parachain.
Onboarding,
@@ -255,7 +256,7 @@ impl<N: Ord + Copy + PartialEq> ParaPastCodeMeta<N> {
}
/// Arguments for initializing a para.
#[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug)]
#[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug, TypeInfo)]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
pub struct ParaGenesisArgs {
/// The initial head data to use.
@@ -135,11 +135,11 @@ pub mod pallet {
},
};
Some(Call::enter(inherent_data))
Some(Call::enter { data: inherent_data })
}
fn is_inherent(call: &Self::Call) -> bool {
matches!(call, Call::enter(..))
matches!(call, Call::enter { .. })
}
}
@@ -429,12 +429,14 @@ mod tests {
System::set_block_consumed_resources(used_block_weight, 0);
// execute the paras inherent
let post_info = Call::<Test>::enter(ParachainsInherentData {
bitfields: signed_bitfields,
backed_candidates,
disputes: Vec::new(),
parent_header: default_header(),
})
let post_info = Call::<Test>::enter {
data: ParachainsInherentData {
bitfields: signed_bitfields,
backed_candidates,
disputes: Vec::new(),
parent_header: default_header(),
},
}
.dispatch_bypass_filter(None.into())
.unwrap_err()
.post_info;
@@ -477,12 +479,14 @@ mod tests {
System::set_block_consumed_resources(used_block_weight, 0);
// execute the paras inherent
let post_info = Call::<Test>::enter(ParachainsInherentData {
bitfields: signed_bitfields,
backed_candidates,
disputes: Vec::new(),
parent_header: header,
})
let post_info = Call::<Test>::enter {
data: ParachainsInherentData {
bitfields: signed_bitfields,
backed_candidates,
disputes: Vec::new(),
parent_header: header,
},
}
.dispatch_bypass_filter(None.into())
.unwrap();
+5 -4
View File
@@ -40,6 +40,7 @@ use primitives::v1::{
CollatorId, CoreIndex, CoreOccupied, GroupIndex, GroupRotationInfo, Id as ParaId,
ParathreadClaim, ParathreadEntry, ScheduledCore, ValidatorIndex,
};
use scale_info::TypeInfo;
use sp_runtime::traits::{One, Saturating};
use sp_std::{convert::TryInto, prelude::*};
@@ -48,7 +49,7 @@ use crate::{configuration, initializer::SessionChangeNotification, paras};
pub use pallet::*;
/// A queued parathread entry, pre-assigned to a core.
#[derive(Encode, Decode, Default)]
#[derive(Encode, Decode, Default, TypeInfo)]
#[cfg_attr(test, derive(PartialEq, Debug))]
pub struct QueuedParathread {
claim: ParathreadEntry,
@@ -56,7 +57,7 @@ pub struct QueuedParathread {
}
/// The queue of all parathread claims.
#[derive(Encode, Decode, Default)]
#[derive(Encode, Decode, Default, TypeInfo)]
#[cfg_attr(test, derive(PartialEq, Debug))]
pub struct ParathreadClaimQueue {
queue: Vec<QueuedParathread>,
@@ -97,7 +98,7 @@ pub enum FreedReason {
}
/// The assignment type.
#[derive(Clone, Encode, Decode)]
#[derive(Clone, Encode, Decode, TypeInfo)]
#[cfg_attr(feature = "std", derive(PartialEq, Debug))]
pub enum AssignmentKind {
/// A parachain.
@@ -107,7 +108,7 @@ pub enum AssignmentKind {
}
/// How a free core is scheduled to be assigned.
#[derive(Clone, Encode, Decode)]
#[derive(Clone, Encode, Decode, TypeInfo)]
#[cfg_attr(feature = "std", derive(PartialEq, Debug))]
pub struct CoreAssignment {
/// The core that is assigned.
+2
View File
@@ -8,6 +8,7 @@ build = "build.rs"
[dependencies]
bitvec = { version = "0.20.1", default-features = false, features = ["alloc"] }
parity-scale-codec = { version = "2.2.0", default-features = false, features = ["derive", "max-encoded-len"] }
scale-info = { version = "1.0", default-features = false, features = ["derive"] }
log = { version = "0.4.14", default-features = false }
rustc-hex = { version = "2.1.0", default-features = false }
serde = { version = "1.0.130", default-features = false }
@@ -100,6 +101,7 @@ std = [
"primitives/std",
"rustc-hex/std",
"parity-scale-codec/std",
"scale-info/std",
"inherents/std",
"sp-core/std",
"sp-api/std",
+23 -13
View File
@@ -906,7 +906,17 @@ parameter_types! {
/// The type used to represent the kinds of proxying allowed.
#[derive(
Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, RuntimeDebug, MaxEncodedLen,
Copy,
Clone,
Eq,
PartialEq,
Ord,
PartialOrd,
Encode,
Decode,
RuntimeDebug,
MaxEncodedLen,
scale_info::TypeInfo,
)]
pub enum ProxyType {
Any = 0,
@@ -964,9 +974,9 @@ impl InstanceFilter<Call> for ProxyType {
Call::Scheduler(..) |
Call::Babe(..) |
Call::Timestamp(..) |
Call::Indices(pallet_indices::Call::claim(..)) |
Call::Indices(pallet_indices::Call::free(..)) |
Call::Indices(pallet_indices::Call::freeze(..)) |
Call::Indices(pallet_indices::Call::claim{..}) |
Call::Indices(pallet_indices::Call::free{..}) |
Call::Indices(pallet_indices::Call::freeze{..}) |
// Specifically omitting Indices `transfer`, `force_transfer`
// Specifically omitting the entire Balances pallet
Call::Authorship(..) |
@@ -983,8 +993,8 @@ impl InstanceFilter<Call> for ProxyType {
Call::Bounties(..) |
Call::Tips(..) |
Call::Claims(..) |
Call::Vesting(pallet_vesting::Call::vest(..)) |
Call::Vesting(pallet_vesting::Call::vest_other(..)) |
Call::Vesting(pallet_vesting::Call::vest{..}) |
Call::Vesting(pallet_vesting::Call::vest_other{..}) |
// Specifically omitting Vesting `vested_transfer`, and `force_vested_transfer`
Call::Utility(..) |
Call::Identity(..) |
@@ -1004,10 +1014,10 @@ impl InstanceFilter<Call> for ProxyType {
},
ProxyType::IdentityJudgement => matches!(
c,
Call::Identity(pallet_identity::Call::provide_judgement(..)) | Call::Utility(..)
Call::Identity(pallet_identity::Call::provide_judgement { .. }) | Call::Utility(..)
),
ProxyType::CancelProxy => {
matches!(c, Call::Proxy(pallet_proxy::Call::reject_announcement(..)))
matches!(c, Call::Proxy(pallet_proxy::Call::reject_announcement { .. }))
},
}
}
@@ -1271,7 +1281,7 @@ sp_api::impl_runtime_apis! {
impl sp_api::Metadata<Block> for Runtime {
fn metadata() -> OpaqueMetadata {
Runtime::metadata().into()
OpaqueMetadata::new(Runtime::metadata().into())
}
}
@@ -1699,10 +1709,10 @@ mod test_fees {
#[ignore]
fn transfer_cost_min_multiplier() {
let min_multiplier = runtime_common::MinimumMultiplier::get();
let call = <pallet_balances::Call<Runtime>>::transfer_keep_alive(
Default::default(),
Default::default(),
);
let call = pallet_balances::Call::<Runtime>::transfer_keep_alive {
dest: Default::default(),
value: Default::default(),
};
let info = call.get_dispatch_info();
// convert to outer call.
let call = Call::Balances(call);
+2
View File
@@ -7,6 +7,7 @@ build = "build.rs"
[dependencies]
parity-scale-codec = { version = "2.2.0", default-features = false, features = ["derive", "max-encoded-len"] }
scale-info = { version = "1.0", default-features = false, features = ["derive"] }
serde = { version = "1.0.130", default-features = false }
serde_derive = { version = "1.0.117", optional = true }
smallvec = "1.6.1"
@@ -92,6 +93,7 @@ std = [
"bp-wococo/std",
"bridge-runtime-common/std",
"parity-scale-codec/std",
"scale-info/std",
"frame-executive/std",
"pallet-authority-discovery/std",
"pallet-authorship/std",
+18 -4
View File
@@ -46,6 +46,7 @@ use runtime_common::{
BlockHashCount, BlockLength, BlockWeights, RocksDbWeight, SlowAdjustingFeeUpdate,
};
use runtime_parachains::{self, runtime_api_impl::v1 as runtime_api_impl};
use scale_info::TypeInfo;
use sp_core::{OpaqueMetadata, RuntimeDebug};
use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys,
@@ -1034,7 +1035,17 @@ parameter_types! {
/// The type used to represent the kinds of proxying allowed.
#[derive(
Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, RuntimeDebug, MaxEncodedLen,
Copy,
Clone,
Eq,
PartialEq,
Ord,
PartialOrd,
Encode,
Decode,
RuntimeDebug,
MaxEncodedLen,
TypeInfo,
)]
pub enum ProxyType {
Any,
@@ -1051,10 +1062,13 @@ impl InstanceFilter<Call> for ProxyType {
match self {
ProxyType::Any => true,
ProxyType::CancelProxy =>
matches!(c, Call::Proxy(pallet_proxy::Call::reject_announcement(..))),
matches!(c, Call::Proxy(pallet_proxy::Call::reject_announcement { .. })),
ProxyType::Auction => matches!(
c,
Call::Auctions(..) | Call::Crowdloan(..) | Call::Registrar(..) | Call::Slots(..)
Call::Auctions { .. } |
Call::Crowdloan { .. } |
Call::Registrar { .. } |
Call::Slots { .. }
),
}
}
@@ -1129,7 +1143,7 @@ sp_api::impl_runtime_apis! {
impl sp_api::Metadata<Block> for Runtime {
fn metadata() -> OpaqueMetadata {
Runtime::metadata().into()
OpaqueMetadata::new(Runtime::metadata().into())
}
}
+2
View File
@@ -10,6 +10,7 @@ bitvec = { version = "0.20.1", default-features = false, features = ["alloc"] }
parity-scale-codec = { version = "2.0.0", default-features = false, features = ["derive"] }
log = { version = "0.4.14", default-features = false }
rustc-hex = { version = "2.1.0", default-features = false }
scale-info = { version = "1.0", default-features = false, features = ["derive"] }
serde = { version = "1.0.130", default-features = false }
serde_derive = { version = "1.0.117", optional = true }
smallvec = "1.6.1"
@@ -83,6 +84,7 @@ std = [
"primitives/std",
"rustc-hex/std",
"parity-scale-codec/std",
"scale-info/std",
"inherents/std",
"sp-core/std",
"polkadot-parachain/std",
+3 -2
View File
@@ -593,7 +593,8 @@ pub mod pallet_test_notifier {
let id = who
.using_encoded(|mut d| <[u8; 32]>::decode(&mut d))
.map_err(|_| Error::<T>::BadAccountFormat)?;
let call = Call::<T>::notification_received(0, Default::default());
let call =
Call::<T>::notification_received { query_id: 0, response: Default::default() };
let qid = pallet_xcm::Pallet::<T>::new_notify_query(
Junction::AccountId32 { network: Any, id }.into(),
<T as Config>::Call::from(call),
@@ -723,7 +724,7 @@ sp_api::impl_runtime_apis! {
impl sp_api::Metadata<Block> for Runtime {
fn metadata() -> OpaqueMetadata {
Runtime::metadata().into()
OpaqueMetadata::new(Runtime::metadata().into())
}
}
+2
View File
@@ -8,6 +8,7 @@ build = "build.rs"
[dependencies]
bitvec = { version = "0.20.1", default-features = false, features = ["alloc"] }
parity-scale-codec = { version = "2.2.0", default-features = false, features = ["derive", "max-encoded-len"] }
scale-info = { version = "1.0", default-features = false, features = ["derive"] }
log = { version = "0.4.14", default-features = false }
rustc-hex = { version = "2.1.0", default-features = false }
serde = { version = "1.0.130", default-features = false }
@@ -105,6 +106,7 @@ std = [
"primitives/std",
"rustc-hex/std",
"parity-scale-codec/std",
"scale-info/std",
"inherents/std",
"sp-core/std",
"polkadot-parachain/std",
+29 -19
View File
@@ -651,7 +651,17 @@ parameter_types! {
/// The type used to represent the kinds of proxying allowed.
#[derive(
Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, RuntimeDebug, MaxEncodedLen,
Copy,
Clone,
Eq,
PartialEq,
Ord,
PartialOrd,
Encode,
Decode,
RuntimeDebug,
MaxEncodedLen,
scale_info::TypeInfo,
)]
pub enum ProxyType {
Any,
@@ -676,9 +686,9 @@ impl InstanceFilter<Call> for ProxyType {
Call::System(..) |
Call::Babe(..) |
Call::Timestamp(..) |
Call::Indices(pallet_indices::Call::claim(..)) |
Call::Indices(pallet_indices::Call::free(..)) |
Call::Indices(pallet_indices::Call::freeze(..)) |
Call::Indices(pallet_indices::Call::claim{..}) |
Call::Indices(pallet_indices::Call::free{..}) |
Call::Indices(pallet_indices::Call::freeze{..}) |
// Specifically omitting Indices `transfer`, `force_transfer`
// Specifically omitting the entire Balances pallet
Call::Authorship(..) |
@@ -688,24 +698,24 @@ impl InstanceFilter<Call> for ProxyType {
Call::ImOnline(..) |
Call::Utility(..) |
Call::Identity(..) |
Call::Recovery(pallet_recovery::Call::as_recovered(..)) |
Call::Recovery(pallet_recovery::Call::vouch_recovery(..)) |
Call::Recovery(pallet_recovery::Call::claim_recovery(..)) |
Call::Recovery(pallet_recovery::Call::close_recovery(..)) |
Call::Recovery(pallet_recovery::Call::remove_recovery(..)) |
Call::Recovery(pallet_recovery::Call::cancel_recovered(..)) |
Call::Recovery(pallet_recovery::Call::as_recovered{..}) |
Call::Recovery(pallet_recovery::Call::vouch_recovery{..}) |
Call::Recovery(pallet_recovery::Call::claim_recovery{..}) |
Call::Recovery(pallet_recovery::Call::close_recovery{..}) |
Call::Recovery(pallet_recovery::Call::remove_recovery{..}) |
Call::Recovery(pallet_recovery::Call::cancel_recovered{..}) |
// Specifically omitting Recovery `create_recovery`, `initiate_recovery`
Call::Vesting(pallet_vesting::Call::vest(..)) |
Call::Vesting(pallet_vesting::Call::vest_other(..)) |
Call::Vesting(pallet_vesting::Call::vest{..}) |
Call::Vesting(pallet_vesting::Call::vest_other{..}) |
// Specifically omitting Vesting `vested_transfer`, and `force_vested_transfer`
Call::Scheduler(..) |
// Specifically omitting Sudo pallet
Call::Proxy(..) |
Call::Multisig(..) |
Call::Registrar(paras_registrar::Call::register(..)) |
Call::Registrar(paras_registrar::Call::deregister(..)) |
Call::Registrar(paras_registrar::Call::register{..}) |
Call::Registrar(paras_registrar::Call::deregister{..}) |
// Specifically omitting Registrar `swap`
Call::Registrar(paras_registrar::Call::reserve(..)) |
Call::Registrar(paras_registrar::Call::reserve{..}) |
Call::Crowdloan(..) |
Call::Slots(..) |
Call::Auctions(..) // Specifically omitting the entire XCM Pallet
@@ -714,7 +724,7 @@ impl InstanceFilter<Call> for ProxyType {
matches!(c, Call::Staking(..) | Call::Session(..) | Call::Utility(..))
},
ProxyType::SudoBalances => match c {
Call::Sudo(pallet_sudo::Call::sudo(ref x)) => {
Call::Sudo(pallet_sudo::Call::sudo { call: ref x }) => {
matches!(x.as_ref(), &Call::Balances(..))
},
Call::Utility(..) => true,
@@ -722,10 +732,10 @@ impl InstanceFilter<Call> for ProxyType {
},
ProxyType::IdentityJudgement => matches!(
c,
Call::Identity(pallet_identity::Call::provide_judgement(..)) | Call::Utility(..)
Call::Identity(pallet_identity::Call::provide_judgement { .. }) | Call::Utility(..)
),
ProxyType::CancelProxy => {
matches!(c, Call::Proxy(pallet_proxy::Call::reject_announcement(..)))
matches!(c, Call::Proxy(pallet_proxy::Call::reject_announcement { .. }))
},
ProxyType::Auction => matches!(
c,
@@ -1109,7 +1119,7 @@ sp_api::impl_runtime_apis! {
impl sp_api::Metadata<Block> for Runtime {
fn metadata() -> OpaqueMetadata {
Runtime::metadata().into()
OpaqueMetadata::new(Runtime::metadata().into())
}
}
+1 -1
View File
@@ -81,7 +81,7 @@ macro_rules! construct_runtime_prelude {
let crate::signer::Signer { account, pair, .. } = signer;
let local_call = EPMCall::<Runtime>::submit(Box::new(raw_solution), witness);
let local_call = EPMCall::<Runtime>::submit { raw_solution: Box::new(raw_solution), num_signed_submissions: witness };
let call: Call = <EPMCall<Runtime> as std::convert::TryInto<Call>>::try_into(local_call)
.expect("election provider pallet must exist in the runtime, thus \
inner call can be converted, qed."
+2
View File
@@ -8,6 +8,7 @@ edition = "2018"
[dependencies]
impl-trait-for-tuples = "0.2.0"
parity-scale-codec = { version = "2.0.0", default-features = false, features = [ "derive" ] }
scale-info = { version = "1.0", default-features = false, features = ["derive"] }
derivative = {version = "2.2.0", default-features = false, features = [ "use_core" ] }
log = { version = "0.4.14", default-features = false }
xcm-procedural = { path = "procedural" }
@@ -17,4 +18,5 @@ default = ["std"]
wasm-api = []
std = [
"parity-scale-codec/std",
"scale-info/std",
]
+2
View File
@@ -6,6 +6,7 @@ version = "0.9.9"
[dependencies]
codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false, features = ["derive"] }
scale-info = { version = "1.0", default-features = false, features = ["derive"] }
serde = { version = "1.0.130", optional = true, features = ["derive"] }
log = { version = "0.4.14", default-features = false }
@@ -29,6 +30,7 @@ polkadot-parachain = { path = "../../parachain" }
default = ["std"]
std = [
"codec/std",
"scale-info/std",
"serde",
"sp-std/std",
"sp-core/std",
+4 -3
View File
@@ -25,6 +25,7 @@ mod tests;
use codec::{Decode, Encode, EncodeLike};
use frame_support::traits::{Contains, EnsureOrigin, Get, OriginTrait};
use scale_info::TypeInfo;
use sp_runtime::{
traits::{BadOrigin, Saturating},
RuntimeDebug,
@@ -217,7 +218,7 @@ pub mod pallet {
}
#[pallet::origin]
#[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug)]
#[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug, TypeInfo)]
pub enum Origin {
/// It comes from somewhere in the XCM space wanting to transact.
Xcm(MultiLocation),
@@ -264,7 +265,7 @@ pub mod pallet {
}
/// The status of a query.
#[derive(Clone, Eq, PartialEq, Encode, Decode, RuntimeDebug)]
#[derive(Clone, Eq, PartialEq, Encode, Decode, RuntimeDebug, TypeInfo)]
pub enum QueryStatus<BlockNumber> {
/// The query was sent but no response has yet been received.
Pending {
@@ -290,7 +291,7 @@ pub mod pallet {
}
}
#[derive(Clone, Encode, Decode, Eq, PartialEq, Ord, PartialOrd)]
#[derive(Clone, Encode, Decode, Eq, PartialEq, Ord, PartialOrd, TypeInfo)]
pub enum VersionMigrationStage {
MigrateSupportedVersion,
MigrateVersionNotifiers,
+2 -1
View File
@@ -93,7 +93,8 @@ pub mod pallet_test_notifier {
let id = who
.using_encoded(|mut d| <[u8; 32]>::decode(&mut d))
.map_err(|_| Error::<T>::BadAccountFormat)?;
let call = Call::<T>::notification_received(0, Default::default());
let call =
Call::<T>::notification_received { query_id: 0, response: Default::default() };
let qid = crate::Pallet::<T>::new_notify_query(
Junction::AccountId32 { network: Any, id }.into(),
<T as Config>::Call::from(call),
+4 -1
View File
@@ -44,7 +44,10 @@ fn report_outcome_notify_works() {
assets: (Here, SEND_AMOUNT).into(),
beneficiary: sender.clone(),
}]);
let call = pallet_test_notifier::Call::notification_received(0, Default::default());
let call = pallet_test_notifier::Call::notification_received {
query_id: 0,
response: Default::default(),
};
let notify = Call::TestNotifier(call);
new_test_ext_with_balances(balances).execute_with(|| {
XcmPallet::report_outcome_notify(&mut message, Parachain(PARA_ID).into(), notify, 100)
+2 -1
View File
@@ -20,9 +20,10 @@ use parity_scale_codec::{Decode, DecodeLimit, Encode};
/// Wrapper around the encoded and decoded versions of a value.
/// Caches the decoded value once computed.
#[derive(Encode, Decode)]
#[derive(Encode, Decode, scale_info::TypeInfo)]
#[codec(encode_bound())]
#[codec(decode_bound())]
#[scale_info(bounds(), skip_type_params(T))]
pub struct DoubleEncoded<T> {
encoded: Vec<u8>,
#[codec(skip)]
+7 -5
View File
@@ -30,6 +30,7 @@ use core::{
};
use derivative::Derivative;
use parity_scale_codec::{Decode, Encode, Error as CodecError, Input};
use scale_info::TypeInfo;
pub mod v0;
pub mod v1;
@@ -69,7 +70,7 @@ pub trait IntoVersion: Sized {
}
/// A single `MultiLocation` value, together with its version code.
#[derive(Derivative, Encode, Decode)]
#[derive(Derivative, Encode, Decode, TypeInfo)]
#[derivative(Clone(bound = ""), Eq(bound = ""), PartialEq(bound = ""), Debug(bound = ""))]
#[codec(encode_bound())]
#[codec(decode_bound())]
@@ -123,7 +124,7 @@ impl TryFrom<VersionedMultiLocation> for v1::MultiLocation {
}
/// A single `Response` value, together with its version code.
#[derive(Derivative, Encode, Decode)]
#[derive(Derivative, Encode, Decode, TypeInfo)]
#[derivative(Clone(bound = ""), Eq(bound = ""), PartialEq(bound = ""), Debug(bound = ""))]
#[codec(encode_bound())]
#[codec(decode_bound())]
@@ -199,7 +200,7 @@ impl TryFrom<VersionedResponse> for v2::Response {
}
/// A single `MultiAsset` value, together with its version code.
#[derive(Derivative, Encode, Decode)]
#[derive(Derivative, Encode, Decode, TypeInfo)]
#[derivative(Clone(bound = ""), Eq(bound = ""), PartialEq(bound = ""), Debug(bound = ""))]
#[codec(encode_bound())]
#[codec(decode_bound())]
@@ -253,7 +254,7 @@ impl TryFrom<VersionedMultiAsset> for v1::MultiAsset {
}
/// A single `MultiAssets` value, together with its version code.
#[derive(Derivative, Encode, Decode)]
#[derive(Derivative, Encode, Decode, TypeInfo)]
#[derivative(Clone(bound = ""), Eq(bound = ""), PartialEq(bound = ""), Debug(bound = ""))]
#[codec(encode_bound())]
#[codec(decode_bound())]
@@ -307,10 +308,11 @@ impl TryFrom<VersionedMultiAssets> for v1::MultiAssets {
}
/// A single XCM message, together with its version code.
#[derive(Derivative, Encode, Decode)]
#[derive(Derivative, Encode, Decode, TypeInfo)]
#[derivative(Clone(bound = ""), Eq(bound = ""), PartialEq(bound = ""), Debug(bound = ""))]
#[codec(encode_bound())]
#[codec(decode_bound())]
#[scale_info(bounds(), skip_type_params(Call))]
pub enum VersionedXcm<Call> {
V0(v0::Xcm<Call>),
V1(v1::Xcm<Call>),
+5 -4
View File
@@ -18,9 +18,10 @@
use alloc::vec::Vec;
use parity_scale_codec::{Decode, Encode};
use scale_info::TypeInfo;
/// A global identifier of an account-bearing consensus system.
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug)]
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo)]
pub enum NetworkId {
/// Unidentified/any.
Any,
@@ -33,7 +34,7 @@ pub enum NetworkId {
}
/// An identifier of a pluralistic body.
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug)]
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo)]
pub enum BodyId {
/// The only body in its context.
Unit,
@@ -54,7 +55,7 @@ pub enum BodyId {
}
/// A part of a pluralistic body.
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug)]
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo)]
pub enum BodyPart {
/// The body's declaration, under whatever means it decides.
Voice,
@@ -101,7 +102,7 @@ impl BodyPart {
/// A single item in a path to describe the relative location of a consensus system.
///
/// Each item assumes a pre-existing location as its context and is defined in terms of it.
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug)]
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo)]
pub enum Junction {
/// The consensus system of which the context is a member and state-wise super-set.
///
+5 -3
View File
@@ -24,6 +24,7 @@ use core::{
};
use derivative::Derivative;
use parity_scale_codec::{self, Decode, Encode};
use scale_info::TypeInfo;
mod junction;
mod multi_asset;
@@ -58,7 +59,7 @@ pub mod prelude {
// the number of items in the vector.
/// Basically just the XCM (more general) version of `ParachainDispatchOrigin`.
#[derive(Copy, Clone, Eq, PartialEq, Encode, Decode, Debug)]
#[derive(Copy, Clone, Eq, PartialEq, Encode, Decode, Debug, TypeInfo)]
pub enum OriginKind {
/// Origin should just be the native dispatch origin representation for the sender in the
/// local runtime framework. For Cumulus/Frame chains this is the `Parachain` or `Relay` origin
@@ -81,7 +82,7 @@ pub enum OriginKind {
}
/// Response data to a query.
#[derive(Clone, Eq, PartialEq, Encode, Decode, Debug)]
#[derive(Clone, Eq, PartialEq, Encode, Decode, Debug, TypeInfo)]
pub enum Response {
/// Some assets.
Assets(Vec<MultiAsset>),
@@ -95,10 +96,11 @@ pub enum Response {
///
/// This is the inner XCM format and is version-sensitive. Messages are typically passed using the outer
/// XCM format, known as `VersionedXcm`.
#[derive(Derivative, Encode, Decode)]
#[derive(Derivative, Encode, Decode, TypeInfo)]
#[derivative(Clone(bound = ""), Eq(bound = ""), PartialEq(bound = ""), Debug(bound = ""))]
#[codec(encode_bound())]
#[codec(decode_bound())]
#[scale_info(bounds(), skip_type_params(Call))]
pub enum Xcm<Call> {
/// Withdraw asset(s) (`assets`) from the ownership of `origin` and place them into `holding`. Execute the
/// orders (`effects`).
+2 -1
View File
@@ -24,6 +24,7 @@ use core::{
result,
};
use parity_scale_codec::{self, Decode, Encode};
use scale_info::TypeInfo;
pub use crate::v1::AssetInstance;
@@ -82,7 +83,7 @@ pub use crate::v1::AssetInstance;
/// - `<chain>/AccountId32` for an ERC-20-style single-asset smart-contract on a Frame-based contracts chain.
/// - `<chain>/AccountKey20` for an ERC-20-style single-asset smart-contract on an Ethereum-like chain.
///
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug)]
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo)]
pub enum MultiAsset {
/// No assets. Rarely used.
None,
+1 -1
View File
@@ -42,7 +42,7 @@ use parity_scale_codec::{self, Decode, Encode};
/// This specific `MultiLocation` implementation uses a Rust `enum` in order to make pattern matching easier.
///
/// The `MultiLocation` value of `Null` simply refers to the interpreting consensus system.
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug)]
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, scale_info::TypeInfo)]
pub enum MultiLocation {
/// The interpreting consensus system.
Null,
+2 -1
View File
@@ -26,10 +26,11 @@ use derivative::Derivative;
use parity_scale_codec::{self, Decode, Encode};
/// An instruction to be executed on some or all of the assets in holding, used by asset-related XCM messages.
#[derive(Derivative, Encode, Decode)]
#[derive(Derivative, Encode, Decode, scale_info::TypeInfo)]
#[derivative(Clone(bound = ""), Eq(bound = ""), PartialEq(bound = ""), Debug(bound = ""))]
#[codec(encode_bound())]
#[codec(decode_bound())]
#[scale_info(bounds(), skip_type_params(Call))]
pub enum Order<Call> {
/// Do nothing. Not generally used.
#[codec(index = 0)]
+2 -2
View File
@@ -21,7 +21,7 @@ use parity_scale_codec::{Decode, Encode};
use super::{MultiLocation, Xcm};
#[derive(Clone, Encode, Decode, Eq, PartialEq, Debug)]
#[derive(Clone, Encode, Decode, Eq, PartialEq, Debug, scale_info::TypeInfo)]
pub enum Error {
Undefined,
/// An arithmetic overflow happened.
@@ -103,7 +103,7 @@ pub type Result = result::Result<(), Error>;
pub type Weight = u64;
/// Outcome of an XCM execution.
#[derive(Clone, Encode, Decode, Eq, PartialEq, Debug)]
#[derive(Clone, Encode, Decode, Eq, PartialEq, Debug, scale_info::TypeInfo)]
pub enum Outcome {
/// Execution completed successfully; given weight was used.
Complete(Weight),
+2 -1
View File
@@ -21,11 +21,12 @@ use crate::v0::Junction as Junction0;
use alloc::vec::Vec;
use core::convert::TryFrom;
use parity_scale_codec::{self, Decode, Encode};
use scale_info::TypeInfo;
/// A single item in a path to describe the relative location of a consensus system.
///
/// Each item assumes a pre-existing location as its context and is defined in terms of it.
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug)]
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo)]
pub enum Junction {
/// An indexed parachain belonging to and operated by the context.
///
+4 -2
View File
@@ -29,6 +29,7 @@ use core::{
};
use derivative::Derivative;
use parity_scale_codec::{self, Decode, Encode};
use scale_info::TypeInfo;
mod junction;
mod multiasset;
@@ -75,7 +76,7 @@ pub mod prelude {
}
/// Response data to a query.
#[derive(Clone, Eq, PartialEq, Encode, Decode, Debug)]
#[derive(Clone, Eq, PartialEq, Encode, Decode, Debug, TypeInfo)]
pub enum Response {
/// Some assets.
Assets(MultiAssets),
@@ -91,10 +92,11 @@ pub enum Response {
///
/// This is the inner XCM format and is version-sensitive. Messages are typically passed using the outer
/// XCM format, known as `VersionedXcm`.
#[derive(Derivative, Encode, Decode)]
#[derive(Derivative, Encode, Decode, TypeInfo)]
#[derivative(Clone(bound = ""), Eq(bound = ""), PartialEq(bound = ""), Debug(bound = ""))]
#[codec(encode_bound())]
#[codec(decode_bound())]
#[scale_info(bounds(), skip_type_params(Call))]
pub enum Xcm<Call> {
/// Withdraw asset(s) (`assets`) from the ownership of `origin` and place them into `holding`. Execute the
/// orders (`effects`).
+9 -8
View File
@@ -31,9 +31,10 @@ use core::{
result,
};
use parity_scale_codec::{self as codec, Decode, Encode};
use scale_info::TypeInfo;
/// A general identifier for an instance of a non-fungible asset class.
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug)]
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo)]
pub enum AssetInstance {
/// Undefined - used if the non-fungible asset class has only one instance.
Undefined,
@@ -95,7 +96,7 @@ impl From<Vec<u8>> for AssetInstance {
}
/// Classification of an asset being concrete or abstract.
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Encode, Decode)]
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Encode, Decode, TypeInfo)]
pub enum AssetId {
Concrete(MultiLocation),
Abstract(Vec<u8>),
@@ -135,7 +136,7 @@ impl AssetId {
}
/// Classification of whether an asset is fungible or not, along with a mandatory amount or instance.
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Encode, Decode)]
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Encode, Decode, TypeInfo)]
pub enum Fungibility {
Fungible(#[codec(compact)] u128),
NonFungible(AssetInstance),
@@ -162,7 +163,7 @@ impl<T: Into<AssetInstance>> From<T> for Fungibility {
}
}
#[derive(Clone, Eq, PartialEq, Debug, Encode, Decode)]
#[derive(Clone, Eq, PartialEq, Debug, Encode, Decode, TypeInfo)]
pub struct MultiAsset {
pub id: AssetId,
pub fun: Fungibility,
@@ -266,7 +267,7 @@ impl TryFrom<Vec<super::super::v0::MultiAsset>> for MultiAsset {
}
/// A `Vec` of `MultiAsset`s. There may be no duplicate fungible items in here and when decoding, they must be sorted.
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Encode)]
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Encode, TypeInfo)]
pub struct MultiAssets(Vec<MultiAsset>);
impl Decode for MultiAssets {
@@ -422,14 +423,14 @@ impl MultiAssets {
}
}
/// Classification of whether an asset is fungible or not.
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Encode, Decode)]
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Encode, Decode, TypeInfo)]
pub enum WildFungibility {
Fungible,
NonFungible,
}
/// A wildcard representing a set of assets.
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Encode, Decode)]
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Encode, Decode, TypeInfo)]
pub enum WildMultiAsset {
/// All assets in the holding register, up to `usize` individual assets (different instances of non-fungibles could
/// be separate assets).
@@ -501,7 +502,7 @@ impl<A: Into<AssetId>, B: Into<WildFungibility>> From<(A, B)> for WildMultiAsset
///
/// Note: Vectors of wildcards whose encoding is supported in XCM v0 are unsupported
/// in this implementation and will result in a decode error.
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Encode, Decode)]
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Encode, Decode, TypeInfo)]
pub enum MultiAssetFilter {
Definite(MultiAssets),
Wild(WildMultiAsset),
+3 -2
View File
@@ -19,6 +19,7 @@
use super::Junction;
use core::{convert::TryFrom, mem, result};
use parity_scale_codec::{Decode, Encode};
use scale_info::TypeInfo;
/// A relative path between state-bearing consensus systems.
///
@@ -46,7 +47,7 @@ use parity_scale_codec::{Decode, Encode};
/// that a value is strictly an interior location, in those cases, `Junctions` may be used.
///
/// The `MultiLocation` value of `Null` simply refers to the interpreting consensus system.
#[derive(Clone, Decode, Encode, Eq, PartialEq, Ord, PartialOrd, Debug)]
#[derive(Clone, Decode, Encode, Eq, PartialEq, Ord, PartialOrd, Debug, TypeInfo)]
pub struct MultiLocation {
/// The number of parent junctions at the beginning of this `MultiLocation`.
pub parents: u8,
@@ -370,7 +371,7 @@ const MAX_JUNCTIONS: usize = 8;
///
/// Parent junctions cannot be constructed with this type. Refer to `MultiLocation` for
/// instructions on constructing parent junctions.
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug)]
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo)]
pub enum Junctions {
/// The interpreting consensus system.
Here,
+3 -1
View File
@@ -25,12 +25,14 @@ use core::{
};
use derivative::Derivative;
use parity_scale_codec::{self, Decode, Encode};
use scale_info::TypeInfo;
/// An instruction to be executed on some or all of the assets in holding, used by asset-related XCM messages.
#[derive(Derivative, Encode, Decode)]
#[derive(Derivative, Encode, Decode, TypeInfo)]
#[derivative(Clone(bound = ""), Eq(bound = ""), PartialEq(bound = ""), Debug(bound = ""))]
#[codec(encode_bound())]
#[codec(decode_bound())]
#[scale_info(bounds(), skip_type_params(Call))]
pub enum Order<Call> {
/// Do nothing. Not generally used.
#[codec(index = 0)]
+3 -2
View File
@@ -18,10 +18,11 @@
use core::result;
use parity_scale_codec::{Decode, Encode};
use scale_info::TypeInfo;
use super::{MultiLocation, Xcm};
#[derive(Clone, Encode, Decode, Eq, PartialEq, Debug)]
#[derive(Clone, Encode, Decode, Eq, PartialEq, Debug, TypeInfo)]
pub enum Error {
Undefined,
/// An arithmetic overflow happened.
@@ -105,7 +106,7 @@ pub type Result = result::Result<(), Error>;
pub type Weight = u64;
/// Outcome of an XCM execution.
#[derive(Clone, Encode, Decode, Eq, PartialEq, Debug)]
#[derive(Clone, Encode, Decode, Eq, PartialEq, Debug, TypeInfo)]
pub enum Outcome {
/// Execution completed successfully; given weight was used.
Complete(Weight),
+7 -4
View File
@@ -26,6 +26,7 @@ use core::{
};
use derivative::Derivative;
use parity_scale_codec::{self, Decode, Encode};
use scale_info::TypeInfo;
mod traits;
@@ -45,10 +46,11 @@ pub const VERSION: super::Version = 2;
/// An identifier for a query.
pub type QueryId = u64;
#[derive(Derivative, Default, Encode, Decode)]
#[derive(Derivative, Default, Encode, Decode, TypeInfo)]
#[derivative(Clone(bound = ""), Eq(bound = ""), PartialEq(bound = ""), Debug(bound = ""))]
#[codec(encode_bound())]
#[codec(decode_bound())]
#[scale_info(bounds(), skip_type_params(Call))]
pub struct Xcm<Call>(pub Vec<Instruction<Call>>);
impl<Call> Xcm<Call> {
@@ -143,7 +145,7 @@ pub mod prelude {
}
/// Response data to a query.
#[derive(Clone, Eq, PartialEq, Encode, Decode, Debug)]
#[derive(Clone, Eq, PartialEq, Encode, Decode, Debug, TypeInfo)]
pub enum Response {
/// No response. Serves as a neutral default.
Null,
@@ -162,7 +164,7 @@ impl Default for Response {
}
/// An optional weight limit.
#[derive(Clone, Eq, PartialEq, Encode, Decode, Debug)]
#[derive(Clone, Eq, PartialEq, Encode, Decode, Debug, TypeInfo)]
pub enum WeightLimit {
/// No weight limit imposed.
Unlimited,
@@ -196,10 +198,11 @@ impl From<WeightLimit> for Option<u64> {
///
/// This is the inner XCM format and is version-sensitive. Messages are typically passed using the outer
/// XCM format, known as `VersionedXcm`.
#[derive(Derivative, Encode, Decode)]
#[derive(Derivative, Encode, Decode, TypeInfo)]
#[derivative(Clone(bound = ""), Eq(bound = ""), PartialEq(bound = ""), Debug(bound = ""))]
#[codec(encode_bound())]
#[codec(decode_bound())]
#[scale_info(bounds(), skip_type_params(Call))]
pub enum Instruction<Call> {
/// Withdraw asset(s) (`assets`) from the ownership of `origin` and place them into the Holding
/// Register.
+3 -2
View File
@@ -18,10 +18,11 @@
use core::result;
use parity_scale_codec::{Decode, Encode};
use scale_info::TypeInfo;
use super::*;
#[derive(Copy, Clone, Encode, Decode, Eq, PartialEq, Debug)]
#[derive(Copy, Clone, Encode, Decode, Eq, PartialEq, Debug, TypeInfo)]
pub enum Error {
Undefined,
/// An arithmetic overflow happened.
@@ -126,7 +127,7 @@ pub type Result = result::Result<(), Error>;
pub type Weight = u64;
/// Outcome of an XCM execution.
#[derive(Clone, Encode, Decode, Eq, PartialEq, Debug)]
#[derive(Clone, Encode, Decode, Eq, PartialEq, Debug, TypeInfo)]
pub enum Outcome {
/// Execution completed successfully; given weight was used.
Complete(Weight),
+2
View File
@@ -7,6 +7,7 @@ version = "0.9.9"
[dependencies]
parity-scale-codec = { version = "2.0.0", default-features = false, features = ["derive"] }
scale-info = { version = "1.0", default-features = false, features = ["derive"] }
xcm = { path = "..", default-features = false }
xcm-executor = { path = "../xcm-executor", default-features = false }
sp-std = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
@@ -32,6 +33,7 @@ runtime-benchmarks = []
std = [
"log/std",
"parity-scale-codec/std",
"scale-info/std",
"xcm/std",
"xcm-executor/std",
"sp-std/std",
+1 -1
View File
@@ -53,7 +53,7 @@ pub enum TestOrigin {
///
/// Each item contains the amount of weight that it *wants* to consume as the first item, and the actual amount (if
/// different from the former) in the second option.
#[derive(Debug, Encode, Decode, Eq, PartialEq, Clone, Copy)]
#[derive(Debug, Encode, Decode, Eq, PartialEq, Clone, Copy, scale_info::TypeInfo)]
pub enum TestCall {
OnlyRoot(Weight, Option<Weight>),
OnlyParachain(Weight, Option<Weight>, Option<u32>),
@@ -44,10 +44,10 @@ fn basic_buy_fees_message_executes() {
let execute = construct_extrinsic(
&client,
polkadot_test_runtime::Call::Xcm(pallet_xcm::Call::execute(
Box::new(VersionedXcm::from(msg)),
1_000_000_000,
)),
polkadot_test_runtime::Call::Xcm(pallet_xcm::Call::execute {
message: Box::new(VersionedXcm::from(msg)),
max_weight: 1_000_000_000,
}),
sp_keyring::Sr25519Keyring::Alice,
0,
);
@@ -88,7 +88,7 @@ fn query_response_fires() {
let execute = construct_extrinsic(
&client,
polkadot_test_runtime::Call::TestNotifier(pallet_test_notifier::Call::prepare_new_query()),
polkadot_test_runtime::Call::TestNotifier(pallet_test_notifier::Call::prepare_new_query {}),
sp_keyring::Sr25519Keyring::Alice,
0,
);
@@ -124,7 +124,10 @@ fn query_response_fires() {
let execute = construct_extrinsic(
&client,
polkadot_test_runtime::Call::Xcm(pallet_xcm::Call::execute(msg, 1_000_000_000)),
polkadot_test_runtime::Call::Xcm(pallet_xcm::Call::execute {
message: msg,
max_weight: 1_000_000_000,
}),
sp_keyring::Sr25519Keyring::Alice,
1,
);
@@ -173,7 +176,7 @@ fn query_response_elicits_handler() {
let execute = construct_extrinsic(
&client,
polkadot_test_runtime::Call::TestNotifier(
pallet_test_notifier::Call::prepare_new_notify_query(),
pallet_test_notifier::Call::prepare_new_notify_query {},
),
sp_keyring::Sr25519Keyring::Alice,
0,
@@ -209,10 +212,10 @@ fn query_response_elicits_handler() {
let execute = construct_extrinsic(
&client,
polkadot_test_runtime::Call::Xcm(pallet_xcm::Call::execute(
Box::new(VersionedXcm::from(msg)),
1_000_000_000,
)),
polkadot_test_runtime::Call::Xcm(pallet_xcm::Call::execute {
message: Box::new(VersionedXcm::from(msg)),
max_weight: 1_000_000_000,
}),
sp_keyring::Sr25519Keyring::Alice,
1,
);
@@ -7,6 +7,7 @@ edition = "2018"
[dependencies]
codec = { package = "parity-scale-codec", version = "2.0.0" }
scale-info = { version = "1.0", features = ["derive"] }
frame-system = { git = "https://github.com/paritytech/substrate", branch = "master" }
frame-support = { git = "https://github.com/paritytech/substrate", branch = "master" }
@@ -118,9 +118,10 @@ mod tests {
fn dmp() {
MockNet::reset();
let remark = parachain::Call::System(
frame_system::Call::<parachain::Runtime>::remark_with_event(vec![1, 2, 3]),
);
let remark =
parachain::Call::System(frame_system::Call::<parachain::Runtime>::remark_with_event {
remark: vec![1, 2, 3],
});
Relay::execute_with(|| {
assert_ok!(RelayChainPalletXcm::send_xcm(
Here,
@@ -146,7 +147,7 @@ mod tests {
MockNet::reset();
let remark = relay_chain::Call::System(
frame_system::Call::<relay_chain::Runtime>::remark_with_event(vec![1, 2, 3]),
frame_system::Call::<relay_chain::Runtime>::remark_with_event { remark: vec![1, 2, 3] },
);
ParaA::execute_with(|| {
assert_ok!(ParachainPalletXcm::send_xcm(
@@ -172,9 +173,10 @@ mod tests {
fn xcmp() {
MockNet::reset();
let remark = parachain::Call::System(
frame_system::Call::<parachain::Runtime>::remark_with_event(vec![1, 2, 3]),
);
let remark =
parachain::Call::System(frame_system::Call::<parachain::Runtime>::remark_with_event {
remark: vec![1, 2, 3],
});
ParaA::execute_with(|| {
assert_ok!(ParachainPalletXcm::send_xcm(
Here,