Skip to content

Commit

Permalink
Merge pull request Phala-Network#989 from Phala-Network/pink-default-cfg
Browse files Browse the repository at this point in the history
Lock pink runtime config parameters
  • Loading branch information
kvinwang authored Oct 10, 2022
2 parents e6d4402 + 17fbda5 commit e84053a
Show file tree
Hide file tree
Showing 3 changed files with 1,315 additions and 8 deletions.
29 changes: 21 additions & 8 deletions crates/pink/src/runtime.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
mod extension;
mod mock_types;
mod pallet_pink;
mod weights;

use std::time::{Duration, Instant};

use crate::types::{AccountId, Balance, BlockNumber, Hash, Hashing, Index};
use frame_support::{
parameter_types,
traits::ConstU128,
weights::{constants::WEIGHT_PER_SECOND, Weight},
};
use frame_support::{parameter_types, traits::ConstU128, weights::Weight};
use pallet_contracts::{Config, Frame, Schedule};
use sp_runtime::{
generic::Header,
Expand All @@ -18,7 +15,7 @@ use sp_runtime::{
};

pub use extension::{get_side_effects, ExecSideEffects};
pub use pink_extension::{Message, OspMessage, PinkEvent, HookPoint};
pub use pink_extension::{HookPoint, Message, OspMessage, PinkEvent};

type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<PinkRuntime>;
type Block = frame_system::mocking::MockBlock<PinkRuntime>;
Expand All @@ -37,6 +34,8 @@ frame_support::construct_runtime! {
}
}

const WEIGHT_PER_SECOND: Weight = Weight::from_ref_time(1_000_000_000_000);

parameter_types! {
pub const BlockHashCount: u32 = 250;
pub RuntimeBlockWeights: frame_system::limits::BlockWeights =
Expand Down Expand Up @@ -126,7 +125,7 @@ impl Config for PinkRuntime {
type CallFilter = frame_support::traits::Everything;
type CallStack = [Frame<Self>; 31];
type WeightPrice = Self;
type WeightInfo = ();
type WeightInfo = weights::PinkWeights<Self>;
type ChainExtension = extension::PinkExtension;
type DeletionQueueDepth = DeletionQueueDepth;
type DeletionWeightLimit = DeletionWeightLimit;
Expand All @@ -139,6 +138,20 @@ impl Config for PinkRuntime {
type MaxStorageKeyLen = MaxStorageKeyLen;
}

#[test]
fn detect_parameter_changes() {
use sp_core::Get;
insta::assert_debug_snapshot!((
<PinkRuntime as frame_system::Config>::BlockWeights::get(),
<PinkRuntime as Config>::Schedule::get(),
<PinkRuntime as Config>::ContractAccessWeight::get(),
<PinkRuntime as Config>::DeletionQueueDepth::get(),
<PinkRuntime as Config>::DeletionWeightLimit::get(),
<PinkRuntime as Config>::MaxCodeLen::get(),
<PinkRuntime as Config>::MaxStorageKeyLen::get(),
));
}

#[derive(Clone, Copy)]
pub enum CallMode {
Query,
Expand Down Expand Up @@ -194,7 +207,7 @@ mod tests {
use sp_runtime::{traits::Hash, AccountId32};

use crate::{
runtime::{Contracts, RuntimeOrigin as Origin, PinkRuntime},
runtime::{Contracts, PinkRuntime, RuntimeOrigin as Origin},
types::{ENOUGH, QUERY_GAS_LIMIT},
};
pub use frame_support::weights::Weight;
Expand Down
Loading

0 comments on commit e84053a

Please sign in to comment.