diff --git a/parachain/Cargo.lock b/parachain/Cargo.lock index 01f9aeb123..99ecbf01dc 100644 --- a/parachain/Cargo.lock +++ b/parachain/Cargo.lock @@ -9255,6 +9255,7 @@ dependencies = [ "pallet-chain-bridge", "pallet-collab-ai-common", "pallet-collective", + "pallet-conviction-voting", "pallet-curator", "pallet-democracy", "pallet-ethereum", @@ -9291,6 +9292,7 @@ dependencies = [ "pallet-pool-proposal", "pallet-preimage", "pallet-proxy", + "pallet-referenda", "pallet-scheduler", "pallet-score-staking", "pallet-session", @@ -9304,6 +9306,7 @@ dependencies = [ "pallet-utility", "pallet-vc-management", "pallet-vesting", + "pallet-whitelist", "pallet-xcm", "parachains-common", "parity-scale-codec", diff --git a/parachain/Cargo.toml b/parachain/Cargo.toml index 9a6b259916..5457d59786 100644 --- a/parachain/Cargo.toml +++ b/parachain/Cargo.toml @@ -207,6 +207,7 @@ pallet-authorship = { git = "https://github.com/paritytech/polkadot-sdk", branch pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407", default-features = false } pallet-bounties = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407", default-features = false } pallet-collective = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407", default-features = false } +pallet-conviction-voting = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407", default-features = false } pallet-democracy = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407", default-features = false } pallet-identity = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407", default-features = false } pallet-membership = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407", default-features = false } @@ -214,12 +215,14 @@ pallet-message-queue = { git = "https://github.com/paritytech/polkadot-sdk", bra pallet-multisig = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407", default-features = false } pallet-preimage = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407", default-features = false } pallet-proxy = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407", default-features = false } +pallet-referenda = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407", default-features = false } pallet-scheduler = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407", default-features = false } pallet-transaction-payment = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407", default-features = false } pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407", default-features = false } pallet-treasury = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407", default-features = false } pallet-vesting = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407", default-features = false } pallet-utility = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407", default-features = false } +pallet-whitelist = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407", default-features = false } pallet-session = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407", default-features = false } pallet-sudo = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407", default-features = false } pallet-tips = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407", default-features = false } diff --git a/parachain/runtime/paseo/Cargo.toml b/parachain/runtime/paseo/Cargo.toml index 3f0cb5a128..8df201903c 100644 --- a/parachain/runtime/paseo/Cargo.toml +++ b/parachain/runtime/paseo/Cargo.toml @@ -36,6 +36,7 @@ pallet-authorship = { workspace = true } pallet-balances = { workspace = true } pallet-bounties = { workspace = true } pallet-collective = { workspace = true } +pallet-conviction-voting = { workspace = true } pallet-democracy = { workspace = true } pallet-identity = { workspace = true } pallet-membership = { workspace = true } @@ -43,6 +44,7 @@ pallet-message-queue = { workspace = true } pallet-multisig = { workspace = true } pallet-preimage = { workspace = true } pallet-proxy = { workspace = true } +pallet-referenda = { workspace = true } pallet-scheduler = { workspace = true } pallet-session = { workspace = true } pallet-sudo = { workspace = true } @@ -53,6 +55,7 @@ pallet-transaction-payment-rpc-runtime-api = { workspace = true } pallet-treasury = { workspace = true } pallet-utility = { workspace = true } pallet-vesting = { workspace = true } +pallet-whitelist = { workspace = true } cumulus-pallet-aura-ext = { workspace = true } cumulus-pallet-dmp-queue = { workspace = true } @@ -167,6 +170,7 @@ runtime-benchmarks = [ "pallet-bridge-transfer/runtime-benchmarks", "pallet-chain-bridge/runtime-benchmarks", "pallet-collective/runtime-benchmarks", + "pallet-conviction-voting/runtime-benchmarks", "pallet-democracy/runtime-benchmarks", "pallet-ethereum/runtime-benchmarks", "pallet-evm-assertions/runtime-benchmarks", @@ -183,6 +187,7 @@ runtime-benchmarks = [ "pallet-parachain-staking/runtime-benchmarks", "pallet-preimage/runtime-benchmarks", "pallet-proxy/runtime-benchmarks", + "pallet-referenda/runtime-benchmarks", "pallet-scheduler/runtime-benchmarks", "pallet-score-staking/runtime-benchmarks", "pallet-sudo/runtime-benchmarks", @@ -193,6 +198,7 @@ runtime-benchmarks = [ "pallet-utility/runtime-benchmarks", "pallet-vc-management/runtime-benchmarks", "pallet-vesting/runtime-benchmarks", + "pallet-whitelist/runtime-benchmarks", "pallet-xcm/runtime-benchmarks", "parachains-common/runtime-benchmarks", "polkadot-parachain-primitives/runtime-benchmarks", @@ -250,6 +256,7 @@ std = [ "pallet-bridge-transfer/std", "pallet-chain-bridge/std", "pallet-collective/std", + "pallet-conviction-voting/std", "pallet-democracy/std", "pallet-ethereum/std", "pallet-evm-assertions/std", @@ -277,6 +284,7 @@ std = [ "pallet-parachain-staking/std", "pallet-preimage/std", "pallet-proxy/std", + "pallet-referenda/std", "pallet-scheduler/std", "pallet-score-staking/std", "pallet-session/std", @@ -290,6 +298,7 @@ std = [ "pallet-utility/std", "pallet-vc-management/std", "pallet-vesting/std", + "pallet-whitelist/std", "pallet-xcm/std", "parachain-info/std", "parachains-common/std", @@ -353,6 +362,7 @@ try-runtime = [ "pallet-bridge-transfer/try-runtime", "pallet-chain-bridge/try-runtime", "pallet-collective/try-runtime", + "pallet-conviction-voting/try-runtime", "pallet-democracy/try-runtime", "pallet-ethereum/try-runtime", "pallet-evm-assertions/try-runtime", @@ -368,6 +378,7 @@ try-runtime = [ "pallet-parachain-staking/try-runtime", "pallet-preimage/try-runtime", "pallet-proxy/try-runtime", + "pallet-referenda/try-runtime", "pallet-scheduler/try-runtime", "pallet-score-staking/try-runtime", "pallet-session/try-runtime", @@ -380,6 +391,7 @@ try-runtime = [ "pallet-utility/try-runtime", "pallet-vc-management/try-runtime", "pallet-vesting/try-runtime", + "pallet-whitelist/try-runtime", "pallet-xcm/try-runtime", "parachain-info/try-runtime", "polkadot-runtime-common/try-runtime", diff --git a/parachain/runtime/paseo/src/governance_v2/mod.rs b/parachain/runtime/paseo/src/governance_v2/mod.rs new file mode 100644 index 0000000000..c47a6866ed --- /dev/null +++ b/parachain/runtime/paseo/src/governance_v2/mod.rs @@ -0,0 +1,89 @@ +// Copyright 2020-2024 Trust Computing GmbH. +// This file is part of Litentry. +// +// Litentry is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Litentry is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Litentry. If not, see . + +//! # Gov2 config +//! Includes runtime configs for these substrate pallets: +//! 1. pallet-conviction-voting +//! 2. pallet-whitelist +//! 3. pallet-referenda + +use super::*; +use frame_support::traits::EitherOf; + +mod origins; +pub use origins::{ + pallet_custom_origins, ReferendumCanceller, ReferendumKiller, WhitelistedCaller, +}; + +mod tracks; +pub use tracks::TracksInfo; + +parameter_types! { + pub const VoteLockingPeriod: BlockNumber = 1 * DAYS; +} + +impl pallet_conviction_voting::Config for Runtime { + type WeightInfo = weights::pallet_conviction_voting::WeightInfo; + type RuntimeEvent = RuntimeEvent; + type Currency = Balances; + type Polls = Referenda; + type MaxTurnout = frame_support::traits::TotalIssuanceOf; + // Maximum number of concurrent votes an account may have + type MaxVotes = ConstU32<20>; + // Minimum period of vote locking + type VoteLockingPeriod = VoteLockingPeriod; +} + +parameter_types! { + pub const AlarmInterval: BlockNumber = 1; + pub const SubmissionDeposit: Balance = 100 * DOLLARS; + pub const UndecidingTimeout: BlockNumber = 21 * DAYS; +} + +impl pallet_custom_origins::Config for Runtime {} + +// The purpose of this pallet is to queue calls to be dispatched as by root later => the Dispatch +// origin corresponds to the Gov2 Whitelist track. +impl pallet_whitelist::Config for Runtime { + type WeightInfo = weights::pallet_whitelist::WeightInfo; + type RuntimeEvent = RuntimeEvent; + type RuntimeCall = RuntimeCall; + type WhitelistOrigin = EnsureRootOrTwoThirdsCouncil; + type DispatchWhitelistedOrigin = EitherOf, WhitelistedCaller>; + type Preimages = Preimage; +} + +pallet_referenda::impl_tracksinfo_get!(TracksInfo, Balance, BlockNumber); + +impl pallet_referenda::Config for Runtime { + type WeightInfo = weights::pallet_referenda::WeightInfo; + type RuntimeCall = RuntimeCall; + type RuntimeEvent = RuntimeEvent; + type Scheduler = Scheduler; + type Currency = Balances; + type SubmitOrigin = frame_system::EnsureSigned; + type CancelOrigin = EitherOf, ReferendumCanceller>; + type KillOrigin = EitherOf, ReferendumKiller>; + type Slash = Treasury; + type Votes = pallet_conviction_voting::VotesOf; + type Tally = pallet_conviction_voting::TallyOf; + type SubmissionDeposit = SubmissionDeposit; + type MaxQueued = ConstU32<100>; + type UndecidingTimeout = UndecidingTimeout; + type AlarmInterval = AlarmInterval; + type Tracks = TracksInfo; + type Preimages = Preimage; +} diff --git a/parachain/runtime/paseo/src/governance_v2/origins.rs b/parachain/runtime/paseo/src/governance_v2/origins.rs new file mode 100644 index 0000000000..46fb4f4c9f --- /dev/null +++ b/parachain/runtime/paseo/src/governance_v2/origins.rs @@ -0,0 +1,73 @@ +// Copyright 2020-2024 Trust Computing GmbH. +// This file is part of Litentry. +// +// Litentry is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Litentry is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Litentry. If not, see . + +//! Custom origins for governance interventions. + +pub use pallet_custom_origins::*; + +#[frame_support::pallet] +pub mod pallet_custom_origins { + use frame_support::pallet_prelude::*; + + #[pallet::config] + pub trait Config: frame_system::Config {} + + #[pallet::pallet] + pub struct Pallet(_); + + #[derive(PartialEq, Eq, Clone, MaxEncodedLen, Encode, Decode, TypeInfo, RuntimeDebug)] + #[pallet::origin] + pub enum Origin { + /// Origin able to cancel referenda. + ReferendumCanceller, + /// Origin able to kill referenda. + ReferendumKiller, + /// Origin able to dispatch a whitelisted call. + WhitelistedCaller, + } + + macro_rules! decl_unit_ensures { + ( $name:ident: $success_type:ty = $success:expr ) => { + pub struct $name; + impl> + From> + EnsureOrigin for $name + { + type Success = $success_type; + fn try_origin(o: O) -> Result { + o.into().and_then(|o| match o { + Origin::$name => Ok($success), + r => Err(O::from(r)), + }) + } + #[cfg(feature = "runtime-benchmarks")] + fn try_successful_origin() -> Result { + Ok(O::from(Origin::$name)) + } + } + }; + ( $name:ident ) => { decl_unit_ensures! { $name : () = () } }; + ( $name:ident: $success_type:ty = $success:expr, $( $rest:tt )* ) => { + decl_unit_ensures! { $name: $success_type = $success } + decl_unit_ensures! { $( $rest )* } + }; + ( $name:ident, $( $rest:tt )* ) => { + decl_unit_ensures! { $name } + decl_unit_ensures! { $( $rest )* } + }; + () => {} + } + decl_unit_ensures!(ReferendumCanceller, ReferendumKiller, WhitelistedCaller,); +} diff --git a/parachain/runtime/paseo/src/governance_v2/tracks.rs b/parachain/runtime/paseo/src/governance_v2/tracks.rs new file mode 100644 index 0000000000..0bd12a6960 --- /dev/null +++ b/parachain/runtime/paseo/src/governance_v2/tracks.rs @@ -0,0 +1,125 @@ +// Copyright 2020-2024 Trust Computing GmbH. +// This file is part of Litentry. +// +// Litentry is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Litentry is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Litentry. If not, see . + +//! Track configurations for governance. + +use super::*; +use runtime_common::currency::DOLLARS; + +const fn percent(x: i32) -> sp_runtime::FixedI64 { + sp_runtime::FixedI64::from_rational(x as u128, 100) +} +const fn permill(x: i32) -> sp_runtime::FixedI64 { + sp_runtime::FixedI64::from_rational(x as u128, 1000) +} + +use pallet_referenda::Curve; +const TRACKS_DATA: [(u16, pallet_referenda::TrackInfo); 4] = [ + ( + 0, + pallet_referenda::TrackInfo { + // Name of this track. + name: "root", + // A limit for the number of referenda on this track that can be being decided at once. + // For Root origin this should generally be just one. + max_deciding: 5, + // Amount that must be placed on deposit before a decision can be made. + decision_deposit: 100 * DOLLARS, + // Amount of time this must be submitted for before a decision can be made. + prepare_period: 1 * DAYS, + // Amount of time that a decision may take to be approved prior to cancellation. + decision_period: 14 * DAYS, + // Amount of time that the approval criteria must hold before it can be approved. + confirm_period: 1 * DAYS, + // Minimum amount of time that an approved proposal must be in the dispatch queue. + min_enactment_period: 1 * DAYS, + // Minimum aye votes as percentage of overall conviction-weighted votes needed for + // approval as a function of time into decision period. + min_approval: Curve::make_reciprocal(4, 14, percent(80), percent(50), percent(100)), + // Minimum pre-conviction aye-votes ("support") as percentage of overall population that + // is needed for approval as a function of time into decision period. + min_support: Curve::make_linear(14, 14, permill(5), percent(25)), + }, + ), + ( + 1, + pallet_referenda::TrackInfo { + name: "whitelisted_caller", + max_deciding: 100, + decision_deposit: 100 * DOLLARS, + prepare_period: 10 * MINUTES, + decision_period: 14 * DAYS, + confirm_period: 10 * MINUTES, + min_enactment_period: 30 * MINUTES, + min_approval: Curve::make_reciprocal(1, 14, percent(96), percent(50), percent(100)), + min_support: Curve::make_reciprocal(1, 14 * 24, percent(1), percent(0), percent(2)), + }, + ), + ( + 2, + pallet_referenda::TrackInfo { + name: "referendum_canceller", + max_deciding: 20, + decision_deposit: 10 * DOLLARS, + prepare_period: 1 * HOURS, + decision_period: 14 * DAYS, + confirm_period: 3 * HOURS, + min_enactment_period: 10 * MINUTES, + min_approval: Curve::make_reciprocal(1, 14, percent(96), percent(50), percent(100)), + min_support: Curve::make_reciprocal(1, 14, percent(1), percent(0), percent(50)), + }, + ), + ( + 3, + pallet_referenda::TrackInfo { + name: "referendum_killer", + max_deciding: 100, + decision_deposit: 10 * DOLLARS, + prepare_period: 1 * HOURS, + decision_period: 14 * DAYS, + confirm_period: 3 * HOURS, + min_enactment_period: 10 * MINUTES, + min_approval: Curve::make_reciprocal(1, 14, percent(96), percent(50), percent(100)), + min_support: Curve::make_reciprocal(1, 14, percent(1), percent(0), percent(10)), + }, + ), +]; + +pub struct TracksInfo; +impl pallet_referenda::TracksInfo for TracksInfo { + type Id = u16; + type RuntimeOrigin = ::PalletsOrigin; + fn tracks() -> &'static [(Self::Id, pallet_referenda::TrackInfo)] { + &TRACKS_DATA[..] + } + fn track_for(id: &Self::RuntimeOrigin) -> Result { + if let Ok(system_origin) = frame_system::RawOrigin::try_from(id.clone()) { + match system_origin { + frame_system::RawOrigin::Root => Ok(0), + _ => Err(()), + } + } else if let Ok(custom_origin) = origins::Origin::try_from(id.clone()) { + match custom_origin { + origins::Origin::WhitelistedCaller => Ok(1), + // Referendum admins + origins::Origin::ReferendumCanceller => Ok(2), + origins::Origin::ReferendumKiller => Ok(3), + } + } else { + Err(()) + } + } +} diff --git a/parachain/runtime/paseo/src/lib.rs b/parachain/runtime/paseo/src/lib.rs index 8fbbce8fee..e26a7825ab 100644 --- a/parachain/runtime/paseo/src/lib.rs +++ b/parachain/runtime/paseo/src/lib.rs @@ -99,6 +99,7 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); pub mod asset_config; pub mod constants; +pub mod governance_v2; pub mod precompiles; #[cfg(test)] @@ -1479,6 +1480,12 @@ construct_runtime! { InvestingPool: pallet_investing_pool = 153, AIUSDConvertor: pallet_aiusd_convertor = 154, + // New Goverance + ConvictionVoting: pallet_conviction_voting = 170, + Referenda: pallet_referenda = 171, + Origins: governance_v2::pallet_custom_origins::{Origin} = 172, + Whitelist: pallet_whitelist::{Pallet, Call, Storage, Event} = 173, + // TMP AccountFix: pallet_account_fix = 254, Sudo: pallet_sudo = 255, @@ -1615,6 +1622,9 @@ mod benches { [pallet_chain_bridge,ChainBridge] [pallet_bridge_transfer,BridgeTransfer] [pallet_teebag, Teebag] + [pallet_conviction_voting, ConvictionVoting] + [pallet_referenda, Referenda] + [pallet_whitelist, Whitelist] ); } diff --git a/parachain/runtime/paseo/src/weights/mod.rs b/parachain/runtime/paseo/src/weights/mod.rs index a92269089f..f8121f20e4 100644 --- a/parachain/runtime/paseo/src/weights/mod.rs +++ b/parachain/runtime/paseo/src/weights/mod.rs @@ -40,3 +40,7 @@ pub mod pallet_timestamp; // pub mod pallet_treasury; pub mod pallet_utility; pub mod pallet_vc_management; + +pub mod pallet_conviction_voting; +pub mod pallet_referenda; +pub mod pallet_whitelist; diff --git a/parachain/runtime/paseo/src/weights/pallet_conviction_voting.rs b/parachain/runtime/paseo/src/weights/pallet_conviction_voting.rs new file mode 100644 index 0000000000..ab2f26c008 --- /dev/null +++ b/parachain/runtime/paseo/src/weights/pallet_conviction_voting.rs @@ -0,0 +1,200 @@ +// Copyright (C) Parity Technologies and the various Polkadot contributors, see Contributions.md +// for a list of specific contributors. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//! Autogenerated weights for `pallet_conviction_voting` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 +//! DATE: 2024-08-14, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `ggwpez-ref-hw`, CPU: `AMD EPYC 7232P 8-Core Processor` +//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("./polkadot-chain-spec.json")`, DB CACHE: 1024 + +// Executed Command: +// ./target/production/polkadot +// benchmark +// pallet +// --chain=./polkadot-chain-spec.json +// --steps=50 +// --repeat=20 +// --pallet=pallet_conviction_voting +// --extrinsic=* +// --wasm-execution=compiled +// --heap-pages=4096 +// --output=./polkadot-weights/ +// --header=./file_header.txt + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] +#![allow(missing_docs)] + +use frame_support::{traits::Get, weights::Weight}; +use core::marker::PhantomData; + +/// Weight functions for `pallet_conviction_voting`. +pub struct WeightInfo(PhantomData); +impl pallet_conviction_voting::WeightInfo for WeightInfo { + /// Storage: `Referenda::ReferendumInfoFor` (r:1 w:1) + /// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`) + /// Storage: `ConvictionVoting::VotingFor` (r:1 w:1) + /// Proof: `ConvictionVoting::VotingFor` (`max_values`: None, `max_size`: Some(27241), added: 29716, mode: `MaxEncodedLen`) + /// Storage: `ConvictionVoting::ClassLocksFor` (r:1 w:1) + /// Proof: `ConvictionVoting::ClassLocksFor` (`max_values`: None, `max_size`: Some(329), added: 2804, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(193), added: 2668, mode: `MaxEncodedLen`) + /// Storage: `Scheduler::Agenda` (r:1 w:1) + /// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`) + fn vote_new() -> Weight { + // Proof Size summary in bytes: + // Measured: `13480` + // Estimated: `42428` + // Minimum execution time: 193_972_000 picoseconds. + Weight::from_parts(196_922_000, 0) + .saturating_add(Weight::from_parts(0, 42428)) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(5)) + } + /// Storage: `Referenda::ReferendumInfoFor` (r:1 w:1) + /// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`) + /// Storage: `ConvictionVoting::VotingFor` (r:1 w:1) + /// Proof: `ConvictionVoting::VotingFor` (`max_values`: None, `max_size`: Some(27241), added: 29716, mode: `MaxEncodedLen`) + /// Storage: `ConvictionVoting::ClassLocksFor` (r:1 w:1) + /// Proof: `ConvictionVoting::ClassLocksFor` (`max_values`: None, `max_size`: Some(329), added: 2804, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(193), added: 2668, mode: `MaxEncodedLen`) + /// Storage: `Scheduler::Agenda` (r:2 w:2) + /// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`) + /// Storage: `Scheduler::Retries` (r:0 w:1) + /// Proof: `Scheduler::Retries` (`max_values`: None, `max_size`: Some(30), added: 2505, mode: `MaxEncodedLen`) + fn vote_existing() -> Weight { + // Proof Size summary in bytes: + // Measured: `14201` + // Estimated: `83866` + // Minimum execution time: 234_562_000 picoseconds. + Weight::from_parts(241_072_000, 0) + .saturating_add(Weight::from_parts(0, 83866)) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().writes(7)) + } + /// Storage: `ConvictionVoting::VotingFor` (r:1 w:1) + /// Proof: `ConvictionVoting::VotingFor` (`max_values`: None, `max_size`: Some(27241), added: 29716, mode: `MaxEncodedLen`) + /// Storage: `Referenda::ReferendumInfoFor` (r:1 w:1) + /// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`) + /// Storage: `Scheduler::Agenda` (r:2 w:2) + /// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`) + /// Storage: `Scheduler::Retries` (r:0 w:1) + /// Proof: `Scheduler::Retries` (`max_values`: None, `max_size`: Some(30), added: 2505, mode: `MaxEncodedLen`) + fn remove_vote() -> Weight { + // Proof Size summary in bytes: + // Measured: `13919` + // Estimated: `83866` + // Minimum execution time: 186_301_000 picoseconds. + Weight::from_parts(201_021_000, 0) + .saturating_add(Weight::from_parts(0, 83866)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(5)) + } + /// Storage: `ConvictionVoting::VotingFor` (r:1 w:1) + /// Proof: `ConvictionVoting::VotingFor` (`max_values`: None, `max_size`: Some(27241), added: 29716, mode: `MaxEncodedLen`) + /// Storage: `Referenda::ReferendumInfoFor` (r:1 w:0) + /// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`) + fn remove_other_vote() -> Weight { + // Proof Size summary in bytes: + // Measured: `13005` + // Estimated: `30706` + // Minimum execution time: 110_321_000 picoseconds. + Weight::from_parts(114_901_000, 0) + .saturating_add(Weight::from_parts(0, 30706)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: `ConvictionVoting::VotingFor` (r:2 w:2) + /// Proof: `ConvictionVoting::VotingFor` (`max_values`: None, `max_size`: Some(27241), added: 29716, mode: `MaxEncodedLen`) + /// Storage: `Referenda::ReferendumInfoFor` (r:512 w:512) + /// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`) + /// Storage: `Scheduler::Agenda` (r:2 w:2) + /// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`) + /// Storage: `ConvictionVoting::ClassLocksFor` (r:1 w:1) + /// Proof: `ConvictionVoting::ClassLocksFor` (`max_values`: None, `max_size`: Some(329), added: 2804, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(193), added: 2668, mode: `MaxEncodedLen`) + /// Storage: `Scheduler::Retries` (r:0 w:50) + /// Proof: `Scheduler::Retries` (`max_values`: None, `max_size`: Some(30), added: 2505, mode: `MaxEncodedLen`) + /// The range of component `r` is `[0, 512]`. + fn delegate(r: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `28987 + r * (364 ±0)` + // Estimated: `83866 + r * (3411 ±0)` + // Minimum execution time: 92_131_000 picoseconds. + Weight::from_parts(1_084_574_814, 0) + .saturating_add(Weight::from_parts(0, 83866)) + // Standard Error: 76_865 + .saturating_add(Weight::from_parts(23_984_016, 0).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) + .saturating_add(T::DbWeight::get().writes(45)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(r.into()))) + .saturating_add(Weight::from_parts(0, 3411).saturating_mul(r.into())) + } + /// Storage: `ConvictionVoting::VotingFor` (r:2 w:2) + /// Proof: `ConvictionVoting::VotingFor` (`max_values`: None, `max_size`: Some(27241), added: 29716, mode: `MaxEncodedLen`) + /// Storage: `Referenda::ReferendumInfoFor` (r:512 w:512) + /// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`) + /// Storage: `Scheduler::Agenda` (r:2 w:2) + /// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`) + /// Storage: `Scheduler::Retries` (r:0 w:50) + /// Proof: `Scheduler::Retries` (`max_values`: None, `max_size`: Some(30), added: 2505, mode: `MaxEncodedLen`) + /// The range of component `r` is `[0, 512]`. + fn undelegate(r: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `28868 + r * (364 ±0)` + // Estimated: `83866 + r * (3411 ±0)` + // Minimum execution time: 56_411_000 picoseconds. + Weight::from_parts(1_043_005_163, 0) + .saturating_add(Weight::from_parts(0, 83866)) + // Standard Error: 76_275 + .saturating_add(Weight::from_parts(23_984_056, 0).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) + .saturating_add(T::DbWeight::get().writes(43)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(r.into()))) + .saturating_add(Weight::from_parts(0, 3411).saturating_mul(r.into())) + } + /// Storage: `ConvictionVoting::VotingFor` (r:1 w:1) + /// Proof: `ConvictionVoting::VotingFor` (`max_values`: None, `max_size`: Some(27241), added: 29716, mode: `MaxEncodedLen`) + /// Storage: `ConvictionVoting::ClassLocksFor` (r:1 w:1) + /// Proof: `ConvictionVoting::ClassLocksFor` (`max_values`: None, `max_size`: Some(329), added: 2804, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(193), added: 2668, mode: `MaxEncodedLen`) + fn unlock() -> Weight { + // Proof Size summary in bytes: + // Measured: `12270` + // Estimated: `30706` + // Minimum execution time: 137_861_000 picoseconds. + Weight::from_parts(148_901_000, 0) + .saturating_add(Weight::from_parts(0, 30706)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } +} diff --git a/parachain/runtime/paseo/src/weights/pallet_referenda.rs b/parachain/runtime/paseo/src/weights/pallet_referenda.rs new file mode 100644 index 0000000000..daacbc6058 --- /dev/null +++ b/parachain/runtime/paseo/src/weights/pallet_referenda.rs @@ -0,0 +1,512 @@ +// Copyright (C) Parity Technologies and the various Polkadot contributors, see Contributions.md +// for a list of specific contributors. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//! Autogenerated weights for `pallet_referenda` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 +//! DATE: 2024-08-14, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `ggwpez-ref-hw`, CPU: `AMD EPYC 7232P 8-Core Processor` +//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("./polkadot-chain-spec.json")`, DB CACHE: 1024 + +// Executed Command: +// ./target/production/polkadot +// benchmark +// pallet +// --chain=./polkadot-chain-spec.json +// --steps=50 +// --repeat=20 +// --pallet=pallet_referenda +// --extrinsic=* +// --wasm-execution=compiled +// --heap-pages=4096 +// --output=./polkadot-weights/ +// --header=./file_header.txt + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] +#![allow(missing_docs)] + +use frame_support::{traits::Get, weights::Weight}; +use core::marker::PhantomData; + +/// Weight functions for `pallet_referenda`. +pub struct WeightInfo(PhantomData); +impl pallet_referenda::WeightInfo for WeightInfo { + /// Storage: `Referenda::ReferendumCount` (r:1 w:1) + /// Proof: `Referenda::ReferendumCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Scheduler::Agenda` (r:1 w:1) + /// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`) + /// Storage: `Referenda::ReferendumInfoFor` (r:0 w:1) + /// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`) + fn submit() -> Weight { + // Proof Size summary in bytes: + // Measured: `186` + // Estimated: `42428` + // Minimum execution time: 36_921_000 picoseconds. + Weight::from_parts(37_510_000, 0) + .saturating_add(Weight::from_parts(0, 42428)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: `Referenda::ReferendumInfoFor` (r:1 w:1) + /// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`) + /// Storage: `Scheduler::Agenda` (r:2 w:2) + /// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`) + /// Storage: `Scheduler::Retries` (r:0 w:1) + /// Proof: `Scheduler::Retries` (`max_values`: None, `max_size`: Some(30), added: 2505, mode: `MaxEncodedLen`) + fn place_decision_deposit_preparing() -> Weight { + // Proof Size summary in bytes: + // Measured: `439` + // Estimated: `83866` + // Minimum execution time: 53_440_000 picoseconds. + Weight::from_parts(53_830_000, 0) + .saturating_add(Weight::from_parts(0, 83866)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(4)) + } + /// Storage: `Referenda::ReferendumInfoFor` (r:1 w:1) + /// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`) + /// Storage: `Referenda::DecidingCount` (r:1 w:0) + /// Proof: `Referenda::DecidingCount` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `MaxEncodedLen`) + /// Storage: `Referenda::TrackQueue` (r:1 w:1) + /// Proof: `Referenda::TrackQueue` (`max_values`: None, `max_size`: Some(2012), added: 4487, mode: `MaxEncodedLen`) + /// Storage: `Scheduler::Agenda` (r:1 w:1) + /// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`) + /// Storage: `Scheduler::Retries` (r:0 w:1) + /// Proof: `Scheduler::Retries` (`max_values`: None, `max_size`: Some(30), added: 2505, mode: `MaxEncodedLen`) + fn place_decision_deposit_queued() -> Weight { + // Proof Size summary in bytes: + // Measured: `3226` + // Estimated: `42428` + // Minimum execution time: 63_310_000 picoseconds. + Weight::from_parts(64_100_000, 0) + .saturating_add(Weight::from_parts(0, 42428)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(4)) + } + /// Storage: `Referenda::ReferendumInfoFor` (r:1 w:1) + /// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`) + /// Storage: `Referenda::DecidingCount` (r:1 w:0) + /// Proof: `Referenda::DecidingCount` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `MaxEncodedLen`) + /// Storage: `Referenda::TrackQueue` (r:1 w:1) + /// Proof: `Referenda::TrackQueue` (`max_values`: None, `max_size`: Some(2012), added: 4487, mode: `MaxEncodedLen`) + /// Storage: `Scheduler::Agenda` (r:1 w:1) + /// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`) + /// Storage: `Scheduler::Retries` (r:0 w:1) + /// Proof: `Scheduler::Retries` (`max_values`: None, `max_size`: Some(30), added: 2505, mode: `MaxEncodedLen`) + fn place_decision_deposit_not_queued() -> Weight { + // Proof Size summary in bytes: + // Measured: `3246` + // Estimated: `42428` + // Minimum execution time: 62_980_000 picoseconds. + Weight::from_parts(63_660_000, 0) + .saturating_add(Weight::from_parts(0, 42428)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(4)) + } + /// Storage: `Referenda::ReferendumInfoFor` (r:1 w:1) + /// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`) + /// Storage: `Referenda::DecidingCount` (r:1 w:1) + /// Proof: `Referenda::DecidingCount` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `MaxEncodedLen`) + /// Storage: `Scheduler::Agenda` (r:2 w:2) + /// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`) + /// Storage: `Scheduler::Retries` (r:0 w:1) + /// Proof: `Scheduler::Retries` (`max_values`: None, `max_size`: Some(30), added: 2505, mode: `MaxEncodedLen`) + fn place_decision_deposit_passing() -> Weight { + // Proof Size summary in bytes: + // Measured: `439` + // Estimated: `83866` + // Minimum execution time: 63_141_000 picoseconds. + Weight::from_parts(63_991_000, 0) + .saturating_add(Weight::from_parts(0, 83866)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(5)) + } + /// Storage: `Referenda::ReferendumInfoFor` (r:1 w:1) + /// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`) + /// Storage: `Referenda::DecidingCount` (r:1 w:1) + /// Proof: `Referenda::DecidingCount` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `MaxEncodedLen`) + /// Storage: `Scheduler::Agenda` (r:2 w:2) + /// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`) + /// Storage: `Scheduler::Retries` (r:0 w:1) + /// Proof: `Scheduler::Retries` (`max_values`: None, `max_size`: Some(30), added: 2505, mode: `MaxEncodedLen`) + fn place_decision_deposit_failing() -> Weight { + // Proof Size summary in bytes: + // Measured: `439` + // Estimated: `83866` + // Minimum execution time: 60_881_000 picoseconds. + Weight::from_parts(61_751_000, 0) + .saturating_add(Weight::from_parts(0, 83866)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(5)) + } + /// Storage: `Referenda::ReferendumInfoFor` (r:1 w:1) + /// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`) + fn refund_decision_deposit() -> Weight { + // Proof Size summary in bytes: + // Measured: `279` + // Estimated: `4401` + // Minimum execution time: 28_140_000 picoseconds. + Weight::from_parts(28_571_000, 0) + .saturating_add(Weight::from_parts(0, 4401)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: `Referenda::ReferendumInfoFor` (r:1 w:1) + /// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`) + fn refund_submission_deposit() -> Weight { + // Proof Size summary in bytes: + // Measured: `269` + // Estimated: `4401` + // Minimum execution time: 28_281_000 picoseconds. + Weight::from_parts(28_860_000, 0) + .saturating_add(Weight::from_parts(0, 4401)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: `Referenda::ReferendumInfoFor` (r:1 w:1) + /// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`) + /// Storage: `Scheduler::Agenda` (r:2 w:2) + /// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`) + /// Storage: `Scheduler::Retries` (r:0 w:1) + /// Proof: `Scheduler::Retries` (`max_values`: None, `max_size`: Some(30), added: 2505, mode: `MaxEncodedLen`) + fn cancel() -> Weight { + // Proof Size summary in bytes: + // Measured: `347` + // Estimated: `83866` + // Minimum execution time: 34_490_000 picoseconds. + Weight::from_parts(34_850_000, 0) + .saturating_add(Weight::from_parts(0, 83866)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(4)) + } + /// Storage: `Referenda::ReferendumInfoFor` (r:1 w:1) + /// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`) + /// Storage: `Scheduler::Agenda` (r:2 w:2) + /// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`) + /// Storage: `Referenda::MetadataOf` (r:1 w:0) + /// Proof: `Referenda::MetadataOf` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) + /// Storage: `Scheduler::Retries` (r:0 w:1) + /// Proof: `Scheduler::Retries` (`max_values`: None, `max_size`: Some(30), added: 2505, mode: `MaxEncodedLen`) + fn kill() -> Weight { + // Proof Size summary in bytes: + // Measured: `588` + // Estimated: `83866` + // Minimum execution time: 97_201_000 picoseconds. + Weight::from_parts(98_191_000, 0) + .saturating_add(Weight::from_parts(0, 83866)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(4)) + } + /// Storage: `Referenda::TrackQueue` (r:1 w:0) + /// Proof: `Referenda::TrackQueue` (`max_values`: None, `max_size`: Some(2012), added: 4487, mode: `MaxEncodedLen`) + /// Storage: `Referenda::DecidingCount` (r:1 w:1) + /// Proof: `Referenda::DecidingCount` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `MaxEncodedLen`) + fn one_fewer_deciding_queue_empty() -> Weight { + // Proof Size summary in bytes: + // Measured: `102` + // Estimated: `5477` + // Minimum execution time: 9_970_000 picoseconds. + Weight::from_parts(10_150_000, 0) + .saturating_add(Weight::from_parts(0, 5477)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: `Referenda::TrackQueue` (r:1 w:1) + /// Proof: `Referenda::TrackQueue` (`max_values`: None, `max_size`: Some(2012), added: 4487, mode: `MaxEncodedLen`) + /// Storage: `Referenda::ReferendumInfoFor` (r:1 w:1) + /// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`) + /// Storage: `Scheduler::Agenda` (r:1 w:1) + /// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`) + fn one_fewer_deciding_failing() -> Weight { + // Proof Size summary in bytes: + // Measured: `3116` + // Estimated: `42428` + // Minimum execution time: 43_510_000 picoseconds. + Weight::from_parts(44_151_000, 0) + .saturating_add(Weight::from_parts(0, 42428)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: `Referenda::TrackQueue` (r:1 w:1) + /// Proof: `Referenda::TrackQueue` (`max_values`: None, `max_size`: Some(2012), added: 4487, mode: `MaxEncodedLen`) + /// Storage: `Referenda::ReferendumInfoFor` (r:1 w:1) + /// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`) + /// Storage: `Scheduler::Agenda` (r:1 w:1) + /// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`) + fn one_fewer_deciding_passing() -> Weight { + // Proof Size summary in bytes: + // Measured: `3116` + // Estimated: `42428` + // Minimum execution time: 46_160_000 picoseconds. + Weight::from_parts(46_531_000, 0) + .saturating_add(Weight::from_parts(0, 42428)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: `Referenda::ReferendumInfoFor` (r:1 w:0) + /// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`) + /// Storage: `Referenda::TrackQueue` (r:1 w:1) + /// Proof: `Referenda::TrackQueue` (`max_values`: None, `max_size`: Some(2012), added: 4487, mode: `MaxEncodedLen`) + fn nudge_referendum_requeued_insertion() -> Weight { + // Proof Size summary in bytes: + // Measured: `2939` + // Estimated: `5477` + // Minimum execution time: 21_640_000 picoseconds. + Weight::from_parts(22_330_000, 0) + .saturating_add(Weight::from_parts(0, 5477)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: `Referenda::ReferendumInfoFor` (r:1 w:0) + /// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`) + /// Storage: `Referenda::TrackQueue` (r:1 w:1) + /// Proof: `Referenda::TrackQueue` (`max_values`: None, `max_size`: Some(2012), added: 4487, mode: `MaxEncodedLen`) + fn nudge_referendum_requeued_slide() -> Weight { + // Proof Size summary in bytes: + // Measured: `2939` + // Estimated: `5477` + // Minimum execution time: 21_710_000 picoseconds. + Weight::from_parts(22_270_000, 0) + .saturating_add(Weight::from_parts(0, 5477)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: `Referenda::ReferendumInfoFor` (r:1 w:1) + /// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`) + /// Storage: `Referenda::DecidingCount` (r:1 w:0) + /// Proof: `Referenda::DecidingCount` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `MaxEncodedLen`) + /// Storage: `Referenda::TrackQueue` (r:1 w:1) + /// Proof: `Referenda::TrackQueue` (`max_values`: None, `max_size`: Some(2012), added: 4487, mode: `MaxEncodedLen`) + fn nudge_referendum_queued() -> Weight { + // Proof Size summary in bytes: + // Measured: `2943` + // Estimated: `5477` + // Minimum execution time: 26_700_000 picoseconds. + Weight::from_parts(27_041_000, 0) + .saturating_add(Weight::from_parts(0, 5477)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: `Referenda::ReferendumInfoFor` (r:1 w:1) + /// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`) + /// Storage: `Referenda::DecidingCount` (r:1 w:0) + /// Proof: `Referenda::DecidingCount` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `MaxEncodedLen`) + /// Storage: `Referenda::TrackQueue` (r:1 w:1) + /// Proof: `Referenda::TrackQueue` (`max_values`: None, `max_size`: Some(2012), added: 4487, mode: `MaxEncodedLen`) + fn nudge_referendum_not_queued() -> Weight { + // Proof Size summary in bytes: + // Measured: `2963` + // Estimated: `5477` + // Minimum execution time: 26_050_000 picoseconds. + Weight::from_parts(26_730_000, 0) + .saturating_add(Weight::from_parts(0, 5477)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: `Referenda::ReferendumInfoFor` (r:1 w:1) + /// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`) + /// Storage: `Scheduler::Agenda` (r:1 w:1) + /// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`) + fn nudge_referendum_no_deposit() -> Weight { + // Proof Size summary in bytes: + // Measured: `299` + // Estimated: `42428` + // Minimum execution time: 21_870_000 picoseconds. + Weight::from_parts(22_361_000, 0) + .saturating_add(Weight::from_parts(0, 42428)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: `Referenda::ReferendumInfoFor` (r:1 w:1) + /// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`) + /// Storage: `Scheduler::Agenda` (r:1 w:1) + /// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`) + fn nudge_referendum_preparing() -> Weight { + // Proof Size summary in bytes: + // Measured: `347` + // Estimated: `42428` + // Minimum execution time: 22_141_000 picoseconds. + Weight::from_parts(22_571_000, 0) + .saturating_add(Weight::from_parts(0, 42428)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: `Referenda::ReferendumInfoFor` (r:1 w:1) + /// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`) + fn nudge_referendum_timed_out() -> Weight { + // Proof Size summary in bytes: + // Measured: `206` + // Estimated: `4401` + // Minimum execution time: 13_930_000 picoseconds. + Weight::from_parts(14_230_000, 0) + .saturating_add(Weight::from_parts(0, 4401)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: `Referenda::ReferendumInfoFor` (r:1 w:1) + /// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`) + /// Storage: `Referenda::DecidingCount` (r:1 w:1) + /// Proof: `Referenda::DecidingCount` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `MaxEncodedLen`) + /// Storage: `Scheduler::Agenda` (r:1 w:1) + /// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`) + fn nudge_referendum_begin_deciding_failing() -> Weight { + // Proof Size summary in bytes: + // Measured: `347` + // Estimated: `42428` + // Minimum execution time: 30_280_000 picoseconds. + Weight::from_parts(30_600_000, 0) + .saturating_add(Weight::from_parts(0, 42428)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: `Referenda::ReferendumInfoFor` (r:1 w:1) + /// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`) + /// Storage: `Referenda::DecidingCount` (r:1 w:1) + /// Proof: `Referenda::DecidingCount` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `MaxEncodedLen`) + /// Storage: `Scheduler::Agenda` (r:1 w:1) + /// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`) + fn nudge_referendum_begin_deciding_passing() -> Weight { + // Proof Size summary in bytes: + // Measured: `347` + // Estimated: `42428` + // Minimum execution time: 32_150_000 picoseconds. + Weight::from_parts(32_601_000, 0) + .saturating_add(Weight::from_parts(0, 42428)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: `Referenda::ReferendumInfoFor` (r:1 w:1) + /// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`) + /// Storage: `Scheduler::Agenda` (r:1 w:1) + /// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`) + fn nudge_referendum_begin_confirming() -> Weight { + // Proof Size summary in bytes: + // Measured: `400` + // Estimated: `42428` + // Minimum execution time: 29_920_000 picoseconds. + Weight::from_parts(30_330_000, 0) + .saturating_add(Weight::from_parts(0, 42428)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: `Referenda::ReferendumInfoFor` (r:1 w:1) + /// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`) + /// Storage: `Scheduler::Agenda` (r:1 w:1) + /// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`) + fn nudge_referendum_end_confirming() -> Weight { + // Proof Size summary in bytes: + // Measured: `383` + // Estimated: `42428` + // Minimum execution time: 30_160_000 picoseconds. + Weight::from_parts(30_790_000, 0) + .saturating_add(Weight::from_parts(0, 42428)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: `Referenda::ReferendumInfoFor` (r:1 w:1) + /// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`) + /// Storage: `Scheduler::Agenda` (r:1 w:1) + /// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`) + fn nudge_referendum_continue_not_confirming() -> Weight { + // Proof Size summary in bytes: + // Measured: `400` + // Estimated: `42428` + // Minimum execution time: 28_641_000 picoseconds. + Weight::from_parts(29_180_000, 0) + .saturating_add(Weight::from_parts(0, 42428)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: `Referenda::ReferendumInfoFor` (r:1 w:1) + /// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`) + /// Storage: `Scheduler::Agenda` (r:1 w:1) + /// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`) + fn nudge_referendum_continue_confirming() -> Weight { + // Proof Size summary in bytes: + // Measured: `404` + // Estimated: `42428` + // Minimum execution time: 27_240_000 picoseconds. + Weight::from_parts(28_041_000, 0) + .saturating_add(Weight::from_parts(0, 42428)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: `Referenda::ReferendumInfoFor` (r:1 w:1) + /// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`) + /// Storage: `Scheduler::Agenda` (r:2 w:2) + /// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`) + /// Storage: `Scheduler::Lookup` (r:1 w:1) + /// Proof: `Scheduler::Lookup` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) + fn nudge_referendum_approved() -> Weight { + // Proof Size summary in bytes: + // Measured: `404` + // Estimated: `83866` + // Minimum execution time: 41_201_000 picoseconds. + Weight::from_parts(41_691_000, 0) + .saturating_add(Weight::from_parts(0, 83866)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(4)) + } + /// Storage: `Referenda::ReferendumInfoFor` (r:1 w:1) + /// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`) + /// Storage: `Scheduler::Agenda` (r:1 w:1) + /// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`) + fn nudge_referendum_rejected() -> Weight { + // Proof Size summary in bytes: + // Measured: `400` + // Estimated: `42428` + // Minimum execution time: 29_940_000 picoseconds. + Weight::from_parts(30_460_000, 0) + .saturating_add(Weight::from_parts(0, 42428)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: `Referenda::ReferendumInfoFor` (r:1 w:0) + /// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`) + /// Storage: `Preimage::StatusFor` (r:1 w:0) + /// Proof: `Preimage::StatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`) + /// Storage: `Preimage::RequestStatusFor` (r:1 w:0) + /// Proof: `Preimage::RequestStatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`) + /// Storage: `Referenda::MetadataOf` (r:0 w:1) + /// Proof: `Referenda::MetadataOf` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) + fn set_some_metadata() -> Weight { + // Proof Size summary in bytes: + // Measured: `350` + // Estimated: `4401` + // Minimum execution time: 20_600_000 picoseconds. + Weight::from_parts(21_060_000, 0) + .saturating_add(Weight::from_parts(0, 4401)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: `Referenda::ReferendumInfoFor` (r:1 w:0) + /// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`) + /// Storage: `Referenda::MetadataOf` (r:1 w:1) + /// Proof: `Referenda::MetadataOf` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) + fn clear_metadata() -> Weight { + // Proof Size summary in bytes: + // Measured: `283` + // Estimated: `4401` + // Minimum execution time: 16_111_000 picoseconds. + Weight::from_parts(16_420_000, 0) + .saturating_add(Weight::from_parts(0, 4401)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) + } +} diff --git a/parachain/runtime/paseo/src/weights/pallet_whitelist.rs b/parachain/runtime/paseo/src/weights/pallet_whitelist.rs new file mode 100644 index 0000000000..7aaf50f60a --- /dev/null +++ b/parachain/runtime/paseo/src/weights/pallet_whitelist.rs @@ -0,0 +1,123 @@ +// Copyright (C) Parity Technologies and the various Polkadot contributors, see Contributions.md +// for a list of specific contributors. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//! Autogenerated weights for `pallet_whitelist` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 +//! DATE: 2024-08-14, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `ggwpez-ref-hw`, CPU: `AMD EPYC 7232P 8-Core Processor` +//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("./polkadot-chain-spec.json")`, DB CACHE: 1024 + +// Executed Command: +// ./target/production/polkadot +// benchmark +// pallet +// --chain=./polkadot-chain-spec.json +// --steps=50 +// --repeat=20 +// --pallet=pallet_whitelist +// --extrinsic=* +// --wasm-execution=compiled +// --heap-pages=4096 +// --output=./polkadot-weights/ +// --header=./file_header.txt + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] +#![allow(missing_docs)] + +use frame_support::{traits::Get, weights::Weight}; +use core::marker::PhantomData; + +/// Weight functions for `pallet_whitelist`. +pub struct WeightInfo(PhantomData); +impl pallet_whitelist::WeightInfo for WeightInfo { + /// Storage: `Whitelist::WhitelistedCall` (r:1 w:1) + /// Proof: `Whitelist::WhitelistedCall` (`max_values`: None, `max_size`: Some(40), added: 2515, mode: `MaxEncodedLen`) + /// Storage: `Preimage::StatusFor` (r:1 w:0) + /// Proof: `Preimage::StatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`) + /// Storage: `Preimage::RequestStatusFor` (r:1 w:1) + /// Proof: `Preimage::RequestStatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`) + fn whitelist_call() -> Weight { + // Proof Size summary in bytes: + // Measured: `118` + // Estimated: `3556` + // Minimum execution time: 19_700_000 picoseconds. + Weight::from_parts(20_170_000, 0) + .saturating_add(Weight::from_parts(0, 3556)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: `Whitelist::WhitelistedCall` (r:1 w:1) + /// Proof: `Whitelist::WhitelistedCall` (`max_values`: None, `max_size`: Some(40), added: 2515, mode: `MaxEncodedLen`) + /// Storage: `Preimage::StatusFor` (r:1 w:0) + /// Proof: `Preimage::StatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`) + /// Storage: `Preimage::RequestStatusFor` (r:1 w:1) + /// Proof: `Preimage::RequestStatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`) + fn remove_whitelisted_call() -> Weight { + // Proof Size summary in bytes: + // Measured: `247` + // Estimated: `3556` + // Minimum execution time: 18_890_000 picoseconds. + Weight::from_parts(19_351_000, 0) + .saturating_add(Weight::from_parts(0, 3556)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: `Whitelist::WhitelistedCall` (r:1 w:1) + /// Proof: `Whitelist::WhitelistedCall` (`max_values`: None, `max_size`: Some(40), added: 2515, mode: `MaxEncodedLen`) + /// Storage: `Preimage::PreimageFor` (r:1 w:1) + /// Proof: `Preimage::PreimageFor` (`max_values`: None, `max_size`: Some(4194344), added: 4196819, mode: `Measured`) + /// Storage: `Preimage::StatusFor` (r:1 w:0) + /// Proof: `Preimage::StatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`) + /// Storage: `Preimage::RequestStatusFor` (r:1 w:1) + /// Proof: `Preimage::RequestStatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`) + /// The range of component `n` is `[1, 4194294]`. + fn dispatch_whitelisted_call(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `323 + n * (1 ±0)` + // Estimated: `3787 + n * (1 ±0)` + // Minimum execution time: 31_320_000 picoseconds. + Weight::from_parts(31_561_000, 0) + .saturating_add(Weight::from_parts(0, 3787)) + // Standard Error: 2 + .saturating_add(Weight::from_parts(1_147, 0).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) + } + /// Storage: `Whitelist::WhitelistedCall` (r:1 w:1) + /// Proof: `Whitelist::WhitelistedCall` (`max_values`: None, `max_size`: Some(40), added: 2515, mode: `MaxEncodedLen`) + /// Storage: `Preimage::StatusFor` (r:1 w:0) + /// Proof: `Preimage::StatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`) + /// Storage: `Preimage::RequestStatusFor` (r:1 w:1) + /// Proof: `Preimage::RequestStatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`) + /// The range of component `n` is `[1, 10000]`. + fn dispatch_whitelisted_call_with_preimage(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `247` + // Estimated: `3556` + // Minimum execution time: 23_100_000 picoseconds. + Weight::from_parts(23_541_355, 0) + .saturating_add(Weight::from_parts(0, 3556)) + // Standard Error: 2 + .saturating_add(Weight::from_parts(1_468, 0).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(2)) + } +} diff --git a/parachain/scripts/launch-network.sh b/parachain/scripts/launch-network.sh index d8a1125f19..a75e6502df 100755 --- a/parachain/scripts/launch-network.sh +++ b/parachain/scripts/launch-network.sh @@ -17,7 +17,7 @@ function print_divider() { CHAIN=$1 -ZOMBIENET_VERSION=v1.3.116 +ZOMBIENET_VERSION=v1.3.117 ZOMBIENET_DIR=$(LC_ALL=C tr -dc A-Za-z0-9 ) -> Result<(), Error>; + fn send_extrinsics(&self, extrinsics: Vec) -> Result<(), Error>; } pub trait LightClientState { diff --git a/tee-worker/common/core/parentchain/light-client/src/light_validation.rs b/tee-worker/common/core/parentchain/light-client/src/light_validation.rs index 43b9836fe6..09af1e1e23 100644 --- a/tee-worker/common/core/parentchain/light-client/src/light_validation.rs +++ b/tee-worker/common/core/parentchain/light-client/src/light_validation.rs @@ -210,7 +210,7 @@ where Block: ParentchainBlockTrait, OCallApi: EnclaveOnChainOCallApi, { - fn send_extrinsics(&mut self, extrinsics: Vec) -> Result<(), Error> { + fn send_extrinsics(&self, extrinsics: Vec) -> Result<(), Error> { self.ocall_api .send_to_parentchain(extrinsics, &self.parentchain_id, None) .map_err(|e| { diff --git a/tee-worker/common/core/parentchain/light-client/src/mocks/validator_mock.rs b/tee-worker/common/core/parentchain/light-client/src/mocks/validator_mock.rs index ed33d59225..17d634b038 100644 --- a/tee-worker/common/core/parentchain/light-client/src/mocks/validator_mock.rs +++ b/tee-worker/common/core/parentchain/light-client/src/mocks/validator_mock.rs @@ -59,7 +59,7 @@ impl Validator for ValidatorMock { } impl ExtrinsicSender for ValidatorMock { - fn send_extrinsics(&mut self, _extrinsics: Vec) -> Result<()> { + fn send_extrinsics(&self, _extrinsics: Vec) -> Result<()> { Ok(()) } } diff --git a/tee-worker/identity/core/offchain-worker-executor/Cargo.toml b/tee-worker/identity/core/offchain-worker-executor/Cargo.toml index a333fc7838..54f7c3676d 100644 --- a/tee-worker/identity/core/offchain-worker-executor/Cargo.toml +++ b/tee-worker/identity/core/offchain-worker-executor/Cargo.toml @@ -16,6 +16,8 @@ thiserror_sgx = { workspace = true, optional = true } itc-parentchain-light-client = { workspace = true } itp-extrinsics-factory = { workspace = true } +itp-node-api = { workspace = true } +itp-sgx-runtime-primitives = { workspace = true } itp-stf-executor = { package = "id-itp-stf-executor", path = "../../core-primitives/stf-executor", default-features = false } itp-stf-interface = { workspace = true } itp-stf-primitives = { workspace = true } @@ -40,7 +42,9 @@ sp-core = { workspace = true, features = ["full_crypto"] } default = ["std"] std = [ "itc-parentchain-light-client/std", + "itp-sgx-runtime-primitives/std", "itp-extrinsics-factory/std", + "itp-node-api/std", "itp-stf-executor/std", "itp-stf-interface/std", "itp-stf-primitives/std", @@ -52,6 +56,7 @@ std = [ ] sgx = [ "itc-parentchain-light-client/sgx", + "itp-node-api/sgx", "itp-extrinsics-factory/sgx", "itp-stf-executor/sgx", "itp-stf-state-handler/sgx", diff --git a/tee-worker/identity/core/offchain-worker-executor/src/executor.rs b/tee-worker/identity/core/offchain-worker-executor/src/executor.rs index 5cf3e778b8..132a706f67 100644 --- a/tee-worker/identity/core/offchain-worker-executor/src/executor.rs +++ b/tee-worker/identity/core/offchain-worker-executor/src/executor.rs @@ -23,14 +23,17 @@ use itc_parentchain_light_client::{ NumberFor, }; use itp_extrinsics_factory::CreateExtrinsics; +use itp_node_api::api_client::ParentchainAdditionalParams; use itp_stf_executor::{traits::StateUpdateProposer, ExecutedOperation}; use itp_stf_interface::system_pallet::SystemPalletEventInterface; use itp_stf_primitives::{traits::TrustedCallVerification, types::TrustedOperationOrHash}; use itp_stf_state_handler::{handle_state::HandleState, query_shard_state::QueryShardState}; use itp_top_pool_author::traits::AuthorApi; -use itp_types::{parentchain::ParentchainCall, OpaqueCall, ShardIdentifier, H256}; +use itp_types::{ + parentchain::ParentchainCall, Header as ParentchainHeader, OpaqueCall, ShardIdentifier, H256, +}; use log::*; -use sp_runtime::traits::Block; +use sp_runtime::{generic::Era, traits::Block}; use std::{marker::PhantomData, sync::Arc, time::Duration, vec::Vec}; /// Off-chain worker executor implementation. @@ -82,7 +85,7 @@ impl< TCS, G, > where - ParentchainBlock: Block, + ParentchainBlock: Block, StfExecutor: StateUpdateProposer, TopPoolAuthor: AuthorApi, StateHandler: QueryShardState + HandleState, @@ -175,7 +178,7 @@ impl< Ok(()) } - fn get_latest_parentchain_header(&self) -> Result { + fn get_latest_parentchain_header(&self) -> Result { let header = self.validator_accessor.execute_on_validator(|v| { let latest_parentchain_header = v.latest_finalized_header()?; Ok(latest_parentchain_header) @@ -218,10 +221,13 @@ impl< warn!("sending extrinsics to target B unimplemented") }; + let params = self.get_latest_parentchain_header().ok().map(|h| { + ParentchainAdditionalParams::new().era(Era::mortal(5, h.number.into()), h.hash()) + }); let extrinsics = - self.extrinsics_factory.create_extrinsics(integritee_calls.as_slice(), None)?; + self.extrinsics_factory.create_extrinsics(integritee_calls.as_slice(), params)?; self.validator_accessor - .execute_mut_on_validator(|v| v.send_extrinsics(extrinsics))?; + .execute_on_validator(|v| v.send_extrinsics(extrinsics))?; Ok(()) } diff --git a/tee-worker/identity/core/parentchain/block-importer/Cargo.toml b/tee-worker/identity/core/parentchain/block-importer/Cargo.toml index 5eabe65488..c060eae67f 100644 --- a/tee-worker/identity/core/parentchain/block-importer/Cargo.toml +++ b/tee-worker/identity/core/parentchain/block-importer/Cargo.toml @@ -13,6 +13,7 @@ itc-parentchain-indirect-calls-executor = { package = "id-itc-parentchain-indire itc-parentchain-light-client = { workspace = true } itp-enclave-metrics = { workspace = true } itp-extrinsics-factory = { workspace = true } +itp-node-api = { workspace = true } itp-ocall-api = { workspace = true } itp-stf-executor = { package = "id-itp-stf-executor", path = "../../../core-primitives/stf-executor", default-features = false } itp-stf-interface = { workspace = true } @@ -41,6 +42,7 @@ std = [ "sp-runtime/std", "thiserror", "itp-ocall-api/std", + "itp-node-api/std", ] sgx = [ "sgx_tstd", @@ -51,6 +53,7 @@ sgx = [ "itp-extrinsics-factory/sgx", "itp-stf-executor/sgx", "thiserror_sgx", + "itp-node-api/sgx", ] # feature to export mock implementations, only to be used for dev-dependencies! diff --git a/tee-worker/identity/core/parentchain/block-importer/src/block_importer.rs b/tee-worker/identity/core/parentchain/block-importer/src/block_importer.rs index efbb129429..819e290f45 100644 --- a/tee-worker/identity/core/parentchain/block-importer/src/block_importer.rs +++ b/tee-worker/identity/core/parentchain/block-importer/src/block_importer.rs @@ -22,11 +22,12 @@ use crate::{error::Result, ImportParentchainBlocks}; use ita_stf::ParentchainHeader; use itc_parentchain_indirect_calls_executor::ExecuteIndirectCalls; use itc_parentchain_light_client::{ - concurrent_access::ValidatorAccess, BlockNumberOps, ExtrinsicSender, Validator, + concurrent_access::ValidatorAccess, BlockNumberOps, LightClientState, Validator, }; use itp_enclave_metrics::EnclaveMetric; use itp_extrinsics_factory::CreateExtrinsics; -use itp_ocall_api::EnclaveMetricsOCallApi; +use itp_node_api::api_client::ParentchainAdditionalParams; +use itp_ocall_api::{EnclaveMetricsOCallApi, EnclaveOnChainOCallApi}; use itp_stf_executor::traits::StfUpdateState; use itp_stf_interface::ShardCreationInfo; use itp_types::{ @@ -35,7 +36,7 @@ use itp_types::{ }; use log::*; use sp_runtime::{ - generic::SignedBlock as SignedBlockG, + generic::{Era, SignedBlock as SignedBlockG}, traits::{Block as ParentchainBlockTrait, Header as HeaderT, NumberFor}, }; use std::{marker::PhantomData, sync::Arc, vec, vec::Vec}; @@ -120,7 +121,7 @@ impl< StfExecutor: StfUpdateState, ExtrinsicsFactory: CreateExtrinsics, IndirectCallsExecutor: ExecuteIndirectCalls, - OcallApi: EnclaveMetricsOCallApi, + OcallApi: EnclaveMetricsOCallApi + EnclaveOnChainOCallApi, { type SignedBlockType = SignedBlockG; @@ -143,6 +144,7 @@ impl< } else { events_to_import }; + for (signed_block, raw_events) in blocks_to_import.into_iter().zip(events_to_import_aligned.into_iter()) { @@ -205,13 +207,22 @@ impl< ); } - // Create extrinsics for all `unshielding` and `block processed` calls we've gathered. + let params = self + .validator_accessor + .execute_on_validator(|v| v.latest_finalized_header()) + .ok() + .map(|h| { + ParentchainAdditionalParams::new().era(Era::mortal(5, h.number.into()), h.hash()) + }); + let parentchain_extrinsics = - self.extrinsics_factory.create_extrinsics(calls.as_slice(), None)?; + self.extrinsics_factory.create_extrinsics(calls.as_slice(), params)?; - // Sending the extrinsic requires mut access because the validator caches the sent extrinsics internally. - self.validator_accessor - .execute_mut_on_validator(|v| v.send_extrinsics(parentchain_extrinsics))?; + self.ocall_api.send_to_parentchain( + parentchain_extrinsics, + &ParentchainId::Litentry, + None, + )?; Ok(()) } diff --git a/tee-worker/identity/enclave-runtime/Cargo.lock b/tee-worker/identity/enclave-runtime/Cargo.lock index c3a5ca6eab..c94e71cc70 100644 --- a/tee-worker/identity/enclave-runtime/Cargo.lock +++ b/tee-worker/identity/enclave-runtime/Cargo.lock @@ -1924,6 +1924,8 @@ dependencies = [ "id-itp-top-pool-author", "itc-parentchain-light-client", "itp-extrinsics-factory", + "itp-node-api", + "itp-sgx-runtime-primitives", "itp-stf-interface", "itp-stf-primitives", "itp-stf-state-handler", @@ -1970,6 +1972,7 @@ dependencies = [ "itc-parentchain-light-client", "itp-enclave-metrics", "itp-extrinsics-factory", + "itp-node-api", "itp-ocall-api", "itp-stf-interface", "itp-types", @@ -2767,6 +2770,7 @@ dependencies = [ "itp-enclave-metrics", "itp-extrinsics-factory", "itp-import-queue", + "itp-node-api", "itp-node-api-metadata", "itp-node-api-metadata-provider", "itp-ocall-api", @@ -3154,6 +3158,7 @@ dependencies = [ "serde_json 1.0.133", "sgx_tstd", "sp-core", + "sp-runtime", ] [[package]] @@ -3305,6 +3310,7 @@ dependencies = [ "parity-scale-codec", "sgx_tstd", "sp-core", + "sp-runtime", ] [[package]] diff --git a/tee-worker/identity/enclave-runtime/src/rpc/common_api.rs b/tee-worker/identity/enclave-runtime/src/rpc/common_api.rs index 6995ac26ae..a3a39827a2 100644 --- a/tee-worker/identity/enclave-runtime/src/rpc/common_api.rs +++ b/tee-worker/identity/enclave-runtime/src/rpc/common_api.rs @@ -589,7 +589,7 @@ fn forward_dcap_quote_inner(params: Params) -> Result { let validator_access = get_validator_accessor_from_integritee_solo_or_parachain() .map_err(|e| format!("{:?}", e))?; validator_access - .execute_mut_on_validator(|v| v.send_extrinsics(vec![ext.clone()])) + .execute_on_validator(|v| v.send_extrinsics(vec![ext.clone()])) .map_err(|e| format!("{:?}", e))?; Ok(ext) @@ -623,7 +623,7 @@ fn attesteer_forward_ias_attestation_report_inner( let validator_access = get_validator_accessor_from_integritee_solo_or_parachain() .map_err(|e| format!("{:?}", e))?; validator_access - .execute_mut_on_validator(|v| v.send_extrinsics(vec![ext.clone()])) + .execute_on_validator(|v| v.send_extrinsics(vec![ext.clone()])) .map_err(|e| format!("{:?}", e))?; Ok(ext) diff --git a/tee-worker/identity/enclave-runtime/src/top_pool_execution.rs b/tee-worker/identity/enclave-runtime/src/top_pool_execution.rs index 439a3f2463..35bc9893f2 100644 --- a/tee-worker/identity/enclave-runtime/src/top_pool_execution.rs +++ b/tee-worker/identity/enclave-runtime/src/top_pool_execution.rs @@ -49,6 +49,7 @@ use itc_parentchain::{ use itp_component_container::ComponentGetter; use itp_enclave_metrics::EnclaveMetric; use itp_extrinsics_factory::CreateExtrinsics; +use itp_node_api::api_client::ParentchainAdditionalParams; use itp_ocall_api::{EnclaveMetricsOCallApi, EnclaveOnChainOCallApi, EnclaveSidechainOCallApi}; use itp_settings::sidechain::SLOT_DURATION; use itp_sgx_crypto::key_repository::AccessKey; @@ -72,7 +73,9 @@ use log::*; use sgx_types::sgx_status_t; use sp_core::{crypto::UncheckedFrom, Pair}; use sp_runtime::{ - generic::SignedBlock as SignedParentchainBlock, traits::Block as BlockTrait, MultiSignature, + generic::{Era, SignedBlock as SignedParentchainBlock}, + traits::Block as BlockTrait, + MultiSignature, }; use std::{sync::Arc, time::Instant, vec::Vec}; @@ -364,9 +367,15 @@ where debug!("Enclave wants to send {} extrinsics to Integritee Parentchain", calls.len()); if !calls.is_empty() { let extrinsics_factory = get_extrinsic_factory_from_integritee_solo_or_parachain()?; - let xts = extrinsics_factory.create_extrinsics(calls.as_slice(), None)?; let validator_access = get_validator_accessor_from_integritee_solo_or_parachain()?; - validator_access.execute_mut_on_validator(|v| v.send_extrinsics(xts))?; + let params = validator_access + .execute_on_validator(|v| v.latest_finalized_header()) + .ok() + .map(|h| { + ParentchainAdditionalParams::new().era(Era::mortal(5, h.number.into()), h.hash()) + }); + let xts = extrinsics_factory.create_extrinsics(calls.as_slice(), params)?; + validator_access.execute_on_validator(|v| v.send_extrinsics(xts))?; } let calls: Vec = parentchain_calls .iter() @@ -375,9 +384,15 @@ where debug!("Enclave wants to send {} extrinsics to TargetA Parentchain", calls.len()); if !calls.is_empty() { let extrinsics_factory = get_extrinsic_factory_from_target_a_solo_or_parachain()?; - let xts = extrinsics_factory.create_extrinsics(calls.as_slice(), None)?; let validator_access = get_validator_accessor_from_target_a_solo_or_parachain()?; - validator_access.execute_mut_on_validator(|v| v.send_extrinsics(xts))?; + let params = validator_access + .execute_on_validator(|v| v.latest_finalized_header()) + .ok() + .map(|h| { + ParentchainAdditionalParams::new().era(Era::mortal(5, h.number.into()), h.hash()) + }); + let xts = extrinsics_factory.create_extrinsics(calls.as_slice(), params)?; + validator_access.execute_on_validator(|v| v.send_extrinsics(xts))?; } let calls: Vec = parentchain_calls .iter() @@ -386,9 +401,15 @@ where debug!("Enclave wants to send {} extrinsics to TargetB Parentchain", calls.len()); if !calls.is_empty() { let extrinsics_factory = get_extrinsic_factory_from_target_b_solo_or_parachain()?; - let xts = extrinsics_factory.create_extrinsics(calls.as_slice(), None)?; let validator_access = get_validator_accessor_from_target_b_solo_or_parachain()?; - validator_access.execute_mut_on_validator(|v| v.send_extrinsics(xts))?; + let params = validator_access + .execute_on_validator(|v| v.latest_finalized_header()) + .ok() + .map(|h| { + ParentchainAdditionalParams::new().era(Era::mortal(5, h.number.into()), h.hash()) + }); + let xts = extrinsics_factory.create_extrinsics(calls.as_slice(), params)?; + validator_access.execute_on_validator(|v| v.send_extrinsics(xts))?; } Ok(()) diff --git a/tee-worker/identity/litentry/core/native-task/receiver/Cargo.toml b/tee-worker/identity/litentry/core/native-task/receiver/Cargo.toml index 4ec3218592..cc8b7fa5be 100644 --- a/tee-worker/identity/litentry/core/native-task/receiver/Cargo.toml +++ b/tee-worker/identity/litentry/core/native-task/receiver/Cargo.toml @@ -14,6 +14,7 @@ sgx_tstd = { workspace = true, features = ["net", "thread"], optional = true } codec = { package = "parity-scale-codec", workspace = true } log = { workspace = true } sp-core = { workspace = true, features = ["full_crypto"] } +sp-runtime = { workspace = true } ita-sgx-runtime = { package = "id-ita-sgx-runtime", path = "../../../../app-libs/sgx-runtime", default-features = false } ita-stf = { package = "id-ita-stf", path = "../../../../app-libs/stf", default-features = false } @@ -69,6 +70,7 @@ std = [ "itp-stf-primitives/std", "itp-extrinsics-factory/std", "sp-core/std", + "sp-runtime/std", "litentry-primitives/std", "frame-support/std", "itp-node-api/std", diff --git a/tee-worker/identity/litentry/core/native-task/receiver/src/lib.rs b/tee-worker/identity/litentry/core/native-task/receiver/src/lib.rs index a2ef326732..053f9ec99d 100644 --- a/tee-worker/identity/litentry/core/native-task/receiver/src/lib.rs +++ b/tee-worker/identity/litentry/core/native-task/receiver/src/lib.rs @@ -66,7 +66,7 @@ use ita_stf::{ }; use itp_extrinsics_factory::CreateExtrinsics; use itp_node_api::{ - api_client::{compose_call, XtStatus}, + api_client::{compose_call, ParentchainAdditionalParams, XtStatus}, metadata::{provider::AccessNodeMetadata, NodeMetadata}, }; use itp_ocall_api::{EnclaveAttestationOCallApi, EnclaveMetricsOCallApi, EnclaveOnChainOCallApi}; @@ -94,6 +94,7 @@ use litentry_primitives::{ AesRequest, DecryptableRequest, Identity, Intent, MemberAccount, ValidationData, }; use sp_core::{blake2_256, H160, H256}; +use sp_runtime::generic::Era; use std::collections::HashSet; const THREAD_POOL_SIZE: usize = 480; @@ -553,7 +554,11 @@ fn handle_trusted_call extrinsic, Err(e) => { log::error!("Failed to create extrinsic: {:?}", e); diff --git a/tee-worker/identity/litentry/core/native-task/receiver/src/trusted_call_handlers/request_vc_handler.rs b/tee-worker/identity/litentry/core/native-task/receiver/src/trusted_call_handlers/request_vc_handler.rs index e23256205d..d7bc97a270 100644 --- a/tee-worker/identity/litentry/core/native-task/receiver/src/trusted_call_handlers/request_vc_handler.rs +++ b/tee-worker/identity/litentry/core/native-task/receiver/src/trusted_call_handlers/request_vc_handler.rs @@ -30,7 +30,7 @@ use ita_stf::{ use itp_enclave_metrics::EnclaveMetric; use itp_extrinsics_factory::CreateExtrinsics; use itp_node_api::{ - api_client::compose_call, + api_client::{compose_call, ParentchainAdditionalParams}, metadata::{pallet_system::SystemConstants, provider::AccessNodeMetadata, NodeMetadata}, }; use itp_ocall_api::{EnclaveMetricsOCallApi, EnclaveOnChainOCallApi}; @@ -56,6 +56,7 @@ use litentry_primitives::{ ParentchainBlockNumber, RequestAesKey, }; use sp_core::{H160, H256 as Hash}; +use sp_runtime::generic::Era; use std::{collections::HashMap, time::Instant}; pub type HandleRequestVcResult = Result; @@ -156,9 +157,12 @@ where "create_account_store", who.clone() )); + let params = context.ocall_api.get_header().ok().map(|h: itp_types::Header| { + ParentchainAdditionalParams::new().era(Era::mortal(5, h.number.into()), h.hash()) + }); let xt = context .extrinsic_factory - .create_extrinsics(&[create_account_store_call], None) + .create_extrinsics(&[create_account_store_call], params) .map_err(|e| RequestVcErrorDetail::CreateAccountStoreFailed(e.to_string()))?; context .ocall_api @@ -238,9 +242,13 @@ where req_ext_hash )); + let params = context.ocall_api.get_header().ok().map(|h: itp_types::Header| { + ParentchainAdditionalParams::new().era(Era::mortal(5, h.number.into()), h.hash()) + }); + let xt = context .extrinsic_factory - .create_extrinsics(&[on_vc_issued_call], None) + .create_extrinsics(&[on_vc_issued_call], params) .map_err(|e| RequestVcErrorDetail::ExtrinsicConstructionFailed(e.to_string()))?; context diff --git a/tee-worker/identity/litentry/core/vc-task/receiver/Cargo.toml b/tee-worker/identity/litentry/core/vc-task/receiver/Cargo.toml index cafe82d635..16789ea81d 100644 --- a/tee-worker/identity/litentry/core/vc-task/receiver/Cargo.toml +++ b/tee-worker/identity/litentry/core/vc-task/receiver/Cargo.toml @@ -11,6 +11,7 @@ sgx_tstd = { workspace = true, features = ["net", "thread"], optional = true } codec = { package = "parity-scale-codec", workspace = true } log = { workspace = true } sp-core = { workspace = true, features = ["full_crypto"] } +sp-runtime = { workspace = true } ita-sgx-runtime = { package = "id-ita-sgx-runtime", path = "../../../../app-libs/sgx-runtime", default-features = false } ita-stf = { package = "id-ita-stf", path = "../../../../app-libs/stf", default-features = false } @@ -69,6 +70,7 @@ std = [ "itp-stf-primitives/std", "itp-extrinsics-factory/std", "sp-core/std", + "sp-runtime/std", "litentry-primitives/std", "ita-sgx-runtime/std", "frame-support/std", diff --git a/tee-worker/identity/litentry/core/vc-task/receiver/src/lib.rs b/tee-worker/identity/litentry/core/vc-task/receiver/src/lib.rs index e4c6400fdd..8b2670dd58 100644 --- a/tee-worker/identity/litentry/core/vc-task/receiver/src/lib.rs +++ b/tee-worker/identity/litentry/core/vc-task/receiver/src/lib.rs @@ -38,9 +38,12 @@ use ita_stf::{ }; use itp_enclave_metrics::EnclaveMetric; use itp_extrinsics_factory::CreateExtrinsics; -use itp_node_api::metadata::{ - pallet_system::SystemConstants, pallet_vcmp::VCMPCallIndexes, provider::AccessNodeMetadata, - NodeMetadataTrait, +use itp_node_api::{ + api_client::ParentchainAdditionalParams, + metadata::{ + pallet_system::SystemConstants, pallet_vcmp::VCMPCallIndexes, provider::AccessNodeMetadata, + NodeMetadataTrait, + }, }; use itp_ocall_api::{EnclaveAttestationOCallApi, EnclaveMetricsOCallApi, EnclaveOnChainOCallApi}; use itp_sgx_crypto::{key_repository::AccessKey, ShieldingCryptoDecrypt, ShieldingCryptoEncrypt}; @@ -65,6 +68,7 @@ use litentry_primitives::{ use log::*; use pallet_identity_management_tee::{identity_context::sort_id_graph, IdentityContext}; use sp_core::{blake2_256, H160}; +use sp_runtime::generic::Era; use std::{ boxed::Box, collections::{HashMap, HashSet}, @@ -615,9 +619,13 @@ where .send((shard, c)) .map_err(|e| RequestVcErrorDetail::TrustedCallSendingFailed(e.to_string()))?; + let params = context.ocall_api.get_header().ok().map(|h: itp_types::Header| { + ParentchainAdditionalParams::new().era(Era::mortal(5, h.number.into()), h.hash()) + }); + // this internally fetches nonce from a mutex and then updates it thereby ensuring ordering let xt = extrinsic_factory - .create_extrinsics(&[call], None) + .create_extrinsics(&[call], params) .map_err(|e| RequestVcErrorDetail::ExtrinsicConstructionFailed(e.to_string()))?; context diff --git a/tee-worker/identity/sidechain/consensus/common/Cargo.toml b/tee-worker/identity/sidechain/consensus/common/Cargo.toml index f1457a4298..523d21c9a5 100644 --- a/tee-worker/identity/sidechain/consensus/common/Cargo.toml +++ b/tee-worker/identity/sidechain/consensus/common/Cargo.toml @@ -14,6 +14,7 @@ itc-parentchain-light-client = { workspace = true } itp-enclave-metrics = { workspace = true } itp-extrinsics-factory = { workspace = true } itp-import-queue = { workspace = true } +itp-node-api = { workspace = true } itp-node-api-metadata = { workspace = true } itp-node-api-metadata-provider = { workspace = true } itp-ocall-api = { workspace = true } @@ -51,6 +52,7 @@ std = [ "itp-import-queue/std", "itp-enclave-metrics/std", "itp-extrinsics-factory/std", + "itp-node-api/std", "itp-node-api-metadata/std", "itp-node-api-metadata-provider/std", "itp-ocall-api/std", @@ -70,6 +72,7 @@ sgx = [ "itp-import-queue/sgx", "itp-enclave-metrics/sgx", "itp-extrinsics-factory/sgx", + "itp-node-api/sgx", "itp-node-api-metadata-provider/sgx", "itp-sgx-crypto/sgx", "itp-sgx-externalities/sgx", diff --git a/tee-worker/identity/sidechain/consensus/common/src/block_import_confirmation_handler.rs b/tee-worker/identity/sidechain/consensus/common/src/block_import_confirmation_handler.rs index 759a6e3eee..87351d6da5 100644 --- a/tee-worker/identity/sidechain/consensus/common/src/block_import_confirmation_handler.rs +++ b/tee-worker/identity/sidechain/consensus/common/src/block_import_confirmation_handler.rs @@ -17,16 +17,18 @@ use crate::error::{Error, Result}; use itc_parentchain_light_client::{ - concurrent_access::ValidatorAccess, BlockNumberOps, ExtrinsicSender, NumberFor, + concurrent_access::ValidatorAccess, BlockNumberOps, ExtrinsicSender, LightClientState, + NumberFor, }; use itp_extrinsics_factory::CreateExtrinsics; +use itp_node_api::api_client::ParentchainAdditionalParams; use itp_node_api_metadata::{pallet_teebag::TeebagCallIndexes, NodeMetadataTrait}; use itp_node_api_metadata_provider::AccessNodeMetadata; use itp_settings::worker::BLOCK_NUMBER_FINALIZATION_DIFF; -use itp_types::{OpaqueCall, ShardIdentifier}; +use itp_types::{Header, OpaqueCall, ShardIdentifier}; use its_primitives::traits::Header as HeaderTrait; use log::*; -use sp_runtime::traits::Block as ParentchainBlockTrait; +use sp_runtime::{generic::Era, traits::Block as ParentchainBlockTrait}; use std::{marker::PhantomData, sync::Arc}; /// Trait to confirm a sidechain block import. @@ -91,7 +93,7 @@ impl< ExtrinsicsFactory, ValidatorAccessor, > where - ParentchainBlock: ParentchainBlockTrait, + ParentchainBlock: ParentchainBlockTrait
, NumberFor: BlockNumberOps, SidechainHeader: HeaderTrait, NodeMetadataRepository: AccessNodeMetadata, @@ -115,14 +117,23 @@ impl< header.hash(), )); + let params = self + .validator_accessor + .execute_on_validator(|v| v.latest_finalized_header()) + .ok() + .map(|h| { + ParentchainAdditionalParams::new() + .era(Era::mortal(5, h.number.into()), h.hash()) + }); + let xts = self .extrinsics_factory - .create_extrinsics(&[opaque_call], None) + .create_extrinsics(&[opaque_call], params) .map_err(|e| Error::Other(e.into()))?; debug!("Sending sidechain block import confirmation extrinsic.."); self.validator_accessor - .execute_mut_on_validator(|v| v.send_extrinsics(xts)) + .execute_on_validator(|v| v.send_extrinsics(xts)) .map_err(|e| Error::Other(e.into()))?; } Ok(())