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
@@ -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");