Skip to content

Commit

Permalink
chore: default contracts config
Browse files Browse the repository at this point in the history
  • Loading branch information
Daanvdplas committed Dec 21, 2024
1 parent 373225e commit 9e2e592
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 28 deletions.
17 changes: 3 additions & 14 deletions runtime/devnet/src/config/contracts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,6 @@ use crate::{
Timestamp,
};

fn schedule<T: pallet_contracts::Config>() -> pallet_contracts::Schedule<T> {
pallet_contracts::Schedule {
limits: pallet_contracts::Limits {
runtime_memory: 1024 * 1024 * 1024,
validator_runtime_memory: 2 * 1024 * 1024 * 1024,
..Default::default()
},
..Default::default()
}
}

// randomness-collective-flip is insecure. Provide dummy randomness as placeholder for the
// deprecated trait. https://github.com/paritytech/polkadot-sdk/blob/9bf1a5e23884921498b381728bfddaae93f83744/substrate/frame/contracts/mock-network/src/parachain/contracts_config.rs#L45
pub struct DummyRandomness<T: pallet_contracts::Config>(PhantomData<T>);
Expand All @@ -36,7 +25,7 @@ impl<T: pallet_contracts::Config> Randomness<T::Hash, BlockNumberFor<T>> for Dum
parameter_types! {
pub const DepositPerItem: Balance = deposit(1, 0);
pub const DepositPerByte: Balance = deposit(0, 1);
pub Schedule: pallet_contracts::Schedule<Runtime> = schedule::<Runtime>();
pub Schedule: pallet_contracts::Schedule<Runtime> = Default::default();
pub const DefaultDepositLimit: Balance = deposit(1024, 1024 * 1024);
pub const CodeHashLockupDepositPercent: Perbill = Perbill::from_percent(0);
}
Expand All @@ -46,7 +35,7 @@ impl pallet_contracts::Config for Runtime {
type ApiVersion = ();
// IMPORTANT: only runtime calls through the api are allowed.
type CallFilter = Nothing;
type CallStack = [pallet_contracts::Frame<Self>; 23];
type CallStack = [pallet_contracts::Frame<Self>; 5];
type ChainExtension = api::Extension<Config>;
type CodeHashLockupDepositPercent = CodeHashLockupDepositPercent;
type Currency = Balances;
Expand All @@ -64,7 +53,7 @@ impl pallet_contracts::Config for Runtime {
// if a too-large contract is uploaded. We noticed that it poses
// less friction during development when the requirement here is
// just more lax.
type MaxCodeLen = ConstU32<{ 256 * 1024 }>;
type MaxCodeLen = ConstU32<{ 123 * 1024 }>;
type MaxDebugBufferLen = ConstU32<{ 2 * 1024 * 1024 }>;
type MaxDelegateDependencies = ConstU32<32>;
type MaxStorageKeyLen = ConstU32<128>;
Expand Down
17 changes: 3 additions & 14 deletions runtime/testnet/src/config/contracts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,6 @@ use crate::{
Timestamp,
};

fn schedule<T: pallet_contracts::Config>() -> pallet_contracts::Schedule<T> {
pallet_contracts::Schedule {
limits: pallet_contracts::Limits {
runtime_memory: 1024 * 1024 * 1024,
validator_runtime_memory: 2 * 1024 * 1024 * 1024,
..Default::default()
},
..Default::default()
}
}

// randomness-collective-flip is insecure. Provide dummy randomness as placeholder for the
// deprecated trait. https://github.com/paritytech/polkadot-sdk/blob/9bf1a5e23884921498b381728bfddaae93f83744/substrate/frame/contracts/mock-network/src/parachain/contracts_config.rs#L45
pub struct DummyRandomness<T: pallet_contracts::Config>(PhantomData<T>);
Expand All @@ -36,7 +25,7 @@ impl<T: pallet_contracts::Config> Randomness<T::Hash, BlockNumberFor<T>> for Dum
parameter_types! {
pub const DepositPerItem: Balance = deposit(1, 0);
pub const DepositPerByte: Balance = deposit(0, 1);
pub Schedule: pallet_contracts::Schedule<Runtime> = schedule::<Runtime>();
pub Schedule: pallet_contracts::Schedule<Runtime> = Default::default();
pub const DefaultDepositLimit: Balance = deposit(1024, 1024 * 1024);
pub const CodeHashLockupDepositPercent: Perbill = Perbill::from_percent(0);
}
Expand All @@ -46,7 +35,7 @@ impl pallet_contracts::Config for Runtime {
type ApiVersion = ();
// IMPORTANT: only runtime calls through the api are allowed.
type CallFilter = Nothing;
type CallStack = [pallet_contracts::Frame<Self>; 23];
type CallStack = [pallet_contracts::Frame<Self>; 5];
type ChainExtension = api::Extension<Config>;
type CodeHashLockupDepositPercent = CodeHashLockupDepositPercent;
type Currency = Balances;
Expand All @@ -64,7 +53,7 @@ impl pallet_contracts::Config for Runtime {
// if a too-large contract is uploaded. We noticed that it poses
// less friction during development when the requirement here is
// just more lax.
type MaxCodeLen = ConstU32<{ 256 * 1024 }>;
type MaxCodeLen = ConstU32<{ 123 * 1024 }>;
type MaxDebugBufferLen = ConstU32<{ 2 * 1024 * 1024 }>;
type MaxDelegateDependencies = ConstU32<32>;
type MaxStorageKeyLen = ConstU32<128>;
Expand Down

0 comments on commit 9e2e592

Please sign in to comment.