From e170a012536aee791a9ef41d6f159b11b6add3d3 Mon Sep 17 00:00:00 2001 From: magecnion Date: Thu, 18 Jul 2024 11:00:45 +0200 Subject: [PATCH 01/16] include moonbeam's staking precompile code as it is --- Cargo.lock | 27 + Cargo.toml | 3 + precompiles/parachain-staking/Cargo.toml | 57 + .../parachain-staking/StakingInterface.sol | 305 +++ precompiles/parachain-staking/src/lib.rs | 920 +++++++++ precompiles/parachain-staking/src/mock.rs | 365 ++++ precompiles/parachain-staking/src/tests.rs | 1744 +++++++++++++++++ 7 files changed, 3421 insertions(+) create mode 100644 precompiles/parachain-staking/Cargo.toml create mode 100644 precompiles/parachain-staking/StakingInterface.sol create mode 100644 precompiles/parachain-staking/src/lib.rs create mode 100644 precompiles/parachain-staking/src/mock.rs create mode 100644 precompiles/parachain-staking/src/tests.rs diff --git a/Cargo.lock b/Cargo.lock index 8d0159f04..2487562e7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7106,6 +7106,33 @@ dependencies = [ "num", ] +[[package]] +name = "pallet-evm-precompile-parachain-staking" +version = "1.0.0" +dependencies = [ + "derive_more", + "fp-evm", + "frame-support", + "frame-system", + "log", + "num_enum", + "pallet-balances", + "pallet-evm", + "pallet-parachain-staking", + "pallet-timestamp", + "parity-scale-codec", + "precompile-utils", + "rustc-hex", + "scale-info", + "serde", + "sha3", + "sp-consensus-slots", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] + [[package]] name = "pallet-evm-precompile-simple" version = "2.0.0-dev" diff --git a/Cargo.toml b/Cargo.toml index ccc65fea6..f8b9f4027 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,6 +12,7 @@ members = [ "node", "runtime/*", "pallets/*", + "precompiles/*", "primitives", ] @@ -247,11 +248,13 @@ orml-xtokens = { git = "https://github.com/open-web3-stack/open-runtime-module-l # Other pallets # (wasm) substrate-fixed = { git = "https://github.com/encointer/substrate-fixed", default-features = false } +derive_more = "0.99" # LAOS pallets pallet-laos-evolution = { path = "./pallets/laos-evolution", default-features = false } pallet-asset-metadata-extender = { path = "./pallets/asset-metadata-extender", default-features = false } pallet-parachain-staking = { path = "./pallets/parachain-staking", default-features = false } +pallet-evm-precompile-parachain-staking = { path = "./precompiles/parachain-staking", default-features = false } # Primitives laos-primitives = { path = "./primitives", default-features = false } diff --git a/precompiles/parachain-staking/Cargo.toml b/precompiles/parachain-staking/Cargo.toml new file mode 100644 index 000000000..9ab8d0d32 --- /dev/null +++ b/precompiles/parachain-staking/Cargo.toml @@ -0,0 +1,57 @@ +[package] +name = "pallet-evm-precompile-parachain-staking" +authors = { workspace = true } +description = "A Precompile to make parachain staking accessible to pallet-evm" +edition = "2021" +version = "1.0.0" + +[dependencies] +log = { workspace = true } +num_enum = { workspace = true } +rustc-hex = { workspace = true } + +# Moonbeam +pallet-parachain-staking = { workspace = true } +precompile-utils = { workspace = true } + +# Substrate +frame-support = { workspace = true } +frame-system = { workspace = true } +parity-scale-codec = { workspace = true, features = [ "max-encoded-len" ] } +sp-consensus-slots = { workspace = true } +sp-core = { workspace = true } +sp-io = { workspace = true } +sp-std = { workspace = true } +sp-runtime = { workspace = true } + +# Frontier +fp-evm = { workspace = true } +pallet-evm = { workspace = true, features = [ "forbid-evm-reentrancy" ] } + +[dev-dependencies] +derive_more = { workspace = true } +serde = { workspace = true } +sha3 = { workspace = true } + +# Moonbeam +precompile-utils = { workspace = true, features = [ "std", "testing" ] } + +# Substrate +pallet-balances = { workspace = true, features = [ "insecure_zero_ed", "std" ] } +pallet-timestamp = { workspace = true, features = [ "std" ] } +scale-info = { workspace = true, features = [ "derive", "std" ] } +sp-runtime = { workspace = true, features = [ "std" ] } + +[features] +default = [ "std" ] +std = [ + "fp-evm/std", + "frame-support/std", + "frame-system/std", + "pallet-parachain-staking/std", + "parity-scale-codec/std", + "precompile-utils/std", + "sp-consensus-slots/std", + "sp-core/std", + "sp-std/std", +] diff --git a/precompiles/parachain-staking/StakingInterface.sol b/precompiles/parachain-staking/StakingInterface.sol new file mode 100644 index 000000000..ec939050e --- /dev/null +++ b/precompiles/parachain-staking/StakingInterface.sol @@ -0,0 +1,305 @@ +// SPDX-License-Identifier: GPL-3.0-only +pragma solidity >=0.8.3; + +/// @dev The ParachainStaking contract's address. +address constant PARACHAIN_STAKING_ADDRESS = 0x0000000000000000000000000000000000000800; + +/// @dev The ParachainStaking contract's instance. +ParachainStaking constant PARACHAIN_STAKING_CONTRACT = ParachainStaking( + PARACHAIN_STAKING_ADDRESS +); + +/// @author The Moonbeam Team +/// @title Pallet Parachain Staking Interface +/// @dev The interface through which solidity contracts will interact with Parachain Staking +/// We follow this same interface including four-byte function selectors, in the precompile that +/// wraps the pallet +/// @custom:address 0x0000000000000000000000000000000000000800 +interface ParachainStaking { + /// @dev Check whether the specified address is currently a staking delegator + /// @custom:selector fd8ab482 + /// @param delegator the address that we want to confirm is a delegator + /// @return A boolean confirming whether the address is a delegator + function isDelegator(address delegator) external view returns (bool); + + /// @dev Check whether the specified address is currently a collator candidate + /// @custom:selector d51b9e93 + /// @param candidate the address that we want to confirm is a collator andidate + /// @return A boolean confirming whether the address is a collator candidate + function isCandidate(address candidate) external view returns (bool); + + /// @dev Check whether the specifies address is currently a part of the active set + /// @custom:selector 740d7d2a + /// @param candidate the address that we want to confirm is a part of the active set + /// @return A boolean confirming whether the address is a part of the active set + function isSelectedCandidate( + address candidate + ) external view returns (bool); + + /// @dev Total points awarded to all collators in a particular round + /// @custom:selector 9799b4e7 + /// @param round the round for which we are querying the points total + /// @return The total points awarded to all collators in the round + function points(uint256 round) external view returns (uint256); + + /// @dev Total points awarded to a specific collator in a particular round. + /// A value of `0` may signify that no blocks were produced or that the storage for that round has been removed + /// @custom:selector bfea66ac + /// @param round the round for which we are querying the awarded points + /// @param candidate The candidate to whom the points are awarded + /// @return The total points awarded to the collator for the provided round + function awardedPoints( + uint32 round, + address candidate + ) external view returns (uint32); + + /// @dev The amount delegated in support of the candidate by the delegator + /// @custom:selector a73e51bc + /// @param delegator Who made this delegation + /// @param candidate The candidate for which the delegation is in support of + /// @return The amount of the delegation in support of the candidate by the delegator + function delegationAmount( + address delegator, + address candidate + ) external view returns (uint256); + + /// @dev Whether the delegation is in the top delegations + /// @custom:selector 91cc8657 + /// @param delegator Who made this delegation + /// @param candidate The candidate for which the delegation is in support of + /// @return If delegation is in top delegations (is counted) + function isInTopDelegations( + address delegator, + address candidate + ) external view returns (bool); + + /// @dev Get the minimum delegation amount + /// @custom:selector 02985992 + /// @return The minimum delegation amount + function minDelegation() external view returns (uint256); + + /// @dev Get the CandidateCount weight hint + /// @custom:selector a9a981a3 + /// @return The CandidateCount weight hint + function candidateCount() external view returns (uint256); + + /// @dev Get the current round number + /// @custom:selector 146ca531 + /// @return The current round number + function round() external view returns (uint256); + + /// @dev Get the CandidateDelegationCount weight hint + /// @custom:selector 2ec087eb + /// @param candidate The address for which we are querying the nomination count + /// @return The number of nominations backing the collator + function candidateDelegationCount( + address candidate + ) external view returns (uint32); + + /// @dev Get the CandidateAutoCompoundingDelegationCount weight hint + /// @custom:selector 905f0806 + /// @param candidate The address for which we are querying the auto compounding + /// delegation count + /// @return The number of auto compounding delegations + function candidateAutoCompoundingDelegationCount( + address candidate + ) external view returns (uint32); + + /// @dev Get the DelegatorDelegationCount weight hint + /// @custom:selector 067ec822 + /// @param delegator The address for which we are querying the delegation count + /// @return The number of delegations made by the delegator + function delegatorDelegationCount( + address delegator + ) external view returns (uint256); + + /// @dev Get the selected candidates for the current round + /// @custom:selector bcf868a6 + /// @return The selected candidate accounts + function selectedCandidates() external view returns (address[] memory); + + /// @dev Whether there exists a pending request for a delegation made by a delegator + /// @custom:selector 3b16def8 + /// @param delegator the delegator that made the delegation + /// @param candidate the candidate for which the delegation was made + /// @return Whether a pending request exists for such delegation + function delegationRequestIsPending( + address delegator, + address candidate + ) external view returns (bool); + + /// @dev Whether there exists a pending exit for candidate + /// @custom:selector 43443682 + /// @param candidate the candidate for which the exit request was made + /// @return Whether a pending request exists for such delegation + function candidateExitIsPending( + address candidate + ) external view returns (bool); + + /// @dev Whether there exists a pending bond less request made by a candidate + /// @custom:selector d0deec11 + /// @param candidate the candidate which made the request + /// @return Whether a pending bond less request was made by the candidate + function candidateRequestIsPending( + address candidate + ) external view returns (bool); + + /// @dev Returns the percent value of auto-compound set for a delegation + /// @custom:selector b4d4c7fd + /// @param delegator the delegator that made the delegation + /// @param candidate the candidate for which the delegation was made + /// @return Percent of rewarded amount that is auto-compounded on each payout + function delegationAutoCompound( + address delegator, + address candidate + ) external view returns (uint8); + + /// @dev Join the set of collator candidates + /// @custom:selector 1f2f83ad + /// @param amount The amount self-bonded by the caller to become a collator candidate + /// @param candidateCount The number of candidates in the CandidatePool + function joinCandidates(uint256 amount, uint256 candidateCount) external; + + /// @dev Request to leave the set of collator candidates + /// @custom:selector b1a3c1b7 + /// @param candidateCount The number of candidates in the CandidatePool + function scheduleLeaveCandidates(uint256 candidateCount) external; + + /// @dev Execute due request to leave the set of collator candidates + /// @custom:selector 3867f308 + /// @param candidate The candidate address for which the pending exit request will be executed + /// @param candidateDelegationCount The number of delegations for the candidate to be revoked + function executeLeaveCandidates( + address candidate, + uint256 candidateDelegationCount + ) external; + + /// @dev Cancel request to leave the set of collator candidates + /// @custom:selector 9c76ebb4 + /// @param candidateCount The number of candidates in the CandidatePool + function cancelLeaveCandidates(uint256 candidateCount) external; + + /// @dev Temporarily leave the set of collator candidates without unbonding + /// @custom:selector a6485ccd + function goOffline() external; + + /// @dev Rejoin the set of collator candidates if previously had called `goOffline` + /// @custom:selector 6e5b676b + function goOnline() external; + + /// @dev Request to bond more for collator candidates + /// @custom:selector a52c8643 + /// @param more The additional amount self-bonded + function candidateBondMore(uint256 more) external; + + /// @dev Request to bond less for collator candidates + /// @custom:selector 60744ae0 + /// @param less The amount to be subtracted from self-bond and unreserved + function scheduleCandidateBondLess(uint256 less) external; + + /// @dev Execute pending candidate bond request + /// @custom:selector 2e290290 + /// @param candidate The address for the candidate for which the request will be executed + function executeCandidateBondLess(address candidate) external; + + /// @dev Cancel pending candidate bond request + /// @custom:selector b5ad5f07 + function cancelCandidateBondLess() external; + + /// @notice DEPRECATED use delegateWithAutoCompound instead for lower weight and better UX + /// @dev Make a delegation in support of a collator candidate + /// @custom:selector 829f5ee3 + /// @param candidate The address of the supported collator candidate + /// @param amount The amount bonded in support of the collator candidate + /// @param candidateDelegationCount The number of delegations in support of the candidate + /// @param delegatorDelegationCount The number of existing delegations by the caller + function delegate( + address candidate, + uint256 amount, + uint256 candidateDelegationCount, + uint256 delegatorDelegationCount + ) external; + + /// @dev Make a delegation in support of a collator candidate + /// @custom:selector 4b8bc9bf + /// @param candidate The address of the supported collator candidate + /// @param amount The amount bonded in support of the collator candidate + /// @param autoCompound The percent of reward that should be auto-compounded + /// @param candidateDelegationCount The number of delegations in support of the candidate + /// @param candidateAutoCompoundingDelegationCount The number of auto-compounding delegations + /// in support of the candidate + /// @param delegatorDelegationCount The number of existing delegations by the caller + function delegateWithAutoCompound( + address candidate, + uint256 amount, + uint8 autoCompound, + uint256 candidateDelegationCount, + uint256 candidateAutoCompoundingDelegationCount, + uint256 delegatorDelegationCount + ) external; + + /// @dev Request to revoke an existing delegation + /// @custom:selector 1a1c740c + /// @param candidate The address of the collator candidate which will no longer be supported + function scheduleRevokeDelegation(address candidate) external; + + /// @dev Bond more for delegators with respect to a specific collator candidate + /// @custom:selector 0465135b + /// @param candidate The address of the collator candidate for which delegation shall increase + /// @param more The amount by which the delegation is increased + function delegatorBondMore(address candidate, uint256 more) external; + + /// @dev Request to bond less for delegators with respect to a specific collator candidate + /// @custom:selector c172fd2b + /// @param candidate The address of the collator candidate for which delegation shall decrease + /// @param less The amount by which the delegation is decreased (upon execution) + function scheduleDelegatorBondLess( + address candidate, + uint256 less + ) external; + + /// @dev Execute pending delegation request (if exists && is due) + /// @custom:selector e98c8abe + /// @param delegator The address of the delegator + /// @param candidate The address of the candidate + function executeDelegationRequest( + address delegator, + address candidate + ) external; + + /// @dev Cancel pending delegation request (already made in support of input by caller) + /// @custom:selector c90eee83 + /// @param candidate The address of the candidate + function cancelDelegationRequest(address candidate) external; + + /// @dev Sets an auto-compound value for a delegation + /// @custom:selector faa1786f + /// @param candidate The address of the supported collator candidate + /// @param value The percent of reward that should be auto-compounded + /// @param candidateAutoCompoundingDelegationCount The number of auto-compounding delegations + /// in support of the candidate + /// @param delegatorDelegationCount The number of existing delegations by the caller + function setAutoCompound( + address candidate, + uint8 value, + uint256 candidateAutoCompoundingDelegationCount, + uint256 delegatorDelegationCount + ) external; + + /// @dev Fetch the total staked amount of a delegator, regardless of the + /// candidate. + /// @custom:selector e6861713 + /// @param delegator Address of the delegator. + /// @return Total amount of stake. + function getDelegatorTotalStaked( + address delegator + ) external view returns (uint256); + + /// @dev Fetch the total staked towards a candidate. + /// @custom:selector bc5a1043 + /// @param candidate Address of the candidate. + /// @return Total amount of stake. + function getCandidateTotalCounted( + address candidate + ) external view returns (uint256); +} diff --git a/precompiles/parachain-staking/src/lib.rs b/precompiles/parachain-staking/src/lib.rs new file mode 100644 index 000000000..d3f290678 --- /dev/null +++ b/precompiles/parachain-staking/src/lib.rs @@ -0,0 +1,920 @@ +// Copyright 2019-2022 PureStake Inc. +// This file is part of Moonbeam. + +// Moonbeam 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. + +// Moonbeam 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 Moonbeam. If not, see . + +//! Precompile to call parachain-staking runtime methods via the EVM + +#![cfg_attr(not(feature = "std"), no_std)] + +#[cfg(test)] +mod mock; +#[cfg(test)] +mod tests; + +use fp_evm::PrecompileHandle; +use frame_support::dispatch::{GetDispatchInfo, PostDispatchInfo}; +use frame_support::sp_runtime::Percent; +use frame_support::traits::{Currency, Get}; +use pallet_evm::AddressMapping; +use precompile_utils::prelude::*; +use sp_core::{H160, U256}; +use sp_runtime::traits::Dispatchable; +use sp_std::{convert::TryInto, marker::PhantomData, vec::Vec}; + +type BalanceOf = <::Currency as Currency< + ::AccountId, +>>::Balance; + +/// A precompile to wrap the functionality from parachain_staking. +/// +/// EXAMPLE USECASE: +/// A simple example usecase is a contract that allows donors to donate, and stakes all the funds +/// toward one fixed address chosen by the deployer. +/// Such a contract could be deployed by a collator candidate, and the deploy address distributed to +/// supporters who want to donate toward a perpetual nomination fund. +pub struct ParachainStakingPrecompile(PhantomData); + +#[precompile_utils::precompile] +impl ParachainStakingPrecompile +where + Runtime: pallet_parachain_staking::Config + pallet_evm::Config, + Runtime::AccountId: Into, + Runtime::RuntimeCall: Dispatchable + GetDispatchInfo, + ::RuntimeOrigin: From>, + Runtime::RuntimeCall: From>, + BalanceOf: TryFrom + Into + solidity::Codec, +{ + // Constants + #[precompile::public("minDelegation()")] + #[precompile::public("min_delegation()")] + #[precompile::view] + fn min_delegation(_handle: &mut impl PrecompileHandle) -> EvmResult { + let min_nomination: u128 = + <::MinDelegation as Get< + BalanceOf, + >>::get() + .try_into() + .map_err(|_| revert("Amount is too large for provided balance type"))?; + + Ok(min_nomination) + } + + // Storage Getters + #[precompile::public("points(uint256)")] + #[precompile::view] + fn points(handle: &mut impl PrecompileHandle, round: Convert) -> EvmResult { + let round = round.converted(); + // AccountsPayable: Twox64Concat(8) + RoundIndex(4) + RewardPoint(4) + handle.record_db_read::(16)?; + let points: u32 = pallet_parachain_staking::Pallet::::points(round); + + Ok(points) + } + + #[precompile::public("awardedPoints(uint32,address)")] + #[precompile::view] + fn awarded_points( + handle: &mut impl PrecompileHandle, + round: u32, + candidate: Address, + ) -> EvmResult { + // AccountsPayable: Twox64Concat(8) + RoundIndex(4) + Twox64Concat(8) + AccountId(20) + // + RewardPoint(4) + handle.record_db_read::(44)?; + + let candidate = Runtime::AddressMapping::into_account_id(candidate.0); + + let points = >::awarded_pts(&round, &candidate); + + Ok(points) + } + + #[precompile::public("candidateCount()")] + #[precompile::public("candidate_count()")] + #[precompile::view] + fn candidate_count(handle: &mut impl PrecompileHandle) -> EvmResult { + // CandidatePool: UnBoundedVec(AccountId(20) + Balance(16)) + // TODO CandidatePool is unbounded, we account for a theoretical 200 pool. + handle.record_db_read::(7200)?; + // Fetch info. + let candidate_count: u32 = >::candidate_pool() + .0 + .len() as u32; + + // Build output. + Ok(candidate_count) + } + + #[precompile::public("round()")] + #[precompile::view] + fn round(handle: &mut impl PrecompileHandle) -> EvmResult { + // Round: RoundInfo(RoundIndex(4) + BlockNumber(4) + 4) + handle.record_db_read::(12)?; + let round: u32 = >::round().current; + + Ok(round) + } + + #[precompile::public("candidateDelegationCount(address)")] + #[precompile::public("candidate_delegation_count(address)")] + #[precompile::view] + fn candidate_delegation_count( + handle: &mut impl PrecompileHandle, + candidate: Address, + ) -> EvmResult { + let candidate = Runtime::AddressMapping::into_account_id(candidate.0); + // CandidateInfo: Twox64Concat(8) + AccountId(20) + CandidateMetadata(105) + handle.record_db_read::(133)?; + let result = if let Some(state) = + >::candidate_info(&candidate) + { + let candidate_delegation_count: u32 = state.delegation_count; + + log::trace!( + target: "staking-precompile", + "Result from pallet is {:?}", + candidate_delegation_count + ); + candidate_delegation_count + } else { + log::trace!( + target: "staking-precompile", + "Candidate {:?} not found, so delegation count is 0", + candidate + ); + 0u32 + }; + + Ok(result) + } + + #[precompile::public("candidateAutoCompoundingDelegationCount(address)")] + #[precompile::view] + fn candidate_auto_compounding_delegation_count( + handle: &mut impl PrecompileHandle, + candidate: Address, + ) -> EvmResult { + // AutoCompoundingDelegations: + // Blake2128(16) + AccountId(20) + // + BoundedVec( + // AutoCompoundConfig * (MaxTopDelegationsPerCandidate + MaxBottomDelegationsPerCandidate) + // ) + handle.record_db_read::( + 36 + ( + 22 * (::MaxTopDelegationsPerCandidate::get() + + ::MaxBottomDelegationsPerCandidate::get()) + as usize), + )?; + + let candidate = Runtime::AddressMapping::into_account_id(candidate.0); + + let count = + >::auto_compounding_delegations(&candidate) + .len() as u32; + + Ok(count) + } + + #[precompile::public("delegatorDelegationCount(address)")] + #[precompile::public("delegator_delegation_count(address)")] + #[precompile::view] + fn delegator_delegation_count( + handle: &mut impl PrecompileHandle, + delegator: Address, + ) -> EvmResult { + let delegator = Runtime::AddressMapping::into_account_id(delegator.0); + // CandidateInfo: + // Twox64Concat(8) + AccountId(20) + Delegator(56 + MaxDelegationsPerDelegator) + handle.record_db_read::( + 84 + (::MaxDelegationsPerDelegator::get() + as usize), + )?; + let result = if let Some(state) = + >::delegator_state(&delegator) + { + let delegator_delegation_count: u32 = state.delegations.0.len() as u32; + + log::trace!( + target: "staking-precompile", + "Result from pallet is {:?}", + delegator_delegation_count + ); + + delegator_delegation_count + } else { + log::trace!( + target: "staking-precompile", + "Delegator {:?} not found, so delegation count is 0", + delegator + ); + 0u32 + }; + + Ok(result) + } + + #[precompile::public("selectedCandidates()")] + #[precompile::public("selected_candidates()")] + #[precompile::view] + fn selected_candidates(handle: &mut impl PrecompileHandle) -> EvmResult> { + // TotalSelected + handle.record_db_read::(4)?; + let total_selected = pallet_parachain_staking::Pallet::::total_selected(); + // SelectedCandidates: total_selected * AccountId(20) + handle.record_db_read::(20 * (total_selected as usize))?; + let selected_candidates: Vec
= + pallet_parachain_staking::Pallet::::selected_candidates() + .into_iter() + .map(|address| Address(address.into())) + .collect(); + + Ok(selected_candidates) + } + + #[precompile::public("delegationAmount(address,address)")] + #[precompile::view] + fn delegation_amount( + handle: &mut impl PrecompileHandle, + delegator: Address, + candidate: Address, + ) -> EvmResult { + // DelegatorState: + // Twox64Concat(8) + AccountId(20) + Delegator(56 + MaxDelegationsPerDelegator) + handle.record_db_read::( + 84 + (::MaxDelegationsPerDelegator::get() + as usize), + )?; + let (candidate, delegator) = ( + Runtime::AddressMapping::into_account_id(candidate.0), + Runtime::AddressMapping::into_account_id(delegator.0), + ); + let amount = pallet_parachain_staking::Pallet::::delegator_state(&delegator) + .and_then(|state| { + state + .delegations + .0 + .into_iter() + .find(|b| b.owner == candidate) + }) + .map_or( + U256::zero(), + |pallet_parachain_staking::Bond { amount, .. }| amount.into(), + ); + + Ok(amount) + } + + // Role Verifiers + #[precompile::public("isInTopDelegations(address,address)")] + #[precompile::view] + fn is_in_top_delegations( + handle: &mut impl PrecompileHandle, + delegator: Address, + candidate: Address, + ) -> EvmResult { + let (candidate, delegator) = ( + Runtime::AddressMapping::into_account_id(candidate.0), + Runtime::AddressMapping::into_account_id(delegator.0), + ); + // TopDelegations: + // Twox64Concat(8) + AccountId(20) + Balance(16) + // + (AccountId(20) + Balance(16) * MaxTopDelegationsPerCandidate) + handle.record_db_read::( + 44 + ((36 + * ::MaxTopDelegationsPerCandidate::get( + )) as usize), + )?; + let is_in_top_delegations = pallet_parachain_staking::Pallet::::top_delegations( + &candidate, + ) + .map_or(false, |delegations| { + delegations + .delegations + .into_iter() + .any(|b| b.owner == delegator) + }); + + Ok(is_in_top_delegations) + } + + #[precompile::public("isDelegator(address)")] + #[precompile::public("is_delegator(address)")] + #[precompile::view] + fn is_delegator(handle: &mut impl PrecompileHandle, delegator: Address) -> EvmResult { + let delegator = Runtime::AddressMapping::into_account_id(delegator.0); + // DelegatorState: + // Twox64Concat(8) + AccountId(20) + Delegator(56 + MaxDelegationsPerDelegator) + handle.record_db_read::( + 84 + (::MaxDelegationsPerDelegator::get() + as usize), + )?; + let is_delegator = pallet_parachain_staking::Pallet::::is_delegator(&delegator); + + Ok(is_delegator) + } + + #[precompile::public("isCandidate(address)")] + #[precompile::public("is_candidate(address)")] + #[precompile::view] + fn is_candidate(handle: &mut impl PrecompileHandle, candidate: Address) -> EvmResult { + let candidate = Runtime::AddressMapping::into_account_id(candidate.0); + + // CandidateInfo: Twox64Concat(8) + AccountId(20) + CandidateMetadata(105) + handle.record_db_read::(133)?; + let is_candidate = pallet_parachain_staking::Pallet::::is_candidate(&candidate); + + Ok(is_candidate) + } + + #[precompile::public("isSelectedCandidate(address)")] + #[precompile::public("is_selected_candidate(address)")] + #[precompile::view] + fn is_selected_candidate( + handle: &mut impl PrecompileHandle, + candidate: Address, + ) -> EvmResult { + let candidate = Runtime::AddressMapping::into_account_id(candidate.0); + + // TotalSelected + handle.record_db_read::(4)?; + let total_selected = pallet_parachain_staking::Pallet::::total_selected(); + // SelectedCandidates: total_selected * AccountId(20) + handle.record_db_read::(20 * (total_selected as usize))?; + let is_selected = + pallet_parachain_staking::Pallet::::is_selected_candidate(&candidate); + + Ok(is_selected) + } + + #[precompile::public("delegationRequestIsPending(address,address)")] + #[precompile::public("delegation_request_is_pending(address,address)")] + #[precompile::view] + fn delegation_request_is_pending( + handle: &mut impl PrecompileHandle, + delegator: Address, + candidate: Address, + ) -> EvmResult { + let delegator = Runtime::AddressMapping::into_account_id(delegator.0); + let candidate = Runtime::AddressMapping::into_account_id(candidate.0); + + // DelegationScheduledRequests: + // Blake2128(16) + AccountId(20) + // + Vec( + // ScheduledRequest(20 + 4 + DelegationAction(18)) + // * (MaxTopDelegationsPerCandidate + MaxBottomDelegationsPerCandidate) + // ) + handle.record_db_read::( + 36 + ( + 42 * (::MaxTopDelegationsPerCandidate::get() + + ::MaxBottomDelegationsPerCandidate::get()) + as usize), + )?; + + // If we are not able to get delegator state, we return false + // Users can call `is_delegator` to determine when this happens + let pending = >::delegation_request_exists( + &candidate, &delegator, + ); + + Ok(pending) + } + + #[precompile::public("candidateExitIsPending(address)")] + #[precompile::public("candidate_exit_is_pending(address)")] + #[precompile::view] + fn candidate_exit_is_pending( + handle: &mut impl PrecompileHandle, + candidate: Address, + ) -> EvmResult { + let candidate = Runtime::AddressMapping::into_account_id(candidate.0); + + // CandidateInfo: Twox64Concat(8) + AccountId(20) + CandidateMetadata(105) + handle.record_db_read::(133)?; + + // If we are not able to get delegator state, we return false + // Users can call `is_candidate` to determine when this happens + let pending = if let Some(state) = + >::candidate_info(&candidate) + { + state.is_leaving() + } else { + log::trace!( + target: "staking-precompile", + "Candidate state for {:?} not found, so pending exit is false", + candidate + ); + false + }; + + Ok(pending) + } + + #[precompile::public("candidateRequestIsPending(address)")] + #[precompile::public("candidate_request_is_pending(address)")] + #[precompile::view] + fn candidate_request_is_pending( + handle: &mut impl PrecompileHandle, + candidate: Address, + ) -> EvmResult { + let candidate = Runtime::AddressMapping::into_account_id(candidate.0); + + // CandidateInfo: Twox64Concat(8) + AccountId(20) + CandidateMetadata(105) + handle.record_db_read::(133)?; + + // If we are not able to get candidate metadata, we return false + // Users can call `is_candidate` to determine when this happens + let pending = if let Some(state) = + >::candidate_info(&candidate) + { + state.request.is_some() + } else { + log::trace!( + target: "staking-precompile", + "Candidate metadata for {:?} not found, so pending request is false", + candidate + ); + false + }; + + Ok(pending) + } + + #[precompile::public("delegationAutoCompound(address,address)")] + #[precompile::view] + fn delegation_auto_compound( + handle: &mut impl PrecompileHandle, + delegator: Address, + candidate: Address, + ) -> EvmResult { + let delegator = Runtime::AddressMapping::into_account_id(delegator.0); + let candidate = Runtime::AddressMapping::into_account_id(candidate.0); + + // AutoCompoundingDelegations: + // Blake2128(16) + AccountId(20) + // + BoundedVec( + // AutoCompoundConfig * (MaxTopDelegationsPerCandidate + MaxBottomDelegationsPerCandidate) + // ) + handle.record_db_read::( + 36 + ( + 22 * (::MaxTopDelegationsPerCandidate::get() + + ::MaxBottomDelegationsPerCandidate::get()) + as usize), + )?; + + let value = >::delegation_auto_compound( + &candidate, &delegator, + ); + + Ok(value.deconstruct()) + } + + // Runtime Methods (dispatchables) + + #[precompile::public("joinCandidates(uint256,uint256)")] + #[precompile::public("join_candidates(uint256,uint256)")] + fn join_candidates( + handle: &mut impl PrecompileHandle, + amount: U256, + candidate_count: Convert, + ) -> EvmResult { + let amount = Self::u256_to_amount(amount).in_field("amount")?; + let candidate_count = candidate_count.converted(); + + // Build call with origin. + let origin = Runtime::AddressMapping::into_account_id(handle.context().caller); + let call = pallet_parachain_staking::Call::::join_candidates { + bond: amount, + candidate_count, + }; + + // Dispatch call (if enough gas). + RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call, 0)?; + + Ok(()) + } + + #[precompile::public("scheduleLeaveCandidates(uint256)")] + #[precompile::public("schedule_leave_candidates(uint256)")] + fn schedule_leave_candidates( + handle: &mut impl PrecompileHandle, + candidate_count: Convert, + ) -> EvmResult { + let candidate_count = candidate_count.converted(); + + // Build call with origin. + let origin = Runtime::AddressMapping::into_account_id(handle.context().caller); + let call = pallet_parachain_staking::Call::::schedule_leave_candidates { + candidate_count, + }; + + // Dispatch call (if enough gas). + RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call, 0)?; + + Ok(()) + } + + #[precompile::public("executeLeaveCandidates(address,uint256)")] + #[precompile::public("execute_leave_candidates(address,uint256)")] + fn execute_leave_candidates( + handle: &mut impl PrecompileHandle, + candidate: Address, + candidate_count: Convert, + ) -> EvmResult { + let candidate_count = candidate_count.converted(); + let candidate = Runtime::AddressMapping::into_account_id(candidate.0); + + // Build call with origin. + let origin = Runtime::AddressMapping::into_account_id(handle.context().caller); + let call = pallet_parachain_staking::Call::::execute_leave_candidates { + candidate, + candidate_delegation_count: candidate_count, + }; + + // Dispatch call (if enough gas). + RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call, 0)?; + + Ok(()) + } + + #[precompile::public("cancelLeaveCandidates(uint256)")] + #[precompile::public("cancel_leave_candidates(uint256)")] + fn cancel_leave_candidates( + handle: &mut impl PrecompileHandle, + candidate_count: Convert, + ) -> EvmResult { + let candidate_count = candidate_count.converted(); + + // Build call with origin. + let origin = Runtime::AddressMapping::into_account_id(handle.context().caller); + let call = + pallet_parachain_staking::Call::::cancel_leave_candidates { candidate_count }; + + // Dispatch call (if enough gas). + RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call, 0)?; + + Ok(()) + } + + #[precompile::public("goOffline()")] + #[precompile::public("go_offline()")] + fn go_offline(handle: &mut impl PrecompileHandle) -> EvmResult { + // Build call with origin. + let origin = Runtime::AddressMapping::into_account_id(handle.context().caller); + let call = pallet_parachain_staking::Call::::go_offline {}; + + // Dispatch call (if enough gas). + RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call, 0)?; + + Ok(()) + } + + #[precompile::public("goOnline()")] + #[precompile::public("go_online()")] + fn go_online(handle: &mut impl PrecompileHandle) -> EvmResult { + // Build call with origin. + let origin = Runtime::AddressMapping::into_account_id(handle.context().caller); + let call = pallet_parachain_staking::Call::::go_online {}; + + // Dispatch call (if enough gas). + RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call, 0)?; + + Ok(()) + } + + #[precompile::public("candidateBondMore(uint256)")] + #[precompile::public("candidate_bond_more(uint256)")] + fn candidate_bond_more(handle: &mut impl PrecompileHandle, more: U256) -> EvmResult { + let more = Self::u256_to_amount(more).in_field("more")?; + + // Build call with origin. + let origin = Runtime::AddressMapping::into_account_id(handle.context().caller); + let call = pallet_parachain_staking::Call::::candidate_bond_more { more }; + + // Dispatch call (if enough gas). + RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call, 0)?; + + Ok(()) + } + + #[precompile::public("scheduleCandidateBondLess(uint256)")] + #[precompile::public("schedule_candidate_bond_less(uint256)")] + fn schedule_candidate_bond_less(handle: &mut impl PrecompileHandle, less: U256) -> EvmResult { + let less = Self::u256_to_amount(less).in_field("less")?; + + // Build call with origin. + let origin = Runtime::AddressMapping::into_account_id(handle.context().caller); + let call = pallet_parachain_staking::Call::::schedule_candidate_bond_less { less }; + + // Dispatch call (if enough gas). + RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call, 0)?; + + Ok(()) + } + + #[precompile::public("executeCandidateBondLess(address)")] + #[precompile::public("execute_candidate_bond_less(address)")] + fn execute_candidate_bond_less( + handle: &mut impl PrecompileHandle, + candidate: Address, + ) -> EvmResult { + let candidate = Runtime::AddressMapping::into_account_id(candidate.0); + + // Build call with origin. + let origin = Runtime::AddressMapping::into_account_id(handle.context().caller); + let call = + pallet_parachain_staking::Call::::execute_candidate_bond_less { candidate }; + + // Dispatch call (if enough gas). + RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call, 0)?; + + Ok(()) + } + + #[precompile::public("cancelCandidateBondLess()")] + #[precompile::public("cancel_candidate_bond_less()")] + fn cancel_candidate_bond_less(handle: &mut impl PrecompileHandle) -> EvmResult { + // Build call with origin. + let origin = Runtime::AddressMapping::into_account_id(handle.context().caller); + let call = pallet_parachain_staking::Call::::cancel_candidate_bond_less {}; + + // Dispatch call (if enough gas). + RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call, 0)?; + + Ok(()) + } + + #[precompile::public("delegate(address,uint256,uint256,uint256)")] + fn delegate( + handle: &mut impl PrecompileHandle, + candidate: Address, + amount: U256, + candidate_delegation_count: Convert, + delegator_delegation_count: Convert, + ) -> EvmResult { + let amount = Self::u256_to_amount(amount).in_field("amount")?; + let candidate_delegation_count = candidate_delegation_count.converted(); + let delegator_delegation_count = delegator_delegation_count.converted(); + + let candidate = Runtime::AddressMapping::into_account_id(candidate.0); + + // Build call with origin. + let origin = Runtime::AddressMapping::into_account_id(handle.context().caller); + let call = pallet_parachain_staking::Call::::delegate { + candidate, + amount, + candidate_delegation_count, + delegation_count: delegator_delegation_count, + }; + + // Dispatch call (if enough gas). + RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call, 0)?; + + Ok(()) + } + + #[precompile::public("delegateWithAutoCompound(address,uint256,uint8,uint256,uint256,uint256)")] + fn delegate_with_auto_compound( + handle: &mut impl PrecompileHandle, + candidate: Address, + amount: U256, + auto_compound: u8, + candidate_delegation_count: Convert, + candidate_auto_compounding_delegation_count: Convert, + delegator_delegation_count: Convert, + ) -> EvmResult { + if auto_compound > 100 { + return Err( + RevertReason::custom("Must be an integer between 0 and 100 included") + .in_field("auto_compound") + .into(), + ); + } + + let amount = Self::u256_to_amount(amount).in_field("amount")?; + let auto_compound = Percent::from_percent(auto_compound); + let candidate_delegation_count = candidate_delegation_count.converted(); + let candidate_auto_compounding_delegation_count = + candidate_auto_compounding_delegation_count.converted(); + let delegator_delegation_count = delegator_delegation_count.converted(); + + let candidate = Runtime::AddressMapping::into_account_id(candidate.0); + + // Build call with origin. + let origin = Runtime::AddressMapping::into_account_id(handle.context().caller); + let call = pallet_parachain_staking::Call::::delegate_with_auto_compound { + candidate, + amount, + auto_compound, + candidate_delegation_count, + candidate_auto_compounding_delegation_count, + delegation_count: delegator_delegation_count, + }; + + // Dispatch call (if enough gas). + RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call, 0)?; + + Ok(()) + } + + #[precompile::public("scheduleRevokeDelegation(address)")] + #[precompile::public("schedule_revoke_delegation(address)")] + fn schedule_revoke_delegation( + handle: &mut impl PrecompileHandle, + candidate: Address, + ) -> EvmResult { + let candidate = Runtime::AddressMapping::into_account_id(candidate.0); + + // Build call with origin. + let origin = Runtime::AddressMapping::into_account_id(handle.context().caller); + let call = pallet_parachain_staking::Call::::schedule_revoke_delegation { + collator: candidate, + }; + + // Dispatch call (if enough gas). + RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call, 0)?; + + Ok(()) + } + + #[precompile::public("delegatorBondMore(address,uint256)")] + #[precompile::public("delegator_bond_more(address,uint256)")] + fn delegator_bond_more( + handle: &mut impl PrecompileHandle, + candidate: Address, + more: U256, + ) -> EvmResult { + let candidate = Runtime::AddressMapping::into_account_id(candidate.0); + let more = Self::u256_to_amount(more).in_field("more")?; + + // Build call with origin. + let origin = Runtime::AddressMapping::into_account_id(handle.context().caller); + let call = + pallet_parachain_staking::Call::::delegator_bond_more { candidate, more }; + + // Dispatch call (if enough gas). + RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call, 0)?; + + Ok(()) + } + + #[precompile::public("scheduleDelegatorBondLess(address,uint256)")] + #[precompile::public("schedule_delegator_bond_less(address,uint256)")] + fn schedule_delegator_bond_less( + handle: &mut impl PrecompileHandle, + candidate: Address, + less: U256, + ) -> EvmResult { + let candidate = Runtime::AddressMapping::into_account_id(candidate.0); + let less = Self::u256_to_amount(less).in_field("less")?; + + // Build call with origin. + let origin = Runtime::AddressMapping::into_account_id(handle.context().caller); + let call = pallet_parachain_staking::Call::::schedule_delegator_bond_less { + candidate, + less, + }; + + // Dispatch call (if enough gas). + RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call, 0)?; + + Ok(()) + } + + #[precompile::public("executeDelegationRequest(address,address)")] + #[precompile::public("execute_delegation_request(address,address)")] + fn execute_delegation_request( + handle: &mut impl PrecompileHandle, + delegator: Address, + candidate: Address, + ) -> EvmResult { + let delegator = Runtime::AddressMapping::into_account_id(delegator.0); + let candidate = Runtime::AddressMapping::into_account_id(candidate.0); + + // Build call with origin. + let origin = Runtime::AddressMapping::into_account_id(handle.context().caller); + let call = pallet_parachain_staking::Call::::execute_delegation_request { + delegator, + candidate, + }; + + // Dispatch call (if enough gas). + RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call, 0)?; + + Ok(()) + } + + #[precompile::public("cancelDelegationRequest(address)")] + #[precompile::public("cancel_delegation_request(address)")] + fn cancel_delegation_request( + handle: &mut impl PrecompileHandle, + candidate: Address, + ) -> EvmResult { + let candidate = Runtime::AddressMapping::into_account_id(candidate.0); + + // Build call with origin. + let origin = Runtime::AddressMapping::into_account_id(handle.context().caller); + let call = + pallet_parachain_staking::Call::::cancel_delegation_request { candidate }; + + // Dispatch call (if enough gas). + RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call, 0)?; + + Ok(()) + } + + #[precompile::public("setAutoCompound(address,uint8,uint256,uint256)")] + fn set_auto_compound( + handle: &mut impl PrecompileHandle, + candidate: Address, + value: u8, + candidate_auto_compounding_delegation_count: Convert, + delegator_delegation_count: Convert, + ) -> EvmResult { + if value > 100 { + return Err( + RevertReason::custom("Must be an integer between 0 and 100 included") + .in_field("value") + .into(), + ); + } + + let value = Percent::from_percent(value); + let candidate_auto_compounding_delegation_count_hint = + candidate_auto_compounding_delegation_count.converted(); + let delegation_count_hint = delegator_delegation_count.converted(); + + let candidate = Runtime::AddressMapping::into_account_id(candidate.0); + + // Build call with origin. + let origin = Runtime::AddressMapping::into_account_id(handle.context().caller); + let call = pallet_parachain_staking::Call::::set_auto_compound { + candidate, + value, + candidate_auto_compounding_delegation_count_hint, + delegation_count_hint, + }; + + // Dispatch call (if enough gas). + RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call, 0)?; + + Ok(()) + } + + #[precompile::public("getDelegatorTotalStaked(address)")] + #[precompile::view] + fn get_delegator_total_staked( + handle: &mut impl PrecompileHandle, + delegator: Address, + ) -> EvmResult { + // DelegatorState: + // Twox64Concat(8) + AccountId(20) + Delegator(56 + MaxDelegationsPerDelegator) + handle.record_db_read::( + 84 + (::MaxDelegationsPerDelegator::get() + as usize), + )?; + + let delegator = Runtime::AddressMapping::into_account_id(delegator.0); + + let amount = >::delegator_state(&delegator) + .map(|state| state.total) + .unwrap_or_default(); + + Ok(amount.into()) + } + + #[precompile::public("getCandidateTotalCounted(address)")] + #[precompile::view] + fn get_candidate_total_counted( + handle: &mut impl PrecompileHandle, + candidate: Address, + ) -> EvmResult { + // CandidateInfo: Twox64Concat(8) + AccountId(20) + CandidateMetadata(105) + handle.record_db_read::(133)?; + + let candidate = Runtime::AddressMapping::into_account_id(candidate.0); + + let amount = >::candidate_info(&candidate) + .map(|state| state.total_counted) + .unwrap_or_default(); + + Ok(amount.into()) + } + + fn u256_to_amount(value: U256) -> MayRevert> { + value + .try_into() + .map_err(|_| RevertReason::value_is_too_large("balance type").into()) + } +} diff --git a/precompiles/parachain-staking/src/mock.rs b/precompiles/parachain-staking/src/mock.rs new file mode 100644 index 000000000..af20411be --- /dev/null +++ b/precompiles/parachain-staking/src/mock.rs @@ -0,0 +1,365 @@ +// Copyright 2019-2022 PureStake Inc. +// This file is part of Moonbeam. + +// Moonbeam 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. + +// Moonbeam 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 Moonbeam. If not, see . + +//! Test utilities +use super::*; +use frame_support::{ + construct_runtime, parameter_types, + traits::{Everything, Get, OnFinalize, OnInitialize}, + weights::Weight, +}; +use frame_system::pallet_prelude::BlockNumberFor; +use pallet_evm::{EnsureAddressNever, EnsureAddressRoot}; +use pallet_parachain_staking::{AwardedPts, InflationInfo, Points, Range}; +use precompile_utils::{ + precompile_set::*, + testing::{Alice, MockAccount}, +}; +use sp_consensus_slots::Slot; +use sp_core::{H256, U256}; +use sp_io; +use sp_runtime::{ + traits::{BlakeTwo256, IdentityLookup}, + BuildStorage, Perbill, Percent, +}; + +pub type AccountId = MockAccount; +pub type Balance = u128; +pub type BlockNumber = BlockNumberFor; + +type Block = frame_system::mocking::MockBlockU32; + +construct_runtime!( + pub enum Runtime { + System: frame_system, + Balances: pallet_balances, + Evm: pallet_evm, + Timestamp: pallet_timestamp, + ParachainStaking: pallet_parachain_staking, + } +); + +parameter_types! { + pub const BlockHashCount: u32 = 250; + pub const MaximumBlockWeight: Weight = Weight::from_parts(1024, 1); + pub const MaximumBlockLength: u32 = 2 * 1024; + pub const AvailableBlockRatio: Perbill = Perbill::one(); + pub const SS58Prefix: u8 = 42; +} + +impl frame_system::Config for Runtime { + type BaseCallFilter = Everything; + type DbWeight = (); + type RuntimeOrigin = RuntimeOrigin; + type RuntimeTask = RuntimeTask; + type Nonce = u64; + type Block = Block; + type RuntimeCall = RuntimeCall; + type Hash = H256; + type Hashing = BlakeTwo256; + type AccountId = AccountId; + type Lookup = IdentityLookup; + type RuntimeEvent = RuntimeEvent; + type BlockHashCount = BlockHashCount; + type Version = (); + type PalletInfo = PalletInfo; + type AccountData = pallet_balances::AccountData; + type OnNewAccount = (); + type OnKilledAccount = (); + type SystemWeightInfo = (); + type BlockWeights = (); + type BlockLength = (); + type SS58Prefix = SS58Prefix; + type OnSetCode = (); + type MaxConsumers = frame_support::traits::ConstU32<16>; +} + +parameter_types! { + pub const ExistentialDeposit: u128 = 0; +} +impl pallet_balances::Config for Runtime { + type MaxReserves = (); + type ReserveIdentifier = [u8; 4]; + type MaxLocks = (); + type Balance = Balance; + type RuntimeEvent = RuntimeEvent; + type DustRemoval = (); + type ExistentialDeposit = ExistentialDeposit; + type AccountStore = System; + type WeightInfo = (); + type RuntimeHoldReason = (); + type FreezeIdentifier = (); + type MaxFreezes = (); + type RuntimeFreezeReason = (); +} + +const MAX_POV_SIZE: u64 = 5 * 1024 * 1024; +/// Block storage limit in bytes. Set to 40 KB. +const BLOCK_STORAGE_LIMIT: u64 = 40 * 1024; + +parameter_types! { + pub BlockGasLimit: U256 = U256::from(u64::MAX); + pub PrecompilesValue: Precompiles = Precompiles::new(); + pub const WeightPerGas: Weight = Weight::from_parts(1, 0); + pub GasLimitPovSizeRatio: u64 = { + let block_gas_limit = BlockGasLimit::get().min(u64::MAX.into()).low_u64(); + block_gas_limit.saturating_div(MAX_POV_SIZE) + }; + pub GasLimitStorageGrowthRatio: u64 = { + let block_gas_limit = BlockGasLimit::get().min(u64::MAX.into()).low_u64(); + block_gas_limit.saturating_div(BLOCK_STORAGE_LIMIT) + }; + pub SuicideQuickClearLimit: u32 = 0; +} + +pub type Precompiles = + PrecompileSetBuilder, ParachainStakingPrecompile>,)>; + +pub type PCall = ParachainStakingPrecompileCall; + +impl pallet_evm::Config for Runtime { + type FeeCalculator = (); + type GasWeightMapping = pallet_evm::FixedGasWeightMapping; + type WeightPerGas = WeightPerGas; + type CallOrigin = EnsureAddressRoot; + type WithdrawOrigin = EnsureAddressNever; + type AddressMapping = AccountId; + type Currency = Balances; + type RuntimeEvent = RuntimeEvent; + type Runner = pallet_evm::runner::stack::Runner; + type PrecompilesType = Precompiles; + type PrecompilesValue = PrecompilesValue; + type ChainId = (); + type OnChargeTransaction = (); + type BlockGasLimit = BlockGasLimit; + type BlockHashMapping = pallet_evm::SubstrateBlockHashMapping; + type FindAuthor = (); + type OnCreate = (); + type GasLimitPovSizeRatio = GasLimitPovSizeRatio; + type SuicideQuickClearLimit = SuicideQuickClearLimit; + type GasLimitStorageGrowthRatio = GasLimitStorageGrowthRatio; + type Timestamp = Timestamp; + type WeightInfo = pallet_evm::weights::SubstrateWeight; +} + +parameter_types! { + pub const MinimumPeriod: u64 = 5; +} +impl pallet_timestamp::Config for Runtime { + type Moment = u64; + type OnTimestampSet = (); + type MinimumPeriod = MinimumPeriod; + type WeightInfo = (); +} +const GENESIS_BLOCKS_PER_ROUND: u32 = 5; +const GENESIS_COLLATOR_COMMISSION: Perbill = Perbill::from_percent(20); +const GENESIS_PARACHAIN_BOND_RESERVE_PERCENT: Percent = Percent::from_percent(30); +const GENESIS_NUM_SELECTED_CANDIDATES: u32 = 5; +parameter_types! { + pub const MinBlocksPerRound: u32 = 3; + pub const MaxOfflineRounds: u32 = 2; + pub const LeaveCandidatesDelay: u32 = 2; + pub const CandidateBondLessDelay: u32 = 2; + pub const LeaveDelegatorsDelay: u32 = 2; + pub const RevokeDelegationDelay: u32 = 2; + pub const DelegationBondLessDelay: u32 = 2; + pub const RewardPaymentDelay: u32 = 2; + pub const MinSelectedCandidates: u32 = GENESIS_NUM_SELECTED_CANDIDATES; + pub const MaxTopDelegationsPerCandidate: u32 = 2; + pub const MaxBottomDelegationsPerCandidate: u32 = 4; + pub const MaxDelegationsPerDelegator: u32 = 4; + pub const MinCandidateStk: u128 = 10; + pub const MinDelegation: u128 = 3; + pub const MaxCandidates: u32 = 10; + pub BlockAuthor: AccountId = Alice.into(); +} + +pub struct StakingRoundSlotProvider; +impl Get for StakingRoundSlotProvider { + fn get() -> Slot { + let block_number: u64 = System::block_number().into(); + Slot::from(block_number) + } +} + +impl pallet_parachain_staking::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type Currency = Balances; + type MonetaryGovernanceOrigin = frame_system::EnsureRoot; + type MinBlocksPerRound = MinBlocksPerRound; + type MaxOfflineRounds = MaxOfflineRounds; + type LeaveCandidatesDelay = LeaveCandidatesDelay; + type CandidateBondLessDelay = CandidateBondLessDelay; + type LeaveDelegatorsDelay = LeaveDelegatorsDelay; + type RevokeDelegationDelay = RevokeDelegationDelay; + type DelegationBondLessDelay = DelegationBondLessDelay; + type RewardPaymentDelay = RewardPaymentDelay; + type MinSelectedCandidates = MinSelectedCandidates; + type MaxTopDelegationsPerCandidate = MaxTopDelegationsPerCandidate; + type MaxBottomDelegationsPerCandidate = MaxBottomDelegationsPerCandidate; + type MaxDelegationsPerDelegator = MaxDelegationsPerDelegator; + type MinCandidateStk = MinCandidateStk; + type MinDelegation = MinDelegation; + type BlockAuthor = BlockAuthor; + type PayoutCollatorReward = (); + type OnCollatorPayout = (); + type OnInactiveCollator = (); + type OnNewRound = (); + type SlotProvider = StakingRoundSlotProvider; + type WeightInfo = (); + type MaxCandidates = MaxCandidates; + type SlotDuration = frame_support::traits::ConstU64<6_000>; + type BlockTime = frame_support::traits::ConstU64<6_000>; +} + +pub(crate) struct ExtBuilder { + // endowed accounts with balances + balances: Vec<(AccountId, Balance)>, + // [collator, amount] + collators: Vec<(AccountId, Balance)>, + // [delegator, collator, delegation_amount] + delegations: Vec<(AccountId, AccountId, Balance, Percent)>, + // inflation config + inflation: InflationInfo, +} + +impl Default for ExtBuilder { + fn default() -> ExtBuilder { + ExtBuilder { + balances: vec![], + delegations: vec![], + collators: vec![], + inflation: InflationInfo { + expect: Range { + min: 700, + ideal: 700, + max: 700, + }, + // not used + annual: Range { + min: Perbill::from_percent(50), + ideal: Perbill::from_percent(50), + max: Perbill::from_percent(50), + }, + // unrealistically high parameterization, only for testing + round: Range { + min: Perbill::from_percent(5), + ideal: Perbill::from_percent(5), + max: Perbill::from_percent(5), + }, + }, + } + } +} + +impl ExtBuilder { + pub(crate) fn with_balances(mut self, balances: Vec<(AccountId, Balance)>) -> Self { + self.balances = balances; + self + } + + pub(crate) fn with_candidates(mut self, collators: Vec<(AccountId, Balance)>) -> Self { + self.collators = collators; + self + } + + pub(crate) fn with_delegations( + mut self, + delegations: Vec<(AccountId, AccountId, Balance)>, + ) -> Self { + self.delegations = delegations + .into_iter() + .map(|d| (d.0, d.1, d.2, Percent::zero())) + .collect(); + self + } + + pub(crate) fn with_auto_compounding_delegations( + mut self, + delegations: Vec<(AccountId, AccountId, Balance, Percent)>, + ) -> Self { + self.delegations = delegations + .into_iter() + .map(|d| (d.0, d.1, d.2, d.3)) + .collect(); + self + } + + #[allow(dead_code)] + pub(crate) fn with_inflation(mut self, inflation: InflationInfo) -> Self { + self.inflation = inflation; + self + } + + pub(crate) fn build(self) -> sp_io::TestExternalities { + let mut t = frame_system::GenesisConfig::::default() + .build_storage() + .expect("Frame system builds valid default genesis config"); + + pallet_balances::GenesisConfig:: { + balances: self.balances, + } + .assimilate_storage(&mut t) + .expect("Pallet balances storage can be assimilated"); + pallet_parachain_staking::GenesisConfig:: { + candidates: self.collators, + delegations: self.delegations, + inflation_config: self.inflation, + collator_commission: GENESIS_COLLATOR_COMMISSION, + parachain_bond_reserve_percent: GENESIS_PARACHAIN_BOND_RESERVE_PERCENT, + blocks_per_round: GENESIS_BLOCKS_PER_ROUND, + num_selected_candidates: GENESIS_NUM_SELECTED_CANDIDATES, + } + .assimilate_storage(&mut t) + .expect("Parachain Staking's storage can be assimilated"); + + let mut ext = sp_io::TestExternalities::new(t); + ext.execute_with(|| System::set_block_number(1)); + ext + } +} + +// Sets the same storage changes as EventHandler::note_author impl +pub(crate) fn set_points(round: BlockNumber, acc: impl Into, pts: u32) { + >::mutate(round, |p| *p += pts); + >::mutate(round, acc.into(), |p| *p += pts); +} + +pub(crate) fn roll_to(n: BlockNumber) { + while System::block_number() < n { + ParachainStaking::on_finalize(System::block_number()); + Balances::on_finalize(System::block_number()); + System::on_finalize(System::block_number()); + System::set_block_number(System::block_number() + 1); + System::on_initialize(System::block_number()); + Balances::on_initialize(System::block_number()); + ParachainStaking::on_initialize(System::block_number()); + } +} + +/// Rolls block-by-block to the beginning of the specified round. +/// This will complete the block in which the round change occurs. +pub(crate) fn roll_to_round_begin(round: BlockNumber) { + let block = (round - 1) * GENESIS_BLOCKS_PER_ROUND; + roll_to(block) +} + +pub(crate) fn events() -> Vec { + System::events() + .into_iter() + .map(|r| r.event) + .collect::>() +} diff --git a/precompiles/parachain-staking/src/tests.rs b/precompiles/parachain-staking/src/tests.rs new file mode 100644 index 000000000..4477dadb8 --- /dev/null +++ b/precompiles/parachain-staking/src/tests.rs @@ -0,0 +1,1744 @@ +// Copyright 2019-2022 PureStake Inc. +// This file is part of Moonbeam. + +// Moonbeam 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. + +// Moonbeam 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 Moonbeam. If not, see . + +use crate::mock::{ + events, roll_to, roll_to_round_begin, set_points, ExtBuilder, PCall, ParachainStaking, + Precompiles, PrecompilesValue, Runtime, RuntimeCall, RuntimeOrigin, +}; +use core::str::from_utf8; +use frame_support::assert_ok; +use frame_support::sp_runtime::Percent; +use pallet_evm::Call as EvmCall; +use pallet_parachain_staking::Event as StakingEvent; +use precompile_utils::{prelude::*, testing::*}; +use sp_core::{H160, U256}; +use sp_runtime::traits::Dispatchable; + +fn precompiles() -> Precompiles { + PrecompilesValue::get() +} + +fn evm_call(source: impl Into, input: Vec) -> EvmCall { + EvmCall::call { + source: source.into(), + target: Precompile1.into(), + input, + value: U256::zero(), // No value sent in EVM + gas_limit: u64::max_value(), + max_fee_per_gas: 0.into(), + max_priority_fee_per_gas: Some(U256::zero()), + nonce: None, // Use the next nonce + access_list: Vec::new(), + } +} + +#[test] +fn selectors() { + assert!(PCall::is_delegator_selectors().contains(&0xfd8ab482)); + assert!(PCall::is_candidate_selectors().contains(&0xd51b9e93)); + assert!(PCall::is_selected_candidate_selectors().contains(&0x740d7d2a)); + assert!(PCall::delegation_amount_selectors().contains(&0xa73e51bc)); + assert!(PCall::is_in_top_delegations_selectors().contains(&0x91cc8657)); + assert!(PCall::points_selectors().contains(&0x9799b4e7)); + assert!(PCall::min_delegation_selectors().contains(&0x02985992)); + assert!(PCall::candidate_count_selectors().contains(&0xa9a981a3)); + assert!(PCall::round_selectors().contains(&0x146ca531)); + assert!(PCall::candidate_delegation_count_selectors().contains(&0x2ec087eb)); + assert!(PCall::candidate_auto_compounding_delegation_count_selectors().contains(&0x905f0806)); + assert!(PCall::delegator_delegation_count_selectors().contains(&0x067ec822)); + assert!(PCall::selected_candidates_selectors().contains(&0xbcf868a6)); + assert!(PCall::delegation_request_is_pending_selectors().contains(&0x3b16def8)); + assert!(PCall::candidate_exit_is_pending_selectors().contains(&0x43443682)); + assert!(PCall::candidate_request_is_pending_selectors().contains(&0xd0deec11)); + assert!(PCall::join_candidates_selectors().contains(&0x1f2f83ad)); + assert!(PCall::schedule_leave_candidates_selectors().contains(&0xb1a3c1b7)); + assert!(PCall::execute_leave_candidates_selectors().contains(&0x3867f308)); + assert!(PCall::cancel_leave_candidates_selectors().contains(&0x9c76ebb4)); + assert!(PCall::go_offline_selectors().contains(&0xa6485ccd)); + assert!(PCall::go_online_selectors().contains(&0x6e5b676b)); + assert!(PCall::candidate_bond_more_selectors().contains(&0xa52c8643)); + assert!(PCall::schedule_candidate_bond_less_selectors().contains(&0x60744ae0)); + assert!(PCall::execute_candidate_bond_less_selectors().contains(&0x2e290290)); + assert!(PCall::cancel_candidate_bond_less_selectors().contains(&0xb5ad5f07)); + assert!(PCall::delegate_selectors().contains(&0x829f5ee3)); + assert!(PCall::schedule_revoke_delegation_selectors().contains(&0x1a1c740c)); + assert!(PCall::delegator_bond_more_selectors().contains(&0x0465135b)); + assert!(PCall::schedule_delegator_bond_less_selectors().contains(&0xc172fd2b)); + assert!(PCall::execute_delegation_request_selectors().contains(&0xe98c8abe)); + assert!(PCall::cancel_delegation_request_selectors().contains(&0xc90eee83)); + assert!(PCall::get_delegator_total_staked_selectors().contains(&0xe6861713)); + assert!(PCall::get_candidate_total_counted_selectors().contains(&0xbc5a1043)); +} + +#[test] +fn modifiers() { + ExtBuilder::default().build().execute_with(|| { + let mut tester = PrecompilesModifierTester::new(precompiles(), Alice, Precompile1); + + tester.test_view_modifier(PCall::is_delegator_selectors()); + tester.test_view_modifier(PCall::is_candidate_selectors()); + tester.test_view_modifier(PCall::is_selected_candidate_selectors()); + tester.test_view_modifier(PCall::points_selectors()); + tester.test_view_modifier(PCall::delegation_amount_selectors()); + tester.test_view_modifier(PCall::is_in_top_delegations_selectors()); + tester.test_view_modifier(PCall::min_delegation_selectors()); + tester.test_view_modifier(PCall::candidate_count_selectors()); + tester.test_view_modifier(PCall::round_selectors()); + tester.test_view_modifier(PCall::candidate_delegation_count_selectors()); + tester.test_view_modifier(PCall::delegator_delegation_count_selectors()); + tester.test_view_modifier(PCall::selected_candidates_selectors()); + tester.test_view_modifier(PCall::delegation_request_is_pending_selectors()); + tester.test_view_modifier(PCall::candidate_exit_is_pending_selectors()); + tester.test_view_modifier(PCall::candidate_request_is_pending_selectors()); + tester.test_default_modifier(PCall::join_candidates_selectors()); + tester.test_default_modifier(PCall::schedule_leave_candidates_selectors()); + tester.test_default_modifier(PCall::execute_leave_candidates_selectors()); + tester.test_default_modifier(PCall::cancel_leave_candidates_selectors()); + tester.test_default_modifier(PCall::go_offline_selectors()); + tester.test_default_modifier(PCall::go_online_selectors()); + tester.test_default_modifier(PCall::candidate_bond_more_selectors()); + tester.test_default_modifier(PCall::schedule_candidate_bond_less_selectors()); + tester.test_default_modifier(PCall::execute_candidate_bond_less_selectors()); + tester.test_default_modifier(PCall::cancel_candidate_bond_less_selectors()); + tester.test_default_modifier(PCall::delegate_selectors()); + tester.test_default_modifier(PCall::schedule_revoke_delegation_selectors()); + tester.test_default_modifier(PCall::delegator_bond_more_selectors()); + tester.test_default_modifier(PCall::schedule_delegator_bond_less_selectors()); + tester.test_default_modifier(PCall::execute_delegation_request_selectors()); + tester.test_default_modifier(PCall::cancel_delegation_request_selectors()); + tester.test_view_modifier(PCall::get_delegator_total_staked_selectors()); + tester.test_view_modifier(PCall::get_candidate_total_counted_selectors()); + }); +} + +#[test] +fn selector_less_than_four_bytes() { + ExtBuilder::default().build().execute_with(|| { + precompiles() + .prepare_test(Alice, Precompile1, vec![1u8, 2u8, 3u8]) + .execute_reverts(|output| output == b"Tried to read selector out of bounds"); + }); +} + +#[test] +fn no_selector_exists_but_length_is_right() { + ExtBuilder::default().build().execute_with(|| { + precompiles() + .prepare_test(Alice, Precompile1, vec![1u8, 2u8, 3u8, 4u8]) + .execute_reverts(|output| output == b"Unknown selector"); + }); +} + +#[test] +fn min_delegation_works() { + ExtBuilder::default().build().execute_with(|| { + precompiles() + .prepare_test(Alice, Precompile1, PCall::min_delegation {}) + .expect_cost(0) // TODO: Test db read/write costs + .expect_no_logs() + .execute_returns(3u32) + }); +} + +#[test] +fn points_zero() { + ExtBuilder::default() + .with_balances(vec![(Alice.into(), 1_000)]) + .with_candidates(vec![(Alice.into(), 1_000)]) + .build() + .execute_with(|| { + precompiles() + // Assert that there are total 0 points in round 1 + .prepare_test(Alice, Precompile1, PCall::points { round: 1.into() }) + .expect_cost(0) // TODO: Test db read/write costs + .expect_no_logs() + .execute_returns(0u32); + }); +} + +#[test] +fn points_non_zero() { + ExtBuilder::default() + .with_balances(vec![(Alice.into(), 1_000)]) + .with_candidates(vec![(Alice.into(), 1_000)]) + .build() + .execute_with(|| { + set_points(1u32, Alice, 100); + + // Assert that there are total 100 points in round 1 + precompiles() + .prepare_test(Alice, Precompile1, PCall::points { round: 1.into() }) + .expect_cost(0) // TODO: Test db read/write costs + .expect_no_logs() + .execute_returns(100u32); + }); +} + +#[test] +fn awarded_points_zero() { + ExtBuilder::default() + .with_balances(vec![(Alice.into(), 1_000)]) + .with_candidates(vec![(Alice.into(), 1_000)]) + .build() + .execute_with(|| { + set_points(1u32, Alice, 100); + + precompiles() + .prepare_test( + Alice, + Precompile1, + PCall::awarded_points { + round: 1u32.into(), + candidate: Address(Bob.into()), + }, + ) + .expect_cost(0) + .expect_no_logs() + .execute_returns(0u32); + }); +} + +#[test] +fn awarded_points_non_zero() { + ExtBuilder::default() + .with_balances(vec![(Alice.into(), 1_000)]) + .with_candidates(vec![(Alice.into(), 1_000)]) + .build() + .execute_with(|| { + set_points(1u32, Alice, 100); + set_points(1u32, Bob, 10); + + precompiles() + .prepare_test( + Alice, + Precompile1, + PCall::awarded_points { + round: 1u32.into(), + candidate: Address(Alice.into()), + }, + ) + .expect_cost(0) + .expect_no_logs() + .execute_returns(100u32); + }); +} + +#[test] +fn delegation_amount_zero() { + ExtBuilder::default() + .with_balances(vec![(Alice.into(), 1_000)]) + .build() + .execute_with(|| { + precompiles() + .prepare_test( + Alice, + Precompile1, + PCall::delegation_amount { + delegator: Address(Alice.into()), + candidate: Address(Alice.into()), + }, + ) + .expect_cost(0) // TODO: Test db read/write costs + .expect_no_logs() + .execute_returns(0u32); + }); +} + +#[test] +fn delegation_amount_nonzero() { + ExtBuilder::default() + .with_balances(vec![(Alice.into(), 1_000), (Bob.into(), 1_000)]) + .with_candidates(vec![(Alice.into(), 1_000)]) + .with_delegations(vec![(Bob.into(), Alice.into(), 1_000)]) + .build() + .execute_with(|| { + precompiles() + .prepare_test( + Alice, + Precompile1, + PCall::delegation_amount { + delegator: Address(Bob.into()), + candidate: Address(Alice.into()), + }, + ) + .expect_cost(0) // TODO: Test db read/write costs + .expect_no_logs() + .execute_returns(1000u32); + }); +} + +#[test] +fn is_not_in_top_delegations_when_delegation_dne() { + ExtBuilder::default() + .with_balances(vec![(Alice.into(), 1_000)]) + .build() + .execute_with(|| { + precompiles() + .prepare_test( + Alice, + Precompile1, + PCall::delegation_amount { + delegator: Address(Alice.into()), + candidate: Address(Alice.into()), + }, + ) + .expect_cost(0) // TODO: Test db read/write costs + .expect_no_logs() + .execute_returns(false); + }); +} + +#[test] +fn is_not_in_top_delegations_because_not_in_top() { + ExtBuilder::default() + .with_balances(vec![ + (Alice.into(), 1_000), + (Bob.into(), 500), + (Charlie.into(), 501), + (David.into(), 502), + ]) + .with_candidates(vec![(Alice.into(), 1_000)]) + .with_delegations(vec![ + (Bob.into(), Alice.into(), 500), + (Charlie.into(), Alice.into(), 501), + (David.into(), Alice.into(), 502), + ]) + .build() + .execute_with(|| { + precompiles() + .prepare_test( + Alice, + Precompile1, + PCall::is_in_top_delegations { + delegator: Address(Bob.into()), + candidate: Address(Alice.into()), + }, + ) + .expect_cost(0) // TODO: Test db read/write costs + .expect_no_logs() + .execute_returns(false); + }); +} + +#[test] +fn is_in_top_delegations() { + ExtBuilder::default() + .with_balances(vec![(Alice.into(), 1_000), (Bob.into(), 500)]) + .with_candidates(vec![(Alice.into(), 1_000)]) + .with_delegations(vec![(Bob.into(), Alice.into(), 500)]) + .build() + .execute_with(|| { + precompiles() + .prepare_test( + Alice, + Precompile1, + PCall::is_in_top_delegations { + delegator: Address(Bob.into()), + candidate: Address(Alice.into()), + }, + ) + .expect_cost(0) // TODO: Test db read/write costs + .expect_no_logs() + .execute_returns(true); + }); +} + +#[test] +fn round_works() { + ExtBuilder::default().build().execute_with(|| { + precompiles() + .prepare_test(Alice, Precompile1, PCall::round {}) + .expect_cost(0) // TODO: Test db read/write costs + .expect_no_logs() + .execute_returns(1u32); + + // test next `ROUNDS_TO_TEST` rounds + const ROUNDS_TO_TEST: u32 = 10; + let mut current_round = 1; + while current_round < ROUNDS_TO_TEST { + current_round += 1; + roll_to_round_begin(current_round); + + // Assert that round is equal to expectation + precompiles() + .prepare_test(Alice, Precompile1, PCall::round {}) + .expect_cost(0) // TODO: Test db read/write costs + .expect_no_logs() + .execute_returns(current_round); + } + }); +} + +#[test] +fn candidate_delegation_count_works() { + ExtBuilder::default() + .with_balances(vec![ + (Alice.into(), 1_000), + (Bob.into(), 50), + (Charlie.into(), 50), + (David.into(), 50), + ]) + .with_candidates(vec![(Alice.into(), 1_000)]) + .with_delegations(vec![ + (Bob.into(), Alice.into(), 50), + (Charlie.into(), Alice.into(), 50), + (David.into(), Alice.into(), 50), + ]) + .build() + .execute_with(|| { + // Assert that there 3 delegations to Alice + precompiles() + .prepare_test( + Alice, + Precompile1, + PCall::candidate_delegation_count { + candidate: Address(Alice.into()), + }, + ) + .expect_cost(0) // TODO: Test db read/write costs + .expect_no_logs() + .execute_returns(3u32); + }); +} + +#[test] +fn candidate_auto_compounding_delegation_count_works() { + ExtBuilder::default() + .with_balances(vec![ + (Alice.into(), 1_000), + (Bob.into(), 50), + (Charlie.into(), 50), + (David.into(), 50), + ]) + .with_candidates(vec![(Alice.into(), 1_000)]) + .with_delegations(vec![ + (Bob.into(), Alice.into(), 50), + (Charlie.into(), Alice.into(), 50), + (David.into(), Alice.into(), 50), + ]) + .with_auto_compounding_delegations(vec![( + Charlie.into(), + Alice.into(), + 50, + Percent::from_percent(50), + )]) + .build() + .execute_with(|| { + // Assert that there 1 auto compounding delegations to Alice + precompiles() + .prepare_test( + Alice, + Precompile1, + PCall::candidate_auto_compounding_delegation_count { + candidate: Address(Alice.into()), + }, + ) + .expect_cost(0) // TODO: Test db read/write costs + .expect_no_logs() + .execute_returns(1u32); + }); +} + +#[test] +fn candidate_auto_compounding_elegation_count_works_with_zero() { + ExtBuilder::default() + .with_balances(vec![ + (Alice.into(), 1_000), + (Bob.into(), 50), + (Charlie.into(), 50), + (David.into(), 50), + ]) + .with_candidates(vec![(Alice.into(), 1_000)]) + .with_delegations(vec![ + (Bob.into(), Alice.into(), 50), + (Charlie.into(), Alice.into(), 50), + (David.into(), Alice.into(), 50), + ]) + .build() + .execute_with(|| { + // Assert that there 0 auto compounding delegations to Alice + precompiles() + .prepare_test( + Alice, + Precompile1, + PCall::candidate_auto_compounding_delegation_count { + candidate: Address(Alice.into()), + }, + ) + .expect_cost(0) // TODO: Test db read/write costs + .expect_no_logs() + .execute_returns(0u32); + }); +} + +#[test] +fn delegator_delegation_count_works() { + ExtBuilder::default() + .with_balances(vec![ + (Alice.into(), 1_000), + (Bob.into(), 1_000), + (Charlie.into(), 200), + ]) + .with_candidates(vec![(Alice.into(), 1_000), (Bob.into(), 1_000)]) + .with_delegations(vec![ + (Charlie.into(), Alice.into(), 100), + (Charlie.into(), Bob.into(), 100), + ]) + .build() + .execute_with(|| { + // Assert that Charlie has 2 outstanding nominations + precompiles() + .prepare_test( + Alice, + Precompile1, + PCall::delegator_delegation_count { + delegator: Address(Charlie.into()), + }, + ) + .expect_cost(0) // TODO: Test db read/write costs + .expect_no_logs() + .execute_returns(2u32); + }); +} + +#[test] +fn is_delegator_false() { + ExtBuilder::default().build().execute_with(|| { + // Assert that Charlie is not a delegator + precompiles() + .prepare_test( + Alice, + Precompile1, + PCall::is_delegator { + delegator: Address(Charlie.into()), + }, + ) + .expect_cost(0) // TODO: Test db read/write costs + .expect_no_logs() + .execute_returns(false); + }); +} + +#[test] +fn is_delegator_true() { + ExtBuilder::default() + .with_balances(vec![(Alice.into(), 1_000), (Bob.into(), 50)]) + .with_candidates(vec![(Alice.into(), 1_000)]) + .with_delegations(vec![(Bob.into(), Alice.into(), 50)]) + .build() + .execute_with(|| { + // Assert that Bob is a delegator + precompiles() + .prepare_test( + Alice, + Precompile1, + PCall::is_delegator { + delegator: Address(Bob.into()), + }, + ) + .expect_cost(0) // TODO: Test db read/write costs + .expect_no_logs() + .execute_returns(true); + }); +} + +#[test] +fn is_candidate_false() { + ExtBuilder::default().build().execute_with(|| { + // Assert that Alice is not a candidate + precompiles() + .prepare_test( + Alice, + Precompile1, + PCall::is_candidate { + candidate: Address(Alice.into()), + }, + ) + .expect_cost(0) // TODO: Test db read/write costs + .expect_no_logs() + .execute_returns(false); + }); +} + +#[test] +fn is_candidate_true() { + ExtBuilder::default() + .with_balances(vec![(Alice.into(), 1_000)]) + .with_candidates(vec![(Alice.into(), 1_000)]) + .build() + .execute_with(|| { + // Assert that Alice is a candidate + precompiles() + .prepare_test( + Alice, + Precompile1, + PCall::is_candidate { + candidate: Address(Alice.into()), + }, + ) + .expect_cost(0) // TODO: Test db read/write costs + .expect_no_logs() + .execute_returns(true); + }); +} + +#[test] +fn is_selected_candidate_false() { + ExtBuilder::default().build().execute_with(|| { + // Assert that Alice is not a selected candidate + precompiles() + .prepare_test( + Alice, + Precompile1, + PCall::is_selected_candidate { + candidate: Address(Alice.into()), + }, + ) + .expect_cost(0) // TODO: Test db read/write costs + .expect_no_logs() + .execute_returns(false); + }); +} + +#[test] +fn is_selected_candidate_true() { + ExtBuilder::default() + .with_balances(vec![(Alice.into(), 1_000)]) + .with_candidates(vec![(Alice.into(), 1_000)]) + .build() + .execute_with(|| { + // Assert that Alice is not a selected candidate + precompiles() + .prepare_test( + Alice, + Precompile1, + PCall::is_selected_candidate { + candidate: Address(Alice.into()), + }, + ) + .expect_cost(0) // TODO: Test db read/write costs + .expect_no_logs() + .execute_returns(true); + }); +} + +#[test] +fn selected_candidates_works() { + ExtBuilder::default() + .with_balances(vec![(Alice.into(), 1_000)]) + .with_candidates(vec![(Alice.into(), 1_000)]) + .build() + .execute_with(|| { + precompiles() + .prepare_test(Alice, Precompile1, PCall::selected_candidates {}) + .expect_cost(0) // TODO: Test db read/write costs + .expect_no_logs() + .execute_returns(vec![Address(Alice.into())]); + }); +} + +#[test] +fn delegation_request_is_pending_works() { + ExtBuilder::default() + .with_balances(vec![ + (Alice.into(), 1_000), + (Charlie.into(), 50), + (David.into(), 50), + ]) + .with_candidates(vec![(Alice.into(), 1_000)]) + .with_delegations(vec![(Charlie.into(), Alice.into(), 50)]) + .build() + .execute_with(|| { + // Assert that we dont have pending requests + precompiles() + .prepare_test( + Alice, + Precompile1, + PCall::delegation_request_is_pending { + delegator: Address(Charlie.into()), + candidate: Address(Alice.into()), + }, + ) + .expect_cost(0) // TODO: Test db read/write costs + .expect_no_logs() + .execute_returns(false); + + // Schedule Revoke request + precompiles() + .prepare_test( + Charlie, + Precompile1, + PCall::schedule_revoke_delegation { + candidate: Address(Alice.into()), + }, + ) + .expect_cost(285706258) + .expect_no_logs() + .execute_returns(()); + + // Assert that we have pending requests + precompiles() + .prepare_test( + Alice, + Precompile1, + PCall::delegation_request_is_pending { + delegator: Address(Charlie.into()), + candidate: Address(Alice.into()), + }, + ) + .expect_cost(0) // TODO: Test db read/write costs + .expect_no_logs() + .execute_returns(true); + }) +} + +#[test] +fn delegation_request_is_pending_returns_false_for_non_existing_delegator() { + ExtBuilder::default().build().execute_with(|| { + // Expected false because delegator Bob does not exist + precompiles() + .prepare_test( + Alice, + Precompile1, + PCall::delegation_request_is_pending { + delegator: Address(Bob.into()), + candidate: Address(Alice.into()), + }, + ) + .expect_cost(0) // TODO: Test db read/write costs + .expect_no_logs() + .execute_returns(false); + }) +} + +#[test] +fn candidate_exit_is_pending_works() { + ExtBuilder::default() + .with_balances(vec![(Alice.into(), 1_000)]) + .with_candidates(vec![(Alice.into(), 1_000)]) + .build() + .execute_with(|| { + // Assert that we don't have pending requests + precompiles() + .prepare_test( + Alice, + Precompile1, + PCall::candidate_exit_is_pending { + candidate: Address(Alice.into()), + }, + ) + .expect_cost(0) // TODO: Test db read/write costs + .expect_no_logs() + .execute_returns(false); + + // Schedule exit request + precompiles() + .prepare_test( + Alice, + Precompile1, + PCall::schedule_leave_candidates { + candidate_count: 1.into(), + }, + ) + .expect_cost(284172042) + .expect_no_logs() + .execute_returns(()); + + // Assert that we have pending exit + precompiles() + .prepare_test( + Alice, + Precompile1, + PCall::candidate_exit_is_pending { + candidate: Address(Alice.into()), + }, + ) + .expect_cost(0) // TODO: Test db read/write costs + .expect_no_logs() + .execute_returns(true); + }) +} + +#[test] +fn candidate_exit_is_pending_returns_false_for_non_existing_delegator() { + ExtBuilder::default().build().execute_with(|| { + // Expected false because candidate Bob does not exist + precompiles() + .prepare_test( + Alice, + Precompile1, + PCall::candidate_exit_is_pending { + candidate: Address(Bob.into()), + }, + ) + .expect_cost(0) // TODO: Test db read/write costs + .expect_no_logs() + .execute_returns(false); + }) +} + +#[test] +fn candidate_request_is_pending_works() { + ExtBuilder::default() + .with_balances(vec![(Alice.into(), 1_050)]) + .with_candidates(vec![(Alice.into(), 1_050)]) + .build() + .execute_with(|| { + // Assert that we dont have pending requests + precompiles() + .prepare_test( + Alice, + Precompile1, + PCall::candidate_request_is_pending { + candidate: Address(Alice.into()), + }, + ) + .expect_cost(0) // TODO: Test db read/write costs + .expect_no_logs() + .execute_returns(false); + + // Schedule bond less request + precompiles() + .prepare_test( + Alice, + Precompile1, + PCall::schedule_candidate_bond_less { less: 0.into() }, + ) + .expect_cost(146735000) + .expect_no_logs() + .execute_returns(()); + + // Assert that we have pending requests + precompiles() + .prepare_test( + Alice, + Precompile1, + PCall::candidate_request_is_pending { + candidate: Address(Alice.into()), + }, + ) + .expect_cost(0) // TODO: Test db read/write costs + .expect_no_logs() + .execute_returns(true); + }) +} + +#[test] +fn candidate_request_is_pending_returns_false_for_non_existing_candidate() { + ExtBuilder::default().build().execute_with(|| { + // Expected false because candidate Bob does not exist + precompiles() + .prepare_test( + Alice, + Precompile1, + PCall::candidate_request_is_pending { + candidate: Address(Bob.into()), + }, + ) + .expect_cost(0) // TODO: Test db read/write costs + .expect_no_logs() + .execute_returns(false); + }) +} + +#[test] +fn delegation_auto_compound_returns_value_if_set() { + ExtBuilder::default() + .with_balances(vec![(Alice.into(), 1_000), (Charlie.into(), 50)]) + .with_candidates(vec![(Alice.into(), 1_000)]) + .with_auto_compounding_delegations(vec![( + Charlie.into(), + Alice.into(), + 50, + Percent::from_percent(50), + )]) + .build() + .execute_with(|| { + precompiles() + .prepare_test( + Alice, + Precompile1, + PCall::delegation_auto_compound { + delegator: Address(Charlie.into()), + candidate: Address(Alice.into()), + }, + ) + .expect_cost(0) + .expect_no_logs() + .execute_returns(50u8); + }) +} + +#[test] +fn delegation_auto_compound_returns_zero_if_not_set() { + ExtBuilder::default() + .with_balances(vec![(Alice.into(), 1_000), (Charlie.into(), 50)]) + .with_candidates(vec![(Alice.into(), 1_000)]) + .with_delegations(vec![(Charlie.into(), Alice.into(), 50)]) + .build() + .execute_with(|| { + precompiles() + .prepare_test( + Alice, + Precompile1, + PCall::delegation_auto_compound { + delegator: Address(Charlie.into()), + candidate: Address(Alice.into()), + }, + ) + .expect_cost(0) + .expect_no_logs() + .execute_returns(0u8); + }) +} + +#[test] +fn join_candidates_works() { + ExtBuilder::default() + .with_balances(vec![(Alice.into(), 1_000)]) + .build() + .execute_with(|| { + let input_data = PCall::join_candidates { + amount: 1000.into(), + candidate_count: 0.into(), + } + .into(); + + // Make sure the call goes through successfully + assert_ok!( + RuntimeCall::Evm(evm_call(Alice, input_data)).dispatch(RuntimeOrigin::root()) + ); + + let expected: crate::mock::RuntimeEvent = StakingEvent::JoinedCollatorCandidates { + account: Alice.into(), + amount_locked: 1000, + new_total_amt_locked: 1000, + } + .into(); + // Assert that the events vector contains the one expected + println!("{:?}", events()); + assert!(events().contains(&expected)); + }); +} + +#[test] +fn schedule_leave_candidates_works() { + ExtBuilder::default() + .with_balances(vec![(Alice.into(), 1_000)]) + .with_candidates(vec![(Alice.into(), 1_000)]) + .build() + .execute_with(|| { + let input_data = PCall::schedule_leave_candidates { + candidate_count: 1.into(), + } + .into(); + + // Make sure the call goes through successfully + assert_ok!( + RuntimeCall::Evm(evm_call(Alice, input_data)).dispatch(RuntimeOrigin::root()) + ); + + let expected: crate::mock::RuntimeEvent = StakingEvent::CandidateScheduledExit { + exit_allowed_round: 1, + candidate: Alice.into(), + scheduled_exit: 3, + } + .into(); + // Assert that the events vector contains the one expected + assert!(events().contains(&expected)); + }); +} + +#[test] +fn execute_leave_candidates_works() { + ExtBuilder::default() + .with_balances(vec![(Alice.into(), 1_000)]) + .with_candidates(vec![(Alice.into(), 1_000)]) + .build() + .execute_with(|| { + assert_ok!(ParachainStaking::schedule_leave_candidates( + RuntimeOrigin::signed(Alice.into()), + 1 + )); + roll_to(10); + + let input_data = PCall::execute_leave_candidates { + candidate: Address(Alice.into()), + candidate_count: 0.into(), + } + .into(); + + // Make sure the call goes through successfully + assert_ok!( + RuntimeCall::Evm(evm_call(Alice, input_data)).dispatch(RuntimeOrigin::root()) + ); + + let expected: crate::mock::RuntimeEvent = StakingEvent::CandidateLeft { + ex_candidate: Alice.into(), + unlocked_amount: 1_000, + new_total_amt_locked: 0, + } + .into(); + // Assert that the events vector contains the one expected + assert!(events().contains(&expected)); + }); +} + +#[test] +fn cancel_leave_candidates_works() { + ExtBuilder::default() + .with_balances(vec![(Alice.into(), 1_000)]) + .with_candidates(vec![(Alice.into(), 1_000)]) + .build() + .execute_with(|| { + assert_ok!(ParachainStaking::schedule_leave_candidates( + RuntimeOrigin::signed(Alice.into()), + 1 + )); + + let input_data = PCall::cancel_leave_candidates { + candidate_count: 0.into(), + } + .into(); + + // Make sure the call goes through successfully + assert_ok!( + RuntimeCall::Evm(evm_call(Alice, input_data)).dispatch(RuntimeOrigin::root()) + ); + + let expected: crate::mock::RuntimeEvent = StakingEvent::CancelledCandidateExit { + candidate: Alice.into(), + } + .into(); + // Assert that the events vector contains the one expected + assert!(events().contains(&expected)); + }); +} + +#[test] +fn go_online_works() { + ExtBuilder::default() + .with_balances(vec![(Alice.into(), 1_000)]) + .with_candidates(vec![(Alice.into(), 1_000)]) + .build() + .execute_with(|| { + assert_ok!(ParachainStaking::go_offline(RuntimeOrigin::signed( + Alice.into() + ))); + + let input_data = PCall::go_online {}.into(); + + // Make sure the call goes through successfully + assert_ok!( + RuntimeCall::Evm(evm_call(Alice, input_data)).dispatch(RuntimeOrigin::root()) + ); + + let expected: crate::mock::RuntimeEvent = StakingEvent::CandidateBackOnline { + candidate: Alice.into(), + } + .into(); + // Assert that the events vector contains the one expected + assert!(events().contains(&expected)); + }); +} + +#[test] +fn go_offline_works() { + ExtBuilder::default() + .with_balances(vec![(Alice.into(), 1_000)]) + .with_candidates(vec![(Alice.into(), 1_000)]) + .build() + .execute_with(|| { + let input_data = PCall::go_offline {}.into(); + // Make sure the call goes through successfully + assert_ok!( + RuntimeCall::Evm(evm_call(Alice, input_data)).dispatch(RuntimeOrigin::root()) + ); + + let expected: crate::mock::RuntimeEvent = StakingEvent::CandidateWentOffline { + candidate: Alice.into(), + } + .into(); + // Assert that the events vector contains the one expected + assert!(events().contains(&expected)); + }); +} + +#[test] +fn candidate_bond_more_works() { + ExtBuilder::default() + .with_balances(vec![(Alice.into(), 1_500)]) + .with_candidates(vec![(Alice.into(), 1_000)]) + .build() + .execute_with(|| { + let input_data = PCall::candidate_bond_more { more: 500.into() }.into(); + + // Make sure the call goes through successfully + assert_ok!( + RuntimeCall::Evm(evm_call(Alice, input_data)).dispatch(RuntimeOrigin::root()) + ); + + let expected: crate::mock::RuntimeEvent = StakingEvent::CandidateBondedMore { + candidate: Alice.into(), + amount: 500, + new_total_bond: 1500, + } + .into(); + // Assert that the events vector contains the one expected + assert!(events().contains(&expected)); + }); +} + +#[test] +fn schedule_candidate_bond_less_works() { + ExtBuilder::default() + .with_balances(vec![(Alice.into(), 1_000)]) + .with_candidates(vec![(Alice.into(), 1_000)]) + .build() + .execute_with(|| { + let input_data = PCall::schedule_candidate_bond_less { less: 500.into() }.into(); + + // Make sure the call goes through successfully + assert_ok!( + RuntimeCall::Evm(evm_call(Alice, input_data)).dispatch(RuntimeOrigin::root()) + ); + + let expected: crate::mock::RuntimeEvent = StakingEvent::CandidateBondLessRequested { + candidate: Alice.into(), + amount_to_decrease: 500, + execute_round: 3, + } + .into(); + // Assert that the events vector contains the one expected + assert!(events().contains(&expected)); + }); +} + +#[test] +fn execute_candidate_bond_less_works() { + ExtBuilder::default() + .with_balances(vec![(Alice.into(), 1_500)]) + .with_candidates(vec![(Alice.into(), 1_500)]) + .build() + .execute_with(|| { + assert_ok!(ParachainStaking::schedule_candidate_bond_less( + RuntimeOrigin::signed(Alice.into()), + 500 + )); + roll_to(10); + + // Make sure the call goes through successfully + let input_data = PCall::execute_candidate_bond_less { + candidate: Address(Alice.into()), + } + .into(); + + assert_ok!( + RuntimeCall::Evm(evm_call(Alice, input_data)).dispatch(RuntimeOrigin::root()) + ); + + let expected: crate::mock::RuntimeEvent = StakingEvent::CandidateBondedLess { + candidate: Alice.into(), + amount: 500, + new_bond: 1000, + } + .into(); + // Assert that the events vector contains the one expected + assert!(events().contains(&expected)); + }); +} + +#[test] +fn cancel_candidate_bond_less_works() { + ExtBuilder::default() + .with_balances(vec![(Alice.into(), 1_200)]) + .with_candidates(vec![(Alice.into(), 1_200)]) + .build() + .execute_with(|| { + assert_ok!(ParachainStaking::schedule_candidate_bond_less( + RuntimeOrigin::signed(Alice.into()), + 200 + )); + + let input_data = PCall::cancel_candidate_bond_less {}.into(); + + // Make sure the call goes through successfully + assert_ok!( + RuntimeCall::Evm(evm_call(Alice, input_data)).dispatch(RuntimeOrigin::root()) + ); + + let expected: crate::mock::RuntimeEvent = StakingEvent::CancelledCandidateBondLess { + candidate: Alice.into(), + amount: 200, + execute_round: 3, + } + .into(); + // Assert that the events vector contains the one expected + assert!(events().contains(&expected)); + }); +} + +#[test] +fn delegate_works() { + ExtBuilder::default() + .with_balances(vec![(Alice.into(), 1_000), (Bob.into(), 1_000)]) + .with_candidates(vec![(Alice.into(), 1_000)]) + .build() + .execute_with(|| { + let input_data = PCall::delegate { + candidate: Address(Alice.into()), + amount: 1_000.into(), + candidate_delegation_count: 0.into(), + delegator_delegation_count: 0.into(), + } + .into(); + + // Make sure the call goes through successfully + assert_ok!(RuntimeCall::Evm(evm_call(Bob, input_data)).dispatch(RuntimeOrigin::root())); + + assert!(ParachainStaking::is_delegator(&Bob.into())); + + let expected: crate::mock::RuntimeEvent = StakingEvent::Delegation { + delegator: Bob.into(), + locked_amount: 1_000, + candidate: Alice.into(), + delegator_position: pallet_parachain_staking::DelegatorAdded::AddedToTop { + new_total: 2_000, + }, + auto_compound: Percent::zero(), + } + .into(); + // Assert that the events vector contains the one expected + assert!(events().contains(&expected)); + }); +} + +#[test] +fn schedule_revoke_delegation_works() { + ExtBuilder::default() + .with_balances(vec![(Alice.into(), 1_000), (Bob.into(), 1_000)]) + .with_candidates(vec![(Alice.into(), 1_000)]) + .with_delegations(vec![(Bob.into(), Alice.into(), 1_000)]) + .build() + .execute_with(|| { + let input_data = PCall::schedule_revoke_delegation { + candidate: Address(Alice.into()), + } + .into(); + + // Make sure the call goes through successfully + assert_ok!(RuntimeCall::Evm(evm_call(Bob, input_data)).dispatch(RuntimeOrigin::root())); + + let expected: crate::mock::RuntimeEvent = StakingEvent::DelegationRevocationScheduled { + round: 1, + delegator: Bob.into(), + candidate: Alice.into(), + scheduled_exit: 3, + } + .into(); + // Assert that the events vector contains the one expected + assert!(events().contains(&expected)); + }); +} + +#[test] +fn delegator_bond_more_works() { + ExtBuilder::default() + .with_balances(vec![(Alice.into(), 1_000), (Bob.into(), 1_500)]) + .with_candidates(vec![(Alice.into(), 1_000)]) + .with_delegations(vec![(Bob.into(), Alice.into(), 500)]) + .build() + .execute_with(|| { + let input_data = PCall::delegator_bond_more { + candidate: Address(Alice.into()), + more: 500.into(), + } + .into(); + + assert_ok!(RuntimeCall::Evm(evm_call(Bob, input_data)).dispatch(RuntimeOrigin::root())); + + let expected: crate::mock::RuntimeEvent = StakingEvent::DelegationIncreased { + delegator: Bob.into(), + candidate: Alice.into(), + amount: 500, + in_top: true, + } + .into(); + // Assert that the events vector contains the one expected + assert!(events().contains(&expected)); + }); +} + +#[test] +fn schedule_delegator_bond_less_works() { + ExtBuilder::default() + .with_balances(vec![(Alice.into(), 1_000), (Bob.into(), 1_500)]) + .with_candidates(vec![(Alice.into(), 1_000)]) + .with_delegations(vec![(Bob.into(), Alice.into(), 1_500)]) + .build() + .execute_with(|| { + let input_data = PCall::schedule_delegator_bond_less { + candidate: Address(Alice.into()), + less: 500.into(), + } + .into(); + + assert_ok!(RuntimeCall::Evm(evm_call(Bob, input_data)).dispatch(RuntimeOrigin::root())); + + // Check for the right events. + let expected_event: crate::mock::RuntimeEvent = + StakingEvent::DelegationDecreaseScheduled { + delegator: Bob.into(), + candidate: Alice.into(), + amount_to_decrease: 500, + execute_round: 3, + } + .into(); + + assert!(events().contains(&expected_event)); + }); +} + +#[test] +fn execute_revoke_delegation_works() { + ExtBuilder::default() + .with_balances(vec![(Alice.into(), 1_000), (Bob.into(), 1_000)]) + .with_candidates(vec![(Alice.into(), 1_000)]) + .with_delegations(vec![(Bob.into(), Alice.into(), 1_000)]) + .build() + .execute_with(|| { + assert_ok!(ParachainStaking::schedule_revoke_delegation( + RuntimeOrigin::signed(Bob.into()), + Alice.into() + )); + roll_to(10); + + let input_data = PCall::execute_delegation_request { + delegator: Address(Bob.into()), + candidate: Address(Alice.into()), + } + .into(); + + // Make sure the call goes through successfully + assert_ok!( + RuntimeCall::Evm(evm_call(Alice, input_data)).dispatch(RuntimeOrigin::root()) + ); + + let expected: crate::mock::RuntimeEvent = StakingEvent::DelegationRevoked { + delegator: Bob.into(), + candidate: Alice.into(), + unstaked_amount: 1_000, + } + .into(); + // Assert that the events vector contains the one expected + assert!(events().contains(&expected)); + }); +} + +#[test] +fn execute_delegator_bond_less_works() { + ExtBuilder::default() + .with_balances(vec![(Alice.into(), 1_000), (Bob.into(), 1_000)]) + .with_candidates(vec![(Alice.into(), 1_000)]) + .with_delegations(vec![(Bob.into(), Alice.into(), 1_000)]) + .build() + .execute_with(|| { + assert_ok!(ParachainStaking::schedule_delegator_bond_less( + RuntimeOrigin::signed(Bob.into()), + Alice.into(), + 500 + )); + roll_to(10); + + let input_data = PCall::execute_delegation_request { + delegator: Address(Bob.into()), + candidate: Address(Alice.into()), + } + .into(); + + // Make sure the call goes through successfully + assert_ok!( + RuntimeCall::Evm(evm_call(Alice, input_data)).dispatch(RuntimeOrigin::root()) + ); + + let expected: crate::mock::RuntimeEvent = StakingEvent::DelegationDecreased { + delegator: Bob.into(), + candidate: Alice.into(), + amount: 500, + in_top: true, + } + .into(); + // Assert that the events vector contains the one expected + assert!(events().contains(&expected)); + }); +} + +#[test] +fn cancel_revoke_delegation_works() { + ExtBuilder::default() + .with_balances(vec![(Alice.into(), 1_000), (Bob.into(), 1_000)]) + .with_candidates(vec![(Alice.into(), 1_000)]) + .with_delegations(vec![(Bob.into(), Alice.into(), 1_000)]) + .build() + .execute_with(|| { + assert_ok!(ParachainStaking::schedule_revoke_delegation( + RuntimeOrigin::signed(Bob.into()), + Alice.into() + )); + + let input_data = PCall::cancel_delegation_request { + candidate: Address(Alice.into()), + } + .into(); + + // Make sure the call goes through successfully + assert_ok!(RuntimeCall::Evm(evm_call(Bob, input_data)).dispatch(RuntimeOrigin::root())); + + let expected: crate::mock::RuntimeEvent = StakingEvent::CancelledDelegationRequest { + delegator: Bob.into(), + collator: Alice.into(), + cancelled_request: pallet_parachain_staking::CancelledScheduledRequest { + when_executable: 3, + action: pallet_parachain_staking::DelegationAction::Revoke(1_000), + }, + } + .into(); + // Assert that the events vector contains the one expected + assert!(events().contains(&expected)); + }); +} + +#[test] +fn cancel_delegator_bonded_less_works() { + ExtBuilder::default() + .with_balances(vec![(Alice.into(), 1_000), (Bob.into(), 1_000)]) + .with_candidates(vec![(Alice.into(), 1_000)]) + .with_delegations(vec![(Bob.into(), Alice.into(), 1_000)]) + .build() + .execute_with(|| { + assert_ok!(ParachainStaking::schedule_delegator_bond_less( + RuntimeOrigin::signed(Bob.into()), + Alice.into(), + 500 + )); + + let input_data = PCall::cancel_delegation_request { + candidate: Address(Alice.into()), + } + .into(); + + // Make sure the call goes through successfully + assert_ok!(RuntimeCall::Evm(evm_call(Bob, input_data)).dispatch(RuntimeOrigin::root())); + + let expected: crate::mock::RuntimeEvent = StakingEvent::CancelledDelegationRequest { + delegator: Bob.into(), + collator: Alice.into(), + cancelled_request: pallet_parachain_staking::CancelledScheduledRequest { + when_executable: 3, + action: pallet_parachain_staking::DelegationAction::Decrease(500), + }, + } + .into(); + // Assert that the events vector contains the one expected + assert!(events().contains(&expected)); + }); +} + +#[test] +fn delegate_with_auto_compound_works() { + for auto_compound_percent in [0, 50, 100] { + ExtBuilder::default() + .with_balances(vec![(Alice.into(), 1_000), (Bob.into(), 1_000)]) + .with_candidates(vec![(Alice.into(), 1_000)]) + .build() + .execute_with(|| { + let input_data = PCall::delegate_with_auto_compound { + candidate: Address(Alice.into()), + amount: 1_000.into(), + auto_compound: auto_compound_percent, + candidate_delegation_count: 0.into(), + candidate_auto_compounding_delegation_count: 0.into(), + delegator_delegation_count: 0.into(), + } + .into(); + + // Make sure the call goes through successfully + assert_ok!( + RuntimeCall::Evm(evm_call(Bob, input_data)).dispatch(RuntimeOrigin::root()) + ); + + assert!(ParachainStaking::is_delegator(&Bob.into())); + + let expected: crate::mock::RuntimeEvent = StakingEvent::Delegation { + delegator: Bob.into(), + locked_amount: 1_000, + candidate: Alice.into(), + delegator_position: pallet_parachain_staking::DelegatorAdded::AddedToTop { + new_total: 2_000, + }, + auto_compound: Percent::from_percent(auto_compound_percent), + } + .into(); + // Assert that the events vector contains the one expected + assert!(events().contains(&expected)); + }); + } +} + +#[test] +fn delegate_with_auto_compound_returns_error_if_percent_above_hundred() { + for auto_compound_percent in [101, 255] { + ExtBuilder::default() + .with_balances(vec![(Alice.into(), 1_000), (Bob.into(), 1_000)]) + .with_candidates(vec![(Alice.into(), 1_000)]) + .build() + .execute_with(|| { + PrecompilesValue::get() + .prepare_test( + Bob, + Precompile1, + PCall::delegate_with_auto_compound { + candidate: Address(Alice.into()), + amount: 1_000.into(), + auto_compound: auto_compound_percent, + candidate_delegation_count: 0.into(), + candidate_auto_compounding_delegation_count: 0.into(), + delegator_delegation_count: 0.into(), + }, + ) + .execute_reverts(|output| { + from_utf8(&output).unwrap().contains( + "auto_compound: Must be an integer between 0 and 100 included", + ) + }); + }); + } +} + +#[test] +fn set_auto_compound_works_if_delegation() { + for auto_compound_percent in [0, 50, 100] { + ExtBuilder::default() + .with_balances(vec![(Alice.into(), 1_000), (Bob.into(), 1_000)]) + .with_candidates(vec![(Alice.into(), 1_000)]) + .with_delegations(vec![(Bob.into(), Alice.into(), 1_000)]) + .build() + .execute_with(|| { + let input_data = PCall::set_auto_compound { + candidate: Address(Alice.into()), + value: auto_compound_percent, + candidate_auto_compounding_delegation_count: 0.into(), + delegator_delegation_count: 1.into(), + } + .into(); + + // Make sure the call goes through successfully + assert_ok!( + RuntimeCall::Evm(evm_call(Bob, input_data)).dispatch(RuntimeOrigin::root()) + ); + + assert_eq!( + ParachainStaking::delegation_auto_compound(&Alice.into(), &Bob.into()), + Percent::from_percent(auto_compound_percent) + ); + + let expected: crate::mock::RuntimeEvent = StakingEvent::AutoCompoundSet { + candidate: Alice.into(), + delegator: Bob.into(), + value: Percent::from_percent(auto_compound_percent), + } + .into(); + // Assert that the events vector contains the one expected + assert!(events().contains(&expected)); + }); + } +} + +#[test] +fn set_auto_compound_returns_error_if_value_above_hundred_percent() { + for auto_compound_percent in [101, 255] { + ExtBuilder::default() + .with_balances(vec![(Alice.into(), 1_000), (Bob.into(), 1_000)]) + .with_candidates(vec![(Alice.into(), 1_000)]) + .with_delegations(vec![(Bob.into(), Alice.into(), 1_000)]) + .build() + .execute_with(|| { + PrecompilesValue::get() + .prepare_test( + Bob, + Precompile1, + PCall::set_auto_compound { + candidate: Address(Alice.into()), + value: auto_compound_percent, + candidate_auto_compounding_delegation_count: 0.into(), + delegator_delegation_count: 1.into(), + }, + ) + .execute_reverts(|output| { + from_utf8(&output) + .unwrap() + .contains("value: Must be an integer between 0 and 100 included") + }); + }); + } +} + +#[test] +fn set_auto_compound_fails_if_not_delegation() { + ExtBuilder::default() + .with_balances(vec![(Alice.into(), 1000), (Bob.into(), 1000)]) + .with_candidates(vec![(Alice.into(), 1_000)]) + .build() + .execute_with(|| { + PrecompilesValue::get() + .prepare_test( + Alice, + Precompile1, + PCall::set_auto_compound { + candidate: Address(Alice.into()), + value: 50, + candidate_auto_compounding_delegation_count: 0.into(), + delegator_delegation_count: 0.into(), + }, + ) + .execute_reverts(|output| from_utf8(&output).unwrap().contains("DelegatorDNE")); + }); +} + +#[test] +fn get_delegator_total_staked_getter() { + ExtBuilder::default() + .with_balances(vec![ + (Alice.into(), 1_000), + (Bob.into(), 1_000), + (Charlie.into(), 1_500), + ]) + .with_candidates(vec![(Alice.into(), 1_000), (Bob.into(), 1_000)]) + .with_delegations(vec![ + (Charlie.into(), Alice.into(), 1_000), + (Charlie.into(), Bob.into(), 499), + ]) + .build() + .execute_with(|| { + PrecompilesValue::get() + .prepare_test( + Alice, + Precompile1, + PCall::get_delegator_total_staked { + delegator: Address(Charlie.into()), + }, + ) + .execute_returns(U256::from(1_499)); + }); +} + +#[test] +fn get_delegator_total_staked_getter_unknown() { + ExtBuilder::default() + .with_balances(vec![ + (Alice.into(), 1_000), + (Bob.into(), 1_000), + (Charlie.into(), 1_500), + ]) + .with_candidates(vec![(Alice.into(), 1_000), (Bob.into(), 1_000)]) + .build() + .execute_with(|| { + PrecompilesValue::get() + .prepare_test( + Alice, + Precompile1, + PCall::get_delegator_total_staked { + delegator: Address(Charlie.into()), + }, + ) + .execute_returns(U256::zero()); + }); +} + +#[test] +fn get_candidate_total_counted_getter() { + ExtBuilder::default() + .with_balances(vec![ + (Alice.into(), 1_000), + (Bob.into(), 1_000), + (Charlie.into(), 1_500), + ]) + .with_candidates(vec![(Alice.into(), 1_000), (Bob.into(), 1_000)]) + .with_delegations(vec![ + (Charlie.into(), Alice.into(), 1_000), + (Charlie.into(), Bob.into(), 499), + ]) + .build() + .execute_with(|| { + PrecompilesValue::get() + .prepare_test( + Alice, + Precompile1, + PCall::get_candidate_total_counted { + candidate: Address(Alice.into()), + }, + ) + .execute_returns(U256::from(2_000)); + }); +} + +#[test] +fn test_solidity_interface_has_all_function_selectors_documented_and_implemented() { + check_precompile_implements_solidity_interfaces( + &["StakingInterface.sol"], + PCall::supports_selector, + ) +} + +#[test] +fn test_deprecated_solidity_selectors_are_supported() { + for deprecated_function in [ + "min_delegation()", + "candidate_count()", + "candidate_delegation_count(address)", + "delegator_delegation_count(address)", + "selected_candidates()", + "is_delegator(address)", + "is_candidate(address)", + "is_selected_candidate(address)", + "delegation_request_is_pending(address,address)", + "candidate_exit_is_pending(address)", + "candidate_request_is_pending(address)", + "join_candidates(uint256,uint256)", + "schedule_leave_candidates(uint256)", + "execute_leave_candidates(address,uint256)", + "cancel_leave_candidates(uint256)", + "go_offline()", + "go_online()", + "schedule_candidate_bond_less(uint256)", + "candidate_bond_more(uint256)", + "execute_candidate_bond_less(address)", + "cancel_candidate_bond_less()", + "schedule_revoke_delegation(address)", + "schedule_delegator_bond_less(address,uint256)", + "delegator_bond_more(address,uint256)", + "execute_delegation_request(address,address)", + "cancel_delegation_request(address)", + ] { + let selector = compute_selector(deprecated_function); + if !PCall::supports_selector(selector) { + panic!( + "failed decoding selector 0x{:x} => '{}' as Action", + selector, deprecated_function, + ) + } + } +} From 4ec7ce42f746dbfa10728f93d93f8cf6ab166d46 Mon Sep 17 00:00:00 2001 From: magecnion Date: Thu, 18 Jul 2024 11:04:05 +0200 Subject: [PATCH 02/16] it compiles --- precompiles/parachain-staking/src/lib.rs | 98 +++++------ precompiles/parachain-staking/src/mock.rs | 30 +--- precompiles/parachain-staking/src/tests.rs | 190 ++++++--------------- 3 files changed, 98 insertions(+), 220 deletions(-) diff --git a/precompiles/parachain-staking/src/lib.rs b/precompiles/parachain-staking/src/lib.rs index d3f290678..b5f197a65 100644 --- a/precompiles/parachain-staking/src/lib.rs +++ b/precompiles/parachain-staking/src/lib.rs @@ -24,9 +24,11 @@ mod mock; mod tests; use fp_evm::PrecompileHandle; -use frame_support::dispatch::{GetDispatchInfo, PostDispatchInfo}; -use frame_support::sp_runtime::Percent; -use frame_support::traits::{Currency, Get}; +use frame_support::{ + dispatch::{GetDispatchInfo, PostDispatchInfo}, + sp_runtime::Percent, + traits::{Currency, Get}, +}; use pallet_evm::AddressMapping; use precompile_utils::prelude::*; use sp_core::{H160, U256}; @@ -109,9 +111,8 @@ where // TODO CandidatePool is unbounded, we account for a theoretical 200 pool. handle.record_db_read::(7200)?; // Fetch info. - let candidate_count: u32 = >::candidate_pool() - .0 - .len() as u32; + let candidate_count: u32 = + >::candidate_pool().0.len() as u32; // Build output. Ok(candidate_count) @@ -261,17 +262,8 @@ where Runtime::AddressMapping::into_account_id(delegator.0), ); let amount = pallet_parachain_staking::Pallet::::delegator_state(&delegator) - .and_then(|state| { - state - .delegations - .0 - .into_iter() - .find(|b| b.owner == candidate) - }) - .map_or( - U256::zero(), - |pallet_parachain_staking::Bond { amount, .. }| amount.into(), - ); + .and_then(|state| state.delegations.0.into_iter().find(|b| b.owner == candidate)) + .map_or(U256::zero(), |pallet_parachain_staking::Bond { amount, .. }| amount.into()); Ok(amount) } @@ -292,19 +284,15 @@ where // Twox64Concat(8) + AccountId(20) + Balance(16) // + (AccountId(20) + Balance(16) * MaxTopDelegationsPerCandidate) handle.record_db_read::( - 44 + ((36 - * ::MaxTopDelegationsPerCandidate::get( + 44 + ((36 * + ::MaxTopDelegationsPerCandidate::get( )) as usize), )?; - let is_in_top_delegations = pallet_parachain_staking::Pallet::::top_delegations( - &candidate, - ) - .map_or(false, |delegations| { - delegations - .delegations - .into_iter() - .any(|b| b.owner == delegator) - }); + let is_in_top_delegations = + pallet_parachain_staking::Pallet::::top_delegations(&candidate) + .map_or(false, |delegations| { + delegations.delegations.into_iter().any(|b| b.owner == delegator) + }); Ok(is_in_top_delegations) } @@ -373,7 +361,7 @@ where // Blake2128(16) + AccountId(20) // + Vec( // ScheduledRequest(20 + 4 + DelegationAction(18)) - // * (MaxTopDelegationsPerCandidate + MaxBottomDelegationsPerCandidate) + // * (MaxTopDelegationsPerCandidate + MaxBottomDelegationsPerCandidate) // ) handle.record_db_read::( 36 + ( @@ -500,7 +488,7 @@ where }; // Dispatch call (if enough gas). - RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call, 0)?; + RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call)?; Ok(()) } @@ -520,7 +508,7 @@ where }; // Dispatch call (if enough gas). - RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call, 0)?; + RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call)?; Ok(()) } @@ -543,7 +531,7 @@ where }; // Dispatch call (if enough gas). - RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call, 0)?; + RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call)?; Ok(()) } @@ -562,7 +550,7 @@ where pallet_parachain_staking::Call::::cancel_leave_candidates { candidate_count }; // Dispatch call (if enough gas). - RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call, 0)?; + RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call)?; Ok(()) } @@ -575,7 +563,7 @@ where let call = pallet_parachain_staking::Call::::go_offline {}; // Dispatch call (if enough gas). - RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call, 0)?; + RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call)?; Ok(()) } @@ -588,7 +576,7 @@ where let call = pallet_parachain_staking::Call::::go_online {}; // Dispatch call (if enough gas). - RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call, 0)?; + RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call)?; Ok(()) } @@ -603,7 +591,7 @@ where let call = pallet_parachain_staking::Call::::candidate_bond_more { more }; // Dispatch call (if enough gas). - RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call, 0)?; + RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call)?; Ok(()) } @@ -618,7 +606,7 @@ where let call = pallet_parachain_staking::Call::::schedule_candidate_bond_less { less }; // Dispatch call (if enough gas). - RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call, 0)?; + RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call)?; Ok(()) } @@ -637,7 +625,7 @@ where pallet_parachain_staking::Call::::execute_candidate_bond_less { candidate }; // Dispatch call (if enough gas). - RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call, 0)?; + RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call)?; Ok(()) } @@ -650,7 +638,7 @@ where let call = pallet_parachain_staking::Call::::cancel_candidate_bond_less {}; // Dispatch call (if enough gas). - RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call, 0)?; + RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call)?; Ok(()) } @@ -679,7 +667,7 @@ where }; // Dispatch call (if enough gas). - RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call, 0)?; + RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call)?; Ok(()) } @@ -695,11 +683,9 @@ where delegator_delegation_count: Convert, ) -> EvmResult { if auto_compound > 100 { - return Err( - RevertReason::custom("Must be an integer between 0 and 100 included") - .in_field("auto_compound") - .into(), - ); + return Err(RevertReason::custom("Must be an integer between 0 and 100 included") + .in_field("auto_compound") + .into()); } let amount = Self::u256_to_amount(amount).in_field("amount")?; @@ -723,7 +709,7 @@ where }; // Dispatch call (if enough gas). - RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call, 0)?; + RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call)?; Ok(()) } @@ -743,7 +729,7 @@ where }; // Dispatch call (if enough gas). - RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call, 0)?; + RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call)?; Ok(()) } @@ -764,7 +750,7 @@ where pallet_parachain_staking::Call::::delegator_bond_more { candidate, more }; // Dispatch call (if enough gas). - RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call, 0)?; + RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call)?; Ok(()) } @@ -787,7 +773,7 @@ where }; // Dispatch call (if enough gas). - RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call, 0)?; + RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call)?; Ok(()) } @@ -810,7 +796,7 @@ where }; // Dispatch call (if enough gas). - RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call, 0)?; + RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call)?; Ok(()) } @@ -829,7 +815,7 @@ where pallet_parachain_staking::Call::::cancel_delegation_request { candidate }; // Dispatch call (if enough gas). - RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call, 0)?; + RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call)?; Ok(()) } @@ -843,11 +829,9 @@ where delegator_delegation_count: Convert, ) -> EvmResult { if value > 100 { - return Err( - RevertReason::custom("Must be an integer between 0 and 100 included") - .in_field("value") - .into(), - ); + return Err(RevertReason::custom("Must be an integer between 0 and 100 included") + .in_field("value") + .into()); } let value = Percent::from_percent(value); @@ -867,7 +851,7 @@ where }; // Dispatch call (if enough gas). - RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call, 0)?; + RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call)?; Ok(()) } diff --git a/precompiles/parachain-staking/src/mock.rs b/precompiles/parachain-staking/src/mock.rs index af20411be..e56cdb9cd 100644 --- a/precompiles/parachain-staking/src/mock.rs +++ b/precompiles/parachain-staking/src/mock.rs @@ -243,11 +243,7 @@ impl Default for ExtBuilder { delegations: vec![], collators: vec![], inflation: InflationInfo { - expect: Range { - min: 700, - ideal: 700, - max: 700, - }, + expect: Range { min: 700, ideal: 700, max: 700 }, // not used annual: Range { min: Perbill::from_percent(50), @@ -280,10 +276,8 @@ impl ExtBuilder { mut self, delegations: Vec<(AccountId, AccountId, Balance)>, ) -> Self { - self.delegations = delegations - .into_iter() - .map(|d| (d.0, d.1, d.2, Percent::zero())) - .collect(); + self.delegations = + delegations.into_iter().map(|d| (d.0, d.1, d.2, Percent::zero())).collect(); self } @@ -291,10 +285,7 @@ impl ExtBuilder { mut self, delegations: Vec<(AccountId, AccountId, Balance, Percent)>, ) -> Self { - self.delegations = delegations - .into_iter() - .map(|d| (d.0, d.1, d.2, d.3)) - .collect(); + self.delegations = delegations.into_iter().map(|d| (d.0, d.1, d.2, d.3)).collect(); self } @@ -309,11 +300,9 @@ impl ExtBuilder { .build_storage() .expect("Frame system builds valid default genesis config"); - pallet_balances::GenesisConfig:: { - balances: self.balances, - } - .assimilate_storage(&mut t) - .expect("Pallet balances storage can be assimilated"); + pallet_balances::GenesisConfig:: { balances: self.balances } + .assimilate_storage(&mut t) + .expect("Pallet balances storage can be assimilated"); pallet_parachain_staking::GenesisConfig:: { candidates: self.collators, delegations: self.delegations, @@ -358,8 +347,5 @@ pub(crate) fn roll_to_round_begin(round: BlockNumber) { } pub(crate) fn events() -> Vec { - System::events() - .into_iter() - .map(|r| r.event) - .collect::>() + System::events().into_iter().map(|r| r.event).collect::>() } diff --git a/precompiles/parachain-staking/src/tests.rs b/precompiles/parachain-staking/src/tests.rs index 4477dadb8..6fded4056 100644 --- a/precompiles/parachain-staking/src/tests.rs +++ b/precompiles/parachain-staking/src/tests.rs @@ -19,8 +19,7 @@ use crate::mock::{ Precompiles, PrecompilesValue, Runtime, RuntimeCall, RuntimeOrigin, }; use core::str::from_utf8; -use frame_support::assert_ok; -use frame_support::sp_runtime::Percent; +use frame_support::{assert_ok, sp_runtime::Percent}; use pallet_evm::Call as EvmCall; use pallet_parachain_staking::Event as StakingEvent; use precompile_utils::{prelude::*, testing::*}; @@ -200,10 +199,7 @@ fn awarded_points_zero() { .prepare_test( Alice, Precompile1, - PCall::awarded_points { - round: 1u32.into(), - candidate: Address(Bob.into()), - }, + PCall::awarded_points { round: 1u32.into(), candidate: Address(Bob.into()) }, ) .expect_cost(0) .expect_no_logs() @@ -225,10 +221,7 @@ fn awarded_points_non_zero() { .prepare_test( Alice, Precompile1, - PCall::awarded_points { - round: 1u32.into(), - candidate: Address(Alice.into()), - }, + PCall::awarded_points { round: 1u32.into(), candidate: Address(Alice.into()) }, ) .expect_cost(0) .expect_no_logs() @@ -404,9 +397,7 @@ fn candidate_delegation_count_works() { .prepare_test( Alice, Precompile1, - PCall::candidate_delegation_count { - candidate: Address(Alice.into()), - }, + PCall::candidate_delegation_count { candidate: Address(Alice.into()) }, ) .expect_cost(0) // TODO: Test db read/write costs .expect_no_logs() @@ -487,11 +478,7 @@ fn candidate_auto_compounding_elegation_count_works_with_zero() { #[test] fn delegator_delegation_count_works() { ExtBuilder::default() - .with_balances(vec![ - (Alice.into(), 1_000), - (Bob.into(), 1_000), - (Charlie.into(), 200), - ]) + .with_balances(vec![(Alice.into(), 1_000), (Bob.into(), 1_000), (Charlie.into(), 200)]) .with_candidates(vec![(Alice.into(), 1_000), (Bob.into(), 1_000)]) .with_delegations(vec![ (Charlie.into(), Alice.into(), 100), @@ -504,9 +491,7 @@ fn delegator_delegation_count_works() { .prepare_test( Alice, Precompile1, - PCall::delegator_delegation_count { - delegator: Address(Charlie.into()), - }, + PCall::delegator_delegation_count { delegator: Address(Charlie.into()) }, ) .expect_cost(0) // TODO: Test db read/write costs .expect_no_logs() @@ -522,9 +507,7 @@ fn is_delegator_false() { .prepare_test( Alice, Precompile1, - PCall::is_delegator { - delegator: Address(Charlie.into()), - }, + PCall::is_delegator { delegator: Address(Charlie.into()) }, ) .expect_cost(0) // TODO: Test db read/write costs .expect_no_logs() @@ -545,9 +528,7 @@ fn is_delegator_true() { .prepare_test( Alice, Precompile1, - PCall::is_delegator { - delegator: Address(Bob.into()), - }, + PCall::is_delegator { delegator: Address(Bob.into()) }, ) .expect_cost(0) // TODO: Test db read/write costs .expect_no_logs() @@ -563,9 +544,7 @@ fn is_candidate_false() { .prepare_test( Alice, Precompile1, - PCall::is_candidate { - candidate: Address(Alice.into()), - }, + PCall::is_candidate { candidate: Address(Alice.into()) }, ) .expect_cost(0) // TODO: Test db read/write costs .expect_no_logs() @@ -585,9 +564,7 @@ fn is_candidate_true() { .prepare_test( Alice, Precompile1, - PCall::is_candidate { - candidate: Address(Alice.into()), - }, + PCall::is_candidate { candidate: Address(Alice.into()) }, ) .expect_cost(0) // TODO: Test db read/write costs .expect_no_logs() @@ -603,9 +580,7 @@ fn is_selected_candidate_false() { .prepare_test( Alice, Precompile1, - PCall::is_selected_candidate { - candidate: Address(Alice.into()), - }, + PCall::is_selected_candidate { candidate: Address(Alice.into()) }, ) .expect_cost(0) // TODO: Test db read/write costs .expect_no_logs() @@ -625,9 +600,7 @@ fn is_selected_candidate_true() { .prepare_test( Alice, Precompile1, - PCall::is_selected_candidate { - candidate: Address(Alice.into()), - }, + PCall::is_selected_candidate { candidate: Address(Alice.into()) }, ) .expect_cost(0) // TODO: Test db read/write costs .expect_no_logs() @@ -653,11 +626,7 @@ fn selected_candidates_works() { #[test] fn delegation_request_is_pending_works() { ExtBuilder::default() - .with_balances(vec![ - (Alice.into(), 1_000), - (Charlie.into(), 50), - (David.into(), 50), - ]) + .with_balances(vec![(Alice.into(), 1_000), (Charlie.into(), 50), (David.into(), 50)]) .with_candidates(vec![(Alice.into(), 1_000)]) .with_delegations(vec![(Charlie.into(), Alice.into(), 50)]) .build() @@ -681,9 +650,7 @@ fn delegation_request_is_pending_works() { .prepare_test( Charlie, Precompile1, - PCall::schedule_revoke_delegation { - candidate: Address(Alice.into()), - }, + PCall::schedule_revoke_delegation { candidate: Address(Alice.into()) }, ) .expect_cost(285706258) .expect_no_logs() @@ -736,9 +703,7 @@ fn candidate_exit_is_pending_works() { .prepare_test( Alice, Precompile1, - PCall::candidate_exit_is_pending { - candidate: Address(Alice.into()), - }, + PCall::candidate_exit_is_pending { candidate: Address(Alice.into()) }, ) .expect_cost(0) // TODO: Test db read/write costs .expect_no_logs() @@ -749,9 +714,7 @@ fn candidate_exit_is_pending_works() { .prepare_test( Alice, Precompile1, - PCall::schedule_leave_candidates { - candidate_count: 1.into(), - }, + PCall::schedule_leave_candidates { candidate_count: 1.into() }, ) .expect_cost(284172042) .expect_no_logs() @@ -762,9 +725,7 @@ fn candidate_exit_is_pending_works() { .prepare_test( Alice, Precompile1, - PCall::candidate_exit_is_pending { - candidate: Address(Alice.into()), - }, + PCall::candidate_exit_is_pending { candidate: Address(Alice.into()) }, ) .expect_cost(0) // TODO: Test db read/write costs .expect_no_logs() @@ -780,9 +741,7 @@ fn candidate_exit_is_pending_returns_false_for_non_existing_delegator() { .prepare_test( Alice, Precompile1, - PCall::candidate_exit_is_pending { - candidate: Address(Bob.into()), - }, + PCall::candidate_exit_is_pending { candidate: Address(Bob.into()) }, ) .expect_cost(0) // TODO: Test db read/write costs .expect_no_logs() @@ -802,9 +761,7 @@ fn candidate_request_is_pending_works() { .prepare_test( Alice, Precompile1, - PCall::candidate_request_is_pending { - candidate: Address(Alice.into()), - }, + PCall::candidate_request_is_pending { candidate: Address(Alice.into()) }, ) .expect_cost(0) // TODO: Test db read/write costs .expect_no_logs() @@ -826,9 +783,7 @@ fn candidate_request_is_pending_works() { .prepare_test( Alice, Precompile1, - PCall::candidate_request_is_pending { - candidate: Address(Alice.into()), - }, + PCall::candidate_request_is_pending { candidate: Address(Alice.into()) }, ) .expect_cost(0) // TODO: Test db read/write costs .expect_no_logs() @@ -844,9 +799,7 @@ fn candidate_request_is_pending_returns_false_for_non_existing_candidate() { .prepare_test( Alice, Precompile1, - PCall::candidate_request_is_pending { - candidate: Address(Bob.into()), - }, + PCall::candidate_request_is_pending { candidate: Address(Bob.into()) }, ) .expect_cost(0) // TODO: Test db read/write costs .expect_no_logs() @@ -911,11 +864,8 @@ fn join_candidates_works() { .with_balances(vec![(Alice.into(), 1_000)]) .build() .execute_with(|| { - let input_data = PCall::join_candidates { - amount: 1000.into(), - candidate_count: 0.into(), - } - .into(); + let input_data = + PCall::join_candidates { amount: 1000.into(), candidate_count: 0.into() }.into(); // Make sure the call goes through successfully assert_ok!( @@ -941,10 +891,7 @@ fn schedule_leave_candidates_works() { .with_candidates(vec![(Alice.into(), 1_000)]) .build() .execute_with(|| { - let input_data = PCall::schedule_leave_candidates { - candidate_count: 1.into(), - } - .into(); + let input_data = PCall::schedule_leave_candidates { candidate_count: 1.into() }.into(); // Make sure the call goes through successfully assert_ok!( @@ -1009,20 +956,15 @@ fn cancel_leave_candidates_works() { 1 )); - let input_data = PCall::cancel_leave_candidates { - candidate_count: 0.into(), - } - .into(); + let input_data = PCall::cancel_leave_candidates { candidate_count: 0.into() }.into(); // Make sure the call goes through successfully assert_ok!( RuntimeCall::Evm(evm_call(Alice, input_data)).dispatch(RuntimeOrigin::root()) ); - let expected: crate::mock::RuntimeEvent = StakingEvent::CancelledCandidateExit { - candidate: Alice.into(), - } - .into(); + let expected: crate::mock::RuntimeEvent = + StakingEvent::CancelledCandidateExit { candidate: Alice.into() }.into(); // Assert that the events vector contains the one expected assert!(events().contains(&expected)); }); @@ -1035,9 +977,7 @@ fn go_online_works() { .with_candidates(vec![(Alice.into(), 1_000)]) .build() .execute_with(|| { - assert_ok!(ParachainStaking::go_offline(RuntimeOrigin::signed( - Alice.into() - ))); + assert_ok!(ParachainStaking::go_offline(RuntimeOrigin::signed(Alice.into()))); let input_data = PCall::go_online {}.into(); @@ -1046,10 +986,8 @@ fn go_online_works() { RuntimeCall::Evm(evm_call(Alice, input_data)).dispatch(RuntimeOrigin::root()) ); - let expected: crate::mock::RuntimeEvent = StakingEvent::CandidateBackOnline { - candidate: Alice.into(), - } - .into(); + let expected: crate::mock::RuntimeEvent = + StakingEvent::CandidateBackOnline { candidate: Alice.into() }.into(); // Assert that the events vector contains the one expected assert!(events().contains(&expected)); }); @@ -1068,10 +1006,8 @@ fn go_offline_works() { RuntimeCall::Evm(evm_call(Alice, input_data)).dispatch(RuntimeOrigin::root()) ); - let expected: crate::mock::RuntimeEvent = StakingEvent::CandidateWentOffline { - candidate: Alice.into(), - } - .into(); + let expected: crate::mock::RuntimeEvent = + StakingEvent::CandidateWentOffline { candidate: Alice.into() }.into(); // Assert that the events vector contains the one expected assert!(events().contains(&expected)); }); @@ -1141,10 +1077,8 @@ fn execute_candidate_bond_less_works() { roll_to(10); // Make sure the call goes through successfully - let input_data = PCall::execute_candidate_bond_less { - candidate: Address(Alice.into()), - } - .into(); + let input_data = + PCall::execute_candidate_bond_less { candidate: Address(Alice.into()) }.into(); assert_ok!( RuntimeCall::Evm(evm_call(Alice, input_data)).dispatch(RuntimeOrigin::root()) @@ -1234,10 +1168,8 @@ fn schedule_revoke_delegation_works() { .with_delegations(vec![(Bob.into(), Alice.into(), 1_000)]) .build() .execute_with(|| { - let input_data = PCall::schedule_revoke_delegation { - candidate: Address(Alice.into()), - } - .into(); + let input_data = + PCall::schedule_revoke_delegation { candidate: Address(Alice.into()) }.into(); // Make sure the call goes through successfully assert_ok!(RuntimeCall::Evm(evm_call(Bob, input_data)).dispatch(RuntimeOrigin::root())); @@ -1262,11 +1194,9 @@ fn delegator_bond_more_works() { .with_delegations(vec![(Bob.into(), Alice.into(), 500)]) .build() .execute_with(|| { - let input_data = PCall::delegator_bond_more { - candidate: Address(Alice.into()), - more: 500.into(), - } - .into(); + let input_data = + PCall::delegator_bond_more { candidate: Address(Alice.into()), more: 500.into() } + .into(); assert_ok!(RuntimeCall::Evm(evm_call(Bob, input_data)).dispatch(RuntimeOrigin::root())); @@ -1399,10 +1329,8 @@ fn cancel_revoke_delegation_works() { Alice.into() )); - let input_data = PCall::cancel_delegation_request { - candidate: Address(Alice.into()), - } - .into(); + let input_data = + PCall::cancel_delegation_request { candidate: Address(Alice.into()) }.into(); // Make sure the call goes through successfully assert_ok!(RuntimeCall::Evm(evm_call(Bob, input_data)).dispatch(RuntimeOrigin::root())); @@ -1435,10 +1363,8 @@ fn cancel_delegator_bonded_less_works() { 500 )); - let input_data = PCall::cancel_delegation_request { - candidate: Address(Alice.into()), - } - .into(); + let input_data = + PCall::cancel_delegation_request { candidate: Address(Alice.into()) }.into(); // Make sure the call goes through successfully assert_ok!(RuntimeCall::Evm(evm_call(Bob, input_data)).dispatch(RuntimeOrigin::root())); @@ -1621,11 +1547,7 @@ fn set_auto_compound_fails_if_not_delegation() { #[test] fn get_delegator_total_staked_getter() { ExtBuilder::default() - .with_balances(vec![ - (Alice.into(), 1_000), - (Bob.into(), 1_000), - (Charlie.into(), 1_500), - ]) + .with_balances(vec![(Alice.into(), 1_000), (Bob.into(), 1_000), (Charlie.into(), 1_500)]) .with_candidates(vec![(Alice.into(), 1_000), (Bob.into(), 1_000)]) .with_delegations(vec![ (Charlie.into(), Alice.into(), 1_000), @@ -1637,9 +1559,7 @@ fn get_delegator_total_staked_getter() { .prepare_test( Alice, Precompile1, - PCall::get_delegator_total_staked { - delegator: Address(Charlie.into()), - }, + PCall::get_delegator_total_staked { delegator: Address(Charlie.into()) }, ) .execute_returns(U256::from(1_499)); }); @@ -1648,11 +1568,7 @@ fn get_delegator_total_staked_getter() { #[test] fn get_delegator_total_staked_getter_unknown() { ExtBuilder::default() - .with_balances(vec![ - (Alice.into(), 1_000), - (Bob.into(), 1_000), - (Charlie.into(), 1_500), - ]) + .with_balances(vec![(Alice.into(), 1_000), (Bob.into(), 1_000), (Charlie.into(), 1_500)]) .with_candidates(vec![(Alice.into(), 1_000), (Bob.into(), 1_000)]) .build() .execute_with(|| { @@ -1660,9 +1576,7 @@ fn get_delegator_total_staked_getter_unknown() { .prepare_test( Alice, Precompile1, - PCall::get_delegator_total_staked { - delegator: Address(Charlie.into()), - }, + PCall::get_delegator_total_staked { delegator: Address(Charlie.into()) }, ) .execute_returns(U256::zero()); }); @@ -1671,11 +1585,7 @@ fn get_delegator_total_staked_getter_unknown() { #[test] fn get_candidate_total_counted_getter() { ExtBuilder::default() - .with_balances(vec![ - (Alice.into(), 1_000), - (Bob.into(), 1_000), - (Charlie.into(), 1_500), - ]) + .with_balances(vec![(Alice.into(), 1_000), (Bob.into(), 1_000), (Charlie.into(), 1_500)]) .with_candidates(vec![(Alice.into(), 1_000), (Bob.into(), 1_000)]) .with_delegations(vec![ (Charlie.into(), Alice.into(), 1_000), @@ -1687,9 +1597,7 @@ fn get_candidate_total_counted_getter() { .prepare_test( Alice, Precompile1, - PCall::get_candidate_total_counted { - candidate: Address(Alice.into()), - }, + PCall::get_candidate_total_counted { candidate: Address(Alice.into()) }, ) .execute_returns(U256::from(2_000)); }); From 10a9d9b5b735eebdd8653c48382cded01c35ed6a Mon Sep 17 00:00:00 2001 From: Carla Date: Fri, 19 Jul 2024 12:41:47 +0100 Subject: [PATCH 03/16] Integrate Moonbeam's staking precompile (#673) * it compiles * test compiles * remove unneeded code * clippy issues * fix tests * merge * fix tests * include staking precompile in runtime * update staking precompile address * include readme * update readme * don't use default impl in mocks; resuse moonbeam address --- Cargo.lock | 1 + Cargo.toml | 2 +- precompiles/parachain-staking/README.md | 3 +++ precompiles/parachain-staking/src/lib.rs | 2 +- precompiles/parachain-staking/src/mock.rs | 16 ++++++---------- precompiles/parachain-staking/src/tests.rs | 16 ++++++++-------- runtime/laos/Cargo.toml | 6 +++--- runtime/laos/src/precompiles/mod.rs | 6 ++++++ 8 files changed, 29 insertions(+), 23 deletions(-) create mode 100644 precompiles/parachain-staking/README.md diff --git a/Cargo.lock b/Cargo.lock index 2487562e7..14e5eeb11 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5109,6 +5109,7 @@ dependencies = [ "pallet-evm-precompile-blake2", "pallet-evm-precompile-bn128", "pallet-evm-precompile-modexp", + "pallet-evm-precompile-parachain-staking", "pallet-evm-precompile-simple", "pallet-laos-evolution", "pallet-message-queue", diff --git a/Cargo.toml b/Cargo.toml index f8b9f4027..8b05fa852 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ async-trait = "0.1" num-format = "0.4" num-traits = "0.2" rbtag = "0.3" -rustc-hex = "2.1" +rustc-hex = { version = "2.1", default-features = false } structopt = "0.3" signal-hook = "0.3.16" signal-hook-async-std = "0.2.2" diff --git a/precompiles/parachain-staking/README.md b/precompiles/parachain-staking/README.md new file mode 100644 index 000000000..4537b1e87 --- /dev/null +++ b/precompiles/parachain-staking/README.md @@ -0,0 +1,3 @@ +# Pallet parachain-staking precompile + +This module has been forked from Moonbeam [v0.38.0](https://github.com/moonbeam-foundation/moonbeam/tree/v0.38.0/precompiles/parachain-staking), commit hash `c1417e62a741549ac889373b2a4fb0b6b0b83e74`. \ No newline at end of file diff --git a/precompiles/parachain-staking/src/lib.rs b/precompiles/parachain-staking/src/lib.rs index b5f197a65..5ba0e393c 100644 --- a/precompiles/parachain-staking/src/lib.rs +++ b/precompiles/parachain-staking/src/lib.rs @@ -98,7 +98,7 @@ where let candidate = Runtime::AddressMapping::into_account_id(candidate.0); - let points = >::awarded_pts(&round, &candidate); + let points = >::awarded_pts(round, &candidate); Ok(points) } diff --git a/precompiles/parachain-staking/src/mock.rs b/precompiles/parachain-staking/src/mock.rs index e56cdb9cd..d84436c5b 100644 --- a/precompiles/parachain-staking/src/mock.rs +++ b/precompiles/parachain-staking/src/mock.rs @@ -23,14 +23,13 @@ use frame_support::{ }; use frame_system::pallet_prelude::BlockNumberFor; use pallet_evm::{EnsureAddressNever, EnsureAddressRoot}; -use pallet_parachain_staking::{AwardedPts, InflationInfo, Points, Range}; +use pallet_parachain_staking::{rewards, AwardedPts, InflationInfo, Points, Range}; use precompile_utils::{ precompile_set::*, testing::{Alice, MockAccount}, }; use sp_consensus_slots::Slot; use sp_core::{H256, U256}; -use sp_io; use sp_runtime::{ traits::{BlakeTwo256, IdentityLookup}, BuildStorage, Perbill, Percent, @@ -64,7 +63,6 @@ impl frame_system::Config for Runtime { type BaseCallFilter = Everything; type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; - type RuntimeTask = RuntimeTask; type Nonce = u64; type Block = Block; type RuntimeCall = RuntimeCall; @@ -90,6 +88,7 @@ impl frame_system::Config for Runtime { parameter_types! { pub const ExistentialDeposit: u128 = 0; } + impl pallet_balances::Config for Runtime { type MaxReserves = (); type ReserveIdentifier = [u8; 4]; @@ -103,7 +102,7 @@ impl pallet_balances::Config for Runtime { type RuntimeHoldReason = (); type FreezeIdentifier = (); type MaxFreezes = (); - type RuntimeFreezeReason = (); + type MaxHolds = (); } const MAX_POV_SIZE: u64 = 5 * 1024 * 1024; @@ -122,7 +121,6 @@ parameter_types! { let block_gas_limit = BlockGasLimit::get().min(u64::MAX.into()).low_u64(); block_gas_limit.saturating_div(BLOCK_STORAGE_LIMIT) }; - pub SuicideQuickClearLimit: u32 = 0; } pub type Precompiles = @@ -149,8 +147,6 @@ impl pallet_evm::Config for Runtime { type FindAuthor = (); type OnCreate = (); type GasLimitPovSizeRatio = GasLimitPovSizeRatio; - type SuicideQuickClearLimit = SuicideQuickClearLimit; - type GasLimitStorageGrowthRatio = GasLimitStorageGrowthRatio; type Timestamp = Timestamp; type WeightInfo = pallet_evm::weights::SubstrateWeight; } @@ -214,15 +210,14 @@ impl pallet_parachain_staking::Config for Runtime { type MinCandidateStk = MinCandidateStk; type MinDelegation = MinDelegation; type BlockAuthor = BlockAuthor; - type PayoutCollatorReward = (); type OnCollatorPayout = (); + type PayoutReward = rewards::TransferFromRewardsAccount; type OnInactiveCollator = (); type OnNewRound = (); type SlotProvider = StakingRoundSlotProvider; type WeightInfo = (); type MaxCandidates = MaxCandidates; - type SlotDuration = frame_support::traits::ConstU64<6_000>; - type BlockTime = frame_support::traits::ConstU64<6_000>; + type SlotsPerYear = frame_support::traits::ConstU32<{ 31_557_600 / 6 }>; } pub(crate) struct ExtBuilder { @@ -311,6 +306,7 @@ impl ExtBuilder { parachain_bond_reserve_percent: GENESIS_PARACHAIN_BOND_RESERVE_PERCENT, blocks_per_round: GENESIS_BLOCKS_PER_ROUND, num_selected_candidates: GENESIS_NUM_SELECTED_CANDIDATES, + rewards_account: None, } .assimilate_storage(&mut t) .expect("Parachain Staking's storage can be assimilated"); diff --git a/precompiles/parachain-staking/src/tests.rs b/precompiles/parachain-staking/src/tests.rs index 6fded4056..7616966c8 100644 --- a/precompiles/parachain-staking/src/tests.rs +++ b/precompiles/parachain-staking/src/tests.rs @@ -199,7 +199,7 @@ fn awarded_points_zero() { .prepare_test( Alice, Precompile1, - PCall::awarded_points { round: 1u32.into(), candidate: Address(Bob.into()) }, + PCall::awarded_points { round: 1u32, candidate: Address(Bob.into()) }, ) .expect_cost(0) .expect_no_logs() @@ -221,7 +221,7 @@ fn awarded_points_non_zero() { .prepare_test( Alice, Precompile1, - PCall::awarded_points { round: 1u32.into(), candidate: Address(Alice.into()) }, + PCall::awarded_points { round: 1u32, candidate: Address(Alice.into()) }, ) .expect_cost(0) .expect_no_logs() @@ -652,7 +652,7 @@ fn delegation_request_is_pending_works() { Precompile1, PCall::schedule_revoke_delegation { candidate: Address(Alice.into()) }, ) - .expect_cost(285706258) + .expect_cost(303638378) .expect_no_logs() .execute_returns(()); @@ -716,7 +716,7 @@ fn candidate_exit_is_pending_works() { Precompile1, PCall::schedule_leave_candidates { candidate_count: 1.into() }, ) - .expect_cost(284172042) + .expect_cost(302793032) .expect_no_logs() .execute_returns(()); @@ -774,7 +774,7 @@ fn candidate_request_is_pending_works() { Precompile1, PCall::schedule_candidate_bond_less { less: 0.into() }, ) - .expect_cost(146735000) + .expect_cost(171000000) .expect_no_logs() .execute_returns(()); @@ -1446,7 +1446,7 @@ fn delegate_with_auto_compound_returns_error_if_percent_above_hundred() { }, ) .execute_reverts(|output| { - from_utf8(&output).unwrap().contains( + from_utf8(output).unwrap().contains( "auto_compound: Must be an integer between 0 and 100 included", ) }); @@ -1514,7 +1514,7 @@ fn set_auto_compound_returns_error_if_value_above_hundred_percent() { }, ) .execute_reverts(|output| { - from_utf8(&output) + from_utf8(output) .unwrap() .contains("value: Must be an integer between 0 and 100 included") }); @@ -1540,7 +1540,7 @@ fn set_auto_compound_fails_if_not_delegation() { delegator_delegation_count: 0.into(), }, ) - .execute_reverts(|output| from_utf8(&output).unwrap().contains("DelegatorDNE")); + .execute_reverts(|output| from_utf8(output).unwrap().contains("DelegatorDNE")); }); } diff --git a/runtime/laos/Cargo.toml b/runtime/laos/Cargo.toml index 35268e2dc..6859212ab 100644 --- a/runtime/laos/Cargo.toml +++ b/runtime/laos/Cargo.toml @@ -58,7 +58,7 @@ sp-staking = { workspace = true } pallet-asset-metadata-extender = { workspace = true } pallet-laos-evolution = { workspace = true } - +pallet-parachain-staking = { workspace = true } # Polkadot pallet-xcm = { workspace = true } @@ -95,8 +95,7 @@ pallet-evm-precompile-modexp = { workspace = true } pallet-evm-precompile-simple = { workspace = true } pallet-evm-precompile-bn128 = { workspace = true } pallet-evm-precompile-blake2 = { workspace = true } - -pallet-parachain-staking = { workspace = true } +pallet-evm-precompile-parachain-staking = { workspace = true } precompile-utils = { workspace = true } @@ -179,6 +178,7 @@ std = [ "pallet-evm-precompile-simple/std", "pallet-evm-precompile-bn128/std", "pallet-evm-precompile-blake2/std", + "pallet-evm-precompile-parachain-staking/std", "cumulus-pallet-session-benchmarking/std", "frame-benchmarking?/std", "frame-system-benchmarking?/std", diff --git a/runtime/laos/src/precompiles/mod.rs b/runtime/laos/src/precompiles/mod.rs index d6f5c4e2a..7bfe516dd 100644 --- a/runtime/laos/src/precompiles/mod.rs +++ b/runtime/laos/src/precompiles/mod.rs @@ -22,6 +22,7 @@ use pallet_asset_metadata_extender::precompiles::asset_metadata_extender::AssetM use pallet_evm_precompile_blake2::Blake2F; use pallet_evm_precompile_bn128::{Bn128Add, Bn128Mul, Bn128Pairing}; use pallet_evm_precompile_modexp::Modexp; +use pallet_evm_precompile_parachain_staking::ParachainStakingPrecompile; use pallet_evm_precompile_simple::{ECRecover, Identity, Ripemd160, Sha256}; use pallet_laos_evolution::{ precompiles::{ @@ -65,6 +66,11 @@ pub type LaosPrecompilesSetAt = ( AssetMetadataExtenderPrecompile, (CallableByContract, CallableByPrecompile), >, + PrecompileAt< + AddressU64<1031>, + ParachainStakingPrecompile, + (CallableByContract, CallableByPrecompile), + >, ); parameter_types! { From 036a8e0944bc2a9cc227cb93d81378ac2caea63c Mon Sep 17 00:00:00 2001 From: magecnion Date: Mon, 22 Jul 2024 14:21:51 +0200 Subject: [PATCH 04/16] merge --- runtime/laos/src/precompiles/mod.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/runtime/laos/src/precompiles/mod.rs b/runtime/laos/src/precompiles/mod.rs index 1b2a0eccf..6ae512b15 100644 --- a/runtime/laos/src/precompiles/mod.rs +++ b/runtime/laos/src/precompiles/mod.rs @@ -73,10 +73,10 @@ pub type LaosPrecompilesSetAt = ( (CallableByContract, CallableByPrecompile), >, PrecompileAt< - AddressU64<1031>, - ParachainStakingPrecompile, - (CallableByContract, CallableByPrecompile), ->, + AddressU64<1031>, + ParachainStakingPrecompile, + (CallableByContract, CallableByPrecompile), + >, ); parameter_types! { From f4437f1c191e4aefceba35e7fb0208ba0e33fe40 Mon Sep 17 00:00:00 2001 From: magecnion Date: Tue, 23 Jul 2024 11:57:03 +0200 Subject: [PATCH 05/16] test join candidates --- .github/workflows/e2e.yml | 2 +- e2e-tests/compile_contracts.sh | 1 + e2e-tests/package-lock.json | 1493 +++++++++++++++++++++------ e2e-tests/package.json | 3 + e2e-tests/tests/config.ts | 14 +- e2e-tests/tests/test-staking.ts | 55 + e2e-tests/tests/util.ts | 24 +- node/src/command.rs | 1 - runtime/laos/src/precompiles/mod.rs | 2 +- zombienet/README.md | 2 +- zombienet/native.toml | 6 +- 11 files changed, 1293 insertions(+), 310 deletions(-) create mode 100644 e2e-tests/tests/test-staking.ts diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index e444cb6f8..e22117204 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -40,7 +40,7 @@ jobs: export ZOMBIENET_RELAYCHAIN_COMMAND=./polkadot export ZOMBIENET_LAOS_COMMAND=./target/release/laos export ZOMBIENET_ASTAR_COMMAND=./astar-collator - ./zombienet-linux-x64 spawn ./zombienet/native.toml -p native & + ./zombienet-linux-x64 spawn ./zombienet/native.toml & echo "Zombienet started" - name: Wait for zombienet diff --git a/e2e-tests/compile_contracts.sh b/e2e-tests/compile_contracts.sh index 46a6e9ae6..93c9c95c0 100755 --- a/e2e-tests/compile_contracts.sh +++ b/e2e-tests/compile_contracts.sh @@ -5,6 +5,7 @@ cp -r ../pallets/laos-evolution/src/precompiles/evolution_collection_factory/con cp -r ../pallets/laos-evolution/src/precompiles/evolution_collection/contracts contracts cp -r ../pallets/asset-metadata-extender/src/precompiles/asset_metadata_extender/contracts contracts cp -r ../pallets/precompiles-benchmark/src/precompiles/vesting/contracts contracts +cp -r ../precompiles/parachain-staking contracts truffle compile rm -rf contracts diff --git a/e2e-tests/package-lock.json b/e2e-tests/package-lock.json index 853c72887..42c8e3807 100644 --- a/e2e-tests/package-lock.json +++ b/e2e-tests/package-lock.json @@ -9,6 +9,9 @@ "version": "1.0.0", "license": "ISC", "dependencies": { + "@polkadot/api": "^12.2.1", + "@polkadot/api-augment": "^12.2.1", + "@polkadot/types": "^12.2.1", "@types/chai": "^4.3.5", "@types/mocha": "^10.0.1", "chai": "^4.3.7", @@ -30,9 +33,9 @@ } }, "node_modules/@adraffy/ens-normalize": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/@adraffy/ens-normalize/-/ens-normalize-1.10.0.tgz", - "integrity": "sha512-nA9XHtlAkYfJxY7bce8DcN7eKxWWCWkU+1GR9d+U6MbNpfwQp8TI7vqOsBsMcHoT4mBu2kypKoSKnghEzOOq5Q==" + "version": "1.10.1", + "resolved": "https://registry.npmjs.org/@adraffy/ens-normalize/-/ens-normalize-1.10.1.tgz", + "integrity": "sha512-96Z2IP3mYmF1Xg2cDm8f1gWGf/HUVedQ3FMifV4kG/PQ4yEP51xDtRAEfhVNt5f/uzpNkZHwWQuUcu6D6K+Ekw==" }, "node_modules/@apollo/protobufjs": { "version": "1.2.7", @@ -1548,6 +1551,744 @@ "node": ">=14" } }, + "node_modules/@polkadot-api/json-rpc-provider": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/@polkadot-api/json-rpc-provider/-/json-rpc-provider-0.0.1.tgz", + "integrity": "sha512-/SMC/l7foRjpykLTUTacIH05H3mr9ip8b5xxfwXlVezXrNVLp3Cv0GX6uItkKd+ZjzVPf3PFrDF2B2/HLSNESA==", + "optional": true + }, + "node_modules/@polkadot-api/json-rpc-provider-proxy": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/@polkadot-api/json-rpc-provider-proxy/-/json-rpc-provider-proxy-0.0.1.tgz", + "integrity": "sha512-gmVDUP8LpCH0BXewbzqXF2sdHddq1H1q+XrAW2of+KZj4woQkIGBRGTJHeBEVHe30EB+UejR1N2dT4PO/RvDdg==", + "optional": true + }, + "node_modules/@polkadot-api/metadata-builders": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/@polkadot-api/metadata-builders/-/metadata-builders-0.0.1.tgz", + "integrity": "sha512-GCI78BHDzXAF/L2pZD6Aod/yl82adqQ7ftNmKg51ixRL02JpWUA+SpUKTJE5MY1p8kiJJIo09P2um24SiJHxNA==", + "optional": true, + "dependencies": { + "@polkadot-api/substrate-bindings": "0.0.1", + "@polkadot-api/utils": "0.0.1" + } + }, + "node_modules/@polkadot-api/observable-client": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/@polkadot-api/observable-client/-/observable-client-0.1.0.tgz", + "integrity": "sha512-GBCGDRztKorTLna/unjl/9SWZcRmvV58o9jwU2Y038VuPXZcr01jcw/1O3x+yeAuwyGzbucI/mLTDa1QoEml3A==", + "optional": true, + "dependencies": { + "@polkadot-api/metadata-builders": "0.0.1", + "@polkadot-api/substrate-bindings": "0.0.1", + "@polkadot-api/substrate-client": "0.0.1", + "@polkadot-api/utils": "0.0.1" + }, + "peerDependencies": { + "rxjs": ">=7.8.0" + } + }, + "node_modules/@polkadot-api/substrate-bindings": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/@polkadot-api/substrate-bindings/-/substrate-bindings-0.0.1.tgz", + "integrity": "sha512-bAe7a5bOPnuFVmpv7y4BBMRpNTnMmE0jtTqRUw/+D8ZlEHNVEJQGr4wu3QQCl7k1GnSV1wfv3mzIbYjErEBocg==", + "optional": true, + "dependencies": { + "@noble/hashes": "^1.3.1", + "@polkadot-api/utils": "0.0.1", + "@scure/base": "^1.1.1", + "scale-ts": "^1.6.0" + } + }, + "node_modules/@polkadot-api/substrate-client": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/@polkadot-api/substrate-client/-/substrate-client-0.0.1.tgz", + "integrity": "sha512-9Bg9SGc3AwE+wXONQoW8GC00N3v6lCZLW74HQzqB6ROdcm5VAHM4CB/xRzWSUF9CXL78ugiwtHx3wBcpx4H4Wg==", + "optional": true + }, + "node_modules/@polkadot-api/utils": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/@polkadot-api/utils/-/utils-0.0.1.tgz", + "integrity": "sha512-3j+pRmlF9SgiYDabSdZsBSsN5XHbpXOAce1lWj56IEEaFZVjsiCaxDOA7C9nCcgfVXuvnbxqqEGQvnY+QfBAUw==", + "optional": true + }, + "node_modules/@polkadot/api": { + "version": "12.2.1", + "resolved": "https://registry.npmjs.org/@polkadot/api/-/api-12.2.1.tgz", + "integrity": "sha512-G4PfdfiM3HVXmYTYYhH2+exLFiHtNJsJqbmk7Hj8ZOx0MzSUAFhtgcNXojcwUeW3dDhZRCrhwUApq3P4bvLpug==", + "dependencies": { + "@polkadot/api-augment": "12.2.1", + "@polkadot/api-base": "12.2.1", + "@polkadot/api-derive": "12.2.1", + "@polkadot/keyring": "^13.0.2", + "@polkadot/rpc-augment": "12.2.1", + "@polkadot/rpc-core": "12.2.1", + "@polkadot/rpc-provider": "12.2.1", + "@polkadot/types": "12.2.1", + "@polkadot/types-augment": "12.2.1", + "@polkadot/types-codec": "12.2.1", + "@polkadot/types-create": "12.2.1", + "@polkadot/types-known": "12.2.1", + "@polkadot/util": "^13.0.2", + "@polkadot/util-crypto": "^13.0.2", + "eventemitter3": "^5.0.1", + "rxjs": "^7.8.1", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@polkadot/api-augment": { + "version": "12.2.1", + "resolved": "https://registry.npmjs.org/@polkadot/api-augment/-/api-augment-12.2.1.tgz", + "integrity": "sha512-HrIiTRHL4KhcgeMhu85I5DBB5M0VGj3uA805lALFs/WuwQkUAvJZb6NUKhizG/q+di3KKzoyu1RM9As2LIP5Yg==", + "dependencies": { + "@polkadot/api-base": "12.2.1", + "@polkadot/rpc-augment": "12.2.1", + "@polkadot/types": "12.2.1", + "@polkadot/types-augment": "12.2.1", + "@polkadot/types-codec": "12.2.1", + "@polkadot/util": "^13.0.2", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@polkadot/api-augment/node_modules/tslib": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.3.tgz", + "integrity": "sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==" + }, + "node_modules/@polkadot/api-base": { + "version": "12.2.1", + "resolved": "https://registry.npmjs.org/@polkadot/api-base/-/api-base-12.2.1.tgz", + "integrity": "sha512-xyGt1/iK40/mLHrcmvjzdUWcOoES04+M9XlQ7WC3Hp+Tv/qk+WARXWkJKPIt3HqKrRu2mkyXvqPw2C/k7IhmHg==", + "dependencies": { + "@polkadot/rpc-core": "12.2.1", + "@polkadot/types": "12.2.1", + "@polkadot/util": "^13.0.2", + "rxjs": "^7.8.1", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@polkadot/api-base/node_modules/tslib": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.3.tgz", + "integrity": "sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==" + }, + "node_modules/@polkadot/api-derive": { + "version": "12.2.1", + "resolved": "https://registry.npmjs.org/@polkadot/api-derive/-/api-derive-12.2.1.tgz", + "integrity": "sha512-zk8/20QsUomEipN/DKB2MIgnFMr6JNIv/L/Rf3PsZXGkzOgVnFpjCjbIhHT4IscZXkO7jWmjnA3ID6sJ2+yA9Q==", + "dependencies": { + "@polkadot/api": "12.2.1", + "@polkadot/api-augment": "12.2.1", + "@polkadot/api-base": "12.2.1", + "@polkadot/rpc-core": "12.2.1", + "@polkadot/types": "12.2.1", + "@polkadot/types-codec": "12.2.1", + "@polkadot/util": "^13.0.2", + "@polkadot/util-crypto": "^13.0.2", + "rxjs": "^7.8.1", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@polkadot/api-derive/node_modules/tslib": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.3.tgz", + "integrity": "sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==" + }, + "node_modules/@polkadot/api/node_modules/eventemitter3": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-5.0.1.tgz", + "integrity": "sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA==" + }, + "node_modules/@polkadot/api/node_modules/tslib": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.3.tgz", + "integrity": "sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==" + }, + "node_modules/@polkadot/keyring": { + "version": "13.0.2", + "resolved": "https://registry.npmjs.org/@polkadot/keyring/-/keyring-13.0.2.tgz", + "integrity": "sha512-NeLbhyKDT5W8LI9seWTZGePxNTOVpDhv2018HSrEDwJq9Ie0C4TZhUf3KNERCkSveuThXjfQJMs+1CF33ZXPWw==", + "dependencies": { + "@polkadot/util": "13.0.2", + "@polkadot/util-crypto": "13.0.2", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@polkadot/util": "13.0.2", + "@polkadot/util-crypto": "13.0.2" + } + }, + "node_modules/@polkadot/keyring/node_modules/tslib": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.3.tgz", + "integrity": "sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==" + }, + "node_modules/@polkadot/networks": { + "version": "13.0.2", + "resolved": "https://registry.npmjs.org/@polkadot/networks/-/networks-13.0.2.tgz", + "integrity": "sha512-ABAL+vug/gIwkdFEzeh87JoJd0YKrxSYg/HjUrZ+Zis2ucxQEKpvtCpJ34ku+YrjacBfVqIAkkwd3ZdIPGq9aQ==", + "dependencies": { + "@polkadot/util": "13.0.2", + "@substrate/ss58-registry": "^1.46.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@polkadot/networks/node_modules/tslib": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.3.tgz", + "integrity": "sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==" + }, + "node_modules/@polkadot/rpc-augment": { + "version": "12.2.1", + "resolved": "https://registry.npmjs.org/@polkadot/rpc-augment/-/rpc-augment-12.2.1.tgz", + "integrity": "sha512-rKOyknD7rlZyvdsTq42EPSi4sPikBXRTb7svJ7+t0DwskSbpqLWOFvaX/hGhV4P0ZwobuIn5D82tkxG8c+mwDg==", + "dependencies": { + "@polkadot/rpc-core": "12.2.1", + "@polkadot/types": "12.2.1", + "@polkadot/types-codec": "12.2.1", + "@polkadot/util": "^13.0.2", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@polkadot/rpc-augment/node_modules/tslib": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.3.tgz", + "integrity": "sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==" + }, + "node_modules/@polkadot/rpc-core": { + "version": "12.2.1", + "resolved": "https://registry.npmjs.org/@polkadot/rpc-core/-/rpc-core-12.2.1.tgz", + "integrity": "sha512-ZAxA2Ymi+9ajyW89yD5W7R80fbgTX15Bu7DujhJZQXl7Gd+bUtejdvf8HhleMHRLKSK+YD6+c0qON4ucs2eC4A==", + "dependencies": { + "@polkadot/rpc-augment": "12.2.1", + "@polkadot/rpc-provider": "12.2.1", + "@polkadot/types": "12.2.1", + "@polkadot/util": "^13.0.2", + "rxjs": "^7.8.1", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@polkadot/rpc-core/node_modules/tslib": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.3.tgz", + "integrity": "sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==" + }, + "node_modules/@polkadot/rpc-provider": { + "version": "12.2.1", + "resolved": "https://registry.npmjs.org/@polkadot/rpc-provider/-/rpc-provider-12.2.1.tgz", + "integrity": "sha512-8RdJjmbJygCP4MZ4xrqUUqG0X4EQsT3A4QyZ5lQvxEVvY4Ti2ExIwpVYzYbaSpGut5kdg3atI0jh+qTju/s29Q==", + "dependencies": { + "@polkadot/keyring": "^13.0.2", + "@polkadot/types": "12.2.1", + "@polkadot/types-support": "12.2.1", + "@polkadot/util": "^13.0.2", + "@polkadot/util-crypto": "^13.0.2", + "@polkadot/x-fetch": "^13.0.2", + "@polkadot/x-global": "^13.0.2", + "@polkadot/x-ws": "^13.0.2", + "eventemitter3": "^5.0.1", + "mock-socket": "^9.3.1", + "nock": "^13.5.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "@substrate/connect": "0.8.10" + } + }, + "node_modules/@polkadot/rpc-provider/node_modules/eventemitter3": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-5.0.1.tgz", + "integrity": "sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA==" + }, + "node_modules/@polkadot/rpc-provider/node_modules/tslib": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.3.tgz", + "integrity": "sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==" + }, + "node_modules/@polkadot/types": { + "version": "12.2.1", + "resolved": "https://registry.npmjs.org/@polkadot/types/-/types-12.2.1.tgz", + "integrity": "sha512-axVbEnWLU9H7TMgRyECV79FWbfB4bNU9tkrCrBiOifTpJ4DT9AIbkNTgxI+wexywFbn8ATG6y1kw8leUnLDYvg==", + "dependencies": { + "@polkadot/keyring": "^13.0.2", + "@polkadot/types-augment": "12.2.1", + "@polkadot/types-codec": "12.2.1", + "@polkadot/types-create": "12.2.1", + "@polkadot/util": "^13.0.2", + "@polkadot/util-crypto": "^13.0.2", + "rxjs": "^7.8.1", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@polkadot/types-augment": { + "version": "12.2.1", + "resolved": "https://registry.npmjs.org/@polkadot/types-augment/-/types-augment-12.2.1.tgz", + "integrity": "sha512-4lVAc3HjcP6gjvX6Vea4/Fo7C98ktuavLtxVD5rYBCsNr8IPjG2kc21N+FL1pcv0vDiE0U7RnalWUhdX2nlZQg==", + "dependencies": { + "@polkadot/types": "12.2.1", + "@polkadot/types-codec": "12.2.1", + "@polkadot/util": "^13.0.2", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@polkadot/types-augment/node_modules/tslib": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.3.tgz", + "integrity": "sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==" + }, + "node_modules/@polkadot/types-codec": { + "version": "12.2.1", + "resolved": "https://registry.npmjs.org/@polkadot/types-codec/-/types-codec-12.2.1.tgz", + "integrity": "sha512-lOtY/9rTHrk8c9cQsks3vcNjd2VAC7KEgaCgn/FNyIFuwWP16lBH7SZXJBFq362nGJBiBEvembSDUdtpSYfRng==", + "dependencies": { + "@polkadot/util": "^13.0.2", + "@polkadot/x-bigint": "^13.0.2", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@polkadot/types-codec/node_modules/tslib": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.3.tgz", + "integrity": "sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==" + }, + "node_modules/@polkadot/types-create": { + "version": "12.2.1", + "resolved": "https://registry.npmjs.org/@polkadot/types-create/-/types-create-12.2.1.tgz", + "integrity": "sha512-ifhQUMJ/mpXC9+9DZ+/THyfU+KEk54FkDfGJ6IU8TgrYI9WynGsnToNjcv6ZLHMIg6rMkPBfUOxpGvZR4cVMVg==", + "dependencies": { + "@polkadot/types-codec": "12.2.1", + "@polkadot/util": "^13.0.2", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@polkadot/types-create/node_modules/tslib": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.3.tgz", + "integrity": "sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==" + }, + "node_modules/@polkadot/types-known": { + "version": "12.2.1", + "resolved": "https://registry.npmjs.org/@polkadot/types-known/-/types-known-12.2.1.tgz", + "integrity": "sha512-am/WAUabsKgsfQ6vaPfz4QvVdNGQDXc1/WL7n0mAD7iJDwzW5QbzkSlmSiUHrFtz+zSwREEQL+2nPEDQpVMDlg==", + "dependencies": { + "@polkadot/networks": "^13.0.2", + "@polkadot/types": "12.2.1", + "@polkadot/types-codec": "12.2.1", + "@polkadot/types-create": "12.2.1", + "@polkadot/util": "^13.0.2", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@polkadot/types-known/node_modules/tslib": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.3.tgz", + "integrity": "sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==" + }, + "node_modules/@polkadot/types-support": { + "version": "12.2.1", + "resolved": "https://registry.npmjs.org/@polkadot/types-support/-/types-support-12.2.1.tgz", + "integrity": "sha512-rPquPHi0KKCnyVEeVbFaSjlxMtkvg7I7UwFQRfwbUanOsI4jgR4sqYXgTJSWZwRiiVe0TmfSY5VMX4Gp06bJ9w==", + "dependencies": { + "@polkadot/util": "^13.0.2", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@polkadot/types-support/node_modules/tslib": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.3.tgz", + "integrity": "sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==" + }, + "node_modules/@polkadot/types/node_modules/tslib": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.3.tgz", + "integrity": "sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==" + }, + "node_modules/@polkadot/util": { + "version": "13.0.2", + "resolved": "https://registry.npmjs.org/@polkadot/util/-/util-13.0.2.tgz", + "integrity": "sha512-/6bS9sfhJLhs8QuqWaR1eRapzfDdGC5XAQZEPL9NN5sTTA7HxWos8rVleai0UERm8QUMabjZ9rK9KpzbXl7ojg==", + "dependencies": { + "@polkadot/x-bigint": "13.0.2", + "@polkadot/x-global": "13.0.2", + "@polkadot/x-textdecoder": "13.0.2", + "@polkadot/x-textencoder": "13.0.2", + "@types/bn.js": "^5.1.5", + "bn.js": "^5.2.1", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@polkadot/util-crypto": { + "version": "13.0.2", + "resolved": "https://registry.npmjs.org/@polkadot/util-crypto/-/util-crypto-13.0.2.tgz", + "integrity": "sha512-woUsJJ6zd/caL7U+D30a5oM/+WK9iNI00Y8aNUHSj6Zq/KPzK9uqDBaLGWwlgrejoMQkxxiU2X0f2LzP15AtQg==", + "dependencies": { + "@noble/curves": "^1.3.0", + "@noble/hashes": "^1.3.3", + "@polkadot/networks": "13.0.2", + "@polkadot/util": "13.0.2", + "@polkadot/wasm-crypto": "^7.3.2", + "@polkadot/wasm-util": "^7.3.2", + "@polkadot/x-bigint": "13.0.2", + "@polkadot/x-randomvalues": "13.0.2", + "@scure/base": "^1.1.5", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@polkadot/util": "13.0.2" + } + }, + "node_modules/@polkadot/util-crypto/node_modules/@noble/curves": { + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.4.2.tgz", + "integrity": "sha512-TavHr8qycMChk8UwMld0ZDRvatedkzWfH8IiaeGCfymOP5i0hSCozz9vHOL0nkwk7HRMlFnAiKpS2jrUmSybcw==", + "dependencies": { + "@noble/hashes": "1.4.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@polkadot/util-crypto/node_modules/@noble/hashes": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.4.0.tgz", + "integrity": "sha512-V1JJ1WTRUqHHrOSh597hURcMqVKVGL/ea3kv0gSnEdsEZ0/+VyPghM1lMNGc00z7CIQorSvbKpuJkxvuHbvdbg==", + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@polkadot/util-crypto/node_modules/tslib": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.3.tgz", + "integrity": "sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==" + }, + "node_modules/@polkadot/util/node_modules/tslib": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.3.tgz", + "integrity": "sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==" + }, + "node_modules/@polkadot/wasm-bridge": { + "version": "7.3.2", + "resolved": "https://registry.npmjs.org/@polkadot/wasm-bridge/-/wasm-bridge-7.3.2.tgz", + "integrity": "sha512-AJEXChcf/nKXd5Q/YLEV5dXQMle3UNT7jcXYmIffZAo/KI394a+/24PaISyQjoNC0fkzS1Q8T5pnGGHmXiVz2g==", + "dependencies": { + "@polkadot/wasm-util": "7.3.2", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@polkadot/util": "*", + "@polkadot/x-randomvalues": "*" + } + }, + "node_modules/@polkadot/wasm-bridge/node_modules/tslib": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.3.tgz", + "integrity": "sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==" + }, + "node_modules/@polkadot/wasm-crypto": { + "version": "7.3.2", + "resolved": "https://registry.npmjs.org/@polkadot/wasm-crypto/-/wasm-crypto-7.3.2.tgz", + "integrity": "sha512-+neIDLSJ6jjVXsjyZ5oLSv16oIpwp+PxFqTUaZdZDoA2EyFRQB8pP7+qLsMNk+WJuhuJ4qXil/7XiOnZYZ+wxw==", + "dependencies": { + "@polkadot/wasm-bridge": "7.3.2", + "@polkadot/wasm-crypto-asmjs": "7.3.2", + "@polkadot/wasm-crypto-init": "7.3.2", + "@polkadot/wasm-crypto-wasm": "7.3.2", + "@polkadot/wasm-util": "7.3.2", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@polkadot/util": "*", + "@polkadot/x-randomvalues": "*" + } + }, + "node_modules/@polkadot/wasm-crypto-asmjs": { + "version": "7.3.2", + "resolved": "https://registry.npmjs.org/@polkadot/wasm-crypto-asmjs/-/wasm-crypto-asmjs-7.3.2.tgz", + "integrity": "sha512-QP5eiUqUFur/2UoF2KKKYJcesc71fXhQFLT3D4ZjG28Mfk2ZPI0QNRUfpcxVQmIUpV5USHg4geCBNuCYsMm20Q==", + "dependencies": { + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@polkadot/util": "*" + } + }, + "node_modules/@polkadot/wasm-crypto-asmjs/node_modules/tslib": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.3.tgz", + "integrity": "sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==" + }, + "node_modules/@polkadot/wasm-crypto-init": { + "version": "7.3.2", + "resolved": "https://registry.npmjs.org/@polkadot/wasm-crypto-init/-/wasm-crypto-init-7.3.2.tgz", + "integrity": "sha512-FPq73zGmvZtnuJaFV44brze3Lkrki3b4PebxCy9Fplw8nTmisKo9Xxtfew08r0njyYh+uiJRAxPCXadkC9sc8g==", + "dependencies": { + "@polkadot/wasm-bridge": "7.3.2", + "@polkadot/wasm-crypto-asmjs": "7.3.2", + "@polkadot/wasm-crypto-wasm": "7.3.2", + "@polkadot/wasm-util": "7.3.2", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@polkadot/util": "*", + "@polkadot/x-randomvalues": "*" + } + }, + "node_modules/@polkadot/wasm-crypto-init/node_modules/tslib": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.3.tgz", + "integrity": "sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==" + }, + "node_modules/@polkadot/wasm-crypto-wasm": { + "version": "7.3.2", + "resolved": "https://registry.npmjs.org/@polkadot/wasm-crypto-wasm/-/wasm-crypto-wasm-7.3.2.tgz", + "integrity": "sha512-15wd0EMv9IXs5Abp1ZKpKKAVyZPhATIAHfKsyoWCEFDLSOA0/K0QGOxzrAlsrdUkiKZOq7uzSIgIDgW8okx2Mw==", + "dependencies": { + "@polkadot/wasm-util": "7.3.2", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@polkadot/util": "*" + } + }, + "node_modules/@polkadot/wasm-crypto-wasm/node_modules/tslib": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.3.tgz", + "integrity": "sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==" + }, + "node_modules/@polkadot/wasm-crypto/node_modules/tslib": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.3.tgz", + "integrity": "sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==" + }, + "node_modules/@polkadot/wasm-util": { + "version": "7.3.2", + "resolved": "https://registry.npmjs.org/@polkadot/wasm-util/-/wasm-util-7.3.2.tgz", + "integrity": "sha512-bmD+Dxo1lTZyZNxbyPE380wd82QsX+43mgCm40boyKrRppXEyQmWT98v/Poc7chLuskYb6X8IQ6lvvK2bGR4Tg==", + "dependencies": { + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@polkadot/util": "*" + } + }, + "node_modules/@polkadot/wasm-util/node_modules/tslib": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.3.tgz", + "integrity": "sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==" + }, + "node_modules/@polkadot/x-bigint": { + "version": "13.0.2", + "resolved": "https://registry.npmjs.org/@polkadot/x-bigint/-/x-bigint-13.0.2.tgz", + "integrity": "sha512-h2jKT/UaxiEal8LhQeH6+GCjO7GwEqVAD2SNYteCOXff6yNttqAZYJuHZsndbVjVNwqRNf8D5q/zZkD0HUd6xQ==", + "dependencies": { + "@polkadot/x-global": "13.0.2", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@polkadot/x-bigint/node_modules/tslib": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.3.tgz", + "integrity": "sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==" + }, + "node_modules/@polkadot/x-fetch": { + "version": "13.0.2", + "resolved": "https://registry.npmjs.org/@polkadot/x-fetch/-/x-fetch-13.0.2.tgz", + "integrity": "sha512-B/gf9iriUr6za/Ui7zIFBfHz7UBZ68rJEIteWHx1UHRCZPcLqv+hgpev6xIGrkfFljI0/lI7IwtN2qy6HYzFBg==", + "dependencies": { + "@polkadot/x-global": "13.0.2", + "node-fetch": "^3.3.2", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@polkadot/x-fetch/node_modules/node-fetch": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.2.tgz", + "integrity": "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==", + "dependencies": { + "data-uri-to-buffer": "^4.0.0", + "fetch-blob": "^3.1.4", + "formdata-polyfill": "^4.0.10" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/node-fetch" + } + }, + "node_modules/@polkadot/x-fetch/node_modules/tslib": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.3.tgz", + "integrity": "sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==" + }, + "node_modules/@polkadot/x-global": { + "version": "13.0.2", + "resolved": "https://registry.npmjs.org/@polkadot/x-global/-/x-global-13.0.2.tgz", + "integrity": "sha512-OoNIXLB5y8vIKpk4R+XmpDPhipNXWSUvEwUnpQT7NAxNLmzgMq1FhbrwBWWPRNHPrQonp7mqxV/X+v5lv1HW/g==", + "dependencies": { + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@polkadot/x-global/node_modules/tslib": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.3.tgz", + "integrity": "sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==" + }, + "node_modules/@polkadot/x-randomvalues": { + "version": "13.0.2", + "resolved": "https://registry.npmjs.org/@polkadot/x-randomvalues/-/x-randomvalues-13.0.2.tgz", + "integrity": "sha512-SGj+L0H/7TWZtSmtkWlixO4DFzXDdluI0UscN2h285os2Ns8PnmBbue+iJ8PVSzpY1BOxd66gvkkpboPz+jXFQ==", + "dependencies": { + "@polkadot/x-global": "13.0.2", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@polkadot/util": "13.0.2", + "@polkadot/wasm-util": "*" + } + }, + "node_modules/@polkadot/x-randomvalues/node_modules/tslib": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.3.tgz", + "integrity": "sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==" + }, + "node_modules/@polkadot/x-textdecoder": { + "version": "13.0.2", + "resolved": "https://registry.npmjs.org/@polkadot/x-textdecoder/-/x-textdecoder-13.0.2.tgz", + "integrity": "sha512-mauglOkTJxLGmLwLc3J5Jlq/W+SHP53eiy3F8/8JxxfnXrZKgWoQXGpvXYPjFnMZj0MzDSy/6GjyGWnDCgdQFA==", + "dependencies": { + "@polkadot/x-global": "13.0.2", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@polkadot/x-textdecoder/node_modules/tslib": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.3.tgz", + "integrity": "sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==" + }, + "node_modules/@polkadot/x-textencoder": { + "version": "13.0.2", + "resolved": "https://registry.npmjs.org/@polkadot/x-textencoder/-/x-textencoder-13.0.2.tgz", + "integrity": "sha512-Lq08H2OnVXj97uaOwg7tcmRS7a4VJYkHEeWO4FyEMOk6P6lU6W8OVNjjxG0se9PCEgmyZPUDbJI//1ynzP4cXw==", + "dependencies": { + "@polkadot/x-global": "13.0.2", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@polkadot/x-textencoder/node_modules/tslib": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.3.tgz", + "integrity": "sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==" + }, + "node_modules/@polkadot/x-ws": { + "version": "13.0.2", + "resolved": "https://registry.npmjs.org/@polkadot/x-ws/-/x-ws-13.0.2.tgz", + "integrity": "sha512-nC5e2eY5D5ZR5teQOB7ib+dWLbmNws86cTz3BjKCalSMBBIn6i3V9ElgABpierBmnSJe9D94EyrH1BxdVfDxUg==", + "dependencies": { + "@polkadot/x-global": "13.0.2", + "tslib": "^2.6.2", + "ws": "^8.16.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@polkadot/x-ws/node_modules/tslib": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.3.tgz", + "integrity": "sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==" + }, "node_modules/@protobufjs/aspromise": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/@protobufjs/aspromise/-/aspromise-1.1.2.tgz", @@ -1672,41 +2413,41 @@ "integrity": "sha512-1dgmkh+3so0+LlBWRhGA33ua4MYr7tUOj+a9Si28vUi0IUFNbff1T3sgpeDJI/LaC75bBYnQ0A3wXjn0OrRNBA==" }, "node_modules/@scure/base": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/@scure/base/-/base-1.1.3.tgz", - "integrity": "sha512-/+SgoRjLq7Xlf0CWuLHq2LUZeL/w65kfzAPG5NH9pcmBhs+nunQTn4gvdwgMTIXnt9b2C/1SeL2XiysZEyIC9Q==", + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/@scure/base/-/base-1.1.7.tgz", + "integrity": "sha512-PPNYBslrLNNUQ/Yad37MHYsNQtK67EhWb6WtSvNLLPo7SdVZgkUjD6Dg+5On7zNwmskf8OX7I7Nx5oN+MIWE0g==", "funding": { "url": "https://paulmillr.com/funding/" } }, "node_modules/@scure/bip32": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/@scure/bip32/-/bip32-1.3.1.tgz", - "integrity": "sha512-osvveYtyzdEVbt3OfwwXFr4P2iVBL5u1Q3q4ONBfDY/UpOuXmOlbgwc1xECEboY8wIays8Yt6onaWMUdUbfl0A==", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@scure/bip32/-/bip32-1.4.0.tgz", + "integrity": "sha512-sVUpc0Vq3tXCkDGYVWGIZTRfnvu8LoTDaev7vbwh0omSvVORONr960MQWdKqJDCReIEmTj3PAr73O3aoxz7OPg==", "dependencies": { - "@noble/curves": "~1.1.0", - "@noble/hashes": "~1.3.1", - "@scure/base": "~1.1.0" + "@noble/curves": "~1.4.0", + "@noble/hashes": "~1.4.0", + "@scure/base": "~1.1.6" }, "funding": { "url": "https://paulmillr.com/funding/" } }, "node_modules/@scure/bip32/node_modules/@noble/curves": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.1.0.tgz", - "integrity": "sha512-091oBExgENk/kGj3AZmtBDMpxQPDtxQABR2B9lb1JbVTs6ytdzZNwvhxQ4MWasRNEzlbEH8jCWFCwhF/Obj5AA==", + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.4.2.tgz", + "integrity": "sha512-TavHr8qycMChk8UwMld0ZDRvatedkzWfH8IiaeGCfymOP5i0hSCozz9vHOL0nkwk7HRMlFnAiKpS2jrUmSybcw==", "dependencies": { - "@noble/hashes": "1.3.1" + "@noble/hashes": "1.4.0" }, "funding": { "url": "https://paulmillr.com/funding/" } }, "node_modules/@scure/bip32/node_modules/@noble/hashes": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.1.tgz", - "integrity": "sha512-EbqwksQwz9xDRGfDST86whPBgM65E0OH/pCgqW0GBVzO22bNE+NuIbeTb714+IfSjU3aRk47EUvXIb5bTsenKA==", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.4.0.tgz", + "integrity": "sha512-V1JJ1WTRUqHHrOSh597hURcMqVKVGL/ea3kv0gSnEdsEZ0/+VyPghM1lMNGc00z7CIQorSvbKpuJkxvuHbvdbg==", "engines": { "node": ">= 16" }, @@ -1715,12 +2456,23 @@ } }, "node_modules/@scure/bip39": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@scure/bip39/-/bip39-1.2.1.tgz", - "integrity": "sha512-Z3/Fsz1yr904dduJD0NpiyRHhRYHdcnyh73FZWiV+/qhWi83wNJ3NWolYqCEN+ZWsUz2TWwajJggcRE9r1zUYg==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@scure/bip39/-/bip39-1.3.0.tgz", + "integrity": "sha512-disdg7gHuTDZtY+ZdkmLpPCk7fxZSu3gBiEGuoC1XYxv9cGx3Z6cpTggCgW6odSOOIXCiDjuGejW+aJKCY/pIQ==", "dependencies": { - "@noble/hashes": "~1.3.0", - "@scure/base": "~1.1.0" + "@noble/hashes": "~1.4.0", + "@scure/base": "~1.1.6" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@scure/bip39/node_modules/@noble/hashes": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.4.0.tgz", + "integrity": "sha512-V1JJ1WTRUqHHrOSh597hURcMqVKVGL/ea3kv0gSnEdsEZ0/+VyPghM1lMNGc00z7CIQorSvbKpuJkxvuHbvdbg==", + "engines": { + "node": ">= 16" }, "funding": { "url": "https://paulmillr.com/funding/" @@ -1755,6 +2507,54 @@ "url": "https://github.com/sindresorhus/is?sponsor=1" } }, + "node_modules/@substrate/connect": { + "version": "0.8.10", + "resolved": "https://registry.npmjs.org/@substrate/connect/-/connect-0.8.10.tgz", + "integrity": "sha512-DIyQ13DDlXqVFnLV+S6/JDgiGowVRRrh18kahieJxhgvzcWicw5eLc6jpfQ0moVVLBYkO7rctB5Wreldwpva8w==", + "deprecated": "versions below 1.x are no longer maintained", + "optional": true, + "dependencies": { + "@substrate/connect-extension-protocol": "^2.0.0", + "@substrate/connect-known-chains": "^1.1.4", + "@substrate/light-client-extension-helpers": "^0.0.6", + "smoldot": "2.0.22" + } + }, + "node_modules/@substrate/connect-extension-protocol": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@substrate/connect-extension-protocol/-/connect-extension-protocol-2.0.0.tgz", + "integrity": "sha512-nKu8pDrE3LNCEgJjZe1iGXzaD6OSIDD4Xzz/yo4KO9mQ6LBvf49BVrt4qxBFGL6++NneLiWUZGoh+VSd4PyVIg==", + "optional": true + }, + "node_modules/@substrate/connect-known-chains": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/@substrate/connect-known-chains/-/connect-known-chains-1.1.11.tgz", + "integrity": "sha512-jl6RKTn9bDezKqlOj2X9B/BVftIqqnU9tgr/9WXMCBdLedzQaO/DRRb0c5VqF1+DH8dHV2q5MyKN9gR+KGt7ow==", + "optional": true + }, + "node_modules/@substrate/light-client-extension-helpers": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/@substrate/light-client-extension-helpers/-/light-client-extension-helpers-0.0.6.tgz", + "integrity": "sha512-girltEuxQ1BvkJWmc8JJlk4ZxnlGXc/wkLcNguhY+UoDEMBK0LsdtfzQKIfrIehi4QdeSBlFEFBoI4RqPmsZzA==", + "optional": true, + "dependencies": { + "@polkadot-api/json-rpc-provider": "0.0.1", + "@polkadot-api/json-rpc-provider-proxy": "0.0.1", + "@polkadot-api/observable-client": "0.1.0", + "@polkadot-api/substrate-client": "0.0.1", + "@substrate/connect-extension-protocol": "^2.0.0", + "@substrate/connect-known-chains": "^1.1.4", + "rxjs": "^7.8.1" + }, + "peerDependencies": { + "smoldot": "2.x" + } + }, + "node_modules/@substrate/ss58-registry": { + "version": "1.49.0", + "resolved": "https://registry.npmjs.org/@substrate/ss58-registry/-/ss58-registry-1.49.0.tgz", + "integrity": "sha512-leW6Ix4LD7XgvxT7+aobPWSw+WvPcN2Rxof1rmd0mNC5t2n99k1N7UNEvz7YEFSOUeHWmKIY7F5q8KeIqYoHfA==" + }, "node_modules/@szmarczak/http-timer": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-5.0.1.tgz", @@ -1920,9 +2720,9 @@ } }, "node_modules/@truffle/dashboard-message-bus-client/node_modules/ws": { - "version": "7.5.9", - "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.9.tgz", - "integrity": "sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==", + "version": "7.5.10", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.10.tgz", + "integrity": "sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ==", "optional": true, "engines": { "node": ">=8.3.0" @@ -3278,9 +4078,9 @@ } }, "node_modules/@types/bn.js": { - "version": "5.1.3", - "resolved": "https://registry.npmjs.org/@types/bn.js/-/bn.js-5.1.3.tgz", - "integrity": "sha512-wT1B4iIO82ecXkdN6waCK8Ou7E71WU+mP1osDA5Q8c6Ur+ozU2vIKUIhSpUr6uE5L2YHocKS1Z2jG2fBC1YVeg==", + "version": "5.1.5", + "resolved": "https://registry.npmjs.org/@types/bn.js/-/bn.js-5.1.5.tgz", + "integrity": "sha512-V46N0zwKRF5Q00AZ6hWtN0T8gGmDUaUzLWQvHFo5yThtVwK/VCenFY3wXVbOvNfajEpsTfQM4IN9k/d6gUVX3A==", "dependencies": { "@types/node": "*" } @@ -4087,11 +4887,11 @@ } }, "node_modules/braces": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", "dependencies": { - "fill-range": "^7.0.1" + "fill-range": "^7.1.1" }, "engines": { "node": ">=8" @@ -4662,9 +5462,9 @@ } }, "node_modules/cookie": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.5.0.tgz", - "integrity": "sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==", + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.6.0.tgz", + "integrity": "sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==", "engines": { "node": ">= 0.6" } @@ -4794,6 +5594,14 @@ "node": ">=0.10" } }, + "node_modules/data-uri-to-buffer": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz", + "integrity": "sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==", + "engines": { + "node": ">= 12" + } + }, "node_modules/dataloader": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/dataloader/-/dataloader-2.1.0.tgz", @@ -5248,13 +6056,14 @@ } }, "node_modules/es5-ext": { - "version": "0.10.62", - "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.62.tgz", - "integrity": "sha512-BHLqn0klhEpnOKSrzn/Xsz2UIW8j+cGmo9JLzr8BiUapV8hPL9+FliFqjwr9ngW7jWdnxv6eO+/LqyhJVqgrjA==", + "version": "0.10.64", + "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.64.tgz", + "integrity": "sha512-p2snDhiLaXe6dahss1LddxqEm+SkuDvV8dnIQG0MWjyHpcMNfXKPE+/Cc0y+PhxJX3A4xGNeFCj5oc0BUh6deg==", "hasInstallScript": true, "dependencies": { "es6-iterator": "^2.0.3", "es6-symbol": "^3.1.3", + "esniff": "^2.0.1", "next-tick": "^1.1.0" }, "engines": { @@ -5309,6 +6118,25 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/esniff": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/esniff/-/esniff-2.0.1.tgz", + "integrity": "sha512-kTUIGKQ/mDPFoJ0oVfcmyJn4iBDRptjNVIzwIFR7tqWXdVI9xfA2RMwY/gbSpJG3lkdWNEjLap/NqVHZiJsdfg==", + "dependencies": { + "d": "^1.0.1", + "es5-ext": "^0.10.62", + "event-emitter": "^0.3.5", + "type": "^2.7.2" + }, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/esniff/node_modules/type": { + "version": "2.7.3", + "resolved": "https://registry.npmjs.org/type/-/type-2.7.3.tgz", + "integrity": "sha512-8j+1QmAbPvLZow5Qpi6NCaN8FB60p/6x8/vfNqOk/hC+HuvFZhL4+WfekuhQLiqFZXOgQdrs3B+XxEmCc6b3FQ==" + }, "node_modules/etag": { "version": "1.8.1", "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", @@ -5373,31 +6201,31 @@ } }, "node_modules/ethereum-cryptography": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ethereum-cryptography/-/ethereum-cryptography-2.1.2.tgz", - "integrity": "sha512-Z5Ba0T0ImZ8fqXrJbpHcbpAvIswRte2wGNR/KePnu8GbbvgJ47lMxT/ZZPG6i9Jaht4azPDop4HaM00J0J59ug==", + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ethereum-cryptography/-/ethereum-cryptography-2.2.1.tgz", + "integrity": "sha512-r/W8lkHSiTLxUxW8Rf3u4HGB0xQweG2RyETjywylKZSzLWoWAijRz8WCuOtJ6wah+avllXBqZuk29HCCvhEIRg==", "dependencies": { - "@noble/curves": "1.1.0", - "@noble/hashes": "1.3.1", - "@scure/bip32": "1.3.1", - "@scure/bip39": "1.2.1" + "@noble/curves": "1.4.2", + "@noble/hashes": "1.4.0", + "@scure/bip32": "1.4.0", + "@scure/bip39": "1.3.0" } }, "node_modules/ethereum-cryptography/node_modules/@noble/curves": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.1.0.tgz", - "integrity": "sha512-091oBExgENk/kGj3AZmtBDMpxQPDtxQABR2B9lb1JbVTs6ytdzZNwvhxQ4MWasRNEzlbEH8jCWFCwhF/Obj5AA==", + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.4.2.tgz", + "integrity": "sha512-TavHr8qycMChk8UwMld0ZDRvatedkzWfH8IiaeGCfymOP5i0hSCozz9vHOL0nkwk7HRMlFnAiKpS2jrUmSybcw==", "dependencies": { - "@noble/hashes": "1.3.1" + "@noble/hashes": "1.4.0" }, "funding": { "url": "https://paulmillr.com/funding/" } }, "node_modules/ethereum-cryptography/node_modules/@noble/hashes": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.1.tgz", - "integrity": "sha512-EbqwksQwz9xDRGfDST86whPBgM65E0OH/pCgqW0GBVzO22bNE+NuIbeTb714+IfSjU3aRk47EUvXIb5bTsenKA==", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.4.0.tgz", + "integrity": "sha512-V1JJ1WTRUqHHrOSh597hURcMqVKVGL/ea3kv0gSnEdsEZ0/+VyPghM1lMNGc00z7CIQorSvbKpuJkxvuHbvdbg==", "engines": { "node": ">= 16" }, @@ -5443,9 +6271,9 @@ } }, "node_modules/ethers": { - "version": "6.8.0", - "resolved": "https://registry.npmjs.org/ethers/-/ethers-6.8.0.tgz", - "integrity": "sha512-zrFbmQRlraM+cU5mE4CZTLBurZTs2gdp2ld0nG/f3ecBK+x6lZ69KSxBqZ4NjclxwfTxl5LeNufcBbMsTdY53Q==", + "version": "6.13.1", + "resolved": "https://registry.npmjs.org/ethers/-/ethers-6.13.1.tgz", + "integrity": "sha512-hdJ2HOxg/xx97Lm9HdCWk949BfYqYWpyw4//78SiwOLgASyfrNszfMUNB2joKjvGUdwhHfaiMMFFwacVVoLR9A==", "funding": [ { "type": "individual", @@ -5457,13 +6285,13 @@ } ], "dependencies": { - "@adraffy/ens-normalize": "1.10.0", + "@adraffy/ens-normalize": "1.10.1", "@noble/curves": "1.2.0", "@noble/hashes": "1.3.2", "@types/node": "18.15.13", "aes-js": "4.0.0-beta.5", "tslib": "2.4.0", - "ws": "8.5.0" + "ws": "8.17.1" }, "engines": { "node": ">=14.0.0" @@ -5492,6 +6320,15 @@ "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.6.tgz", "integrity": "sha512-XWwnNNFCuuSQ0m3r3C4LE3EiORltHd9M05pq6FOlVeiophzRbMo50Sbz1ehl8K3Z+jw9+vmgnXefY1hz8X+2wA==" }, + "node_modules/event-emitter": { + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/event-emitter/-/event-emitter-0.3.5.tgz", + "integrity": "sha512-D9rRn9y7kLPnJ+hMq7S/nhvoKwwvVJahBi2BPmx3bvbsEdK3W9ii8cBSGjP+72/LnM4n6fo3+dkCX5FeTQruXA==", + "dependencies": { + "d": "1", + "es5-ext": "~0.10.14" + } + }, "node_modules/event-target-shim": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", @@ -5516,16 +6353,16 @@ } }, "node_modules/express": { - "version": "4.18.2", - "resolved": "https://registry.npmjs.org/express/-/express-4.18.2.tgz", - "integrity": "sha512-5/PsL6iGPdfQ/lKM1UuielYgv3BUoJfz1aUwU9vHZ+J7gyvwdQXFEBIEIaxeGf0GIcreATNyBExtalisDbuMqQ==", + "version": "4.19.2", + "resolved": "https://registry.npmjs.org/express/-/express-4.19.2.tgz", + "integrity": "sha512-5T6nhjsT+EOMzuck8JjBHARTHfMht0POzlA60WV2pMD3gyXw2LZnZ+ueGdNxG+0calOJcWKbpFcuzLZ91YWq9Q==", "dependencies": { "accepts": "~1.3.8", "array-flatten": "1.1.1", - "body-parser": "1.20.1", + "body-parser": "1.20.2", "content-disposition": "0.5.4", "content-type": "~1.0.4", - "cookie": "0.5.0", + "cookie": "0.6.0", "cookie-signature": "1.0.6", "debug": "2.6.9", "depd": "2.0.0", @@ -5556,29 +6393,6 @@ "node": ">= 0.10.0" } }, - "node_modules/express/node_modules/body-parser": { - "version": "1.20.1", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz", - "integrity": "sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw==", - "dependencies": { - "bytes": "3.1.2", - "content-type": "~1.0.4", - "debug": "2.6.9", - "depd": "2.0.0", - "destroy": "1.2.0", - "http-errors": "2.0.0", - "iconv-lite": "0.4.24", - "on-finished": "2.4.1", - "qs": "6.11.0", - "raw-body": "2.5.1", - "type-is": "~1.6.18", - "unpipe": "1.0.0" - }, - "engines": { - "node": ">= 0.8", - "npm": "1.2.8000 || >= 1.4.16" - } - }, "node_modules/express/node_modules/debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", @@ -5592,20 +6406,6 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" }, - "node_modules/express/node_modules/raw-body": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.1.tgz", - "integrity": "sha512-qqJBtEyVgS0ZmPGdCFPWJ3FreoqvG4MVQln/kCgF7Olq95IbOp0/BWyMwbdtn4VTvkM8Y7khCQ2Xgk/tcrCXig==", - "dependencies": { - "bytes": "3.1.2", - "http-errors": "2.0.0", - "iconv-lite": "0.4.24", - "unpipe": "1.0.0" - }, - "engines": { - "node": ">= 0.8" - } - }, "node_modules/ext": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/ext/-/ext-1.7.0.tgz", @@ -5657,6 +6457,28 @@ "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==" }, + "node_modules/fetch-blob": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz", + "integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/jimmywarting" + }, + { + "type": "paypal", + "url": "https://paypal.me/jimmywarting" + } + ], + "dependencies": { + "node-domexception": "^1.0.0", + "web-streams-polyfill": "^3.0.3" + }, + "engines": { + "node": "^12.20 || >= 14.13" + } + }, "node_modules/fetch-cookie": { "version": "0.11.0", "resolved": "https://registry.npmjs.org/fetch-cookie/-/fetch-cookie-0.11.0.tgz", @@ -5670,9 +6492,9 @@ } }, "node_modules/fill-range": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", "dependencies": { "to-regex-range": "^5.0.1" }, @@ -5734,9 +6556,9 @@ } }, "node_modules/follow-redirects": { - "version": "1.15.3", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.3.tgz", - "integrity": "sha512-1VzOtuEM8pC9SFU1E+8KfTjZyMztRsgEfwQl44z8A25uy13jSzTj6dyK2Df52iV0vgHCfBwLhDWevLn95w5v6Q==", + "version": "1.15.6", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz", + "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==", "funding": [ { "type": "individual", @@ -5817,6 +6639,17 @@ "resolved": "https://registry.npmjs.org/form-data-encoder/-/form-data-encoder-1.7.1.tgz", "integrity": "sha512-EFRDrsMm/kyqbTQocNvRXMLjc7Es2Vk+IQFx/YW7hkUH1eBl4J1fqiP34l74Yt0pFLCNpc06fkbVk00008mzjg==" }, + "node_modules/formdata-polyfill": { + "version": "4.0.10", + "resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz", + "integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==", + "dependencies": { + "fetch-blob": "^3.1.2" + }, + "engines": { + "node": ">=12.20.0" + } + }, "node_modules/forwarded": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", @@ -11399,6 +12232,14 @@ "resolved": "https://registry.npmjs.org/mock-fs/-/mock-fs-4.14.0.tgz", "integrity": "sha512-qYvlv/exQ4+svI3UOvPUpLDF0OMX5euvUH0Ny4N5QyRyhNdgAgUrVH3iUINSzEPLvx0kbo/Bp28GJKIqvE7URw==" }, + "node_modules/mock-socket": { + "version": "9.3.1", + "resolved": "https://registry.npmjs.org/mock-socket/-/mock-socket-9.3.1.tgz", + "integrity": "sha512-qxBgB7Qa2sEQgHFjj0dSigq7fX4k6Saisd5Nelwp2q8mlbAFh5dHV9JTTlF8viYJLSSWgMCZFUom8PJcMNBoJw==", + "engines": { + "node": ">= 8" + } + }, "node_modules/ms": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", @@ -11537,6 +12378,19 @@ "lower-case": "^1.1.1" } }, + "node_modules/nock": { + "version": "13.5.4", + "resolved": "https://registry.npmjs.org/nock/-/nock-13.5.4.tgz", + "integrity": "sha512-yAyTfdeNJGGBFxWdzSKCBYxs5FxLbCg5X5Q4ets974hcQzG1+qCxvIyOo4j2Ry6MUlhWVMX4OoYDefAIIwupjw==", + "dependencies": { + "debug": "^4.1.0", + "json-stringify-safe": "^5.0.1", + "propagate": "^2.0.0" + }, + "engines": { + "node": ">= 10.13" + } + }, "node_modules/node-abort-controller": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/node-abort-controller/-/node-abort-controller-3.1.1.tgz", @@ -11548,6 +12402,24 @@ "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-2.0.2.tgz", "integrity": "sha512-Ntyt4AIXyaLIuMHF6IOoTakB3K+RWxwtsHNRxllEoA6vPwP9o4866g6YWDLUdnucilZhmkxiHwHr11gAENw+QA==" }, + "node_modules/node-domexception": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz", + "integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/jimmywarting" + }, + { + "type": "github", + "url": "https://paypal.me/jimmywarting" + } + ], + "engines": { + "node": ">=10.5.0" + } + }, "node_modules/node-fetch": { "version": "2.7.0", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", @@ -12404,6 +13276,14 @@ "node": ">= 0.6.0" } }, + "node_modules/propagate": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/propagate/-/propagate-2.0.1.tgz", + "integrity": "sha512-vGrhOavPSTz4QVNuBNdcNXePNdNMaO1xj9yBeH1ScQPjk/rhg9sSlCXPhMkFuaNNW/syTvYqsnbIJxMBfRbbag==", + "engines": { + "node": ">= 8" + } + }, "node_modules/proxy-addr": { "version": "2.0.7", "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", @@ -12419,8 +13299,7 @@ "node_modules/proxy-from-env": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", - "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==", - "optional": true + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" }, "node_modules/prr": { "version": "1.0.1", @@ -12968,6 +13847,12 @@ "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, + "node_modules/scale-ts": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/scale-ts/-/scale-ts-1.6.0.tgz", + "integrity": "sha512-Ja5VCjNZR8TGKhUumy9clVVxcDpM+YFjAnkMuwQy68Hixio3VRRvWdE3g8T/yC+HXA0ZDQl2TGyUmtmbcVl40Q==", + "optional": true + }, "node_modules/scrypt-js": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/scrypt-js/-/scrypt-js-3.0.1.tgz", @@ -13225,6 +14110,15 @@ "node": ">=4" } }, + "node_modules/smoldot": { + "version": "2.0.22", + "resolved": "https://registry.npmjs.org/smoldot/-/smoldot-2.0.22.tgz", + "integrity": "sha512-B50vRgTY6v3baYH6uCgL15tfaag5tcS2o/P5q1OiXcKGv1axZDfz2dzzMuIkVpyMR2ug11F6EAtQlmYBQd292g==", + "optional": true, + "dependencies": { + "ws": "^8.8.1" + } + }, "node_modules/snake-case": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/snake-case/-/snake-case-2.1.0.tgz", @@ -14175,15 +15069,15 @@ "optional": true }, "node_modules/wait-on": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/wait-on/-/wait-on-7.0.1.tgz", - "integrity": "sha512-9AnJE9qTjRQOlTZIldAaf/da2eW0eSRSgcqq85mXQja/DW3MriHxkpODDSUEg+Gri/rKEcXUZHe+cevvYItaog==", + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/wait-on/-/wait-on-7.2.0.tgz", + "integrity": "sha512-wCQcHkRazgjG5XoAq9jbTMLpNIjoSlZslrJ2+N9MxDsGEv1HnFoVjOCexL0ESva7Y9cu350j+DWADdk54s4AFQ==", "dependencies": { - "axios": "^0.27.2", - "joi": "^17.7.0", + "axios": "^1.6.1", + "joi": "^17.11.0", "lodash": "^4.17.21", - "minimist": "^1.2.7", - "rxjs": "^7.8.0" + "minimist": "^1.2.8", + "rxjs": "^7.8.1" }, "bin": { "wait-on": "bin/wait-on" @@ -14193,36 +15087,45 @@ } }, "node_modules/wait-on/node_modules/axios": { - "version": "0.27.2", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.27.2.tgz", - "integrity": "sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==", + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.2.tgz", + "integrity": "sha512-2A8QhOMrbomlDuiLeK9XibIBzuHeRcqqNOHp0Cyp5EoJ1IFDh+XZH3A6BkXtv0K4gFGCI0Y4BM7B1wOEi0Rmgw==", "dependencies": { - "follow-redirects": "^1.14.9", - "form-data": "^4.0.0" + "follow-redirects": "^1.15.6", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + } + }, + "node_modules/web-streams-polyfill": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.3.3.tgz", + "integrity": "sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw==", + "engines": { + "node": ">= 8" } }, "node_modules/web3": { - "version": "1.10.3", - "resolved": "https://registry.npmjs.org/web3/-/web3-1.10.3.tgz", - "integrity": "sha512-DgUdOOqC/gTqW+VQl1EdPxrVRPB66xVNtuZ5KD4adVBtko87hkgM8BTZ0lZ8IbUfnQk6DyjcDujMiH3oszllAw==", + "version": "1.10.4", + "resolved": "https://registry.npmjs.org/web3/-/web3-1.10.4.tgz", + "integrity": "sha512-kgJvQZjkmjOEKimx/tJQsqWfRDPTTcBfYPa9XletxuHLpHcXdx67w8EFn5AW3eVxCutE9dTVHgGa9VYe8vgsEA==", "hasInstallScript": true, "dependencies": { - "web3-bzz": "1.10.3", - "web3-core": "1.10.3", - "web3-eth": "1.10.3", - "web3-eth-personal": "1.10.3", - "web3-net": "1.10.3", - "web3-shh": "1.10.3", - "web3-utils": "1.10.3" + "web3-bzz": "1.10.4", + "web3-core": "1.10.4", + "web3-eth": "1.10.4", + "web3-eth-personal": "1.10.4", + "web3-net": "1.10.4", + "web3-shh": "1.10.4", + "web3-utils": "1.10.4" }, "engines": { "node": ">=8.0.0" } }, "node_modules/web3-bzz": { - "version": "1.10.3", - "resolved": "https://registry.npmjs.org/web3-bzz/-/web3-bzz-1.10.3.tgz", - "integrity": "sha512-XDIRsTwekdBXtFytMpHBuun4cK4x0ZMIDXSoo1UVYp+oMyZj07c7gf7tNQY5qZ/sN+CJIas4ilhN25VJcjSijQ==", + "version": "1.10.4", + "resolved": "https://registry.npmjs.org/web3-bzz/-/web3-bzz-1.10.4.tgz", + "integrity": "sha512-ZZ/X4sJ0Uh2teU9lAGNS8EjveEppoHNQiKlOXAjedsrdWuaMErBPdLQjXfcrYvN6WM6Su9PMsAxf3FXXZ+HwQw==", "hasInstallScript": true, "dependencies": { "@types/node": "^12.12.6", @@ -14239,38 +15142,38 @@ "integrity": "sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ==" }, "node_modules/web3-core": { - "version": "1.10.3", - "resolved": "https://registry.npmjs.org/web3-core/-/web3-core-1.10.3.tgz", - "integrity": "sha512-Vbk0/vUNZxJlz3RFjAhNNt7qTpX8yE3dn3uFxfX5OHbuon5u65YEOd3civ/aQNW745N0vGUlHFNxxmn+sG9DIw==", + "version": "1.10.4", + "resolved": "https://registry.npmjs.org/web3-core/-/web3-core-1.10.4.tgz", + "integrity": "sha512-B6elffYm81MYZDTrat7aEhnhdtVE3lDBUZft16Z8awYMZYJDbnykEbJVS+l3mnA7AQTnSDr/1MjWofGDLBJPww==", "dependencies": { "@types/bn.js": "^5.1.1", "@types/node": "^12.12.6", "bignumber.js": "^9.0.0", - "web3-core-helpers": "1.10.3", - "web3-core-method": "1.10.3", - "web3-core-requestmanager": "1.10.3", - "web3-utils": "1.10.3" + "web3-core-helpers": "1.10.4", + "web3-core-method": "1.10.4", + "web3-core-requestmanager": "1.10.4", + "web3-utils": "1.10.4" }, "engines": { "node": ">=8.0.0" } }, "node_modules/web3-core-helpers": { - "version": "1.10.3", - "resolved": "https://registry.npmjs.org/web3-core-helpers/-/web3-core-helpers-1.10.3.tgz", - "integrity": "sha512-Yv7dQC3B9ipOc5sWm3VAz1ys70Izfzb8n9rSiQYIPjpqtJM+3V4EeK6ghzNR6CO2es0+Yu9CtCkw0h8gQhrTxA==", + "version": "1.10.4", + "resolved": "https://registry.npmjs.org/web3-core-helpers/-/web3-core-helpers-1.10.4.tgz", + "integrity": "sha512-r+L5ylA17JlD1vwS8rjhWr0qg7zVoVMDvWhajWA5r5+USdh91jRUYosp19Kd1m2vE034v7Dfqe1xYRoH2zvG0g==", "dependencies": { - "web3-eth-iban": "1.10.3", - "web3-utils": "1.10.3" + "web3-eth-iban": "1.10.4", + "web3-utils": "1.10.4" }, "engines": { "node": ">=8.0.0" } }, "node_modules/web3-core-helpers/node_modules/web3-utils": { - "version": "1.10.3", - "resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-1.10.3.tgz", - "integrity": "sha512-OqcUrEE16fDBbGoQtZXWdavsPzbGIDc5v3VrRTZ0XrIpefC/viZ1ZU9bGEemazyS0catk/3rkOOxpzTfY+XsyQ==", + "version": "1.10.4", + "resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-1.10.4.tgz", + "integrity": "sha512-tsu8FiKJLk2PzhDl9fXbGUWTkkVXYhtTA+SmEFkKft+9BgwLxfCRpU96sWv7ICC8zixBNd3JURVoiR3dUXgP8A==", "dependencies": { "@ethereumjs/util": "^8.1.0", "bn.js": "^5.2.1", @@ -14286,24 +15189,24 @@ } }, "node_modules/web3-core-method": { - "version": "1.10.3", - "resolved": "https://registry.npmjs.org/web3-core-method/-/web3-core-method-1.10.3.tgz", - "integrity": "sha512-VZ/Dmml4NBmb0ep5PTSg9oqKoBtG0/YoMPei/bq/tUdlhB2dMB79sbeJPwx592uaV0Vpk7VltrrrBv5hTM1y4Q==", + "version": "1.10.4", + "resolved": "https://registry.npmjs.org/web3-core-method/-/web3-core-method-1.10.4.tgz", + "integrity": "sha512-uZTb7flr+Xl6LaDsyTeE2L1TylokCJwTDrIVfIfnrGmnwLc6bmTWCCrm71sSrQ0hqs6vp/MKbQYIYqUN0J8WyA==", "dependencies": { "@ethersproject/transactions": "^5.6.2", - "web3-core-helpers": "1.10.3", - "web3-core-promievent": "1.10.3", - "web3-core-subscriptions": "1.10.3", - "web3-utils": "1.10.3" + "web3-core-helpers": "1.10.4", + "web3-core-promievent": "1.10.4", + "web3-core-subscriptions": "1.10.4", + "web3-utils": "1.10.4" }, "engines": { "node": ">=8.0.0" } }, "node_modules/web3-core-method/node_modules/web3-utils": { - "version": "1.10.3", - "resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-1.10.3.tgz", - "integrity": "sha512-OqcUrEE16fDBbGoQtZXWdavsPzbGIDc5v3VrRTZ0XrIpefC/viZ1ZU9bGEemazyS0catk/3rkOOxpzTfY+XsyQ==", + "version": "1.10.4", + "resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-1.10.4.tgz", + "integrity": "sha512-tsu8FiKJLk2PzhDl9fXbGUWTkkVXYhtTA+SmEFkKft+9BgwLxfCRpU96sWv7ICC8zixBNd3JURVoiR3dUXgP8A==", "dependencies": { "@ethereumjs/util": "^8.1.0", "bn.js": "^5.2.1", @@ -14319,9 +15222,9 @@ } }, "node_modules/web3-core-promievent": { - "version": "1.10.3", - "resolved": "https://registry.npmjs.org/web3-core-promievent/-/web3-core-promievent-1.10.3.tgz", - "integrity": "sha512-HgjY+TkuLm5uTwUtaAfkTgRx/NzMxvVradCi02gy17NxDVdg/p6svBHcp037vcNpkuGeFznFJgULP+s2hdVgUQ==", + "version": "1.10.4", + "resolved": "https://registry.npmjs.org/web3-core-promievent/-/web3-core-promievent-1.10.4.tgz", + "integrity": "sha512-2de5WnJQ72YcIhYwV/jHLc4/cWJnznuoGTJGD29ncFQHAfwW/MItHFSVKPPA5v8AhJe+r6y4Y12EKvZKjQVBvQ==", "dependencies": { "eventemitter3": "4.0.4" }, @@ -14330,27 +15233,27 @@ } }, "node_modules/web3-core-requestmanager": { - "version": "1.10.3", - "resolved": "https://registry.npmjs.org/web3-core-requestmanager/-/web3-core-requestmanager-1.10.3.tgz", - "integrity": "sha512-VT9sKJfgM2yBOIxOXeXiDuFMP4pxzF6FT+y8KTLqhDFHkbG3XRe42Vm97mB/IvLQCJOmokEjl3ps8yP1kbggyw==", + "version": "1.10.4", + "resolved": "https://registry.npmjs.org/web3-core-requestmanager/-/web3-core-requestmanager-1.10.4.tgz", + "integrity": "sha512-vqP6pKH8RrhT/2MoaU+DY/OsYK9h7HmEBNCdoMj+4ZwujQtw/Mq2JifjwsJ7gits7Q+HWJwx8q6WmQoVZAWugg==", "dependencies": { "util": "^0.12.5", - "web3-core-helpers": "1.10.3", - "web3-providers-http": "1.10.3", - "web3-providers-ipc": "1.10.3", - "web3-providers-ws": "1.10.3" + "web3-core-helpers": "1.10.4", + "web3-providers-http": "1.10.4", + "web3-providers-ipc": "1.10.4", + "web3-providers-ws": "1.10.4" }, "engines": { "node": ">=8.0.0" } }, "node_modules/web3-core-subscriptions": { - "version": "1.10.3", - "resolved": "https://registry.npmjs.org/web3-core-subscriptions/-/web3-core-subscriptions-1.10.3.tgz", - "integrity": "sha512-KW0Mc8sgn70WadZu7RjQ4H5sNDJ5Lx8JMI3BWos+f2rW0foegOCyWhRu33W1s6ntXnqeBUw5rRCXZRlA3z+HNA==", + "version": "1.10.4", + "resolved": "https://registry.npmjs.org/web3-core-subscriptions/-/web3-core-subscriptions-1.10.4.tgz", + "integrity": "sha512-o0lSQo/N/f7/L76C0HV63+S54loXiE9fUPfHFcTtpJRQNDBVsSDdWRdePbWwR206XlsBqD5VHApck1//jEafTw==", "dependencies": { "eventemitter3": "4.0.4", - "web3-core-helpers": "1.10.3" + "web3-core-helpers": "1.10.4" }, "engines": { "node": ">=8.0.0" @@ -14362,9 +15265,9 @@ "integrity": "sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ==" }, "node_modules/web3-core/node_modules/web3-utils": { - "version": "1.10.3", - "resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-1.10.3.tgz", - "integrity": "sha512-OqcUrEE16fDBbGoQtZXWdavsPzbGIDc5v3VrRTZ0XrIpefC/viZ1ZU9bGEemazyS0catk/3rkOOxpzTfY+XsyQ==", + "version": "1.10.4", + "resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-1.10.4.tgz", + "integrity": "sha512-tsu8FiKJLk2PzhDl9fXbGUWTkkVXYhtTA+SmEFkKft+9BgwLxfCRpU96sWv7ICC8zixBNd3JURVoiR3dUXgP8A==", "dependencies": { "@ethereumjs/util": "^8.1.0", "bn.js": "^5.2.1", @@ -14380,22 +15283,22 @@ } }, "node_modules/web3-eth": { - "version": "1.10.3", - "resolved": "https://registry.npmjs.org/web3-eth/-/web3-eth-1.10.3.tgz", - "integrity": "sha512-Uk1U2qGiif2mIG8iKu23/EQJ2ksB1BQXy3wF3RvFuyxt8Ft9OEpmGlO7wOtAyJdoKzD5vcul19bJpPcWSAYZhA==", - "dependencies": { - "web3-core": "1.10.3", - "web3-core-helpers": "1.10.3", - "web3-core-method": "1.10.3", - "web3-core-subscriptions": "1.10.3", - "web3-eth-abi": "1.10.3", - "web3-eth-accounts": "1.10.3", - "web3-eth-contract": "1.10.3", - "web3-eth-ens": "1.10.3", - "web3-eth-iban": "1.10.3", - "web3-eth-personal": "1.10.3", - "web3-net": "1.10.3", - "web3-utils": "1.10.3" + "version": "1.10.4", + "resolved": "https://registry.npmjs.org/web3-eth/-/web3-eth-1.10.4.tgz", + "integrity": "sha512-Sql2kYKmgt+T/cgvg7b9ce24uLS7xbFrxE4kuuor1zSCGrjhTJ5rRNG8gTJUkAJGKJc7KgnWmgW+cOfMBPUDSA==", + "dependencies": { + "web3-core": "1.10.4", + "web3-core-helpers": "1.10.4", + "web3-core-method": "1.10.4", + "web3-core-subscriptions": "1.10.4", + "web3-eth-abi": "1.10.4", + "web3-eth-accounts": "1.10.4", + "web3-eth-contract": "1.10.4", + "web3-eth-ens": "1.10.4", + "web3-eth-iban": "1.10.4", + "web3-eth-personal": "1.10.4", + "web3-net": "1.10.4", + "web3-utils": "1.10.4" }, "engines": { "node": ">=8.0.0" @@ -14414,9 +15317,9 @@ } }, "node_modules/web3-eth-accounts": { - "version": "1.10.3", - "resolved": "https://registry.npmjs.org/web3-eth-accounts/-/web3-eth-accounts-1.10.3.tgz", - "integrity": "sha512-8MipGgwusDVgn7NwKOmpeo3gxzzd+SmwcWeBdpXknuyDiZSQy9tXe+E9LeFGrmys/8mLLYP79n3jSbiTyv+6pQ==", + "version": "1.10.4", + "resolved": "https://registry.npmjs.org/web3-eth-accounts/-/web3-eth-accounts-1.10.4.tgz", + "integrity": "sha512-ysy5sVTg9snYS7tJjxVoQAH6DTOTkRGR8emEVCWNGLGiB9txj+qDvSeT0izjurS/g7D5xlMAgrEHLK1Vi6I3yg==", "dependencies": { "@ethereumjs/common": "2.6.5", "@ethereumjs/tx": "3.5.2", @@ -14424,10 +15327,10 @@ "eth-lib": "0.2.8", "scrypt-js": "^3.0.1", "uuid": "^9.0.0", - "web3-core": "1.10.3", - "web3-core-helpers": "1.10.3", - "web3-core-method": "1.10.3", - "web3-utils": "1.10.3" + "web3-core": "1.10.4", + "web3-core-helpers": "1.10.4", + "web3-core-method": "1.10.4", + "web3-utils": "1.10.4" }, "engines": { "node": ">=8.0.0" @@ -14449,9 +15352,9 @@ "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==" }, "node_modules/web3-eth-accounts/node_modules/web3-utils": { - "version": "1.10.3", - "resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-1.10.3.tgz", - "integrity": "sha512-OqcUrEE16fDBbGoQtZXWdavsPzbGIDc5v3VrRTZ0XrIpefC/viZ1ZU9bGEemazyS0catk/3rkOOxpzTfY+XsyQ==", + "version": "1.10.4", + "resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-1.10.4.tgz", + "integrity": "sha512-tsu8FiKJLk2PzhDl9fXbGUWTkkVXYhtTA+SmEFkKft+9BgwLxfCRpU96sWv7ICC8zixBNd3JURVoiR3dUXgP8A==", "dependencies": { "@ethereumjs/util": "^8.1.0", "bn.js": "^5.2.1", @@ -14467,39 +15370,39 @@ } }, "node_modules/web3-eth-contract": { - "version": "1.10.3", - "resolved": "https://registry.npmjs.org/web3-eth-contract/-/web3-eth-contract-1.10.3.tgz", - "integrity": "sha512-Y2CW61dCCyY4IoUMD4JsEQWrILX4FJWDWC/Txx/pr3K/+fGsBGvS9kWQN5EsVXOp4g7HoFOfVh9Lf7BmVVSRmg==", + "version": "1.10.4", + "resolved": "https://registry.npmjs.org/web3-eth-contract/-/web3-eth-contract-1.10.4.tgz", + "integrity": "sha512-Q8PfolOJ4eV9TvnTj1TGdZ4RarpSLmHnUnzVxZ/6/NiTfe4maJz99R0ISgwZkntLhLRtw0C7LRJuklzGYCNN3A==", "dependencies": { "@types/bn.js": "^5.1.1", - "web3-core": "1.10.3", - "web3-core-helpers": "1.10.3", - "web3-core-method": "1.10.3", - "web3-core-promievent": "1.10.3", - "web3-core-subscriptions": "1.10.3", - "web3-eth-abi": "1.10.3", - "web3-utils": "1.10.3" + "web3-core": "1.10.4", + "web3-core-helpers": "1.10.4", + "web3-core-method": "1.10.4", + "web3-core-promievent": "1.10.4", + "web3-core-subscriptions": "1.10.4", + "web3-eth-abi": "1.10.4", + "web3-utils": "1.10.4" }, "engines": { "node": ">=8.0.0" } }, "node_modules/web3-eth-contract/node_modules/web3-eth-abi": { - "version": "1.10.3", - "resolved": "https://registry.npmjs.org/web3-eth-abi/-/web3-eth-abi-1.10.3.tgz", - "integrity": "sha512-O8EvV67uhq0OiCMekqYsDtb6FzfYzMXT7VMHowF8HV6qLZXCGTdB/NH4nJrEh2mFtEwVdS6AmLFJAQd2kVyoMQ==", + "version": "1.10.4", + "resolved": "https://registry.npmjs.org/web3-eth-abi/-/web3-eth-abi-1.10.4.tgz", + "integrity": "sha512-cZ0q65eJIkd/jyOlQPDjr8X4fU6CRL1eWgdLwbWEpo++MPU/2P4PFk5ZLAdye9T5Sdp+MomePPJ/gHjLMj2VfQ==", "dependencies": { "@ethersproject/abi": "^5.6.3", - "web3-utils": "1.10.3" + "web3-utils": "1.10.4" }, "engines": { "node": ">=8.0.0" } }, "node_modules/web3-eth-contract/node_modules/web3-utils": { - "version": "1.10.3", - "resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-1.10.3.tgz", - "integrity": "sha512-OqcUrEE16fDBbGoQtZXWdavsPzbGIDc5v3VrRTZ0XrIpefC/viZ1ZU9bGEemazyS0catk/3rkOOxpzTfY+XsyQ==", + "version": "1.10.4", + "resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-1.10.4.tgz", + "integrity": "sha512-tsu8FiKJLk2PzhDl9fXbGUWTkkVXYhtTA+SmEFkKft+9BgwLxfCRpU96sWv7ICC8zixBNd3JURVoiR3dUXgP8A==", "dependencies": { "@ethereumjs/util": "^8.1.0", "bn.js": "^5.2.1", @@ -14515,39 +15418,39 @@ } }, "node_modules/web3-eth-ens": { - "version": "1.10.3", - "resolved": "https://registry.npmjs.org/web3-eth-ens/-/web3-eth-ens-1.10.3.tgz", - "integrity": "sha512-hR+odRDXGqKemw1GFniKBEXpjYwLgttTES+bc7BfTeoUyUZXbyDHe5ifC+h+vpzxh4oS0TnfcIoarK0Z9tFSiQ==", + "version": "1.10.4", + "resolved": "https://registry.npmjs.org/web3-eth-ens/-/web3-eth-ens-1.10.4.tgz", + "integrity": "sha512-LLrvxuFeVooRVZ9e5T6OWKVflHPFgrVjJ/jtisRWcmI7KN/b64+D/wJzXqgmp6CNsMQcE7rpmf4CQmJCrTdsgg==", "dependencies": { "content-hash": "^2.5.2", "eth-ens-namehash": "2.0.8", - "web3-core": "1.10.3", - "web3-core-helpers": "1.10.3", - "web3-core-promievent": "1.10.3", - "web3-eth-abi": "1.10.3", - "web3-eth-contract": "1.10.3", - "web3-utils": "1.10.3" + "web3-core": "1.10.4", + "web3-core-helpers": "1.10.4", + "web3-core-promievent": "1.10.4", + "web3-eth-abi": "1.10.4", + "web3-eth-contract": "1.10.4", + "web3-utils": "1.10.4" }, "engines": { "node": ">=8.0.0" } }, "node_modules/web3-eth-ens/node_modules/web3-eth-abi": { - "version": "1.10.3", - "resolved": "https://registry.npmjs.org/web3-eth-abi/-/web3-eth-abi-1.10.3.tgz", - "integrity": "sha512-O8EvV67uhq0OiCMekqYsDtb6FzfYzMXT7VMHowF8HV6qLZXCGTdB/NH4nJrEh2mFtEwVdS6AmLFJAQd2kVyoMQ==", + "version": "1.10.4", + "resolved": "https://registry.npmjs.org/web3-eth-abi/-/web3-eth-abi-1.10.4.tgz", + "integrity": "sha512-cZ0q65eJIkd/jyOlQPDjr8X4fU6CRL1eWgdLwbWEpo++MPU/2P4PFk5ZLAdye9T5Sdp+MomePPJ/gHjLMj2VfQ==", "dependencies": { "@ethersproject/abi": "^5.6.3", - "web3-utils": "1.10.3" + "web3-utils": "1.10.4" }, "engines": { "node": ">=8.0.0" } }, "node_modules/web3-eth-ens/node_modules/web3-utils": { - "version": "1.10.3", - "resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-1.10.3.tgz", - "integrity": "sha512-OqcUrEE16fDBbGoQtZXWdavsPzbGIDc5v3VrRTZ0XrIpefC/viZ1ZU9bGEemazyS0catk/3rkOOxpzTfY+XsyQ==", + "version": "1.10.4", + "resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-1.10.4.tgz", + "integrity": "sha512-tsu8FiKJLk2PzhDl9fXbGUWTkkVXYhtTA+SmEFkKft+9BgwLxfCRpU96sWv7ICC8zixBNd3JURVoiR3dUXgP8A==", "dependencies": { "@ethereumjs/util": "^8.1.0", "bn.js": "^5.2.1", @@ -14563,21 +15466,21 @@ } }, "node_modules/web3-eth-iban": { - "version": "1.10.3", - "resolved": "https://registry.npmjs.org/web3-eth-iban/-/web3-eth-iban-1.10.3.tgz", - "integrity": "sha512-ZCfOjYKAjaX2TGI8uif5ah+J3BYFuo+47JOIV1RIz2l7kD9VfnxvRH5UiQDRyMALQC7KFd2hUqIEtHklapNyKA==", + "version": "1.10.4", + "resolved": "https://registry.npmjs.org/web3-eth-iban/-/web3-eth-iban-1.10.4.tgz", + "integrity": "sha512-0gE5iNmOkmtBmbKH2aTodeompnNE8jEyvwFJ6s/AF6jkw9ky9Op9cqfzS56AYAbrqEFuClsqB/AoRves7LDELw==", "dependencies": { "bn.js": "^5.2.1", - "web3-utils": "1.10.3" + "web3-utils": "1.10.4" }, "engines": { "node": ">=8.0.0" } }, "node_modules/web3-eth-iban/node_modules/web3-utils": { - "version": "1.10.3", - "resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-1.10.3.tgz", - "integrity": "sha512-OqcUrEE16fDBbGoQtZXWdavsPzbGIDc5v3VrRTZ0XrIpefC/viZ1ZU9bGEemazyS0catk/3rkOOxpzTfY+XsyQ==", + "version": "1.10.4", + "resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-1.10.4.tgz", + "integrity": "sha512-tsu8FiKJLk2PzhDl9fXbGUWTkkVXYhtTA+SmEFkKft+9BgwLxfCRpU96sWv7ICC8zixBNd3JURVoiR3dUXgP8A==", "dependencies": { "@ethereumjs/util": "^8.1.0", "bn.js": "^5.2.1", @@ -14593,16 +15496,16 @@ } }, "node_modules/web3-eth-personal": { - "version": "1.10.3", - "resolved": "https://registry.npmjs.org/web3-eth-personal/-/web3-eth-personal-1.10.3.tgz", - "integrity": "sha512-avrQ6yWdADIvuNQcFZXmGLCEzulQa76hUOuVywN7O3cklB4nFc/Gp3yTvD3bOAaE7DhjLQfhUTCzXL7WMxVTsw==", + "version": "1.10.4", + "resolved": "https://registry.npmjs.org/web3-eth-personal/-/web3-eth-personal-1.10.4.tgz", + "integrity": "sha512-BRa/hs6jU1hKHz+AC/YkM71RP3f0Yci1dPk4paOic53R4ZZG4MgwKRkJhgt3/GPuPliwS46f/i5A7fEGBT4F9w==", "dependencies": { "@types/node": "^12.12.6", - "web3-core": "1.10.3", - "web3-core-helpers": "1.10.3", - "web3-core-method": "1.10.3", - "web3-net": "1.10.3", - "web3-utils": "1.10.3" + "web3-core": "1.10.4", + "web3-core-helpers": "1.10.4", + "web3-core-method": "1.10.4", + "web3-net": "1.10.4", + "web3-utils": "1.10.4" }, "engines": { "node": ">=8.0.0" @@ -14614,9 +15517,9 @@ "integrity": "sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ==" }, "node_modules/web3-eth-personal/node_modules/web3-utils": { - "version": "1.10.3", - "resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-1.10.3.tgz", - "integrity": "sha512-OqcUrEE16fDBbGoQtZXWdavsPzbGIDc5v3VrRTZ0XrIpefC/viZ1ZU9bGEemazyS0catk/3rkOOxpzTfY+XsyQ==", + "version": "1.10.4", + "resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-1.10.4.tgz", + "integrity": "sha512-tsu8FiKJLk2PzhDl9fXbGUWTkkVXYhtTA+SmEFkKft+9BgwLxfCRpU96sWv7ICC8zixBNd3JURVoiR3dUXgP8A==", "dependencies": { "@ethereumjs/util": "^8.1.0", "bn.js": "^5.2.1", @@ -14632,21 +15535,21 @@ } }, "node_modules/web3-eth/node_modules/web3-eth-abi": { - "version": "1.10.3", - "resolved": "https://registry.npmjs.org/web3-eth-abi/-/web3-eth-abi-1.10.3.tgz", - "integrity": "sha512-O8EvV67uhq0OiCMekqYsDtb6FzfYzMXT7VMHowF8HV6qLZXCGTdB/NH4nJrEh2mFtEwVdS6AmLFJAQd2kVyoMQ==", + "version": "1.10.4", + "resolved": "https://registry.npmjs.org/web3-eth-abi/-/web3-eth-abi-1.10.4.tgz", + "integrity": "sha512-cZ0q65eJIkd/jyOlQPDjr8X4fU6CRL1eWgdLwbWEpo++MPU/2P4PFk5ZLAdye9T5Sdp+MomePPJ/gHjLMj2VfQ==", "dependencies": { "@ethersproject/abi": "^5.6.3", - "web3-utils": "1.10.3" + "web3-utils": "1.10.4" }, "engines": { "node": ">=8.0.0" } }, "node_modules/web3-eth/node_modules/web3-utils": { - "version": "1.10.3", - "resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-1.10.3.tgz", - "integrity": "sha512-OqcUrEE16fDBbGoQtZXWdavsPzbGIDc5v3VrRTZ0XrIpefC/viZ1ZU9bGEemazyS0catk/3rkOOxpzTfY+XsyQ==", + "version": "1.10.4", + "resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-1.10.4.tgz", + "integrity": "sha512-tsu8FiKJLk2PzhDl9fXbGUWTkkVXYhtTA+SmEFkKft+9BgwLxfCRpU96sWv7ICC8zixBNd3JURVoiR3dUXgP8A==", "dependencies": { "@ethereumjs/util": "^8.1.0", "bn.js": "^5.2.1", @@ -14662,22 +15565,22 @@ } }, "node_modules/web3-net": { - "version": "1.10.3", - "resolved": "https://registry.npmjs.org/web3-net/-/web3-net-1.10.3.tgz", - "integrity": "sha512-IoSr33235qVoI1vtKssPUigJU9Fc/Ph0T9CgRi15sx+itysmvtlmXMNoyd6Xrgm9LuM4CIhxz7yDzH93B79IFg==", + "version": "1.10.4", + "resolved": "https://registry.npmjs.org/web3-net/-/web3-net-1.10.4.tgz", + "integrity": "sha512-mKINnhOOnZ4koA+yV2OT5s5ztVjIx7IY9a03w6s+yao/BUn+Luuty0/keNemZxTr1E8Ehvtn28vbOtW7Ids+Ow==", "dependencies": { - "web3-core": "1.10.3", - "web3-core-method": "1.10.3", - "web3-utils": "1.10.3" + "web3-core": "1.10.4", + "web3-core-method": "1.10.4", + "web3-utils": "1.10.4" }, "engines": { "node": ">=8.0.0" } }, "node_modules/web3-net/node_modules/web3-utils": { - "version": "1.10.3", - "resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-1.10.3.tgz", - "integrity": "sha512-OqcUrEE16fDBbGoQtZXWdavsPzbGIDc5v3VrRTZ0XrIpefC/viZ1ZU9bGEemazyS0catk/3rkOOxpzTfY+XsyQ==", + "version": "1.10.4", + "resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-1.10.4.tgz", + "integrity": "sha512-tsu8FiKJLk2PzhDl9fXbGUWTkkVXYhtTA+SmEFkKft+9BgwLxfCRpU96sWv7ICC8zixBNd3JURVoiR3dUXgP8A==", "dependencies": { "@ethereumjs/util": "^8.1.0", "bn.js": "^5.2.1", @@ -14693,38 +15596,38 @@ } }, "node_modules/web3-providers-http": { - "version": "1.10.3", - "resolved": "https://registry.npmjs.org/web3-providers-http/-/web3-providers-http-1.10.3.tgz", - "integrity": "sha512-6dAgsHR3MxJ0Qyu3QLFlQEelTapVfWNTu5F45FYh8t7Y03T1/o+YAkVxsbY5AdmD+y5bXG/XPJ4q8tjL6MgZHw==", + "version": "1.10.4", + "resolved": "https://registry.npmjs.org/web3-providers-http/-/web3-providers-http-1.10.4.tgz", + "integrity": "sha512-m2P5Idc8hdiO0l60O6DSCPw0kw64Zgi0pMjbEFRmxKIck2Py57RQMu4bxvkxJwkF06SlGaEQF8rFZBmuX7aagQ==", "dependencies": { "abortcontroller-polyfill": "^1.7.5", "cross-fetch": "^4.0.0", "es6-promise": "^4.2.8", - "web3-core-helpers": "1.10.3" + "web3-core-helpers": "1.10.4" }, "engines": { "node": ">=8.0.0" } }, "node_modules/web3-providers-ipc": { - "version": "1.10.3", - "resolved": "https://registry.npmjs.org/web3-providers-ipc/-/web3-providers-ipc-1.10.3.tgz", - "integrity": "sha512-vP5WIGT8FLnGRfswTxNs9rMfS1vCbMezj/zHbBe/zB9GauBRTYVrUo2H/hVrhLg8Ut7AbsKZ+tCJ4mAwpKi2hA==", + "version": "1.10.4", + "resolved": "https://registry.npmjs.org/web3-providers-ipc/-/web3-providers-ipc-1.10.4.tgz", + "integrity": "sha512-YRF/bpQk9z3WwjT+A6FI/GmWRCASgd+gC0si7f9zbBWLXjwzYAKG73bQBaFRAHex1hl4CVcM5WUMaQXf3Opeuw==", "dependencies": { "oboe": "2.1.5", - "web3-core-helpers": "1.10.3" + "web3-core-helpers": "1.10.4" }, "engines": { "node": ">=8.0.0" } }, "node_modules/web3-providers-ws": { - "version": "1.10.3", - "resolved": "https://registry.npmjs.org/web3-providers-ws/-/web3-providers-ws-1.10.3.tgz", - "integrity": "sha512-/filBXRl48INxsh6AuCcsy4v5ndnTZ/p6bl67kmO9aK1wffv7CT++DrtclDtVMeDGCgB3van+hEf9xTAVXur7Q==", + "version": "1.10.4", + "resolved": "https://registry.npmjs.org/web3-providers-ws/-/web3-providers-ws-1.10.4.tgz", + "integrity": "sha512-j3FBMifyuFFmUIPVQR4pj+t5ILhAexAui0opgcpu9R5LxQrLRUZxHSnU+YO25UycSOa/NAX8A+qkqZNpcFAlxA==", "dependencies": { "eventemitter3": "4.0.4", - "web3-core-helpers": "1.10.3", + "web3-core-helpers": "1.10.4", "websocket": "^1.0.32" }, "engines": { @@ -14732,15 +15635,15 @@ } }, "node_modules/web3-shh": { - "version": "1.10.3", - "resolved": "https://registry.npmjs.org/web3-shh/-/web3-shh-1.10.3.tgz", - "integrity": "sha512-cAZ60CPvs9azdwMSQ/PSUdyV4PEtaW5edAZhu3rCXf6XxQRliBboic+AvwUvB6j3eswY50VGa5FygfVmJ1JVng==", + "version": "1.10.4", + "resolved": "https://registry.npmjs.org/web3-shh/-/web3-shh-1.10.4.tgz", + "integrity": "sha512-cOH6iFFM71lCNwSQrC3niqDXagMqrdfFW85hC9PFUrAr3PUrIem8TNstTc3xna2bwZeWG6OBy99xSIhBvyIACw==", "hasInstallScript": true, "dependencies": { - "web3-core": "1.10.3", - "web3-core-method": "1.10.3", - "web3-core-subscriptions": "1.10.3", - "web3-net": "1.10.3" + "web3-core": "1.10.4", + "web3-core-method": "1.10.4", + "web3-core-subscriptions": "1.10.4", + "web3-net": "1.10.4" }, "engines": { "node": ">=8.0.0" @@ -14764,9 +15667,9 @@ } }, "node_modules/web3/node_modules/web3-utils": { - "version": "1.10.3", - "resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-1.10.3.tgz", - "integrity": "sha512-OqcUrEE16fDBbGoQtZXWdavsPzbGIDc5v3VrRTZ0XrIpefC/viZ1ZU9bGEemazyS0catk/3rkOOxpzTfY+XsyQ==", + "version": "1.10.4", + "resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-1.10.4.tgz", + "integrity": "sha512-tsu8FiKJLk2PzhDl9fXbGUWTkkVXYhtTA+SmEFkKft+9BgwLxfCRpU96sWv7ICC8zixBNd3JURVoiR3dUXgP8A==", "dependencies": { "@ethereumjs/util": "^8.1.0", "bn.js": "^5.2.1", @@ -14940,15 +15843,15 @@ "optional": true }, "node_modules/ws": { - "version": "8.5.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.5.0.tgz", - "integrity": "sha512-BWX0SWVgLPzYwF8lTzEy1egjhS4S4OEAHfsO8o65WOVsrnSRGaSiUaa9e0ggGlkMTtBlmOpEXiie9RUcBO86qg==", + "version": "8.17.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.17.1.tgz", + "integrity": "sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ==", "engines": { "node": ">=10.0.0" }, "peerDependencies": { "bufferutil": "^4.0.1", - "utf-8-validate": "^5.0.2" + "utf-8-validate": ">=5.0.2" }, "peerDependenciesMeta": { "bufferutil": { diff --git a/e2e-tests/package.json b/e2e-tests/package.json index 89caa2fda..cade75ad9 100644 --- a/e2e-tests/package.json +++ b/e2e-tests/package.json @@ -13,6 +13,9 @@ "author": "", "license": "ISC", "dependencies": { + "@polkadot/api": "^12.2.1", + "@polkadot/api-augment": "^12.2.1", + "@polkadot/types": "^12.2.1", "@types/chai": "^4.3.5", "@types/mocha": "^10.0.1", "chai": "^4.3.7", diff --git a/e2e-tests/tests/config.ts b/e2e-tests/tests/config.ts index c6a116328..8bec2711f 100644 --- a/e2e-tests/tests/config.ts +++ b/e2e-tests/tests/config.ts @@ -4,6 +4,7 @@ import AssetMetadataExtender from "../build/contracts/AssetMetadataExtender.json import EvolutionCollection from "../build/contracts/EvolutionCollection.json"; import EvolutionCollectionFactory from "../build/contracts/EvolutionCollectionFactory.json"; import Vesting from "../build/contracts/Vesting.json"; +import ParachainStaking from "../build/contracts/ParachainStaking.json"; // Node config export const RUNTIME_SPEC_NAME = "laos"; @@ -13,13 +14,15 @@ export const LOCAL_NODE_URL = "http://127.0.0.1:9999"; // Chain config export const CHAIN_ID = 667; +export const GAS_PRICE = "0x3B9ACA00"; +export const ETH_BLOCK_GAS_LIMIT = 15000000; // The same configuration as runtime +export const GAS_LIMIT = ETH_BLOCK_GAS_LIMIT - 10000000; + +// Accounts export const FAITH = "0xC0F0f4ab324C46e55D02D0033343B4Be8A55532d"; export const FAITH_PRIVATE_KEY = "0xb9d2ea9a615f3165812e8d44de0d24da9bbd164b65c4f0573e1ce2c8dbd9c8df"; export const ALITH = "0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac"; export const ALITH_PRIVATE_KEY = "0x5fb92d6e98884f76de468fa3f6278f8807c48bebc13595d45af5bdc4da702133"; -export const GAS_PRICE = "0x3B9ACA00"; -export const ETH_BLOCK_GAS_LIMIT = 15000000; // The same configuration as runtime -export const GAS_LIMIT = ETH_BLOCK_GAS_LIMIT - 10000000; // LAOS Evolution Contract export const EVOLUTION_COLLECTION_FACTORY_ABI = EvolutionCollectionFactory.abi as AbiItem[]; @@ -47,6 +50,11 @@ export const SELECTOR_LOG_UPDATED_EXTENDED_UL_WITH_EXTERNAL_URI = export const VESTING_CONTRACT_ADDRESS = "0x0000000000000000000000000000000000000406"; export const VESTING_ABI = Vesting.abi as AbiItem[]; +// Staking contract +export const STAKING_CONTRACT_ADDRESS = "0x0000000000000000000000000000000000000800"; +export const STAKING_ABI = ParachainStaking.abi as AbiItem[]; + // Constants export const MAX_U96 = new BN("79228162514264337593543950336"); // 2^96 - 1 export const REVERT_BYTECODE = "0x60006000fd"; +export const UNIT = BigInt(Math.pow(10, 18)); diff --git a/e2e-tests/tests/test-staking.ts b/e2e-tests/tests/test-staking.ts new file mode 100644 index 000000000..a2f3bb3c6 --- /dev/null +++ b/e2e-tests/tests/test-staking.ts @@ -0,0 +1,55 @@ +import { + addressToCollectionId, + createCollection, + describeWithExistingNode, + extractRevertReason, + slotAndOwnerToTokenId, +} from "./util"; +import { + GAS_LIMIT, + FAITH, + SELECTOR_LOG_EVOLVED_WITH_EXTERNAL_TOKEN_URI, + SELECTOR_LOG_MINTED_WITH_EXTERNAL_TOKEN_URI, + SELECTOR_LOG_OWNERSHIP_TRANSFERRED, + SELECTOR_LOG_PUBLIC_MINTING_ENABLED, + SELECTOR_LOG_PUBLIC_MINTING_DISABLED, + ALITH, + ALITH_PRIVATE_KEY, + STAKING_ABI, + STAKING_CONTRACT_ADDRESS, + GAS_PRICE, + UNIT, +} from "./config"; +import { expect } from "chai"; +import Contract from "web3-eth-contract"; +import BN from "bn.js"; +import { step } from "mocha-steps"; +import { Keyring } from "@polkadot/api"; + +describeWithExistingNode("Frontier RPC (Staking)", (context) => { + let contract: Contract; + + before(async function () { + contract = new context.web3.eth.Contract(STAKING_ABI, STAKING_CONTRACT_ADDRESS, { + from: ALITH, + gasPrice: GAS_PRICE, + gas: GAS_LIMIT, + }); + context.web3.eth.accounts.wallet.add(ALITH_PRIVATE_KEY); + }); + step("Alith can join as candidate", async function () { + const alith = new Keyring({ type: "ethereum" }).addFromUri(ALITH_PRIVATE_KEY); + const key = (await context.polkadot.rpc.author.rotateKeys()).toHex(); + context.polkadot.tx.session.setKeys(key, "").signAndSend(alith, (result) => { + console.log(`transaction result: ${result}`); + }).catch((error: any) => { + console.log('transaction failed', error); + }); + + let nonce = await context.web3.eth.getTransactionCount(ALITH); + const result = await contract.methods.joinCandidates(BigInt(20000) * UNIT, 0).send({ from: ALITH, gas: GAS_LIMIT, nonce: nonce++ }); + console.log(`result: ${result}`); + }); + +}); + diff --git a/e2e-tests/tests/util.ts b/e2e-tests/tests/util.ts index 62ea900fd..0b1c43ac7 100644 --- a/e2e-tests/tests/util.ts +++ b/e2e-tests/tests/util.ts @@ -15,6 +15,9 @@ import { } from "./config"; import BN from "bn.js"; import { expect } from "chai"; +import "@polkadot/api-augment"; + +import { ApiPromise, HttpProvider } from '@polkadot/api'; require("events").EventEmitter.prototype._maxListeners = 100; @@ -41,17 +44,24 @@ export async function customRequest(web3: Web3, method: string, params: any[]) { }); } -export function describeWithExistingNode(title: string, cb: (context: { web3: Web3 }) => void, provider?: string) { +export function describeWithExistingNode(title: string, cb: (context: { web3: Web3, polkadot: ApiPromise }) => void, provider?: string) { describe(title, () => { let context: { web3: Web3; ethersjs: ethers.JsonRpcProvider; - } = { web3: null, ethersjs: null }; - - if (!provider) { - context.web3 = new Web3(LOCAL_NODE_URL); - } - + polkadot: ApiPromise; + } = { + web3: null, ethersjs: null, + polkadot: undefined + }; + + before(async () => { + if (!provider) { + context.web3 = new Web3(LOCAL_NODE_URL); + const wsProvider = new HttpProvider(LOCAL_NODE_URL); + context.polkadot = await new ApiPromise({ provider: wsProvider }).isReady; + } + }); cb(context); }); } diff --git a/node/src/command.rs b/node/src/command.rs index 1a7602017..b0bce3ca8 100644 --- a/node/src/command.rs +++ b/node/src/command.rs @@ -57,7 +57,6 @@ fn load_spec(id: &str) -> std::result::Result, String> { )?), "dev" => Box::new(chain_spec::laos::development_config()), "local" => Box::new(chain_spec::laos::local_testnet_config()), - "local-v" => Box::new(chain_spec::laos::local_testnet_config()), path => { let chain_spec = chain_spec::laos::ChainSpec::from_json_file(std::path::PathBuf::from(path))?; diff --git a/runtime/laos/src/precompiles/mod.rs b/runtime/laos/src/precompiles/mod.rs index 6ae512b15..c021150ce 100644 --- a/runtime/laos/src/precompiles/mod.rs +++ b/runtime/laos/src/precompiles/mod.rs @@ -73,7 +73,7 @@ pub type LaosPrecompilesSetAt = ( (CallableByContract, CallableByPrecompile), >, PrecompileAt< - AddressU64<1031>, + AddressU64<2048>, ParachainStakingPrecompile, (CallableByContract, CallableByPrecompile), >, diff --git a/zombienet/README.md b/zombienet/README.md index e378d9204..c01fdf295 100644 --- a/zombienet/README.md +++ b/zombienet/README.md @@ -33,5 +33,5 @@ export ZOMBIENET_ASTAR_COMMAND= ``` ```sh -$ ./zombienet spawn native.toml -p native +$ ./zombienet spawn native.toml ``` diff --git a/zombienet/native.toml b/zombienet/native.toml index 23354ed68..8e3393d2e 100644 --- a/zombienet/native.toml +++ b/zombienet/native.toml @@ -1,3 +1,6 @@ +[settings] +provider = "native" + [relaychain] default_command = "{{ZOMBIENET_RELAYCHAIN_COMMAND}}" chain = "rococo-local" @@ -14,7 +17,8 @@ chain = "rococo-local" [[parachains]] id = 2900 cumulus_based = true -chain = "local-v" +chain = "local" +force_decorator = "generic-evm" [[parachains.collators]] name = "laos" From bbb64467c73ee245325e5075a19ff49fc8ae6bea Mon Sep 17 00:00:00 2001 From: magecnion Date: Tue, 23 Jul 2024 15:55:35 +0200 Subject: [PATCH 06/16] alith can join as candidate --- e2e-tests/tests/test-staking.ts | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/e2e-tests/tests/test-staking.ts b/e2e-tests/tests/test-staking.ts index a2f3bb3c6..f593e627d 100644 --- a/e2e-tests/tests/test-staking.ts +++ b/e2e-tests/tests/test-staking.ts @@ -1,18 +1,8 @@ import { - addressToCollectionId, - createCollection, describeWithExistingNode, - extractRevertReason, - slotAndOwnerToTokenId, } from "./util"; import { GAS_LIMIT, - FAITH, - SELECTOR_LOG_EVOLVED_WITH_EXTERNAL_TOKEN_URI, - SELECTOR_LOG_MINTED_WITH_EXTERNAL_TOKEN_URI, - SELECTOR_LOG_OWNERSHIP_TRANSFERRED, - SELECTOR_LOG_PUBLIC_MINTING_ENABLED, - SELECTOR_LOG_PUBLIC_MINTING_DISABLED, ALITH, ALITH_PRIVATE_KEY, STAKING_ABI, @@ -22,7 +12,6 @@ import { } from "./config"; import { expect } from "chai"; import Contract from "web3-eth-contract"; -import BN from "bn.js"; import { step } from "mocha-steps"; import { Keyring } from "@polkadot/api"; @@ -48,8 +37,7 @@ describeWithExistingNode("Frontier RPC (Staking)", (context) => { let nonce = await context.web3.eth.getTransactionCount(ALITH); const result = await contract.methods.joinCandidates(BigInt(20000) * UNIT, 0).send({ from: ALITH, gas: GAS_LIMIT, nonce: nonce++ }); - console.log(`result: ${result}`); + expect(result.status).to.be.eq(true); }); - }); From f58b52c1f3c627e57260bd3dd359f47df0769594 Mon Sep 17 00:00:00 2001 From: magecnion Date: Tue, 23 Jul 2024 16:23:05 +0200 Subject: [PATCH 07/16] delegate test --- e2e-tests/tests/test-staking.ts | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/e2e-tests/tests/test-staking.ts b/e2e-tests/tests/test-staking.ts index f593e627d..99e9371c2 100644 --- a/e2e-tests/tests/test-staking.ts +++ b/e2e-tests/tests/test-staking.ts @@ -9,6 +9,8 @@ import { STAKING_CONTRACT_ADDRESS, GAS_PRICE, UNIT, + FAITH_PRIVATE_KEY, + FAITH, } from "./config"; import { expect } from "chai"; import Contract from "web3-eth-contract"; @@ -25,19 +27,32 @@ describeWithExistingNode("Frontier RPC (Staking)", (context) => { gas: GAS_LIMIT, }); context.web3.eth.accounts.wallet.add(ALITH_PRIVATE_KEY); + context.web3.eth.accounts.wallet.add(FAITH_PRIVATE_KEY); }); - step("Alith can join as candidate", async function () { - const alith = new Keyring({ type: "ethereum" }).addFromUri(ALITH_PRIVATE_KEY); + + step("Faith can join as candidate", async function () { + // insert session key into the node and link to Faith + const faith = new Keyring({ type: "ethereum" }).addFromUri(FAITH_PRIVATE_KEY); const key = (await context.polkadot.rpc.author.rotateKeys()).toHex(); - context.polkadot.tx.session.setKeys(key, "").signAndSend(alith, (result) => { - console.log(`transaction result: ${result}`); + context.polkadot.tx.session.setKeys(key, "").signAndSend(faith, (result) => { }).catch((error: any) => { console.log('transaction failed', error); }); + expect(await contract.methods.isCandidate(FAITH).call()).to.be.eq(false); + let nonce = await context.web3.eth.getTransactionCount(FAITH); + const candidateCount = await contract.methods.candidateCount().call(); + const result = await contract.methods.joinCandidates(BigInt(20000) * UNIT, candidateCount).send({ from: FAITH, gas: GAS_LIMIT, nonce: nonce++ }); + expect(result.status).to.be.eq(true); + expect(await contract.methods.isCandidate(FAITH).call()).to.be.eq(true); + }); + + step("Alith can delegate to Faith", async function () { + expect(await contract.methods.isDelegator(ALITH).call()).to.be.eq(false); let nonce = await context.web3.eth.getTransactionCount(ALITH); - const result = await contract.methods.joinCandidates(BigInt(20000) * UNIT, 0).send({ from: ALITH, gas: GAS_LIMIT, nonce: nonce++ }); + const result = await contract.methods.delegate(FAITH, BigInt(1000) * UNIT, 0, 0).send({ from: ALITH, gas: GAS_LIMIT, nonce: nonce++ }); expect(result.status).to.be.eq(true); + expect(await contract.methods.isDelegator(ALITH).call()).to.be.eq(true); }); }); From 63b08570e2a67984b0c53404f425ae56a1dba011 Mon Sep 17 00:00:00 2001 From: magecnion Date: Tue, 23 Jul 2024 16:38:59 +0200 Subject: [PATCH 08/16] fmt --- e2e-tests/tests/config.ts | 2 + e2e-tests/tests/test-staking.ts | 96 +++++++++++++++++---------------- e2e-tests/tests/util.ts | 15 ++++-- 3 files changed, 62 insertions(+), 51 deletions(-) diff --git a/e2e-tests/tests/config.ts b/e2e-tests/tests/config.ts index 8bec2711f..47197204f 100644 --- a/e2e-tests/tests/config.ts +++ b/e2e-tests/tests/config.ts @@ -23,6 +23,8 @@ export const FAITH = "0xC0F0f4ab324C46e55D02D0033343B4Be8A55532d"; export const FAITH_PRIVATE_KEY = "0xb9d2ea9a615f3165812e8d44de0d24da9bbd164b65c4f0573e1ce2c8dbd9c8df"; export const ALITH = "0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac"; export const ALITH_PRIVATE_KEY = "0x5fb92d6e98884f76de468fa3f6278f8807c48bebc13595d45af5bdc4da702133"; +export const BALTATHAR = "0x3Cd0A705a2DC65e5b1E1205896BaA2be8A07c6e0"; +export const BALTATHAR_PRIVATE_KEY = "0x8075991ce870b93a8870eca0c0f91913d12f47948ca0fd25b49c6fa7cdbeee8b"; // LAOS Evolution Contract export const EVOLUTION_COLLECTION_FACTORY_ABI = EvolutionCollectionFactory.abi as AbiItem[]; diff --git a/e2e-tests/tests/test-staking.ts b/e2e-tests/tests/test-staking.ts index 99e9371c2..8cdfbd559 100644 --- a/e2e-tests/tests/test-staking.ts +++ b/e2e-tests/tests/test-staking.ts @@ -1,16 +1,15 @@ +import { describeWithExistingNode } from "./util"; import { - describeWithExistingNode, -} from "./util"; -import { - GAS_LIMIT, - ALITH, - ALITH_PRIVATE_KEY, - STAKING_ABI, - STAKING_CONTRACT_ADDRESS, - GAS_PRICE, - UNIT, - FAITH_PRIVATE_KEY, - FAITH, + GAS_LIMIT, + ALITH, + STAKING_ABI, + STAKING_CONTRACT_ADDRESS, + GAS_PRICE, + UNIT, + FAITH_PRIVATE_KEY, + FAITH, + BALTATHAR, + BALTATHAR_PRIVATE_KEY, } from "./config"; import { expect } from "chai"; import Contract from "web3-eth-contract"; @@ -18,41 +17,46 @@ import { step } from "mocha-steps"; import { Keyring } from "@polkadot/api"; describeWithExistingNode("Frontier RPC (Staking)", (context) => { - let contract: Contract; + let contract: Contract; - before(async function () { - contract = new context.web3.eth.Contract(STAKING_ABI, STAKING_CONTRACT_ADDRESS, { - from: ALITH, - gasPrice: GAS_PRICE, - gas: GAS_LIMIT, - }); - context.web3.eth.accounts.wallet.add(ALITH_PRIVATE_KEY); - context.web3.eth.accounts.wallet.add(FAITH_PRIVATE_KEY); - }); + before(async function () { + contract = new context.web3.eth.Contract(STAKING_ABI, STAKING_CONTRACT_ADDRESS, { + from: ALITH, + gasPrice: GAS_PRICE, + gas: GAS_LIMIT, + }); + context.web3.eth.accounts.wallet.add(BALTATHAR_PRIVATE_KEY); + context.web3.eth.accounts.wallet.add(FAITH_PRIVATE_KEY); + }); - step("Faith can join as candidate", async function () { - // insert session key into the node and link to Faith - const faith = new Keyring({ type: "ethereum" }).addFromUri(FAITH_PRIVATE_KEY); - const key = (await context.polkadot.rpc.author.rotateKeys()).toHex(); - context.polkadot.tx.session.setKeys(key, "").signAndSend(faith, (result) => { - }).catch((error: any) => { - console.log('transaction failed', error); - }); + step("Faith can join as candidate", async function () { + // insert session key into the node and link to Faith + const faith = new Keyring({ type: "ethereum" }).addFromUri(FAITH_PRIVATE_KEY); + const key = (await context.polkadot.rpc.author.rotateKeys()).toHex(); + context.polkadot.tx.session + .setKeys(key, "") + .signAndSend(faith, (result) => {}) + .catch((error: any) => { + console.log("transaction failed", error); + }); - expect(await contract.methods.isCandidate(FAITH).call()).to.be.eq(false); - let nonce = await context.web3.eth.getTransactionCount(FAITH); - const candidateCount = await contract.methods.candidateCount().call(); - const result = await contract.methods.joinCandidates(BigInt(20000) * UNIT, candidateCount).send({ from: FAITH, gas: GAS_LIMIT, nonce: nonce++ }); - expect(result.status).to.be.eq(true); - expect(await contract.methods.isCandidate(FAITH).call()).to.be.eq(true); - }); - - step("Alith can delegate to Faith", async function () { - expect(await contract.methods.isDelegator(ALITH).call()).to.be.eq(false); - let nonce = await context.web3.eth.getTransactionCount(ALITH); - const result = await contract.methods.delegate(FAITH, BigInt(1000) * UNIT, 0, 0).send({ from: ALITH, gas: GAS_LIMIT, nonce: nonce++ }); - expect(result.status).to.be.eq(true); - expect(await contract.methods.isDelegator(ALITH).call()).to.be.eq(true); - }); -}); + expect(await contract.methods.isCandidate(FAITH).call()).to.be.eq(false); + let nonce = await context.web3.eth.getTransactionCount(FAITH); + const candidateCount = await contract.methods.candidateCount().call(); + const result = await contract.methods + .joinCandidates(BigInt(20000) * UNIT, candidateCount) + .send({ from: FAITH, gas: GAS_LIMIT, nonce: nonce++ }); + expect(result.status).to.be.eq(true); + expect(await contract.methods.isCandidate(FAITH).call()).to.be.eq(true); + }); + step("Baltathar can delegate to Faith", async function () { + expect(await contract.methods.isDelegator(BALTATHAR).call()).to.be.eq(false); + let nonce = await context.web3.eth.getTransactionCount(BALTATHAR); + const result = await contract.methods + .delegate(FAITH, BigInt(1000) * UNIT, 0, 0) + .send({ from: BALTATHAR, gas: GAS_LIMIT, nonce: nonce++ }); + expect(result.status).to.be.eq(true); + expect(await contract.methods.isDelegator(BALTATHAR).call()).to.be.eq(true); + }); +}); diff --git a/e2e-tests/tests/util.ts b/e2e-tests/tests/util.ts index 0b1c43ac7..b10670c35 100644 --- a/e2e-tests/tests/util.ts +++ b/e2e-tests/tests/util.ts @@ -17,7 +17,7 @@ import BN from "bn.js"; import { expect } from "chai"; import "@polkadot/api-augment"; -import { ApiPromise, HttpProvider } from '@polkadot/api'; +import { ApiPromise, HttpProvider } from "@polkadot/api"; require("events").EventEmitter.prototype._maxListeners = 100; @@ -44,15 +44,20 @@ export async function customRequest(web3: Web3, method: string, params: any[]) { }); } -export function describeWithExistingNode(title: string, cb: (context: { web3: Web3, polkadot: ApiPromise }) => void, provider?: string) { +export function describeWithExistingNode( + title: string, + cb: (context: { web3: Web3; polkadot: ApiPromise }) => void, + provider?: string +) { describe(title, () => { let context: { web3: Web3; ethersjs: ethers.JsonRpcProvider; - polkadot: ApiPromise; + polkadot: ApiPromise; } = { - web3: null, ethersjs: null, - polkadot: undefined + web3: null, + ethersjs: null, + polkadot: undefined, }; before(async () => { From 26a8949309cf7d7f292238e09029da56f5a4c344 Mon Sep 17 00:00:00 2001 From: magecnion Date: Wed, 24 Jul 2024 10:42:18 +0200 Subject: [PATCH 09/16] remove unneeded code --- e2e-tests/tests/test-evolution.ts | 4 ++-- e2e-tests/tests/util.ts | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/e2e-tests/tests/test-evolution.ts b/e2e-tests/tests/test-evolution.ts index 3569351be..bed1dfaf9 100644 --- a/e2e-tests/tests/test-evolution.ts +++ b/e2e-tests/tests/test-evolution.ts @@ -160,7 +160,7 @@ describeWithExistingNode("Frontier RPC (Mint and Evolve Assets)", (context) => { }); }); -describeWithExistingNode("@qa Frontier RPC (Public Minting)", (context) => { +describeWithExistingNode("Frontier RPC (Public Minting)", (context) => { let collectionContract: Contract; beforeEach(async function () { @@ -251,7 +251,7 @@ describeWithExistingNode("@qa Frontier RPC (Public Minting)", (context) => { }); }); -describeWithExistingNode("@qa Frontier RPC (Transfer Ownership)", (context) => { +describeWithExistingNode("Frontier RPC (Transfer Ownership)", (context) => { let collectionContract: Contract; before(async function () { diff --git a/e2e-tests/tests/util.ts b/e2e-tests/tests/util.ts index b10670c35..b43ed6297 100644 --- a/e2e-tests/tests/util.ts +++ b/e2e-tests/tests/util.ts @@ -47,7 +47,7 @@ export async function customRequest(web3: Web3, method: string, params: any[]) { export function describeWithExistingNode( title: string, cb: (context: { web3: Web3; polkadot: ApiPromise }) => void, - provider?: string + providerNodeUrl?: string ) { describe(title, () => { let context: { @@ -61,7 +61,11 @@ export function describeWithExistingNode( }; before(async () => { - if (!provider) { + if (providerNodeUrl) { + context.web3 = new Web3(providerNodeUrl); + const wsProvider = new HttpProvider(providerNodeUrl); + context.polkadot = await new ApiPromise({ provider: wsProvider }).isReady; + } else { context.web3 = new Web3(LOCAL_NODE_URL); const wsProvider = new HttpProvider(LOCAL_NODE_URL); context.polkadot = await new ApiPromise({ provider: wsProvider }).isReady; From 6608e3bfffbe2492471b77e127c1c651f297b910 Mon Sep 17 00:00:00 2001 From: magecnion Date: Wed, 24 Jul 2024 16:20:02 +0200 Subject: [PATCH 10/16] addressing comments --- .../{StakingInterface.sol => ParachainStaking.sol} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename precompiles/parachain-staking/{StakingInterface.sol => ParachainStaking.sol} (100%) diff --git a/precompiles/parachain-staking/StakingInterface.sol b/precompiles/parachain-staking/ParachainStaking.sol similarity index 100% rename from precompiles/parachain-staking/StakingInterface.sol rename to precompiles/parachain-staking/ParachainStaking.sol From 411450ab023f92591b78c05083c8d9027662efd2 Mon Sep 17 00:00:00 2001 From: magecnion Date: Wed, 24 Jul 2024 16:27:00 +0200 Subject: [PATCH 11/16] fix tests --- precompiles/parachain-staking/src/tests.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/precompiles/parachain-staking/src/tests.rs b/precompiles/parachain-staking/src/tests.rs index 7616966c8..6590d394e 100644 --- a/precompiles/parachain-staking/src/tests.rs +++ b/precompiles/parachain-staking/src/tests.rs @@ -1606,7 +1606,7 @@ fn get_candidate_total_counted_getter() { #[test] fn test_solidity_interface_has_all_function_selectors_documented_and_implemented() { check_precompile_implements_solidity_interfaces( - &["StakingInterface.sol"], + &["ParachainStaking.sol"], PCall::supports_selector, ) } From 8112d2f6a3e62b183bdca04c57e5062580b88014 Mon Sep 17 00:00:00 2001 From: magecnion Date: Wed, 24 Jul 2024 17:08:44 +0200 Subject: [PATCH 12/16] use estimate gas in e2e tests --- e2e-tests/tests/test-staking.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/e2e-tests/tests/test-staking.ts b/e2e-tests/tests/test-staking.ts index 8cdfbd559..d596e44fd 100644 --- a/e2e-tests/tests/test-staking.ts +++ b/e2e-tests/tests/test-staking.ts @@ -35,7 +35,7 @@ describeWithExistingNode("Frontier RPC (Staking)", (context) => { const key = (await context.polkadot.rpc.author.rotateKeys()).toHex(); context.polkadot.tx.session .setKeys(key, "") - .signAndSend(faith, (result) => {}) + .signAndSend(faith, () => {}) .catch((error: any) => { console.log("transaction failed", error); }); @@ -43,9 +43,11 @@ describeWithExistingNode("Frontier RPC (Staking)", (context) => { expect(await contract.methods.isCandidate(FAITH).call()).to.be.eq(false); let nonce = await context.web3.eth.getTransactionCount(FAITH); const candidateCount = await contract.methods.candidateCount().call(); + const estimatedGas = await contract.methods.joinCandidates(BigInt(20000) * UNIT, candidateCount).estimateGas(); + expect(estimatedGas).to.be.eq(59208); const result = await contract.methods .joinCandidates(BigInt(20000) * UNIT, candidateCount) - .send({ from: FAITH, gas: GAS_LIMIT, nonce: nonce++ }); + .send({ from: FAITH, gas: estimatedGas, nonce: nonce++ }); expect(result.status).to.be.eq(true); expect(await contract.methods.isCandidate(FAITH).call()).to.be.eq(true); }); @@ -53,9 +55,11 @@ describeWithExistingNode("Frontier RPC (Staking)", (context) => { step("Baltathar can delegate to Faith", async function () { expect(await contract.methods.isDelegator(BALTATHAR).call()).to.be.eq(false); let nonce = await context.web3.eth.getTransactionCount(BALTATHAR); + const estimatedGas = await contract.methods.delegate(FAITH, BigInt(1000) * UNIT, 0, 0).estimateGas(); + expect(estimatedGas).to.be.eq(59208); const result = await contract.methods .delegate(FAITH, BigInt(1000) * UNIT, 0, 0) - .send({ from: BALTATHAR, gas: GAS_LIMIT, nonce: nonce++ }); + .send({ from: BALTATHAR, gas: estimatedGas, nonce: nonce++ }); expect(result.status).to.be.eq(true); expect(await contract.methods.isDelegator(BALTATHAR).call()).to.be.eq(true); }); From 2e45dcc4333e979c8e173ca761c950cf2c4e6d04 Mon Sep 17 00:00:00 2001 From: magecnion Date: Thu, 25 Jul 2024 12:27:52 +0200 Subject: [PATCH 13/16] reproduce estimation bug in a test --- e2e-tests/tests/config.ts | 2 +- e2e-tests/tests/test-staking.ts | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/e2e-tests/tests/config.ts b/e2e-tests/tests/config.ts index 0716c98a4..f487c5b0e 100644 --- a/e2e-tests/tests/config.ts +++ b/e2e-tests/tests/config.ts @@ -16,7 +16,7 @@ export const LOCAL_NODE_URL = "http://127.0.0.1:9999"; export const CHAIN_ID = 667; export const GAS_PRICE = "0x3B9ACA00"; export const ETH_BLOCK_GAS_LIMIT = 15000000; // The same configuration as runtime -export const GAS_LIMIT = ETH_BLOCK_GAS_LIMIT - 10000000; +export const GAS_LIMIT = ETH_BLOCK_GAS_LIMIT - 10000000; // TODO remove subtraction // Accounts export const FAITH = "0xC0F0f4ab324C46e55D02D0033343B4Be8A55532d"; diff --git a/e2e-tests/tests/test-staking.ts b/e2e-tests/tests/test-staking.ts index d596e44fd..a78f27d0b 100644 --- a/e2e-tests/tests/test-staking.ts +++ b/e2e-tests/tests/test-staking.ts @@ -22,8 +22,6 @@ describeWithExistingNode("Frontier RPC (Staking)", (context) => { before(async function () { contract = new context.web3.eth.Contract(STAKING_ABI, STAKING_CONTRACT_ADDRESS, { from: ALITH, - gasPrice: GAS_PRICE, - gas: GAS_LIMIT, }); context.web3.eth.accounts.wallet.add(BALTATHAR_PRIVATE_KEY); context.web3.eth.accounts.wallet.add(FAITH_PRIVATE_KEY); @@ -41,13 +39,17 @@ describeWithExistingNode("Frontier RPC (Staking)", (context) => { }); expect(await contract.methods.isCandidate(FAITH).call()).to.be.eq(false); - let nonce = await context.web3.eth.getTransactionCount(FAITH); const candidateCount = await contract.methods.candidateCount().call(); + expect((await context.web3.eth.getBlock("latest")).baseFeePerGas.toString()).to.be.eq( + await context.web3.eth.getGasPrice() + ); // it starts with 1 Gwei and decreases until 0.5 Gwei const estimatedGas = await contract.methods.joinCandidates(BigInt(20000) * UNIT, candidateCount).estimateGas(); expect(estimatedGas).to.be.eq(59208); + const gasPrice = (await context.web3.eth.getGasPrice()) + 1; // if we don't add +1 tx never gets included in the block + let nonce = await context.web3.eth.getTransactionCount(FAITH); const result = await contract.methods .joinCandidates(BigInt(20000) * UNIT, candidateCount) - .send({ from: FAITH, gas: estimatedGas, nonce: nonce++ }); + .send({ from: FAITH, gas: estimatedGas, gasPrice, nonce: nonce++ }); expect(result.status).to.be.eq(true); expect(await contract.methods.isCandidate(FAITH).call()).to.be.eq(true); }); @@ -56,10 +58,11 @@ describeWithExistingNode("Frontier RPC (Staking)", (context) => { expect(await contract.methods.isDelegator(BALTATHAR).call()).to.be.eq(false); let nonce = await context.web3.eth.getTransactionCount(BALTATHAR); const estimatedGas = await contract.methods.delegate(FAITH, BigInt(1000) * UNIT, 0, 0).estimateGas(); - expect(estimatedGas).to.be.eq(59208); + expect(estimatedGas).to.be.eq(101433); + const gasPrice = (await context.web3.eth.getGasPrice()) + 1; // if we don't add +1 tx never gets included in the block const result = await contract.methods .delegate(FAITH, BigInt(1000) * UNIT, 0, 0) - .send({ from: BALTATHAR, gas: estimatedGas, nonce: nonce++ }); + .send({ from: BALTATHAR, gas: estimatedGas, gasPrice, nonce: nonce++ }); expect(result.status).to.be.eq(true); expect(await contract.methods.isDelegator(BALTATHAR).call()).to.be.eq(true); }); From b9abc98a6f6affbfb9ac225ef2368b3555f57212 Mon Sep 17 00:00:00 2001 From: Alessandro Siniscalchi Date: Thu, 25 Jul 2024 13:48:37 +0200 Subject: [PATCH 14/16] new weights --- .../src/weights/cumulus_pallet_xcmp_queue.rs | 10 +- .../weights/pallet_asset_metadata_extender.rs | 90 ++--- runtime/laos/src/weights/pallet_evm.rs | 6 +- .../laos/src/weights/pallet_laos_evolution.rs | 88 ++--- runtime/laos/src/weights/pallet_multisig.rs | 68 ++-- .../src/weights/pallet_parachain_staking.rs | 308 +++++++++--------- .../weights/pallet_precompiles_benchmark.rs | 22 +- runtime/laos/src/weights/pallet_proxy.rs | 98 +++--- runtime/laos/src/weights/pallet_session.rs | 10 +- runtime/laos/src/weights/pallet_sudo.rs | 14 +- runtime/laos/src/weights/pallet_timestamp.rs | 10 +- runtime/laos/src/weights/pallet_utility.rs | 34 +- 12 files changed, 380 insertions(+), 378 deletions(-) diff --git a/runtime/laos/src/weights/cumulus_pallet_xcmp_queue.rs b/runtime/laos/src/weights/cumulus_pallet_xcmp_queue.rs index 77a7b0689..9cddfc4f2 100644 --- a/runtime/laos/src/weights/cumulus_pallet_xcmp_queue.rs +++ b/runtime/laos/src/weights/cumulus_pallet_xcmp_queue.rs @@ -2,7 +2,7 @@ //! Autogenerated weights for `cumulus_pallet_xcmp_queue` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2024-06-28, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-07-25, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `titan`, CPU: `12th Gen Intel(R) Core(TM) i7-1260P` //! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: 1024 @@ -36,8 +36,8 @@ impl cumulus_pallet_xcmp_queue::WeightInfo for WeightIn // Proof Size summary in bytes: // Measured: `76` // Estimated: `1561` - // Minimum execution time: 4_864_000 picoseconds. - Weight::from_parts(5_143_000, 0) + // Minimum execution time: 5_068_000 picoseconds. + Weight::from_parts(5_360_000, 0) .saturating_add(Weight::from_parts(0, 1561)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -48,8 +48,8 @@ impl cumulus_pallet_xcmp_queue::WeightInfo for WeightIn // Proof Size summary in bytes: // Measured: `76` // Estimated: `1561` - // Minimum execution time: 5_173_000 picoseconds. - Weight::from_parts(5_401_000, 0) + // Minimum execution time: 5_542_000 picoseconds. + Weight::from_parts(5_826_000, 0) .saturating_add(Weight::from_parts(0, 1561)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) diff --git a/runtime/laos/src/weights/pallet_asset_metadata_extender.rs b/runtime/laos/src/weights/pallet_asset_metadata_extender.rs index 1fb70a0f9..ab69c172c 100644 --- a/runtime/laos/src/weights/pallet_asset_metadata_extender.rs +++ b/runtime/laos/src/weights/pallet_asset_metadata_extender.rs @@ -2,7 +2,7 @@ //! Autogenerated weights for `pallet_asset_metadata_extender` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2024-06-28, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-07-25, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `titan`, CPU: `12th Gen Intel(R) Core(TM) i7-1260P` //! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: 1024 @@ -42,13 +42,13 @@ impl pallet_asset_metadata_extender::WeightInfo for Wei // Proof Size summary in bytes: // Measured: `4` // Estimated: `4545` - // Minimum execution time: 16_731_000 picoseconds. - Weight::from_parts(17_826_853, 0) + // Minimum execution time: 16_458_000 picoseconds. + Weight::from_parts(17_735_970, 0) .saturating_add(Weight::from_parts(0, 4545)) - // Standard Error: 99 - .saturating_add(Weight::from_parts(318, 0).saturating_mul(t.into())) - // Standard Error: 99 - .saturating_add(Weight::from_parts(11_825, 0).saturating_mul(u.into())) + // Standard Error: 117 + .saturating_add(Weight::from_parts(917, 0).saturating_mul(t.into())) + // Standard Error: 117 + .saturating_add(Weight::from_parts(12_072, 0).saturating_mul(u.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -60,13 +60,13 @@ impl pallet_asset_metadata_extender::WeightInfo for Wei // Proof Size summary in bytes: // Measured: `185 + u * (1 ±0)` // Estimated: `4545` - // Minimum execution time: 14_551_000 picoseconds. - Weight::from_parts(15_463_865, 0) + // Minimum execution time: 14_397_000 picoseconds. + Weight::from_parts(15_102_024, 0) .saturating_add(Weight::from_parts(0, 4545)) - // Standard Error: 85 - .saturating_add(Weight::from_parts(1_638, 0).saturating_mul(t.into())) - // Standard Error: 85 - .saturating_add(Weight::from_parts(9_881, 0).saturating_mul(u.into())) + // Standard Error: 84 + .saturating_add(Weight::from_parts(1_957, 0).saturating_mul(t.into())) + // Standard Error: 84 + .saturating_add(Weight::from_parts(10_219, 0).saturating_mul(u.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -77,11 +77,11 @@ impl pallet_asset_metadata_extender::WeightInfo for Wei // Proof Size summary in bytes: // Measured: `4` // Estimated: `3999` - // Minimum execution time: 2_303_000 picoseconds. - Weight::from_parts(2_782_864, 0) + // Minimum execution time: 2_282_000 picoseconds. + Weight::from_parts(2_843_665, 0) .saturating_add(Weight::from_parts(0, 3999)) - // Standard Error: 25 - .saturating_add(Weight::from_parts(2_064, 0).saturating_mul(u.into())) + // Standard Error: 30 + .saturating_add(Weight::from_parts(2_022, 0).saturating_mul(u.into())) .saturating_add(T::DbWeight::get().reads(1)) } /// Storage: `AssetMetadataExtender::ExtensionsCounter` (r:1 w:0) @@ -93,11 +93,11 @@ impl pallet_asset_metadata_extender::WeightInfo for Wei // Proof Size summary in bytes: // Measured: `167 + u * (2 ±0)` // Estimated: `4035` - // Minimum execution time: 7_992_000 picoseconds. - Weight::from_parts(9_296_162, 0) + // Minimum execution time: 7_745_000 picoseconds. + Weight::from_parts(9_078_739, 0) .saturating_add(Weight::from_parts(0, 4035)) - // Standard Error: 74 - .saturating_add(Weight::from_parts(14_301, 0).saturating_mul(u.into())) + // Standard Error: 77 + .saturating_add(Weight::from_parts(14_488, 0).saturating_mul(u.into())) .saturating_add(T::DbWeight::get().reads(2)) } /// Storage: `AssetMetadataExtender::ExtensionsCounter` (r:1 w:0) @@ -111,11 +111,11 @@ impl pallet_asset_metadata_extender::WeightInfo for Wei // Proof Size summary in bytes: // Measured: `314 + u * (3 ±0)` // Estimated: `4545` - // Minimum execution time: 11_398_000 picoseconds. - Weight::from_parts(12_923_930, 0) + // Minimum execution time: 10_635_000 picoseconds. + Weight::from_parts(12_743_310, 0) .saturating_add(Weight::from_parts(0, 4545)) - // Standard Error: 89 - .saturating_add(Weight::from_parts(20_319, 0).saturating_mul(u.into())) + // Standard Error: 119 + .saturating_add(Weight::from_parts(20_006, 0).saturating_mul(u.into())) .saturating_add(T::DbWeight::get().reads(3)) } /// Storage: `AssetMetadataExtender::TokenUrisByClaimerAndLocation` (r:1 w:0) @@ -125,11 +125,11 @@ impl pallet_asset_metadata_extender::WeightInfo for Wei // Proof Size summary in bytes: // Measured: `259 + u * (1 ±0)` // Estimated: `4545` - // Minimum execution time: 5_867_000 picoseconds. - Weight::from_parts(6_775_035, 0) + // Minimum execution time: 5_812_000 picoseconds. + Weight::from_parts(6_628_833, 0) .saturating_add(Weight::from_parts(0, 4545)) - // Standard Error: 48 - .saturating_add(Weight::from_parts(5_906, 0).saturating_mul(u.into())) + // Standard Error: 51 + .saturating_add(Weight::from_parts(5_738, 0).saturating_mul(u.into())) .saturating_add(T::DbWeight::get().reads(1)) } /// Storage: `AssetMetadataExtender::TokenUrisByClaimerAndLocation` (r:1 w:0) @@ -139,11 +139,11 @@ impl pallet_asset_metadata_extender::WeightInfo for Wei // Proof Size summary in bytes: // Measured: `4` // Estimated: `4545` - // Minimum execution time: 2_671_000 picoseconds. - Weight::from_parts(3_206_362, 0) + // Minimum execution time: 2_645_000 picoseconds. + Weight::from_parts(3_233_436, 0) .saturating_add(Weight::from_parts(0, 4545)) - // Standard Error: 29 - .saturating_add(Weight::from_parts(2_078, 0).saturating_mul(u.into())) + // Standard Error: 30 + .saturating_add(Weight::from_parts(2_171, 0).saturating_mul(u.into())) .saturating_add(T::DbWeight::get().reads(1)) } /// Storage: `AssetMetadataExtender::TokenUrisByClaimerAndLocation` (r:1 w:1) @@ -158,13 +158,13 @@ impl pallet_asset_metadata_extender::WeightInfo for Wei // Proof Size summary in bytes: // Measured: `4` // Estimated: `4545` - // Minimum execution time: 13_163_000 picoseconds. - Weight::from_parts(13_722_117, 0) + // Minimum execution time: 12_954_000 picoseconds. + Weight::from_parts(13_880_510, 0) .saturating_add(Weight::from_parts(0, 4545)) - // Standard Error: 78 - .saturating_add(Weight::from_parts(805, 0).saturating_mul(t.into())) - // Standard Error: 78 - .saturating_add(Weight::from_parts(8_846, 0).saturating_mul(u.into())) + // Standard Error: 72 + .saturating_add(Weight::from_parts(590, 0).saturating_mul(t.into())) + // Standard Error: 72 + .saturating_add(Weight::from_parts(8_736, 0).saturating_mul(u.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -176,13 +176,13 @@ impl pallet_asset_metadata_extender::WeightInfo for Wei // Proof Size summary in bytes: // Measured: `185 + u * (1 ±0)` // Estimated: `4545` - // Minimum execution time: 11_053_000 picoseconds. - Weight::from_parts(11_893_550, 0) + // Minimum execution time: 11_242_000 picoseconds. + Weight::from_parts(12_071_757, 0) .saturating_add(Weight::from_parts(0, 4545)) - // Standard Error: 67 - .saturating_add(Weight::from_parts(1_014, 0).saturating_mul(t.into())) - // Standard Error: 67 - .saturating_add(Weight::from_parts(7_033, 0).saturating_mul(u.into())) + // Standard Error: 89 + .saturating_add(Weight::from_parts(1_062, 0).saturating_mul(t.into())) + // Standard Error: 89 + .saturating_add(Weight::from_parts(6_574, 0).saturating_mul(u.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } diff --git a/runtime/laos/src/weights/pallet_evm.rs b/runtime/laos/src/weights/pallet_evm.rs index 62a221487..302ba2f32 100644 --- a/runtime/laos/src/weights/pallet_evm.rs +++ b/runtime/laos/src/weights/pallet_evm.rs @@ -2,7 +2,7 @@ //! Autogenerated weights for `pallet_evm` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2024-06-28, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-07-25, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `titan`, CPU: `12th Gen Intel(R) Core(TM) i7-1260P` //! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: 1024 @@ -34,8 +34,8 @@ impl pallet_evm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_416_000 picoseconds. - Weight::from_parts(1_543_000, 0) + // Minimum execution time: 1_371_000 picoseconds. + Weight::from_parts(1_637_000, 0) .saturating_add(Weight::from_parts(0, 0)) } } diff --git a/runtime/laos/src/weights/pallet_laos_evolution.rs b/runtime/laos/src/weights/pallet_laos_evolution.rs index 96944b8af..64c3811b2 100644 --- a/runtime/laos/src/weights/pallet_laos_evolution.rs +++ b/runtime/laos/src/weights/pallet_laos_evolution.rs @@ -2,7 +2,7 @@ //! Autogenerated weights for `pallet_laos_evolution` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2024-06-28, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-07-25, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `titan`, CPU: `12th Gen Intel(R) Core(TM) i7-1260P` //! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: 1024 @@ -34,8 +34,8 @@ impl pallet_laos_evolution::WeightInfo for WeightInfo pallet_laos_evolution::WeightInfo for WeightInfo Weight { // Proof Size summary in bytes: - // Measured: `375` - // Estimated: `3840` - // Minimum execution time: 23_224_000 picoseconds. - Weight::from_parts(23_861_000, 0) - .saturating_add(Weight::from_parts(0, 3840)) + // Measured: `408` + // Estimated: `3873` + // Minimum execution time: 23_301_000 picoseconds. + Weight::from_parts(23_907_000, 0) + .saturating_add(Weight::from_parts(0, 3873)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(5)) } @@ -69,11 +69,11 @@ impl pallet_laos_evolution::WeightInfo for WeightInfo pallet_laos_evolution::WeightInfo for WeightInfo pallet_laos_evolution::WeightInfo for WeightInfo pallet_laos_evolution::WeightInfo for WeightInfo pallet_laos_evolution::WeightInfo for WeightInfo pallet_laos_evolution::WeightInfo for WeightInfo pallet_laos_evolution::WeightInfo for WeightInfo pallet_laos_evolution::WeightInfo for WeightInfo pallet_laos_evolution::WeightInfo for WeightInfo pallet_laos_evolution::WeightInfo for WeightInfo pallet_laos_evolution::WeightInfo for WeightInfo pallet_laos_evolution::WeightInfo for WeightInfo pallet_laos_evolution::WeightInfo for WeightInfo pallet_laos_evolution::WeightInfo for WeightInfo pallet_multisig::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 6_176_000 picoseconds. - Weight::from_parts(6_627_984, 0) + // Minimum execution time: 6_569_000 picoseconds. + Weight::from_parts(7_135_097, 0) .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 2 - .saturating_add(Weight::from_parts(343, 0).saturating_mul(z.into())) + // Standard Error: 17 + .saturating_add(Weight::from_parts(367, 0).saturating_mul(z.into())) } /// Storage: `Multisig::Multisigs` (r:1 w:1) /// Proof: `Multisig::Multisigs` (`max_values`: None, `max_size`: Some(521), added: 2996, mode: `MaxEncodedLen`) @@ -49,13 +49,13 @@ impl pallet_multisig::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `204` // Estimated: `3986` - // Minimum execution time: 32_834_000 picoseconds. - Weight::from_parts(30_610_517, 0) + // Minimum execution time: 35_261_000 picoseconds. + Weight::from_parts(33_092_790, 0) .saturating_add(Weight::from_parts(0, 3986)) - // Standard Error: 3_485 - .saturating_add(Weight::from_parts(159_039, 0).saturating_mul(s.into())) + // Standard Error: 3_701 + .saturating_add(Weight::from_parts(164_496, 0).saturating_mul(s.into())) // Standard Error: 6 - .saturating_add(Weight::from_parts(1_115, 0).saturating_mul(z.into())) + .saturating_add(Weight::from_parts(1_189, 0).saturating_mul(z.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -67,13 +67,13 @@ impl pallet_multisig::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `246` // Estimated: `3986` - // Minimum execution time: 17_989_000 picoseconds. - Weight::from_parts(16_225_068, 0) + // Minimum execution time: 18_025_000 picoseconds. + Weight::from_parts(14_724_510, 0) .saturating_add(Weight::from_parts(0, 3986)) - // Standard Error: 2_028 - .saturating_add(Weight::from_parts(129_351, 0).saturating_mul(s.into())) - // Standard Error: 3 - .saturating_add(Weight::from_parts(1_135, 0).saturating_mul(z.into())) + // Standard Error: 18_233 + .saturating_add(Weight::from_parts(182_059, 0).saturating_mul(s.into())) + // Standard Error: 31 + .saturating_add(Weight::from_parts(1_391, 0).saturating_mul(z.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -87,13 +87,13 @@ impl pallet_multisig::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `334 + s * (20 ±0)` // Estimated: `3986` - // Minimum execution time: 36_265_000 picoseconds. - Weight::from_parts(33_711_951, 0) + // Minimum execution time: 36_106_000 picoseconds. + Weight::from_parts(31_269_988, 0) .saturating_add(Weight::from_parts(0, 3986)) - // Standard Error: 3_653 - .saturating_add(Weight::from_parts(217_810, 0).saturating_mul(s.into())) - // Standard Error: 6 - .saturating_add(Weight::from_parts(1_067, 0).saturating_mul(z.into())) + // Standard Error: 5_512 + .saturating_add(Weight::from_parts(307_066, 0).saturating_mul(s.into())) + // Standard Error: 10 + .saturating_add(Weight::from_parts(1_146, 0).saturating_mul(z.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -104,11 +104,11 @@ impl pallet_multisig::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `204` // Estimated: `3986` - // Minimum execution time: 28_880_000 picoseconds. - Weight::from_parts(29_540_492, 0) + // Minimum execution time: 28_522_000 picoseconds. + Weight::from_parts(29_422_331, 0) .saturating_add(Weight::from_parts(0, 3986)) - // Standard Error: 3_136 - .saturating_add(Weight::from_parts(161_575, 0).saturating_mul(s.into())) + // Standard Error: 3_362 + .saturating_add(Weight::from_parts(156_051, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -119,11 +119,11 @@ impl pallet_multisig::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `246` // Estimated: `3986` - // Minimum execution time: 14_895_000 picoseconds. - Weight::from_parts(15_408_719, 0) + // Minimum execution time: 14_526_000 picoseconds. + Weight::from_parts(15_125_678, 0) .saturating_add(Weight::from_parts(0, 3986)) - // Standard Error: 1_872 - .saturating_add(Weight::from_parts(127_795, 0).saturating_mul(s.into())) + // Standard Error: 1_929 + .saturating_add(Weight::from_parts(124_712, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -134,11 +134,11 @@ impl pallet_multisig::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `374` // Estimated: `3986` - // Minimum execution time: 29_752_000 picoseconds. - Weight::from_parts(30_276_953, 0) + // Minimum execution time: 28_580_000 picoseconds. + Weight::from_parts(30_215_482, 0) .saturating_add(Weight::from_parts(0, 3986)) - // Standard Error: 3_750 - .saturating_add(Weight::from_parts(184_870, 0).saturating_mul(s.into())) + // Standard Error: 3_744 + .saturating_add(Weight::from_parts(184_375, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } diff --git a/runtime/laos/src/weights/pallet_parachain_staking.rs b/runtime/laos/src/weights/pallet_parachain_staking.rs index 449d7f91a..4bdf27401 100644 --- a/runtime/laos/src/weights/pallet_parachain_staking.rs +++ b/runtime/laos/src/weights/pallet_parachain_staking.rs @@ -2,7 +2,7 @@ //! Autogenerated weights for `pallet_parachain_staking` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2024-06-28, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-07-25, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `titan`, CPU: `12th Gen Intel(R) Core(TM) i7-1260P` //! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: 1024 @@ -36,8 +36,8 @@ impl pallet_parachain_staking::WeightInfo for WeightInf // Proof Size summary in bytes: // Measured: `253` // Estimated: `1738` - // Minimum execution time: 9_552_000 picoseconds. - Weight::from_parts(10_065_000, 0) + // Minimum execution time: 10_747_000 picoseconds. + Weight::from_parts(11_238_000, 0) .saturating_add(Weight::from_parts(0, 1738)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -50,8 +50,8 @@ impl pallet_parachain_staking::WeightInfo for WeightInf // Proof Size summary in bytes: // Measured: `293` // Estimated: `1778` - // Minimum execution time: 13_480_000 picoseconds. - Weight::from_parts(14_827_000, 0) + // Minimum execution time: 14_524_000 picoseconds. + Weight::from_parts(15_181_000, 0) .saturating_add(Weight::from_parts(0, 1778)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) @@ -62,8 +62,8 @@ impl pallet_parachain_staking::WeightInfo for WeightInf // Proof Size summary in bytes: // Measured: `210` // Estimated: `1695` - // Minimum execution time: 10_081_000 picoseconds. - Weight::from_parts(10_467_000, 0) + // Minimum execution time: 10_827_000 picoseconds. + Weight::from_parts(11_529_000, 0) .saturating_add(Weight::from_parts(0, 1695)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -74,8 +74,8 @@ impl pallet_parachain_staking::WeightInfo for WeightInf // Proof Size summary in bytes: // Measured: `210` // Estimated: `1695` - // Minimum execution time: 9_788_000 picoseconds. - Weight::from_parts(10_193_000, 0) + // Minimum execution time: 10_853_000 picoseconds. + Weight::from_parts(11_359_000, 0) .saturating_add(Weight::from_parts(0, 1695)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -88,8 +88,8 @@ impl pallet_parachain_staking::WeightInfo for WeightInf // Proof Size summary in bytes: // Measured: `205` // Estimated: `1690` - // Minimum execution time: 11_765_000 picoseconds. - Weight::from_parts(12_219_000, 0) + // Minimum execution time: 12_228_000 picoseconds. + Weight::from_parts(12_664_000, 0) .saturating_add(Weight::from_parts(0, 1690)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) @@ -100,8 +100,8 @@ impl pallet_parachain_staking::WeightInfo for WeightInf // Proof Size summary in bytes: // Measured: `192` // Estimated: `1677` - // Minimum execution time: 9_973_000 picoseconds. - Weight::from_parts(10_248_000, 0) + // Minimum execution time: 10_274_000 picoseconds. + Weight::from_parts(10_699_000, 0) .saturating_add(Weight::from_parts(0, 1677)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -116,8 +116,8 @@ impl pallet_parachain_staking::WeightInfo for WeightInf // Proof Size summary in bytes: // Measured: `293` // Estimated: `1778` - // Minimum execution time: 15_768_000 picoseconds. - Weight::from_parts(16_313_000, 0) + // Minimum execution time: 16_307_000 picoseconds. + Weight::from_parts(17_391_000, 0) .saturating_add(Weight::from_parts(0, 1778)) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) @@ -145,11 +145,11 @@ impl pallet_parachain_staking::WeightInfo for WeightInf // Proof Size summary in bytes: // Measured: `1598 + x * (38 ±0)` // Estimated: `4783 + x * (41 ±0)` - // Minimum execution time: 48_922_000 picoseconds. - Weight::from_parts(58_471_890, 0) + // Minimum execution time: 51_339_000 picoseconds. + Weight::from_parts(60_793_078, 0) .saturating_add(Weight::from_parts(0, 4783)) - // Standard Error: 1_515 - .saturating_add(Weight::from_parts(86_423, 0).saturating_mul(x.into())) + // Standard Error: 1_702 + .saturating_add(Weight::from_parts(82_730, 0).saturating_mul(x.into())) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(7)) .saturating_add(Weight::from_parts(0, 41).saturating_mul(x.into())) @@ -165,11 +165,11 @@ impl pallet_parachain_staking::WeightInfo for WeightInf // Proof Size summary in bytes: // Measured: `980 + x * (37 ±0)` // Estimated: `4333 + x * (38 ±0)` - // Minimum execution time: 20_029_000 picoseconds. - Weight::from_parts(26_467_413, 0) + // Minimum execution time: 19_586_000 picoseconds. + Weight::from_parts(24_992_211, 0) .saturating_add(Weight::from_parts(0, 4333)) - // Standard Error: 1_454 - .saturating_add(Weight::from_parts(43_231, 0).saturating_mul(x.into())) + // Standard Error: 864 + .saturating_add(Weight::from_parts(54_117, 0).saturating_mul(x.into())) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) .saturating_add(Weight::from_parts(0, 38).saturating_mul(x.into())) @@ -199,13 +199,13 @@ impl pallet_parachain_staking::WeightInfo for WeightInf /// The range of component `x` is `[2, 350]`. fn execute_leave_candidates_worst_case(x: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `635 + x * (430 ±0)` - // Estimated: `4980 + x * (3762 ±0)` - // Minimum execution time: 101_215_000 picoseconds. - Weight::from_parts(102_576_000, 0) - .saturating_add(Weight::from_parts(0, 4980)) - // Standard Error: 70_787 - .saturating_add(Weight::from_parts(34_097_652, 0).saturating_mul(x.into())) + // Measured: `734 + x * (430 ±0)` + // Estimated: `5014 + x * (3762 ±0)` + // Minimum execution time: 102_601_000 picoseconds. + Weight::from_parts(104_373_000, 0) + .saturating_add(Weight::from_parts(0, 5014)) + // Standard Error: 39_559 + .saturating_add(Weight::from_parts(32_522_360, 0).saturating_mul(x.into())) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().reads((4_u64).saturating_mul(x.into()))) .saturating_add(T::DbWeight::get().writes(5)) @@ -238,13 +238,13 @@ impl pallet_parachain_staking::WeightInfo for WeightInf /// The range of component `y` is `[2, 350]`. fn execute_leave_candidates_ideal(x: u32, _y: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `628 + x * (430 ±0)` - // Estimated: `4980 + x * (3762 ±0)` - // Minimum execution time: 99_382_000 picoseconds. - Weight::from_parts(101_041_000, 0) - .saturating_add(Weight::from_parts(0, 4980)) - // Standard Error: 54_375 - .saturating_add(Weight::from_parts(34_066_090, 0).saturating_mul(x.into())) + // Measured: `729 + x * (430 ±0)` + // Estimated: `5014 + x * (3762 ±0)` + // Minimum execution time: 93_347_000 picoseconds. + Weight::from_parts(94_926_000, 0) + .saturating_add(Weight::from_parts(0, 5014)) + // Standard Error: 24_983 + .saturating_add(Weight::from_parts(33_165_999, 0).saturating_mul(x.into())) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().reads((4_u64).saturating_mul(x.into()))) .saturating_add(T::DbWeight::get().writes(5)) @@ -260,11 +260,11 @@ impl pallet_parachain_staking::WeightInfo for WeightInf // Proof Size summary in bytes: // Measured: `908 + x * (37 ±0)` // Estimated: `4261 + x * (38 ±0)` - // Minimum execution time: 17_049_000 picoseconds. - Weight::from_parts(22_081_836, 0) + // Minimum execution time: 16_949_000 picoseconds. + Weight::from_parts(21_521_322, 0) .saturating_add(Weight::from_parts(0, 4261)) - // Standard Error: 736 - .saturating_add(Weight::from_parts(51_022, 0).saturating_mul(x.into())) + // Standard Error: 719 + .saturating_add(Weight::from_parts(50_750, 0).saturating_mul(x.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) .saturating_add(Weight::from_parts(0, 38).saturating_mul(x.into())) @@ -278,11 +278,11 @@ impl pallet_parachain_staking::WeightInfo for WeightInf // Proof Size summary in bytes: // Measured: `805 + x * (38 ±0)` // Estimated: `4198 + x * (39 ±0)` - // Minimum execution time: 16_577_000 picoseconds. - Weight::from_parts(21_716_882, 0) + // Minimum execution time: 16_020_000 picoseconds. + Weight::from_parts(21_308_402, 0) .saturating_add(Weight::from_parts(0, 4198)) - // Standard Error: 891 - .saturating_add(Weight::from_parts(50_239, 0).saturating_mul(x.into())) + // Standard Error: 906 + .saturating_add(Weight::from_parts(52_380, 0).saturating_mul(x.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) .saturating_add(Weight::from_parts(0, 39).saturating_mul(x.into())) @@ -296,11 +296,11 @@ impl pallet_parachain_staking::WeightInfo for WeightInf // Proof Size summary in bytes: // Measured: `769 + x * (38 ±0)` // Estimated: `4162 + x * (39 ±0)` - // Minimum execution time: 15_825_000 picoseconds. - Weight::from_parts(20_970_981, 0) + // Minimum execution time: 15_454_000 picoseconds. + Weight::from_parts(21_241_920, 0) .saturating_add(Weight::from_parts(0, 4162)) - // Standard Error: 1_012 - .saturating_add(Weight::from_parts(59_482, 0).saturating_mul(x.into())) + // Standard Error: 940 + .saturating_add(Weight::from_parts(53_396, 0).saturating_mul(x.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) .saturating_add(Weight::from_parts(0, 39).saturating_mul(x.into())) @@ -322,11 +322,11 @@ impl pallet_parachain_staking::WeightInfo for WeightInf // Proof Size summary in bytes: // Measured: `1435 + x * (43 ±0)` // Estimated: `4752 + x * (44 ±0)` - // Minimum execution time: 41_532_000 picoseconds. - Weight::from_parts(55_232_730, 0) + // Minimum execution time: 39_222_000 picoseconds. + Weight::from_parts(50_202_648, 0) .saturating_add(Weight::from_parts(0, 4752)) - // Standard Error: 2_459 - .saturating_add(Weight::from_parts(89_879, 0).saturating_mul(x.into())) + // Standard Error: 1_943 + .saturating_add(Weight::from_parts(99_003, 0).saturating_mul(x.into())) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(5)) .saturating_add(Weight::from_parts(0, 44).saturating_mul(x.into())) @@ -339,8 +339,8 @@ impl pallet_parachain_staking::WeightInfo for WeightInf // Proof Size summary in bytes: // Measured: `448` // Estimated: `3913` - // Minimum execution time: 16_581_000 picoseconds. - Weight::from_parts(16_889_000, 0) + // Minimum execution time: 15_665_000 picoseconds. + Weight::from_parts(16_798_000, 0) .saturating_add(Weight::from_parts(0, 3913)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) @@ -363,12 +363,12 @@ impl pallet_parachain_staking::WeightInfo for WeightInf fn execute_candidate_bond_less(x: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `1658 + x * (42 ±0)` - // Estimated: `4936 + x * (44 ±0)` - // Minimum execution time: 51_245_000 picoseconds. - Weight::from_parts(61_874_192, 0) - .saturating_add(Weight::from_parts(0, 4936)) - // Standard Error: 1_438 - .saturating_add(Weight::from_parts(58_139, 0).saturating_mul(x.into())) + // Estimated: `4939 + x * (44 ±0)` + // Minimum execution time: 50_687_000 picoseconds. + Weight::from_parts(59_796_132, 0) + .saturating_add(Weight::from_parts(0, 4939)) + // Standard Error: 1_575 + .saturating_add(Weight::from_parts(46_987, 0).saturating_mul(x.into())) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(5)) .saturating_add(Weight::from_parts(0, 44).saturating_mul(x.into())) @@ -389,12 +389,12 @@ impl pallet_parachain_staking::WeightInfo for WeightInf fn set_candidate_bond_to_zero(x: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `1561 + x * (42 ±0)` - // Estimated: `4842 + x * (44 ±0)` - // Minimum execution time: 41_881_000 picoseconds. - Weight::from_parts(52_554_007, 0) - .saturating_add(Weight::from_parts(0, 4842)) - // Standard Error: 1_751 - .saturating_add(Weight::from_parts(72_321, 0).saturating_mul(x.into())) + // Estimated: `4845 + x * (44 ±0)` + // Minimum execution time: 39_861_000 picoseconds. + Weight::from_parts(48_151_740, 0) + .saturating_add(Weight::from_parts(0, 4845)) + // Standard Error: 1_331 + .saturating_add(Weight::from_parts(71_861, 0).saturating_mul(x.into())) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(5)) .saturating_add(Weight::from_parts(0, 44).saturating_mul(x.into())) @@ -405,8 +405,8 @@ impl pallet_parachain_staking::WeightInfo for WeightInf // Proof Size summary in bytes: // Measured: `428` // Estimated: `3893` - // Minimum execution time: 13_215_000 picoseconds. - Weight::from_parts(13_580_000, 0) + // Minimum execution time: 12_202_000 picoseconds. + Weight::from_parts(12_900_000, 0) .saturating_add(Weight::from_parts(0, 3893)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -433,13 +433,13 @@ impl pallet_parachain_staking::WeightInfo for WeightInf // Proof Size summary in bytes: // Measured: `2724 + x * (79 ±0) + y * (38 ±0)` // Estimated: `5938 + x * (81 ±0) + y * (39 ±0)` - // Minimum execution time: 82_707_000 picoseconds. - Weight::from_parts(81_671_404, 0) + // Minimum execution time: 83_375_000 picoseconds. + Weight::from_parts(75_792_370, 0) .saturating_add(Weight::from_parts(0, 5938)) - // Standard Error: 1_959 - .saturating_add(Weight::from_parts(59_572, 0).saturating_mul(x.into())) - // Standard Error: 642 - .saturating_add(Weight::from_parts(41_937, 0).saturating_mul(y.into())) + // Standard Error: 1_356 + .saturating_add(Weight::from_parts(137_330, 0).saturating_mul(x.into())) + // Standard Error: 444 + .saturating_add(Weight::from_parts(37_607, 0).saturating_mul(y.into())) .saturating_add(T::DbWeight::get().reads(8)) .saturating_add(T::DbWeight::get().writes(7)) .saturating_add(Weight::from_parts(0, 81).saturating_mul(x.into())) @@ -456,11 +456,11 @@ impl pallet_parachain_staking::WeightInfo for WeightInf // Proof Size summary in bytes: // Measured: `953 + x * (42 ±0)` // Estimated: `4396 + x * (43 ±0)` - // Minimum execution time: 17_994_000 picoseconds. - Weight::from_parts(26_804_635, 0) + // Minimum execution time: 18_769_000 picoseconds. + Weight::from_parts(28_207_899, 0) .saturating_add(Weight::from_parts(0, 4396)) - // Standard Error: 661 - .saturating_add(Weight::from_parts(48_592, 0).saturating_mul(x.into())) + // Standard Error: 798 + .saturating_add(Weight::from_parts(41_193, 0).saturating_mul(x.into())) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) .saturating_add(Weight::from_parts(0, 43).saturating_mul(x.into())) @@ -487,12 +487,12 @@ impl pallet_parachain_staking::WeightInfo for WeightInf fn delegator_bond_more(x: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `2161 + x * (79 ±0)` - // Estimated: `5605 + x * (79 ±0)` - // Minimum execution time: 58_856_000 picoseconds. - Weight::from_parts(76_514_856, 0) - .saturating_add(Weight::from_parts(0, 5605)) - // Standard Error: 1_517 - .saturating_add(Weight::from_parts(85_604, 0).saturating_mul(x.into())) + // Estimated: `5613 + x * (79 ±0)` + // Minimum execution time: 55_987_000 picoseconds. + Weight::from_parts(73_773_403, 0) + .saturating_add(Weight::from_parts(0, 5613)) + // Standard Error: 1_406 + .saturating_add(Weight::from_parts(84_822, 0).saturating_mul(x.into())) .saturating_add(T::DbWeight::get().reads(9)) .saturating_add(T::DbWeight::get().writes(7)) .saturating_add(Weight::from_parts(0, 79).saturating_mul(x.into())) @@ -508,11 +508,11 @@ impl pallet_parachain_staking::WeightInfo for WeightInf // Proof Size summary in bytes: // Measured: `953 + x * (42 ±0)` // Estimated: `4396 + x * (43 ±0)` - // Minimum execution time: 19_337_000 picoseconds. - Weight::from_parts(27_804_195, 0) + // Minimum execution time: 18_718_000 picoseconds. + Weight::from_parts(26_948_975, 0) .saturating_add(Weight::from_parts(0, 4396)) - // Standard Error: 671 - .saturating_add(Weight::from_parts(47_371, 0).saturating_mul(x.into())) + // Standard Error: 684 + .saturating_add(Weight::from_parts(45_577, 0).saturating_mul(x.into())) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) .saturating_add(Weight::from_parts(0, 43).saturating_mul(x.into())) @@ -541,10 +541,10 @@ impl pallet_parachain_staking::WeightInfo for WeightInf /// Proof: `ParachainStaking::Total` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn execute_revoke_delegation() -> Weight { // Proof Size summary in bytes: - // Measured: `1184` + // Measured: `1218` // Estimated: `4752` - // Minimum execution time: 81_863_000 picoseconds. - Weight::from_parts(84_018_000, 0) + // Minimum execution time: 75_886_000 picoseconds. + Weight::from_parts(78_799_000, 0) .saturating_add(Weight::from_parts(0, 4752)) .saturating_add(T::DbWeight::get().reads(11)) .saturating_add(T::DbWeight::get().writes(8)) @@ -577,8 +577,8 @@ impl pallet_parachain_staking::WeightInfo for WeightInf // Proof Size summary in bytes: // Measured: `37613` // Estimated: `41078` - // Minimum execution time: 301_913_000 picoseconds. - Weight::from_parts(326_280_000, 0) + // Minimum execution time: 297_142_000 picoseconds. + Weight::from_parts(329_218_000, 0) .saturating_add(Weight::from_parts(0, 41078)) .saturating_add(T::DbWeight::get().reads(12)) .saturating_add(T::DbWeight::get().writes(10)) @@ -607,8 +607,8 @@ impl pallet_parachain_staking::WeightInfo for WeightInf // Proof Size summary in bytes: // Measured: `28362` // Estimated: `31827` - // Minimum execution time: 268_465_000 picoseconds. - Weight::from_parts(288_004_000, 0) + // Minimum execution time: 264_116_000 picoseconds. + Weight::from_parts(288_775_000, 0) .saturating_add(Weight::from_parts(0, 31827)) .saturating_add(T::DbWeight::get().reads(10)) .saturating_add(T::DbWeight::get().writes(8)) @@ -622,11 +622,11 @@ impl pallet_parachain_staking::WeightInfo for WeightInf // Proof Size summary in bytes: // Measured: `1114 + x * (42 ±0)` // Estimated: `4543 + x * (43 ±0)` - // Minimum execution time: 22_445_000 picoseconds. - Weight::from_parts(24_915_637, 0) + // Minimum execution time: 22_070_000 picoseconds. + Weight::from_parts(23_481_932, 0) .saturating_add(Weight::from_parts(0, 4543)) - // Standard Error: 10_959 - .saturating_add(Weight::from_parts(631_504, 0).saturating_mul(x.into())) + // Standard Error: 8_772 + .saturating_add(Weight::from_parts(641_134, 0).saturating_mul(x.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) .saturating_add(Weight::from_parts(0, 43).saturating_mul(x.into())) @@ -649,10 +649,10 @@ impl pallet_parachain_staking::WeightInfo for WeightInf /// Proof: `ParachainStaking::DelayedPayouts` (`max_values`: None, `max_size`: None, mode: `Measured`) fn prepare_staking_payouts() -> Weight { // Proof Size summary in bytes: - // Measured: `645` + // Measured: `682` // Estimated: `6172` - // Minimum execution time: 55_325_000 picoseconds. - Weight::from_parts(56_392_000, 0) + // Minimum execution time: 56_814_000 picoseconds. + Weight::from_parts(59_138_000, 0) .saturating_add(Weight::from_parts(0, 6172)) .saturating_add(T::DbWeight::get().reads(8)) .saturating_add(T::DbWeight::get().writes(4)) @@ -666,11 +666,11 @@ impl pallet_parachain_staking::WeightInfo for WeightInf // Proof Size summary in bytes: // Measured: `349 + y * (36 ±0)` // Estimated: `3814 + y * (36 ±0)` - // Minimum execution time: 7_290_000 picoseconds. - Weight::from_parts(9_375_813, 0) + // Minimum execution time: 7_050_000 picoseconds. + Weight::from_parts(8_612_617, 0) .saturating_add(Weight::from_parts(0, 3814)) - // Standard Error: 626 - .saturating_add(Weight::from_parts(37_496, 0).saturating_mul(y.into())) + // Standard Error: 487 + .saturating_add(Weight::from_parts(42_762, 0).saturating_mul(y.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(Weight::from_parts(0, 36).saturating_mul(y.into())) } @@ -695,14 +695,14 @@ impl pallet_parachain_staking::WeightInfo for WeightInf fn select_top_candidates(x: u32, y: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0 + x * (3817 ±0) + y * (1800 ±0)` - // Estimated: `7646 + x * (3860 ±40) + y * (639 ±20)` - // Minimum execution time: 9_400_000 picoseconds. - Weight::from_parts(9_612_000, 0) + // Estimated: `7646 + x * (3860 ±41) + y * (639 ±20)` + // Minimum execution time: 8_792_000 picoseconds. + Weight::from_parts(8_903_000, 0) .saturating_add(Weight::from_parts(0, 7646)) - // Standard Error: 49_933 - .saturating_add(Weight::from_parts(15_618_720, 0).saturating_mul(x.into())) - // Standard Error: 24_900 - .saturating_add(Weight::from_parts(908_228, 0).saturating_mul(y.into())) + // Standard Error: 49_336 + .saturating_add(Weight::from_parts(14_716_178, 0).saturating_mul(x.into())) + // Standard Error: 24_602 + .saturating_add(Weight::from_parts(881_699, 0).saturating_mul(y.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().reads((4_u64).saturating_mul(x.into()))) .saturating_add(T::DbWeight::get().writes(1)) @@ -738,14 +738,14 @@ impl pallet_parachain_staking::WeightInfo for WeightInf fn pay_one_collator_reward_best(x: u32, y: u32, z: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0 + x * (394 ±0) + y * (156 ±0) + z * (41 ±0)` - // Estimated: `125180 + x * (2591 ±1) + y * (2234 ±1) + z * (28 ±0)` - // Minimum execution time: 241_000 picoseconds. - Weight::from_parts(274_000, 0) - .saturating_add(Weight::from_parts(0, 125180)) - // Standard Error: 486_279 - .saturating_add(Weight::from_parts(69_471_699, 0).saturating_mul(x.into())) - // Standard Error: 486_279 - .saturating_add(Weight::from_parts(29_167_325, 0).saturating_mul(y.into())) + // Estimated: `125288 + x * (2591 ±28) + y * (2234 ±28) + z * (28 ±0)` + // Minimum execution time: 240_000 picoseconds. + Weight::from_parts(264_000, 0) + .saturating_add(Weight::from_parts(0, 125288)) + // Standard Error: 434_469 + .saturating_add(Weight::from_parts(66_526_810, 0).saturating_mul(x.into())) + // Standard Error: 434_469 + .saturating_add(Weight::from_parts(28_468_981, 0).saturating_mul(y.into())) .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(x.into()))) .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(y.into()))) .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(x.into()))) @@ -771,13 +771,13 @@ impl pallet_parachain_staking::WeightInfo for WeightInf /// The range of component `y` is `[0, 300]`. fn pay_one_collator_reward(y: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `717 + y * (160 ±0)` - // Estimated: `6577 + y * (2591 ±0)` - // Minimum execution time: 34_664_000 picoseconds. - Weight::from_parts(255_984_916, 0) - .saturating_add(Weight::from_parts(0, 6577)) - // Standard Error: 32_890 - .saturating_add(Weight::from_parts(4_642_522, 0).saturating_mul(y.into())) + // Measured: `790 + y * (160 ±0)` + // Estimated: `6646 + y * (2591 ±0)` + // Minimum execution time: 31_358_000 picoseconds. + Weight::from_parts(232_077_533, 0) + .saturating_add(Weight::from_parts(0, 6646)) + // Standard Error: 31_104 + .saturating_add(Weight::from_parts(4_143_717, 0).saturating_mul(y.into())) .saturating_add(T::DbWeight::get().reads(9)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(y.into()))) .saturating_add(T::DbWeight::get().writes(9)) @@ -789,8 +789,8 @@ impl pallet_parachain_staking::WeightInfo for WeightInf // Proof Size summary in bytes: // Measured: `347` // Estimated: `1832` - // Minimum execution time: 4_940_000 picoseconds. - Weight::from_parts(5_236_000, 0) + // Minimum execution time: 4_820_000 picoseconds. + Weight::from_parts(5_016_000, 0) .saturating_add(Weight::from_parts(0, 1832)) .saturating_add(T::DbWeight::get().reads(1)) } @@ -804,13 +804,13 @@ impl pallet_parachain_staking::WeightInfo for WeightInf // Proof Size summary in bytes: // Measured: `1022 + x * (22 ±0) + y * (36 ±0)` // Estimated: `4378 + x * (23 ±0) + y * (36 ±0)` - // Minimum execution time: 25_295_000 picoseconds. - Weight::from_parts(27_083_214, 0) + // Minimum execution time: 24_675_000 picoseconds. + Weight::from_parts(24_454_355, 0) .saturating_add(Weight::from_parts(0, 4378)) - // Standard Error: 285 - .saturating_add(Weight::from_parts(26_899, 0).saturating_mul(x.into())) - // Standard Error: 855 - .saturating_add(Weight::from_parts(30_215, 0).saturating_mul(y.into())) + // Standard Error: 269 + .saturating_add(Weight::from_parts(26_945, 0).saturating_mul(x.into())) + // Standard Error: 805 + .saturating_add(Weight::from_parts(33_867, 0).saturating_mul(y.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) .saturating_add(Weight::from_parts(0, 23).saturating_mul(x.into())) @@ -843,15 +843,15 @@ impl pallet_parachain_staking::WeightInfo for WeightInf // Proof Size summary in bytes: // Measured: `0 + x * (60 ±0) + y * (21 ±0) + z * (78 ±0)` // Estimated: `26419 + x * (44 ±0) + y * (19 ±0) + z * (76 ±1)` - // Minimum execution time: 95_227_000 picoseconds. - Weight::from_parts(86_252_501, 0) + // Minimum execution time: 89_530_000 picoseconds. + Weight::from_parts(78_020_535, 0) .saturating_add(Weight::from_parts(0, 26419)) - // Standard Error: 738 - .saturating_add(Weight::from_parts(82_381, 0).saturating_mul(x.into())) - // Standard Error: 740 - .saturating_add(Weight::from_parts(5_987, 0).saturating_mul(y.into())) - // Standard Error: 2_607 - .saturating_add(Weight::from_parts(112_333, 0).saturating_mul(z.into())) + // Standard Error: 833 + .saturating_add(Weight::from_parts(81_016, 0).saturating_mul(x.into())) + // Standard Error: 835 + .saturating_add(Weight::from_parts(10_311, 0).saturating_mul(y.into())) + // Standard Error: 2_942 + .saturating_add(Weight::from_parts(111_667, 0).saturating_mul(z.into())) .saturating_add(T::DbWeight::get().reads(9)) .saturating_add(T::DbWeight::get().writes(8)) .saturating_add(Weight::from_parts(0, 44).saturating_mul(x.into())) @@ -884,8 +884,8 @@ impl pallet_parachain_staking::WeightInfo for WeightInf // Proof Size summary in bytes: // Measured: `48446` // Estimated: `54386` - // Minimum execution time: 203_566_000 picoseconds. - Weight::from_parts(210_331_000, 0) + // Minimum execution time: 194_988_000 picoseconds. + Weight::from_parts(199_273_000, 0) .saturating_add(Weight::from_parts(0, 54386)) .saturating_add(T::DbWeight::get().reads(15)) .saturating_add(T::DbWeight::get().writes(13)) @@ -896,8 +896,8 @@ impl pallet_parachain_staking::WeightInfo for WeightInf // Proof Size summary in bytes: // Measured: `91` // Estimated: `3581` - // Minimum execution time: 17_962_000 picoseconds. - Weight::from_parts(18_310_000, 0) + // Minimum execution time: 17_732_000 picoseconds. + Weight::from_parts(18_224_000, 0) .saturating_add(Weight::from_parts(0, 3581)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -908,10 +908,10 @@ impl pallet_parachain_staking::WeightInfo for WeightInf /// Proof: `ParachainStaking::RewardsAccount` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn send_collator_rewards() -> Weight { // Proof Size summary in bytes: - // Measured: `463` + // Measured: `500` // Estimated: `6172` - // Minimum execution time: 42_768_000 picoseconds. - Weight::from_parts(43_490_000, 0) + // Minimum execution time: 41_582_000 picoseconds. + Weight::from_parts(43_036_000, 0) .saturating_add(Weight::from_parts(0, 6172)) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) @@ -936,8 +936,8 @@ impl pallet_parachain_staking::WeightInfo for WeightInf // Proof Size summary in bytes: // Measured: `11709` // Estimated: `15174` - // Minimum execution time: 57_258_000 picoseconds. - Weight::from_parts(58_646_000, 0) + // Minimum execution time: 53_792_000 picoseconds. + Weight::from_parts(56_937_000, 0) .saturating_add(Weight::from_parts(0, 15174)) .saturating_add(T::DbWeight::get().reads(8)) .saturating_add(T::DbWeight::get().writes(2)) diff --git a/runtime/laos/src/weights/pallet_precompiles_benchmark.rs b/runtime/laos/src/weights/pallet_precompiles_benchmark.rs index 9566c3b33..4fa9eec98 100644 --- a/runtime/laos/src/weights/pallet_precompiles_benchmark.rs +++ b/runtime/laos/src/weights/pallet_precompiles_benchmark.rs @@ -2,9 +2,9 @@ //! Autogenerated weights for `pallet_precompiles_benchmark` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2024-07-12, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-07-25, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `Luigis-MacBook-Pro.local`, CPU: `` +//! HOSTNAME: `titan`, CPU: `12th Gen Intel(R) Core(TM) i7-1260P` //! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: 1024 // Executed Command: @@ -29,7 +29,7 @@ use core::marker::PhantomData; /// Weight functions for `pallet_precompiles_benchmark`. pub struct WeightInfo(PhantomData); -impl pallet_precompiles_benchmark::weights::WeightInfo for WeightInfo { +impl pallet_precompiles_benchmark::WeightInfo for WeightInfo { /// Storage: `Vesting::Vesting` (r:1 w:1) /// Proof: `Vesting::Vesting` (`max_values`: None, `max_size`: Some(1045), added: 3520, mode: `MaxEncodedLen`) /// Storage: `Balances::Locks` (r:1 w:1) @@ -42,8 +42,8 @@ impl pallet_precompiles_benchmark::weights::WeightInfo // Proof Size summary in bytes: // Measured: `520` // Estimated: `4752` - // Minimum execution time: 38_000_000 picoseconds. - Weight::from_parts(39_000_000, 0) + // Minimum execution time: 36_899_000 picoseconds. + Weight::from_parts(37_998_000, 0) .saturating_add(Weight::from_parts(0, 4752)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(3)) @@ -60,8 +60,8 @@ impl pallet_precompiles_benchmark::weights::WeightInfo // Proof Size summary in bytes: // Measured: `520` // Estimated: `4752` - // Minimum execution time: 38_000_000 picoseconds. - Weight::from_parts(39_000_000, 0) + // Minimum execution time: 35_058_000 picoseconds. + Weight::from_parts(36_201_000, 0) .saturating_add(Weight::from_parts(0, 4752)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(3)) @@ -73,11 +73,11 @@ impl pallet_precompiles_benchmark::weights::WeightInfo // Proof Size summary in bytes: // Measured: `198 + m * (36 ±0)` // Estimated: `4510` - // Minimum execution time: 4_000_000 picoseconds. - Weight::from_parts(5_778_301, 0) + // Minimum execution time: 3_967_000 picoseconds. + Weight::from_parts(5_620_081, 0) .saturating_add(Weight::from_parts(0, 4510)) - // Standard Error: 2_240 - .saturating_add(Weight::from_parts(53_144, 0).saturating_mul(m.into())) + // Standard Error: 1_728 + .saturating_add(Weight::from_parts(34_515, 0).saturating_mul(m.into())) .saturating_add(T::DbWeight::get().reads(1)) } } diff --git a/runtime/laos/src/weights/pallet_proxy.rs b/runtime/laos/src/weights/pallet_proxy.rs index 14af723e9..dc5240780 100644 --- a/runtime/laos/src/weights/pallet_proxy.rs +++ b/runtime/laos/src/weights/pallet_proxy.rs @@ -2,7 +2,7 @@ //! Autogenerated weights for `pallet_proxy` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2024-06-28, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-07-25, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `titan`, CPU: `12th Gen Intel(R) Core(TM) i7-1260P` //! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: 1024 @@ -37,11 +37,11 @@ impl pallet_proxy::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `115 + p * (25 ±0)` // Estimated: `4310` - // Minimum execution time: 13_059_000 picoseconds. - Weight::from_parts(14_635_038, 0) + // Minimum execution time: 12_781_000 picoseconds. + Weight::from_parts(13_379_734, 0) .saturating_add(Weight::from_parts(0, 4310)) - // Standard Error: 1_441 - .saturating_add(Weight::from_parts(29_411, 0).saturating_mul(p.into())) + // Standard Error: 1_040 + .saturating_add(Weight::from_parts(22_848, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(1)) } /// Storage: `Proxy::Proxies` (r:1 w:0) @@ -56,13 +56,13 @@ impl pallet_proxy::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `367 + a * (56 ±0) + p * (25 ±0)` // Estimated: `5302` - // Minimum execution time: 35_858_000 picoseconds. - Weight::from_parts(36_234_232, 0) + // Minimum execution time: 33_548_000 picoseconds. + Weight::from_parts(34_092_286, 0) .saturating_add(Weight::from_parts(0, 5302)) - // Standard Error: 2_219 - .saturating_add(Weight::from_parts(156_984, 0).saturating_mul(a.into())) - // Standard Error: 2_293 - .saturating_add(Weight::from_parts(48_518, 0).saturating_mul(p.into())) + // Standard Error: 2_058 + .saturating_add(Weight::from_parts(138_103, 0).saturating_mul(a.into())) + // Standard Error: 2_126 + .saturating_add(Weight::from_parts(33_031, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -76,13 +76,13 @@ impl pallet_proxy::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `295 + a * (56 ±0)` // Estimated: `5302` - // Minimum execution time: 23_329_000 picoseconds. - Weight::from_parts(24_221_396, 0) + // Minimum execution time: 21_771_000 picoseconds. + Weight::from_parts(22_206_832, 0) .saturating_add(Weight::from_parts(0, 5302)) - // Standard Error: 1_601 - .saturating_add(Weight::from_parts(146_058, 0).saturating_mul(a.into())) - // Standard Error: 1_654 - .saturating_add(Weight::from_parts(6_518, 0).saturating_mul(p.into())) + // Standard Error: 1_814 + .saturating_add(Weight::from_parts(118_125, 0).saturating_mul(a.into())) + // Standard Error: 1_874 + .saturating_add(Weight::from_parts(24_787, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -92,15 +92,17 @@ impl pallet_proxy::WeightInfo for WeightInfo { /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(116), added: 2591, mode: `MaxEncodedLen`) /// The range of component `a` is `[0, 31]`. /// The range of component `p` is `[1, 31]`. - fn reject_announcement(a: u32, _p: u32, ) -> Weight { + fn reject_announcement(a: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `295 + a * (56 ±0)` // Estimated: `5302` - // Minimum execution time: 23_310_000 picoseconds. - Weight::from_parts(24_508_370, 0) + // Minimum execution time: 21_157_000 picoseconds. + Weight::from_parts(22_049_039, 0) .saturating_add(Weight::from_parts(0, 5302)) - // Standard Error: 1_454 - .saturating_add(Weight::from_parts(136_594, 0).saturating_mul(a.into())) + // Standard Error: 1_395 + .saturating_add(Weight::from_parts(129_970, 0).saturating_mul(a.into())) + // Standard Error: 1_441 + .saturating_add(Weight::from_parts(5_049, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -116,13 +118,13 @@ impl pallet_proxy::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `311 + a * (56 ±0) + p * (25 ±0)` // Estimated: `5302` - // Minimum execution time: 32_138_000 picoseconds. - Weight::from_parts(32_751_263, 0) + // Minimum execution time: 28_945_000 picoseconds. + Weight::from_parts(29_552_974, 0) .saturating_add(Weight::from_parts(0, 5302)) - // Standard Error: 1_658 - .saturating_add(Weight::from_parts(157_770, 0).saturating_mul(a.into())) - // Standard Error: 1_713 - .saturating_add(Weight::from_parts(29_400, 0).saturating_mul(p.into())) + // Standard Error: 1_644 + .saturating_add(Weight::from_parts(148_586, 0).saturating_mul(a.into())) + // Standard Error: 1_699 + .saturating_add(Weight::from_parts(29_374, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -133,11 +135,11 @@ impl pallet_proxy::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `115 + p * (25 ±0)` // Estimated: `4310` - // Minimum execution time: 23_138_000 picoseconds. - Weight::from_parts(24_271_673, 0) + // Minimum execution time: 21_281_000 picoseconds. + Weight::from_parts(22_277_921, 0) .saturating_add(Weight::from_parts(0, 4310)) - // Standard Error: 1_364 - .saturating_add(Weight::from_parts(55_628, 0).saturating_mul(p.into())) + // Standard Error: 1_203 + .saturating_add(Weight::from_parts(43_266, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -148,11 +150,11 @@ impl pallet_proxy::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `115 + p * (25 ±0)` // Estimated: `4310` - // Minimum execution time: 23_444_000 picoseconds. - Weight::from_parts(24_826_220, 0) + // Minimum execution time: 21_374_000 picoseconds. + Weight::from_parts(22_612_809, 0) .saturating_add(Weight::from_parts(0, 4310)) - // Standard Error: 1_931 - .saturating_add(Weight::from_parts(50_084, 0).saturating_mul(p.into())) + // Standard Error: 1_619 + .saturating_add(Weight::from_parts(47_057, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -163,11 +165,11 @@ impl pallet_proxy::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `115 + p * (25 ±0)` // Estimated: `4310` - // Minimum execution time: 20_767_000 picoseconds. - Weight::from_parts(21_913_311, 0) + // Minimum execution time: 19_270_000 picoseconds. + Weight::from_parts(20_301_506, 0) .saturating_add(Weight::from_parts(0, 4310)) - // Standard Error: 1_362 - .saturating_add(Weight::from_parts(45_279, 0).saturating_mul(p.into())) + // Standard Error: 1_280 + .saturating_add(Weight::from_parts(35_882, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -178,11 +180,11 @@ impl pallet_proxy::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `127` // Estimated: `4310` - // Minimum execution time: 24_808_000 picoseconds. - Weight::from_parts(26_032_224, 0) + // Minimum execution time: 23_000_000 picoseconds. + Weight::from_parts(23_903_959, 0) .saturating_add(Weight::from_parts(0, 4310)) - // Standard Error: 1_586 - .saturating_add(Weight::from_parts(29_525, 0).saturating_mul(p.into())) + // Standard Error: 1_354 + .saturating_add(Weight::from_parts(20_207, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -193,11 +195,11 @@ impl pallet_proxy::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `140 + p * (25 ±0)` // Estimated: `4310` - // Minimum execution time: 21_695_000 picoseconds. - Weight::from_parts(22_612_205, 0) + // Minimum execution time: 19_759_000 picoseconds. + Weight::from_parts(21_148_563, 0) .saturating_add(Weight::from_parts(0, 4310)) - // Standard Error: 1_494 - .saturating_add(Weight::from_parts(50_439, 0).saturating_mul(p.into())) + // Standard Error: 1_610 + .saturating_add(Weight::from_parts(31_941, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } diff --git a/runtime/laos/src/weights/pallet_session.rs b/runtime/laos/src/weights/pallet_session.rs index e9487f818..163c341b8 100644 --- a/runtime/laos/src/weights/pallet_session.rs +++ b/runtime/laos/src/weights/pallet_session.rs @@ -2,7 +2,7 @@ //! Autogenerated weights for `pallet_session` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2024-06-28, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-07-25, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `titan`, CPU: `12th Gen Intel(R) Core(TM) i7-1260P` //! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: 1024 @@ -38,8 +38,8 @@ impl pallet_session::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `247` // Estimated: `3712` - // Minimum execution time: 14_562_000 picoseconds. - Weight::from_parts(15_495_000, 0) + // Minimum execution time: 12_679_000 picoseconds. + Weight::from_parts(13_127_000, 0) .saturating_add(Weight::from_parts(0, 3712)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) @@ -52,8 +52,8 @@ impl pallet_session::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `229` // Estimated: `3694` - // Minimum execution time: 10_310_000 picoseconds. - Weight::from_parts(10_800_000, 0) + // Minimum execution time: 9_073_000 picoseconds. + Weight::from_parts(9_613_000, 0) .saturating_add(Weight::from_parts(0, 3694)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(2)) diff --git a/runtime/laos/src/weights/pallet_sudo.rs b/runtime/laos/src/weights/pallet_sudo.rs index 29091e8ca..a8d02dc18 100644 --- a/runtime/laos/src/weights/pallet_sudo.rs +++ b/runtime/laos/src/weights/pallet_sudo.rs @@ -2,7 +2,7 @@ //! Autogenerated weights for `pallet_sudo` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2024-06-28, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-07-25, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `titan`, CPU: `12th Gen Intel(R) Core(TM) i7-1260P` //! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: 1024 @@ -36,8 +36,8 @@ impl pallet_sudo::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `120` // Estimated: `1505` - // Minimum execution time: 11_364_000 picoseconds. - Weight::from_parts(11_782_000, 0) + // Minimum execution time: 9_721_000 picoseconds. + Weight::from_parts(10_211_000, 0) .saturating_add(Weight::from_parts(0, 1505)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -48,8 +48,8 @@ impl pallet_sudo::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `120` // Estimated: `1505` - // Minimum execution time: 11_935_000 picoseconds. - Weight::from_parts(12_379_000, 0) + // Minimum execution time: 10_960_000 picoseconds. + Weight::from_parts(11_637_000, 0) .saturating_add(Weight::from_parts(0, 1505)) .saturating_add(T::DbWeight::get().reads(1)) } @@ -59,8 +59,8 @@ impl pallet_sudo::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `120` // Estimated: `1505` - // Minimum execution time: 12_894_000 picoseconds. - Weight::from_parts(13_528_000, 0) + // Minimum execution time: 10_768_000 picoseconds. + Weight::from_parts(11_477_000, 0) .saturating_add(Weight::from_parts(0, 1505)) .saturating_add(T::DbWeight::get().reads(1)) } diff --git a/runtime/laos/src/weights/pallet_timestamp.rs b/runtime/laos/src/weights/pallet_timestamp.rs index 6d35ea2d5..848ed8812 100644 --- a/runtime/laos/src/weights/pallet_timestamp.rs +++ b/runtime/laos/src/weights/pallet_timestamp.rs @@ -2,7 +2,7 @@ //! Autogenerated weights for `pallet_timestamp` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2024-06-28, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-07-25, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `titan`, CPU: `12th Gen Intel(R) Core(TM) i7-1260P` //! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: 1024 @@ -38,8 +38,8 @@ impl pallet_timestamp::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `120` // Estimated: `1493` - // Minimum execution time: 8_327_000 picoseconds. - Weight::from_parts(8_575_000, 0) + // Minimum execution time: 7_734_000 picoseconds. + Weight::from_parts(8_004_000, 0) .saturating_add(Weight::from_parts(0, 1493)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) @@ -48,8 +48,8 @@ impl pallet_timestamp::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `57` // Estimated: `0` - // Minimum execution time: 3_143_000 picoseconds. - Weight::from_parts(3_328_000, 0) + // Minimum execution time: 2_757_000 picoseconds. + Weight::from_parts(2_964_000, 0) .saturating_add(Weight::from_parts(0, 0)) } } diff --git a/runtime/laos/src/weights/pallet_utility.rs b/runtime/laos/src/weights/pallet_utility.rs index acc780dfc..4cb29d5d2 100644 --- a/runtime/laos/src/weights/pallet_utility.rs +++ b/runtime/laos/src/weights/pallet_utility.rs @@ -2,7 +2,7 @@ //! Autogenerated weights for `pallet_utility` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2024-06-28, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-07-25, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `titan`, CPU: `12th Gen Intel(R) Core(TM) i7-1260P` //! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: 1024 @@ -35,18 +35,18 @@ impl pallet_utility::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 5_334_000 picoseconds. - Weight::from_parts(28_912_911, 0) + // Minimum execution time: 5_001_000 picoseconds. + Weight::from_parts(16_747_938, 0) .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 4_074 - .saturating_add(Weight::from_parts(5_057_329, 0).saturating_mul(c.into())) + // Standard Error: 2_982 + .saturating_add(Weight::from_parts(4_438_180, 0).saturating_mul(c.into())) } fn as_derivative() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 4_368_000 picoseconds. - Weight::from_parts(4_549_000, 0) + // Minimum execution time: 3_800_000 picoseconds. + Weight::from_parts(4_004_000, 0) .saturating_add(Weight::from_parts(0, 0)) } /// The range of component `c` is `[0, 1000]`. @@ -54,18 +54,18 @@ impl pallet_utility::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 5_883_000 picoseconds. - Weight::from_parts(24_160_798, 0) + // Minimum execution time: 5_036_000 picoseconds. + Weight::from_parts(16_005_957, 0) .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 4_465 - .saturating_add(Weight::from_parts(5_321_467, 0).saturating_mul(c.into())) + // Standard Error: 2_664 + .saturating_add(Weight::from_parts(4_710_681, 0).saturating_mul(c.into())) } fn dispatch_as() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 8_197_000 picoseconds. - Weight::from_parts(8_560_000, 0) + // Minimum execution time: 7_284_000 picoseconds. + Weight::from_parts(7_508_000, 0) .saturating_add(Weight::from_parts(0, 0)) } /// The range of component `c` is `[0, 1000]`. @@ -73,10 +73,10 @@ impl pallet_utility::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 5_706_000 picoseconds. - Weight::from_parts(14_547_987, 0) + // Minimum execution time: 5_298_000 picoseconds. + Weight::from_parts(14_799_095, 0) .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 1_791 - .saturating_add(Weight::from_parts(4_969_675, 0).saturating_mul(c.into())) + // Standard Error: 1_625 + .saturating_add(Weight::from_parts(4_433_315, 0).saturating_mul(c.into())) } } From 40473463272490e837425746896ba0075aefb75d Mon Sep 17 00:00:00 2001 From: Alessandro Siniscalchi Date: Thu, 25 Jul 2024 13:55:45 +0200 Subject: [PATCH 15/16] compilation fix --- pallets/precompiles-benchmark/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/pallets/precompiles-benchmark/src/lib.rs b/pallets/precompiles-benchmark/src/lib.rs index d5eede58c..33c901748 100644 --- a/pallets/precompiles-benchmark/src/lib.rs +++ b/pallets/precompiles-benchmark/src/lib.rs @@ -21,6 +21,7 @@ use sp_runtime::traits::{Convert, ConvertBack}; pub use pallet::*; pub mod precompiles; pub mod weights; +pub use weights::WeightInfo; #[frame_support::pallet] pub mod pallet { From 240bc113c6be0fecf8cc6b844a84329fde498a5d Mon Sep 17 00:00:00 2001 From: luispdm <17044119+luispdm@users.noreply.github.com> Date: Thu, 25 Jul 2024 15:42:36 +0200 Subject: [PATCH 16/16] fix tests after new weights calculation --- runtime/laos/src/configs/evm.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/runtime/laos/src/configs/evm.rs b/runtime/laos/src/configs/evm.rs index 402ea6c6c..807a1519b 100644 --- a/runtime/laos/src/configs/evm.rs +++ b/runtime/laos/src/configs/evm.rs @@ -180,7 +180,7 @@ mod tests { ); assert_eq!( call_result.actual_weight.unwrap(), - Weight::from_parts(1035236000, 11596) + Weight::from_parts(1035286000, 11597) ); // check gas @@ -194,18 +194,18 @@ mod tests { ::GasWeightMapping::weight_to_gas( call_result.actual_weight.unwrap() ), - 41409 + 41411 ); // check weights from benchmarking let weights_from_benchmarking = weights::pallet_laos_evolution::WeightInfo::::precompile_create_collection(); - assert_eq!(weights_from_benchmarking, Weight::from_parts(623861000, 3_840)); + assert_eq!(weights_from_benchmarking, Weight::from_parts(623907000, 3_873)); assert_eq!( ::GasWeightMapping::weight_to_gas( weights_from_benchmarking ), - 24954 + 24956 ); }); } @@ -256,7 +256,7 @@ mod tests { wrong_address_call_result.actual_weight.unwrap(), Weight::from_parts(402_186_000, 5_266) ); - assert_eq!(call_result.actual_weight.unwrap(), Weight::from_parts(432286000, 5567)); + assert_eq!(call_result.actual_weight.unwrap(), Weight::from_parts(432311000, 5567)); // check gas assert_eq!( @@ -269,18 +269,18 @@ mod tests { ::GasWeightMapping::weight_to_gas( call_result.actual_weight.unwrap() ), - 17291 + 17292 ); // check weights from benchmarking let weights_from_benchmarking = weights::pallet_laos_evolution::WeightInfo::::precompile_owner(); - assert_eq!(weights_from_benchmarking, Weight::from_parts(29907000, 3_509)); + assert_eq!(weights_from_benchmarking, Weight::from_parts(29934000, 3_509)); assert_eq!( ::GasWeightMapping::weight_to_gas( weights_from_benchmarking ), - 1196 + 1197 ); }); }