Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

paras: dismiss pvf_checking_enabled configuration #7138

Merged
merged 16 commits into from
May 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 22 additions & 6 deletions node/test/service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ use polkadot_service::{
ClientHandle, Error, ExecuteWithClient, FullClient, IsCollator, NewFull, PrometheusConfig,
};
use polkadot_test_runtime::{
ParasSudoWrapperCall, Runtime, SignedExtra, SignedPayload, SudoCall, UncheckedExtrinsic,
VERSION,
ParasCall, ParasSudoWrapperCall, Runtime, SignedExtra, SignedPayload, SudoCall,
UncheckedExtrinsic, VERSION,
};
use sc_chain_spec::ChainSpec;
use sc_client_api::execution_extensions::ExecutionStrategies;
Expand Down Expand Up @@ -281,6 +281,19 @@ pub struct PolkadotTestNode {
}

impl PolkadotTestNode {
/// Send a sudo call to this node.
async fn send_sudo(
&self,
call: impl Into<polkadot_test_runtime::RuntimeCall>,
caller: Sr25519Keyring,
nonce: u32,
) -> Result<(), RpcTransactionError> {
let sudo = SudoCall::sudo { call: Box::new(call.into()) };

let extrinsic = construct_extrinsic(&*self.client, sudo, caller, nonce);
eskimor marked this conversation as resolved.
Show resolved Hide resolved
self.rpc_handlers.send_transaction(extrinsic.into()).await.map(drop)
}

/// Send an extrinsic to this node.
pub async fn send_extrinsic(
&self,
Expand All @@ -299,18 +312,21 @@ impl PolkadotTestNode {
validation_code: impl Into<ValidationCode>,
genesis_head: impl Into<HeadData>,
) -> Result<(), RpcTransactionError> {
let validation_code: ValidationCode = validation_code.into();
let call = ParasSudoWrapperCall::sudo_schedule_para_initialize {
id,
genesis: ParaGenesisArgs {
genesis_head: genesis_head.into(),
validation_code: validation_code.into(),
validation_code: validation_code.clone(),
para_kind: ParaKind::Parachain,
},
};

self.send_extrinsic(SudoCall::sudo { call: Box::new(call.into()) }, Sr25519Keyring::Alice)
.await
.map(drop)
self.send_sudo(call, Sr25519Keyring::Alice, 0).await?;

// Bypass pvf-checking.
let call = ParasCall::add_trusted_validation_code { validation_code };
self.send_sudo(call, Sr25519Keyring::Alice, 1).await
}

/// Wait for `count` blocks to be imported in the node and then exit. This function will not return if no blocks
Expand Down
1 change: 1 addition & 0 deletions runtime/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ frame-support-test = { git = "https://github.com/paritytech/substrate", branch =
pallet-babe = { git = "https://github.com/paritytech/substrate", branch = "master" }
pallet-treasury = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "master" }
serde_json = "1.0.96"
libsecp256k1 = "0.7.0"
test-helpers = { package = "polkadot-primitives-test-helpers", path = "../../primitives/test-helpers" }
Expand Down
21 changes: 17 additions & 4 deletions runtime/common/src/auctions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1731,8 +1731,12 @@ mod tests {
#[cfg(feature = "runtime-benchmarks")]
mod benchmarking {
use super::{Pallet as Auctions, *};
use frame_support::traits::{EnsureOrigin, OnInitialize};
use frame_support::{
assert_ok,
traits::{EnsureOrigin, OnInitialize},
};
use frame_system::RawOrigin;
use runtime_parachains::paras;
use sp_runtime::{traits::Bounded, SaturatedConversion};

use frame_benchmarking::{account, benchmarks, whitelisted_caller, BenchmarkError};
Expand All @@ -1745,7 +1749,7 @@ mod benchmarking {
assert_eq!(event, &system_event);
}

fn fill_winners<T: Config>(lease_period_index: LeasePeriodOf<T>) {
fn fill_winners<T: Config + paras::Config>(lease_period_index: LeasePeriodOf<T>) {
let auction_index = AuctionCounter::<T>::get();
let minimum_balance = CurrencyOf::<T>::minimum_balance();

Expand All @@ -1763,6 +1767,10 @@ mod benchmarking {
)
.is_ok());
}
assert_ok!(paras::Pallet::<T>::add_trusted_validation_code(
frame_system::Origin::<T>::Root.into(),
T::Registrar::worst_validation_code(),
));

T::Registrar::execute_pending_transitions();

Expand All @@ -1786,7 +1794,7 @@ mod benchmarking {
}

benchmarks! {
where_clause { where T: pallet_babe::Config }
where_clause { where T: pallet_babe::Config + paras::Config }

new_auction {
let duration = T::BlockNumber::max_value();
Expand Down Expand Up @@ -1824,7 +1832,12 @@ mod benchmarking {
let worst_head_data = T::Registrar::worst_head_data();
let worst_validation_code = T::Registrar::worst_validation_code();
T::Registrar::register(owner.clone(), para, worst_head_data.clone(), worst_validation_code.clone())?;
T::Registrar::register(owner, new_para, worst_head_data, worst_validation_code)?;
T::Registrar::register(owner, new_para, worst_head_data, worst_validation_code.clone())?;
assert_ok!(paras::Pallet::<T>::add_trusted_validation_code(
frame_system::Origin::<T>::Root.into(),
worst_validation_code,
));

T::Registrar::execute_pending_transitions();

// Make an existing bid
Expand Down
30 changes: 26 additions & 4 deletions runtime/common/src/crowdloan/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1953,6 +1953,7 @@ mod benchmarking {
use super::{Pallet as Crowdloan, *};
use frame_support::{assert_ok, traits::OnInitialize};
use frame_system::RawOrigin;
use runtime_parachains::paras;
use sp_core::crypto::UncheckedFrom;
use sp_runtime::traits::{Bounded, CheckedSub};
use sp_std::prelude::*;
Expand All @@ -1967,7 +1968,7 @@ mod benchmarking {
assert_eq!(event, &system_event);
}

fn create_fund<T: Config>(id: u32, end: T::BlockNumber) -> ParaId {
fn create_fund<T: Config + paras::Config>(id: u32, end: T::BlockNumber) -> ParaId {
let cap = BalanceOf::<T>::max_value();
let (_, offset) = T::Auctioneer::lease_period_length();
// Set to the very beginning of lease period index 0.
Expand All @@ -1987,7 +1988,16 @@ mod benchmarking {

let head_data = T::Registrar::worst_head_data();
let validation_code = T::Registrar::worst_validation_code();
assert_ok!(T::Registrar::register(caller.clone(), para_id, head_data, validation_code));
assert_ok!(T::Registrar::register(
caller.clone(),
para_id,
head_data,
validation_code.clone()
));
assert_ok!(paras::Pallet::<T>::add_trusted_validation_code(
frame_system::Origin::<T>::Root.into(),
validation_code,
));
T::Registrar::execute_pending_transitions();

assert_ok!(Crowdloan::<T>::create(
Expand Down Expand Up @@ -2020,6 +2030,8 @@ mod benchmarking {
}

benchmarks! {
where_clause { where T: paras::Config }

create {
let para_id = ParaId::from(1_u32);
let cap = BalanceOf::<T>::max_value();
Expand All @@ -2035,7 +2047,12 @@ mod benchmarking {
let verifier = MultiSigner::unchecked_from(account::<[u8; 32]>("verifier", 0, 0));

CurrencyOf::<T>::make_free_balance_be(&caller, BalanceOf::<T>::max_value());
T::Registrar::register(caller.clone(), para_id, head_data, validation_code)?;
T::Registrar::register(caller.clone(), para_id, head_data, validation_code.clone())?;
assert_ok!(paras::Pallet::<T>::add_trusted_validation_code(
frame_system::Origin::<T>::Root.into(),
validation_code,
));

T::Registrar::execute_pending_transitions();

}: _(RawOrigin::Signed(caller), para_id, cap, first_period, last_period, end, Some(verifier))
Expand Down Expand Up @@ -2123,7 +2140,12 @@ mod benchmarking {
let verifier = MultiSigner::unchecked_from(account::<[u8; 32]>("verifier", 0, 0));

CurrencyOf::<T>::make_free_balance_be(&caller, BalanceOf::<T>::max_value());
T::Registrar::register(caller.clone(), para_id, head_data, validation_code)?;
T::Registrar::register(caller.clone(), para_id, head_data, validation_code.clone())?;
assert_ok!(paras::Pallet::<T>::add_trusted_validation_code(
frame_system::Origin::<T>::Root.into(),
validation_code,
));

T::Registrar::execute_pending_transitions();

Crowdloan::<T>::create(
Expand Down
Loading