Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • nodes/rust/duniter-v2s
  • llaq/lc-core-substrate
  • pini-gh/duniter-v2s
  • vincentux/duniter-v2s
  • mildred/duniter-v2s
  • d0p1/duniter-v2s
  • bgallois/duniter-v2s
  • Nicolas80/duniter-v2s
8 results
Show changes
Showing with 392 additions and 336 deletions
...@@ -25,7 +25,8 @@ use sp_runtime::transaction_validity::TransactionPriority; ...@@ -25,7 +25,8 @@ use sp_runtime::transaction_validity::TransactionPriority;
parameter_types! { parameter_types! {
pub const BlockHashCount: BlockNumber = 2400; pub const BlockHashCount: BlockNumber = 2400;
/// We allow for 2 seconds of compute with a 6 second average block time. /// We allow for 2 seconds of compute with a 6 second average block time.
pub BlockWeights: frame_system::limits::BlockWeights = block_weights(2 * WEIGHT_PER_SECOND, NORMAL_DISPATCH_RATIO); pub BlockWeights: frame_system::limits::BlockWeights = block_weights((WEIGHT_PER_SECOND * 2)
.set_proof_size(5 * 1024 * 1024), NORMAL_DISPATCH_RATIO);
pub BlockLength: frame_system::limits::BlockLength = frame_system::limits::BlockLength pub BlockLength: frame_system::limits::BlockLength = frame_system::limits::BlockLength
::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO); ::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);
pub const SS58Prefix: u16 = 4450; pub const SS58Prefix: u16 = 4450;
......
[build-dependencies.substrate-wasm-builder] [build-dependencies.substrate-wasm-builder]
git = 'https://github.com/duniter/substrate' git = 'https://github.com/duniter/substrate'
branch = 'duniter-substrate-v0.9.26' branch = 'duniter-substrate-v0.9.32'
[package] [package]
authors = ['Axiom-Team Developers <https://axiom-team.fr>'] authors = ['Axiom-Team Developers <https://axiom-team.fr>']
...@@ -104,6 +104,7 @@ std = [ ...@@ -104,6 +104,7 @@ std = [
'sp-version/std', 'sp-version/std',
] ]
try-runtime = [ try-runtime = [
"common-runtime/try-runtime",
"frame-executive/try-runtime", "frame-executive/try-runtime",
"frame-try-runtime", "frame-try-runtime",
"frame-system/try-runtime", "frame-system/try-runtime",
...@@ -126,10 +127,10 @@ try-runtime = [ ...@@ -126,10 +127,10 @@ try-runtime = [
] ]
[dev-dependencies] [dev-dependencies]
sp-consensus-vrf = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26' } sp-consensus-vrf = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32' }
sp-finality-grandpa = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26' } sp-finality-grandpa = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32' }
sp-io = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26' } sp-io = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32' }
sp-keyring = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26' } sp-keyring = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32' }
[dependencies] [dependencies]
# local # local
...@@ -156,45 +157,45 @@ serde = { version = "1.0.101", default-features = false } ...@@ -156,45 +157,45 @@ serde = { version = "1.0.101", default-features = false }
serde_derive = { version = "1.0.101", optional = true } serde_derive = { version = "1.0.101", optional = true }
# substrate # substrate
frame-try-runtime = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false, optional = true } frame-try-runtime = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false, optional = true }
frame-executive = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } frame-executive = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
frame-support = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } frame-support = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
frame-system = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } frame-system = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
frame-system-rpc-runtime-api = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false} frame-system-rpc-runtime-api = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false}
pallet-atomic-swap = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } pallet-atomic-swap = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
pallet-authority-discovery = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } pallet-authority-discovery = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
pallet-authorship = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } pallet-authorship = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
pallet-babe = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } pallet-babe = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
pallet-balances = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } pallet-balances = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
pallet-collective = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } pallet-collective = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
pallet-grandpa = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } pallet-grandpa = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
pallet-im-online = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } pallet-im-online = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
pallet-offences = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } pallet-offences = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
pallet-multisig = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } pallet-multisig = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
pallet-preimage = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } pallet-preimage = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
pallet-proxy = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } pallet-proxy = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
pallet-scheduler = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } pallet-scheduler = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
pallet-session = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } pallet-session = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
pallet-sudo = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } pallet-sudo = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
pallet-timestamp = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } pallet-timestamp = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
pallet-transaction-payment = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } pallet-transaction-payment = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
pallet-transaction-payment-rpc-runtime-api = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } pallet-transaction-payment-rpc-runtime-api = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
pallet-treasury = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } pallet-treasury = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
pallet-utility = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } pallet-utility = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
sp-api = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } sp-api = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
sp-arithmetic = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } sp-arithmetic = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
sp-authority-discovery = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } sp-authority-discovery = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
sp-block-builder = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } sp-block-builder = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
sp-consensus-babe = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } sp-consensus-babe = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
sp-core = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } sp-core = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
sp-inherents = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } sp-inherents = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
sp-offchain = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } sp-offchain = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
sp-runtime = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } sp-runtime = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
sp-session = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } sp-session = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
sp-std = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } sp-std = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
sp-transaction-pool = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } sp-transaction-pool = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
sp-version = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } sp-version = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
# substrate benchmarking # substrate benchmarking
frame-benchmarking = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false, optional = true } frame-benchmarking = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false, optional = true }
frame-system-benchmarking = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false, optional = true } frame-system-benchmarking = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false, optional = true }
...@@ -35,6 +35,7 @@ pub use common_runtime::{ ...@@ -35,6 +35,7 @@ pub use common_runtime::{
constants::*, entities::*, handlers::*, AccountId, Address, Balance, BlockNumber, constants::*, entities::*, handlers::*, AccountId, Address, Balance, BlockNumber,
FullIdentificationOfImpl, GetCurrentEpochIndex, Hash, Header, IdtyIndex, Index, Signature, FullIdentificationOfImpl, GetCurrentEpochIndex, Hash, Header, IdtyIndex, Index, Signature,
}; };
pub use frame_system::Call as SystemCall;
pub use pallet_balances::Call as BalancesCall; pub use pallet_balances::Call as BalancesCall;
pub use pallet_duniter_test_parameters::Parameters as GenesisParameters; pub use pallet_duniter_test_parameters::Parameters as GenesisParameters;
pub use pallet_im_online::sr25519::AuthorityId as ImOnlineId; pub use pallet_im_online::sr25519::AuthorityId as ImOnlineId;
...@@ -109,7 +110,8 @@ pub fn native_version() -> NativeVersion { ...@@ -109,7 +110,8 @@ pub fn native_version() -> NativeVersion {
/// Block type as expected by this runtime. /// Block type as expected by this runtime.
pub type Block = sp_runtime::generic::Block<Header, UncheckedExtrinsic>; pub type Block = sp_runtime::generic::Block<Header, UncheckedExtrinsic>;
/// Unchecked extrinsic type as expected by this runtime. /// Unchecked extrinsic type as expected by this runtime.
pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>; pub type UncheckedExtrinsic =
generic::UncheckedExtrinsic<Address, RuntimeCall, Signature, SignedExtra>;
/// The SignedExtension to the basic transaction logic. /// The SignedExtension to the basic transaction logic.
pub type SignedExtra = ( pub type SignedExtra = (
frame_system::CheckNonZeroSender<Runtime>, frame_system::CheckNonZeroSender<Runtime>,
...@@ -134,32 +136,58 @@ pub type Executive = frame_executive::Executive< ...@@ -134,32 +136,58 @@ pub type Executive = frame_executive::Executive<
pub type TechnicalCommitteeInstance = Instance2; pub type TechnicalCommitteeInstance = Instance2;
#[cfg(feature = "runtime-benchmarks")]
mod benches {
define_benchmarks!(
// Duniter
// NOTE: Make sure to prefix these with `common_runtime::` so
// the that path resolves correctly in the generated file.
[common_runtime::oneshot_account, OneshotAccount]
[common_runtime::universal_dividend, UniversalDividend]
[common_runtime::upgrade_origin, UpgradeOrigin]
// Substrate
[pallet_balances, Balances]
[frame_benchmarking::baseline, Baseline::<Runtime>]
[pallet_collective, TechnicalCommittee]
[pallet_im_online, ImOnline]
[pallet_multisig, Multisig]
[pallet_preimage, Preimage]
[pallet_proxy, Proxy]
[pallet_scheduler, Scheduler]
[frame_system, SystemBench::<Runtime>]
[pallet_timestamp, Timestamp]
[pallet_treasury, Treasury]
[pallet_utility, Utility]
);
}
pub struct BaseCallFilter; pub struct BaseCallFilter;
#[cfg(not(feature = "runtime-benchmarks"))] #[cfg(not(feature = "runtime-benchmarks"))]
impl Contains<Call> for BaseCallFilter { impl Contains<RuntimeCall> for BaseCallFilter {
fn contains(call: &Call) -> bool { fn contains(call: &RuntimeCall) -> bool {
!matches!( !matches!(
call, call,
Call::System( /*RuntimeCall::System(
frame_system::Call::remark { .. } | frame_system::Call::remark_with_event { .. } frame_system::Call::remark { .. } | frame_system::Call::remark_with_event { .. }
) | Call::Membership( ) | */
RuntimeCall::Membership(
pallet_membership::Call::request_membership { .. } pallet_membership::Call::request_membership { .. }
| pallet_membership::Call::claim_membership { .. } | pallet_membership::Call::claim_membership { .. }
| pallet_membership::Call::revoke_membership { .. } | pallet_membership::Call::revoke_membership { .. }
) | Call::Session(_) ) | RuntimeCall::Session(_)
) )
} }
} }
#[cfg(feature = "runtime-benchmarks")] #[cfg(feature = "runtime-benchmarks")]
impl Contains<Call> for BaseCallFilter { impl Contains<RuntimeCall> for BaseCallFilter {
fn contains(call: &Call) -> bool { fn contains(call: &RuntimeCall) -> bool {
!matches!( !matches!(
call, call,
Call::Membership( RuntimeCall::Membership(
pallet_membership::Call::request_membership { .. } pallet_membership::Call::request_membership { .. }
| pallet_membership::Call::claim_membership { .. } | pallet_membership::Call::claim_membership { .. }
| pallet_membership::Call::revoke_membership { .. } | pallet_membership::Call::revoke_membership { .. }
) | Call::Session(_) ) | RuntimeCall::Session(_)
) )
} }
} }
...@@ -190,29 +218,32 @@ impl Default for ProxyType { ...@@ -190,29 +218,32 @@ impl Default for ProxyType {
Self::AlmostAny Self::AlmostAny
} }
} }
impl frame_support::traits::InstanceFilter<Call> for ProxyType { impl frame_support::traits::InstanceFilter<RuntimeCall> for ProxyType {
fn filter(&self, c: &Call) -> bool { fn filter(&self, c: &RuntimeCall) -> bool {
match self { match self {
ProxyType::AlmostAny => { ProxyType::AlmostAny => {
// Some calls are never authorized from a proxied account // Some calls are never authorized from a proxied account
!matches!( !matches!(
c, c,
Call::Cert(..) | Call::Identity(..) | Call::SmithsCert(..) RuntimeCall::Cert(..) | RuntimeCall::Identity(..) | RuntimeCall::SmithsCert(..)
) )
} }
ProxyType::TransferOnly => { ProxyType::TransferOnly => {
matches!(c, Call::Balances(..) | Call::UniversalDividend(..)) matches!(
c,
RuntimeCall::Balances(..) | RuntimeCall::UniversalDividend(..)
)
} }
ProxyType::CancelProxy => { ProxyType::CancelProxy => {
matches!( matches!(
c, c,
Call::Proxy(pallet_proxy::Call::reject_announcement { .. }) RuntimeCall::Proxy(pallet_proxy::Call::reject_announcement { .. })
) )
} }
ProxyType::TechnicalCommitteePropose => { ProxyType::TechnicalCommitteePropose => {
matches!( matches!(
c, c,
Call::TechnicalCommittee(pallet_collective::Call::propose { .. }) RuntimeCall::TechnicalCommittee(pallet_collective::Call::propose { .. })
) )
} }
} }
...@@ -260,8 +291,8 @@ common_runtime::pallets_config! { ...@@ -260,8 +291,8 @@ common_runtime::pallets_config! {
} }
impl pallet_sudo::Config for Runtime { impl pallet_sudo::Config for Runtime {
type Event = Event; type RuntimeEvent = RuntimeEvent;
type Call = Call; type RuntimeCall = RuntimeCall;
} }
} }
...@@ -331,10 +362,10 @@ construct_runtime!( ...@@ -331,10 +362,10 @@ construct_runtime!(
impl<C> frame_system::offchain::SendTransactionTypes<C> for Runtime impl<C> frame_system::offchain::SendTransactionTypes<C> for Runtime
where where
Call: From<C>, RuntimeCall: From<C>,
{ {
type Extrinsic = UncheckedExtrinsic; type Extrinsic = UncheckedExtrinsic;
type OverarchingCall = Call; type OverarchingCall = RuntimeCall;
} }
// All of our runtimes share most of their Runtime API implementations. // All of our runtimes share most of their Runtime API implementations.
......
...@@ -19,13 +19,13 @@ use crate::*; ...@@ -19,13 +19,13 @@ use crate::*;
pub struct MigrationsV400; pub struct MigrationsV400;
impl frame_support::traits::OnRuntimeUpgrade for MigrationsV400 { impl frame_support::traits::OnRuntimeUpgrade for MigrationsV400 {
fn on_runtime_upgrade() -> Weight { fn on_runtime_upgrade() -> Weight {
let mut weight = 1_000_000_000; // Safety margin let mut weight = Weight::from_ref_time(1_000_000_000); // Safety margin
type OldvalueType = AccountId; type OldvalueType = AccountId;
pallet_membership::PendingMembership::<Runtime, Instance1>::translate_values( pallet_membership::PendingMembership::<Runtime, Instance1>::translate_values(
|_: OldvalueType| { |_: OldvalueType| {
weight += <Runtime as frame_system::Config>::DbWeight::get().write; *weight.ref_time_mut() += <Runtime as frame_system::Config>::DbWeight::get().write;
Some(()) Some(())
}, },
); );
...@@ -34,12 +34,12 @@ impl frame_support::traits::OnRuntimeUpgrade for MigrationsV400 { ...@@ -34,12 +34,12 @@ impl frame_support::traits::OnRuntimeUpgrade for MigrationsV400 {
} }
#[cfg(feature = "try-runtime")] #[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<(), &'static str> { fn pre_upgrade() -> Result<frame_benchmarking::Vec<u8>, &'static str> {
Ok(()) Ok(Vec::new())
} }
#[cfg(feature = "try-runtime")] #[cfg(feature = "try-runtime")]
fn post_upgrade() -> Result<(), &'static str> { fn post_upgrade(_state: frame_benchmarking::Vec<u8>) -> Result<(), &'static str> {
Ok(()) Ok(())
} }
} }
...@@ -25,7 +25,8 @@ use sp_runtime::transaction_validity::TransactionPriority; ...@@ -25,7 +25,8 @@ use sp_runtime::transaction_validity::TransactionPriority;
parameter_types! { parameter_types! {
pub const BlockHashCount: BlockNumber = 2400; pub const BlockHashCount: BlockNumber = 2400;
/// We allow for 2 seconds of compute with a 6 second average block time. /// We allow for 2 seconds of compute with a 6 second average block time.
pub BlockWeights: frame_system::limits::BlockWeights = block_weights(2 * WEIGHT_PER_SECOND, NORMAL_DISPATCH_RATIO); pub BlockWeights: frame_system::limits::BlockWeights = block_weights((WEIGHT_PER_SECOND * 2)
.set_proof_size(5 * 1024 * 1024), NORMAL_DISPATCH_RATIO);
pub BlockLength: frame_system::limits::BlockLength = frame_system::limits::BlockLength pub BlockLength: frame_system::limits::BlockLength = frame_system::limits::BlockLength
::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO); ::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);
pub const SS58Prefix: u16 = 42; pub const SS58Prefix: u16 = 42;
......
...@@ -92,15 +92,15 @@ fn test_remove_identity() { ...@@ -92,15 +92,15 @@ fn test_remove_identity() {
None None
)); ));
System::assert_has_event(Event::Membership( System::assert_has_event(RuntimeEvent::Membership(
pallet_membership::Event::MembershipRevoked(4), pallet_membership::Event::MembershipRevoked(4),
)); ));
System::assert_has_event(Event::System(frame_system::Event::KilledAccount { System::assert_has_event(RuntimeEvent::System(frame_system::Event::KilledAccount {
account: AccountKeyring::Dave.to_account_id(), account: AccountKeyring::Dave.to_account_id(),
})); }));
System::assert_has_event(Event::Identity(pallet_identity::Event::IdtyRemoved { System::assert_has_event(RuntimeEvent::Identity(
idty_index: 4, pallet_identity::Event::IdtyRemoved { idty_index: 4 },
})); ));
}); });
} }
#[test] #[test]
...@@ -116,27 +116,27 @@ fn test_remove_identity_after_one_ud() { ...@@ -116,27 +116,27 @@ fn test_remove_identity_after_one_ud() {
)); ));
// Verify events // Verify events
System::assert_has_event(Event::Membership( System::assert_has_event(RuntimeEvent::Membership(
pallet_membership::Event::MembershipRevoked(4), pallet_membership::Event::MembershipRevoked(4),
)); ));
System::assert_has_event(Event::Balances(pallet_balances::Event::Deposit { System::assert_has_event(RuntimeEvent::Balances(pallet_balances::Event::Deposit {
who: AccountKeyring::Dave.to_account_id(), who: AccountKeyring::Dave.to_account_id(),
amount: 1_000, amount: 1_000,
})); }));
System::assert_has_event(Event::Balances(pallet_balances::Event::Endowed { System::assert_has_event(RuntimeEvent::Balances(pallet_balances::Event::Endowed {
account: AccountKeyring::Dave.to_account_id(), account: AccountKeyring::Dave.to_account_id(),
free_balance: 1_000, free_balance: 1_000,
})); }));
System::assert_has_event(Event::UniversalDividend( System::assert_has_event(RuntimeEvent::UniversalDividend(
pallet_universal_dividend::Event::UdsAutoPaidAtRemoval { pallet_universal_dividend::Event::UdsAutoPaidAtRemoval {
count: 1, count: 1,
total: 1_000, total: 1_000,
who: AccountKeyring::Dave.to_account_id(), who: AccountKeyring::Dave.to_account_id(),
}, },
)); ));
System::assert_has_event(Event::Identity(pallet_identity::Event::IdtyRemoved { System::assert_has_event(RuntimeEvent::Identity(
idty_index: 4, pallet_identity::Event::IdtyRemoved { idty_index: 4 },
})); ));
// Verify state // Verify state
assert!(Identity::identity(4).is_none()); assert!(Identity::identity(4).is_none());
...@@ -158,18 +158,18 @@ fn test_remove_smith_identity() { ...@@ -158,18 +158,18 @@ fn test_remove_smith_identity() {
None None
)); ));
// Verify events // Verify events
System::assert_has_event(Event::SmithsMembership( System::assert_has_event(RuntimeEvent::SmithsMembership(
pallet_membership::Event::MembershipRevoked(3), pallet_membership::Event::MembershipRevoked(3),
)); ));
System::assert_has_event(Event::AuthorityMembers( System::assert_has_event(RuntimeEvent::AuthorityMembers(
pallet_authority_members::Event::MemberRemoved(3), pallet_authority_members::Event::MemberRemoved(3),
)); ));
System::assert_has_event(Event::Membership( System::assert_has_event(RuntimeEvent::Membership(
pallet_membership::Event::MembershipRevoked(3), pallet_membership::Event::MembershipRevoked(3),
)); ));
System::assert_has_event(Event::Identity(pallet_identity::Event::IdtyRemoved { System::assert_has_event(RuntimeEvent::Identity(
idty_index: 3, pallet_identity::Event::IdtyRemoved { idty_index: 3 },
})); ));
}); });
} }
...@@ -188,14 +188,14 @@ fn test_create_new_account_with_insufficient_balance() { ...@@ -188,14 +188,14 @@ fn test_create_new_account_with_insufficient_balance() {
400 400
)); ));
System::assert_has_event(Event::System(frame_system::Event::NewAccount { System::assert_has_event(RuntimeEvent::System(frame_system::Event::NewAccount {
account: AccountKeyring::Eve.to_account_id(), account: AccountKeyring::Eve.to_account_id(),
})); }));
System::assert_has_event(Event::Balances(pallet_balances::Event::Endowed { System::assert_has_event(RuntimeEvent::Balances(pallet_balances::Event::Endowed {
account: AccountKeyring::Eve.to_account_id(), account: AccountKeyring::Eve.to_account_id(),
free_balance: 400, free_balance: 400,
})); }));
System::assert_has_event(Event::Balances(pallet_balances::Event::Transfer { System::assert_has_event(RuntimeEvent::Balances(pallet_balances::Event::Transfer {
from: AccountKeyring::Alice.to_account_id(), from: AccountKeyring::Alice.to_account_id(),
to: AccountKeyring::Eve.to_account_id(), to: AccountKeyring::Eve.to_account_id(),
amount: 400, amount: 400,
...@@ -205,17 +205,17 @@ fn test_create_new_account_with_insufficient_balance() { ...@@ -205,17 +205,17 @@ fn test_create_new_account_with_insufficient_balance() {
// to pay the "new account tax" // to pay the "new account tax"
run_to_block(3); run_to_block(3);
System::assert_has_event(Event::Account( System::assert_has_event(RuntimeEvent::Account(
pallet_duniter_account::Event::ForceDestroy { pallet_duniter_account::Event::ForceDestroy {
who: AccountKeyring::Eve.to_account_id(), who: AccountKeyring::Eve.to_account_id(),
balance: 400, balance: 400,
}, },
)); ));
System::assert_has_event(Event::Balances(pallet_balances::Event::Deposit { System::assert_has_event(RuntimeEvent::Balances(pallet_balances::Event::Deposit {
who: Treasury::account_id(), who: Treasury::account_id(),
amount: 400, amount: 400,
})); }));
System::assert_has_event(Event::Treasury(pallet_treasury::Event::Deposit { System::assert_has_event(RuntimeEvent::Treasury(pallet_treasury::Event::Deposit {
value: 400, value: 400,
})); }));
...@@ -242,14 +242,14 @@ fn test_create_new_account() { ...@@ -242,14 +242,14 @@ fn test_create_new_account() {
500 500
)); ));
//println!("{:#?}", System::events()); //println!("{:#?}", System::events());
System::assert_has_event(Event::System(frame_system::Event::NewAccount { System::assert_has_event(RuntimeEvent::System(frame_system::Event::NewAccount {
account: AccountKeyring::Eve.to_account_id(), account: AccountKeyring::Eve.to_account_id(),
})); }));
System::assert_has_event(Event::Balances(pallet_balances::Event::Endowed { System::assert_has_event(RuntimeEvent::Balances(pallet_balances::Event::Endowed {
account: AccountKeyring::Eve.to_account_id(), account: AccountKeyring::Eve.to_account_id(),
free_balance: 500, free_balance: 500,
})); }));
System::assert_has_event(Event::Balances(pallet_balances::Event::Transfer { System::assert_has_event(RuntimeEvent::Balances(pallet_balances::Event::Transfer {
from: AccountKeyring::Alice.to_account_id(), from: AccountKeyring::Alice.to_account_id(),
to: AccountKeyring::Eve.to_account_id(), to: AccountKeyring::Eve.to_account_id(),
amount: 500, amount: 500,
...@@ -259,15 +259,15 @@ fn test_create_new_account() { ...@@ -259,15 +259,15 @@ fn test_create_new_account() {
// and new account tax should be collected and deposited in the treasury // and new account tax should be collected and deposited in the treasury
run_to_block(3); run_to_block(3);
System::assert_has_event(Event::Balances(pallet_balances::Event::Withdraw { System::assert_has_event(RuntimeEvent::Balances(pallet_balances::Event::Withdraw {
who: AccountKeyring::Eve.to_account_id(), who: AccountKeyring::Eve.to_account_id(),
amount: 300, amount: 300,
})); }));
System::assert_has_event(Event::Balances(pallet_balances::Event::Deposit { System::assert_has_event(RuntimeEvent::Balances(pallet_balances::Event::Deposit {
who: Treasury::account_id(), who: Treasury::account_id(),
amount: 300, amount: 300,
})); }));
System::assert_has_event(Event::Treasury(pallet_treasury::Event::Deposit { System::assert_has_event(RuntimeEvent::Treasury(pallet_treasury::Event::Deposit {
value: 300, value: 300,
})); }));
......
[build-dependencies.substrate-wasm-builder] [build-dependencies.substrate-wasm-builder]
git = 'https://github.com/duniter/substrate' git = 'https://github.com/duniter/substrate'
branch = 'duniter-substrate-v0.9.26' branch = 'duniter-substrate-v0.9.32'
[package] [package]
authors = ['Axiom-Team Developers <https://axiom-team.fr>'] authors = ['Axiom-Team Developers <https://axiom-team.fr>']
...@@ -103,10 +103,10 @@ try-runtime = [ ...@@ -103,10 +103,10 @@ try-runtime = [
] ]
[dev-dependencies] [dev-dependencies]
sp-consensus-vrf = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26' } sp-consensus-vrf = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32' }
sp-finality-grandpa = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26' } sp-finality-grandpa = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32' }
sp-io = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26' } sp-io = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32' }
sp-keyring = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26' } sp-keyring = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32' }
[dependencies] [dependencies]
# local # local
...@@ -132,43 +132,43 @@ scale-info = { version = "2.1.1", default-features = false, features = ["derive" ...@@ -132,43 +132,43 @@ scale-info = { version = "2.1.1", default-features = false, features = ["derive"
serde = { version = "1.0.101", optional = true, features = ["derive"] } serde = { version = "1.0.101", optional = true, features = ["derive"] }
# substrate # substrate
frame-benchmarking = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', optional = true } frame-benchmarking = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', optional = true }
frame-try-runtime = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false, optional = true } frame-try-runtime = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false, optional = true }
frame-executive = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } frame-executive = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
frame-support = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } frame-support = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
frame-system = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } frame-system = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
frame-system-benchmarking = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', optional = true } frame-system-benchmarking = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', optional = true }
frame-system-rpc-runtime-api = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false} frame-system-rpc-runtime-api = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false}
pallet-atomic-swap = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } pallet-atomic-swap = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
pallet-authority-discovery = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } pallet-authority-discovery = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
pallet-authorship = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } pallet-authorship = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
pallet-babe = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } pallet-babe = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
pallet-balances = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } pallet-balances = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
pallet-collective = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } pallet-collective = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
pallet-grandpa = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } pallet-grandpa = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
pallet-im-online = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } pallet-im-online = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
pallet-offences = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } pallet-offences = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
pallet-multisig = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } pallet-multisig = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
pallet-preimage = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } pallet-preimage = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
pallet-proxy = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } pallet-proxy = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
pallet-scheduler = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } pallet-scheduler = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
pallet-session = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } pallet-session = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
pallet-sudo = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } pallet-sudo = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
pallet-timestamp = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } pallet-timestamp = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
pallet-transaction-payment = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } pallet-transaction-payment = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
pallet-transaction-payment-rpc-runtime-api = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } pallet-transaction-payment-rpc-runtime-api = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
pallet-treasury = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } pallet-treasury = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
pallet-utility = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } pallet-utility = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
sp-api = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } sp-api = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
sp-arithmetic = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } sp-arithmetic = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
sp-authority-discovery = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } sp-authority-discovery = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
sp-block-builder = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } sp-block-builder = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
sp-consensus-babe = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } sp-consensus-babe = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
sp-core = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } sp-core = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
sp-inherents = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } sp-inherents = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
sp-offchain = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } sp-offchain = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
sp-runtime = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } sp-runtime = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
sp-session = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } sp-session = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
sp-std = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } sp-std = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
sp-transaction-pool = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } sp-transaction-pool = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
sp-version = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26', default-features = false } sp-version = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false }
...@@ -103,7 +103,8 @@ pub fn native_version() -> NativeVersion { ...@@ -103,7 +103,8 @@ pub fn native_version() -> NativeVersion {
/// Block type as expected by this runtime. /// Block type as expected by this runtime.
pub type Block = sp_runtime::generic::Block<Header, UncheckedExtrinsic>; pub type Block = sp_runtime::generic::Block<Header, UncheckedExtrinsic>;
/// Unchecked extrinsic type as expected by this runtime. /// Unchecked extrinsic type as expected by this runtime.
pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>; pub type UncheckedExtrinsic =
generic::UncheckedExtrinsic<Address, RuntimeCall, Signature, SignedExtra>;
/// The SignedExtension to the basic transaction logic. /// The SignedExtension to the basic transaction logic.
pub type SignedExtra = ( pub type SignedExtra = (
frame_system::CheckNonZeroSender<Runtime>, frame_system::CheckNonZeroSender<Runtime>,
...@@ -127,17 +128,42 @@ pub type Executive = frame_executive::Executive< ...@@ -127,17 +128,42 @@ pub type Executive = frame_executive::Executive<
pub type TechnicalCommitteeInstance = Instance2; pub type TechnicalCommitteeInstance = Instance2;
#[cfg(feature = "runtime-benchmarks")]
mod benches {
define_benchmarks!(
// Duniter
// NOTE: Make sure to prefix these with `common_runtime::` so
// the that path resolves correctly in the generated file.
[common_runtime::oneshot_account, OneshotAccount]
[common_runtime::universal_dividend, UniversalDividend]
[common_runtime::upgrade_origin, UpgradeOrigin]
// Substrate
[pallet_balances, Balances]
[frame_benchmarking::baseline, Baseline::<Runtime>]
[pallet_collective, TechnicalCommittee]
[pallet_im_online, ImOnline]
[pallet_multisig, Multisig]
[pallet_preimage, Preimage]
[pallet_proxy, Proxy]
[pallet_scheduler, Scheduler]
[frame_system, SystemBench::<Runtime>]
[pallet_timestamp, Timestamp]
[pallet_treasury, Treasury]
[pallet_utility, Utility]
);
}
pub struct BaseCallFilter; pub struct BaseCallFilter;
impl Contains<Call> for BaseCallFilter { impl Contains<RuntimeCall> for BaseCallFilter {
fn contains(call: &Call) -> bool { fn contains(call: &RuntimeCall) -> bool {
!matches!( !matches!(
call, call,
Call::System( RuntimeCall::System(
frame_system::Call::remark { .. } | frame_system::Call::remark_with_event { .. } frame_system::Call::remark { .. } | frame_system::Call::remark_with_event { .. }
) | Call::Membership( ) | RuntimeCall::Membership(
pallet_membership::Call::claim_membership { .. } pallet_membership::Call::claim_membership { .. }
| pallet_membership::Call::revoke_membership { .. } | pallet_membership::Call::revoke_membership { .. }
) | Call::Session(_) ) | RuntimeCall::Session(_)
) )
} }
} }
...@@ -167,23 +193,26 @@ impl Default for ProxyType { ...@@ -167,23 +193,26 @@ impl Default for ProxyType {
Self::AlmostAny Self::AlmostAny
} }
} }
impl frame_support::traits::InstanceFilter<Call> for ProxyType { impl frame_support::traits::InstanceFilter<RuntimeCall> for ProxyType {
fn filter(&self, c: &Call) -> bool { fn filter(&self, c: &RuntimeCall) -> bool {
match self { match self {
ProxyType::AlmostAny => { ProxyType::AlmostAny => {
// Some calls are never authorized from a proxied account // Some calls are never authorized from a proxied account
!matches!( !matches!(
c, c,
Call::Cert(..) | Call::Identity(..) | Call::SmithsCert(..) RuntimeCall::Cert(..) | RuntimeCall::Identity(..) | RuntimeCall::SmithsCert(..)
) )
} }
ProxyType::TransferOnly => { ProxyType::TransferOnly => {
matches!(c, Call::Balances(..) | Call::UniversalDividend(..)) matches!(
c,
RuntimeCall::Balances(..) | RuntimeCall::UniversalDividend(..)
)
} }
ProxyType::CancelProxy => { ProxyType::CancelProxy => {
matches!( matches!(
c, c,
Call::Proxy(pallet_proxy::Call::reject_announcement { .. }) RuntimeCall::Proxy(pallet_proxy::Call::reject_announcement { .. })
) )
} }
} }
...@@ -192,8 +221,8 @@ impl frame_support::traits::InstanceFilter<Call> for ProxyType { ...@@ -192,8 +221,8 @@ impl frame_support::traits::InstanceFilter<Call> for ProxyType {
common_runtime::pallets_config! { common_runtime::pallets_config! {
impl pallet_sudo::Config for Runtime { impl pallet_sudo::Config for Runtime {
type Event = Event; type RuntimeEvent = RuntimeEvent;
type Call = Call; type RuntimeCall = RuntimeCall;
} }
} }
...@@ -260,10 +289,10 @@ construct_runtime!( ...@@ -260,10 +289,10 @@ construct_runtime!(
impl<C> frame_system::offchain::SendTransactionTypes<C> for Runtime impl<C> frame_system::offchain::SendTransactionTypes<C> for Runtime
where where
Call: From<C>, RuntimeCall: From<C>,
{ {
type Extrinsic = UncheckedExtrinsic; type Extrinsic = UncheckedExtrinsic;
type OverarchingCall = Call; type OverarchingCall = RuntimeCall;
} }
// All of our runtimes share most of their Runtime API implementations. // All of our runtimes share most of their Runtime API implementations.
......
...@@ -25,7 +25,8 @@ use sp_runtime::transaction_validity::TransactionPriority; ...@@ -25,7 +25,8 @@ use sp_runtime::transaction_validity::TransactionPriority;
parameter_types! { parameter_types! {
pub const BlockHashCount: BlockNumber = 2400; pub const BlockHashCount: BlockNumber = 2400;
/// We allow for 2 seconds of compute with a 6 second average block time. /// We allow for 2 seconds of compute with a 6 second average block time.
pub BlockWeights: frame_system::limits::BlockWeights = block_weights(2 * WEIGHT_PER_SECOND, NORMAL_DISPATCH_RATIO); pub BlockWeights: frame_system::limits::BlockWeights = block_weights((WEIGHT_PER_SECOND * 2)
.set_proof_size(5 * 1024 * 1024), NORMAL_DISPATCH_RATIO);
pub BlockLength: frame_system::limits::BlockLength = frame_system::limits::BlockLength pub BlockLength: frame_system::limits::BlockLength = frame_system::limits::BlockLength
::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO); ::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);
pub const SS58Prefix: u16 = 42; pub const SS58Prefix: u16 = 42;
......
[toolchain] [toolchain]
channel = "nightly-2022-04-20" channel = "nightly-2022-10-09"
components = [ "rustfmt", "clippy" ] components = [ "rustfmt", "clippy" ]
targets = [ "wasm32-unknown-unknown" ] targets = [ "wasm32-unknown-unknown" ]
profile = "minimal" profile = "minimal"
...@@ -22,7 +22,7 @@ SPEC_DIR="${4:-resources}" ...@@ -22,7 +22,7 @@ SPEC_DIR="${4:-resources}"
echo "CURRENCY=$CURRENCY" echo "CURRENCY=$CURRENCY"
# constants # constants
DUNITER_IMAGE_TAG="sha-99fb985b" DUNITER_IMAGE_TAG="sha-366af125"
# Clean and (re-)create working forders # Clean and (re-)create working forders
rm -rf $WORK_DIR rm -rf $WORK_DIR
......
...@@ -14,7 +14,7 @@ name = "xtask" ...@@ -14,7 +14,7 @@ name = "xtask"
[dependencies] [dependencies]
anyhow = "1.0.32" anyhow = "1.0.32"
clap = { version = "3.0", features = ["derive"] } clap = { version = "4.0", features = ["derive"] }
codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false, features = ["derive", "full", "bit-vec"] } codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false, features = ["derive", "full", "bit-vec"] }
frame-metadata = "15.0.0" frame-metadata = "15.0.0"
graphql_client = "0.10.0" graphql_client = "0.10.0"
...@@ -29,3 +29,4 @@ serde_json = "1.0" ...@@ -29,3 +29,4 @@ serde_json = "1.0"
tokio = { version = "1.15.0", features = ["macros"] } tokio = { version = "1.15.0", features = ["macros"] }
version_check = "0.9.2" version_check = "0.9.2"
version-compare = "0.0.11" version-compare = "0.0.11"
tera = { version = "1", default-features = false }
\ No newline at end of file
There are **{{ calls_counter }}** {{ category_name }} calls from **{{ pallets | length }}** pallets.
{% for pallet in pallets -%}
### {{ pallet.name }} - {{ pallet.index }}
{% for call in pallet.calls -%}
#### {{ call.name }} - {{ call.index }}
<details><summary><code>{{ call.name }}(
{%- for param in call.params -%}
{{ param.name }}{% if loop.last != true %}, {% endif %}
{%- endfor -%}
)</code></summary>
```rust
{% for param in call.params -%}
{{ param.name }}: {{ param.type_name }}
{% endfor -%}
```
</details>
{# replace markdown sytax in documentation breaking the final result #}
{{ call.documentation | replace(from="# WARNING:", to="WARNING:") }}
{% endfor -%}
{% endfor -%}
# Runtime calls
Calls are categorized according to the dispatch origin they require:
1. **User calls**: the dispatch origin for this kind of call must be signed by
the transactor. This is the only call category that can be submitted with an extrinsic.
1. **Root calls**: This kind of call requires a special origin that can only be invoked
through on-chain governance mechanisms.
1. **Inherent calls**: This kind of call is invoked by the author of the block itself
(usually automatically by the node).
1. **Disabled calls**: These calls can not be called directly, they are reserved for internal use by other runtime calls.
{% set pallets = user_calls_pallets -%}
{% set calls_counter = user_calls_counter -%}
{% set category_name = "user" -%}
## User calls
{% include "runtime-calls-category.md" %}
{% set pallets = root_calls_pallets -%}
{% set calls_counter = root_calls_counter -%}
{% set category_name = "root" -%}
## Root calls
{% include "runtime-calls-category.md" %}
{% set pallets = disabled_calls_pallets %}
{% set calls_counter = disabled_calls_counter %}
{% set category_name = "disabled" %}
## Disabled calls
{% include "runtime-calls-category.md" -%}
...@@ -17,15 +17,87 @@ ...@@ -17,15 +17,87 @@
use anyhow::{bail, Context, Result}; use anyhow::{bail, Context, Result};
use codec::Decode; use codec::Decode;
use scale_info::form::PortableForm; use scale_info::form::PortableForm;
use serde::Serialize;
use std::{ use std::{
fs::File, fs::File,
io::{Read, Write}, io::{Read, Write},
}; };
use tera::Tera;
// consts
const CALLS_DOC_FILEPATH: &str = "docs/api/runtime-calls.md"; const CALLS_DOC_FILEPATH: &str = "docs/api/runtime-calls.md";
const TEMPLATES_GLOB: &str = "xtask/res/templates/*.md";
// define structs and implementations
type RuntimeCalls = Vec<Pallet>; type RuntimeCalls = Vec<Pallet>;
#[derive(Clone, Serialize)]
struct Pallet {
index: u8,
name: String,
calls: Vec<Call>,
}
impl Pallet {
fn new(
index: u8,
name: String,
scale_type_def: &scale_info::TypeDef<PortableForm>,
) -> Result<Self> {
if let scale_info::TypeDef::Variant(calls_enum) = scale_type_def {
Ok(Self {
index,
name,
calls: calls_enum.variants().iter().map(Into::into).collect(),
})
} else {
bail!("Invalid metadata")
}
}
}
#[derive(Clone, Serialize)]
struct Call {
documentation: String,
index: u8,
name: String,
params: Vec<CallParam>,
}
impl From<&scale_info::Variant<PortableForm>> for Call {
fn from(variant: &scale_info::Variant<PortableForm>) -> Self {
Self {
documentation: variant
.docs()
.iter()
.take_while(|line| !line.starts_with("# <weight>"))
.cloned()
.collect::<Vec<_>>()
.join("\n"),
index: variant.index(),
name: variant.name().to_owned(),
params: variant.fields().iter().map(Into::into).collect(),
}
}
}
#[derive(Clone, Serialize)]
struct CallParam {
name: String,
type_name: String,
}
impl From<&scale_info::Field<PortableForm>> for CallParam {
fn from(field: &scale_info::Field<PortableForm>) -> Self {
Self {
name: field.name().cloned().unwrap_or_default(),
type_name: field.type_name().cloned().unwrap_or_default(),
}
}
}
enum CallCategory { enum CallCategory {
Disabled, Disabled,
Inherent, Inherent,
...@@ -81,65 +153,7 @@ impl CallCategory { ...@@ -81,65 +153,7 @@ impl CallCategory {
} }
} }
#[derive(Clone)] /// generate runtime calls documentation
struct Pallet {
index: u8,
name: String,
calls: Vec<Call>,
}
impl Pallet {
fn new(
index: u8,
name: String,
scale_type_def: &scale_info::TypeDef<PortableForm>,
) -> Result<Self> {
if let scale_info::TypeDef::Variant(calls_enum) = scale_type_def {
Ok(Self {
index,
name,
calls: calls_enum.variants().iter().map(Into::into).collect(),
})
} else {
bail!("Invalid metadata")
}
}
}
#[derive(Clone)]
struct Call {
docs: Vec<String>,
index: u8,
name: String,
params: Vec<CallParam>,
}
impl From<&scale_info::Variant<PortableForm>> for Call {
fn from(variant: &scale_info::Variant<PortableForm>) -> Self {
Self {
docs: variant.docs().to_vec(),
index: variant.index(),
name: variant.name().to_owned(),
params: variant.fields().iter().map(Into::into).collect(),
}
}
}
#[derive(Clone)]
struct CallParam {
name: String,
type_name: String,
}
impl From<&scale_info::Field<PortableForm>> for CallParam {
fn from(field: &scale_info::Field<PortableForm>) -> Self {
Self {
name: field.name().cloned().unwrap_or_default(),
type_name: field.type_name().cloned().unwrap_or_default(),
}
}
}
pub(super) fn gen_calls_doc() -> Result<()> { pub(super) fn gen_calls_doc() -> Result<()> {
// Read metadata // Read metadata
let mut file = std::fs::File::open("resources/metadata.scale") let mut file = std::fs::File::open("resources/metadata.scale")
...@@ -192,7 +206,9 @@ fn get_calls_from_metadata_v14( ...@@ -192,7 +206,9 @@ fn get_calls_from_metadata_v14(
Ok(pallets) Ok(pallets)
} }
/// use template to render markdown file with runtime calls documentation
fn print_runtime_calls(pallets: RuntimeCalls) -> String { fn print_runtime_calls(pallets: RuntimeCalls) -> String {
// init variables
let mut user_calls_counter = 0; let mut user_calls_counter = 0;
let user_calls_pallets: RuntimeCalls = pallets let user_calls_pallets: RuntimeCalls = pallets
.iter() .iter()
...@@ -245,109 +261,24 @@ fn print_runtime_calls(pallets: RuntimeCalls) -> String { ...@@ -245,109 +261,24 @@ fn print_runtime_calls(pallets: RuntimeCalls) -> String {
}) })
.collect(); .collect();
let mut output = String::new(); // compile template
let tera = match Tera::new(TEMPLATES_GLOB) {
output.push_str("# Runtime calls\n\n"); Ok(t) => t,
output.push_str("Calls are categorized according to the dispatch origin they require:\n\n"); Err(e) => {
output.push_str( println!("Parsing error(s): {}", e);
r#"1. User calls: the dispatch origin for this kind of call must be Signed by ::std::process::exit(1);
the transactor. This is the only call category that can be submitted with an extrinsic.
"#,
);
output.push_str(
r#"1. Root calls: This kind of call requires a special origin that can only be invoked
through on-chain governance mechanisms.
"#,
);
output.push_str(
r#"1. Inherent calls: This kind of call is invoked by the author of the block itself
(usually automatically by the node).
"#,
);
output.push_str(
r#"1. Disabled calls: These calls are disabled for different reasons (to be documented).
"#,
);
output.push_str("\n\n## User calls\n\n");
output.push_str(&print_calls_category(
user_calls_counter,
"user",
user_calls_pallets,
));
output.push_str("\n\n## Root calls\n\n");
output.push_str(&print_calls_category(
root_calls_counter,
"root",
root_calls_pallets,
));
output.push_str("\n\n## Disabled calls\n\n");
output.push_str(&print_calls_category(
disabled_calls_counter,
"disabled",
disabled_calls_pallets,
));
output
}
fn print_calls_category(calls_counter: usize, category_name: &str, pallets: Vec<Pallet>) -> String {
let mut output = String::new();
output.push_str(&format!(
"There are **{}** {} calls organized in **{}** pallets.\n",
calls_counter,
category_name,
pallets.len()
));
for pallet in pallets {
output.push_str(&format!("\n### {}: {}\n\n", pallet.index, pallet.name));
for call in pallet.calls {
output.push_str(&format!(
"<details><summary>{}: {}({})</summary>\n<p>\n\n{}</p>\n</details>\n\n",
call.index,
call.name,
print_call_params(&call.params),
print_call_details(&call),
));
} }
} };
output
}
fn print_call_details(call: &Call) -> String { // fills tera context for rendering
let mut output = String::new(); let mut context = tera::Context::new();
output.push_str(&format!("### Index\n\n`{}`\n\n", call.index)); context.insert("user_calls_counter", &user_calls_counter);
output.push_str(&format!( context.insert("user_calls_pallets", &user_calls_pallets);
"### Documentation\n\n{}\n\n", context.insert("root_calls_counter", &root_calls_counter);
call.docs context.insert("root_calls_pallets", &root_calls_pallets);
.iter() context.insert("disabled_calls_counter", &disabled_calls_counter);
.take_while(|line| !line.starts_with("# <weight>")) context.insert("disabled_calls_pallets", &disabled_calls_pallets);
.cloned()
.collect::<Vec<_>>()
.join("\n")
));
if !call.params.is_empty() {
output.push_str("### Types of parameters\n\n```rust\n");
output.push_str(
&call
.params
.iter()
.map(|param| format!("{}: {}", param.name, param.type_name))
.collect::<Vec<_>>()
.join(",\n"),
);
output.push_str("\n```\n\n");
}
output
}
fn print_call_params(call_params: &[CallParam]) -> String { tera.render("runtime-calls.md", &context)
call_params .expect("template error")
.iter()
.map(|param| param.name.clone())
.collect::<Vec<_>>()
.join(", ")
} }
...@@ -42,10 +42,10 @@ enum DuniterXTaskCommand { ...@@ -42,10 +42,10 @@ enum DuniterXTaskCommand {
GenCallsDoc, GenCallsDoc,
/// Inject runtime code in raw specs /// Inject runtime code in raw specs
InjectRuntimeCode { InjectRuntimeCode {
#[clap(short, long, parse(from_os_str))] #[clap(short, long)]
/// Runtime filepath /// Runtime filepath
runtime: PathBuf, runtime: PathBuf,
#[clap(short = 's', long, parse(from_os_str))] #[clap(short = 's', long)]
/// Raw spec filepath /// Raw spec filepath
raw_spec: PathBuf, raw_spec: PathBuf,
}, },
...@@ -61,7 +61,7 @@ async fn main() -> Result<()> { ...@@ -61,7 +61,7 @@ async fn main() -> Result<()> {
let args = DuniterXTask::parse(); let args = DuniterXTask::parse();
if !version_check::is_min_version(MIN_RUST_VERSION).unwrap_or(false) if !version_check::is_min_version(MIN_RUST_VERSION).unwrap_or(false)
&& exec_should_success(Command::new("rustup").args(&["update", "stable"])).is_err() && exec_should_success(Command::new("rustup").args(["update", "stable"])).is_err()
{ {
eprintln!( eprintln!(
"Duniter requires stable Rust {} or higher. If you installed the Rust toolchain via rustup, please execute the command `rustup update stable`.", "Duniter requires stable Rust {} or higher. If you installed the Rust toolchain via rustup, please execute the command `rustup update stable`.",
...@@ -125,7 +125,7 @@ fn inject_runtime_code(raw_spec: &Path, runtime: &Path) -> Result<()> { ...@@ -125,7 +125,7 @@ fn inject_runtime_code(raw_spec: &Path, runtime: &Path) -> Result<()> {
.with_context(|| "invalid raw spec file")? .with_context(|| "invalid raw spec file")?
.insert( .insert(
CODE_KEY.to_owned(), CODE_KEY.to_owned(),
serde_json::Value::String(unsafe { std::mem::transmute(hex_runtime_code) }), serde_json::Value::String(hex_runtime_code),
); );
// Write modified raw specs // Write modified raw specs
...@@ -139,16 +139,16 @@ fn inject_runtime_code(raw_spec: &Path, runtime: &Path) -> Result<()> { ...@@ -139,16 +139,16 @@ fn inject_runtime_code(raw_spec: &Path, runtime: &Path) -> Result<()> {
} }
fn build(_production: bool) -> Result<()> { fn build(_production: bool) -> Result<()> {
exec_should_success(Command::new("cargo").args(&["clean", "-p", "duniter"]))?; exec_should_success(Command::new("cargo").args(["clean", "-p", "duniter"]))?;
exec_should_success(Command::new("cargo").args(&["build", "--locked"]))?; exec_should_success(Command::new("cargo").args(["build", "--locked"]))?;
exec_should_success(Command::new("mkdir").args(&["build"]))?; exec_should_success(Command::new("mkdir").args(["build"]))?;
exec_should_success(Command::new("mv").args(&["target/debug/duniter", "build/duniter"]))?; exec_should_success(Command::new("mv").args(["target/debug/duniter", "build/duniter"]))?;
Ok(()) Ok(())
} }
fn test() -> Result<()> { fn test() -> Result<()> {
exec_should_success(Command::new("cargo").args(&[ exec_should_success(Command::new("cargo").args([
"test", "test",
"--workspace", "--workspace",
"--exclude", "--exclude",
......