-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: remove unnecessary parachain feature flag
- Loading branch information
1 parent
be3e0d4
commit a1ff395
Showing
1 changed file
with
68 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,98 +1,98 @@ | ||
use crate::{ | ||
Balance, Balances, BalancesCall, MILLIUNIT, Perbill, Runtime, RuntimeCall, | ||
RuntimeEvent, RuntimeHoldReason, Timestamp, UNIT | ||
Balance, Balances, BalancesCall, Perbill, Runtime, RuntimeCall, RuntimeEvent, | ||
RuntimeHoldReason, Timestamp, MILLIUNIT, UNIT, | ||
}; | ||
use frame_support::{ | ||
parameter_types, | ||
traits::{ConstBool, ConstU32, Randomness}, | ||
}; | ||
parameter_types, | ||
traits::{ConstBool, ConstU32, Randomness}, | ||
}; | ||
use frame_system::pallet_prelude::BlockNumberFor; | ||
|
||
pub enum AllowBalancesCall {} | ||
|
||
impl frame_support::traits::Contains<RuntimeCall> for AllowBalancesCall { | ||
fn contains(call: &RuntimeCall) -> bool { | ||
matches!(call, RuntimeCall::Balances(BalancesCall::transfer_allow_death { .. })) | ||
} | ||
fn contains(call: &RuntimeCall) -> bool { | ||
matches!( | ||
call, | ||
RuntimeCall::Balances(BalancesCall::transfer_allow_death { .. }) | ||
) | ||
} | ||
} | ||
|
||
const fn deposit(items: u32, bytes: u32) -> Balance { | ||
(items as Balance * UNIT + (bytes as Balance) * (5 * MILLIUNIT / 100)) / 10 | ||
(items as Balance * UNIT + (bytes as Balance) * (5 * MILLIUNIT / 100)) / 10 | ||
} | ||
|
||
fn schedule<T: pallet_contracts::Config>() -> pallet_contracts::Schedule<T> { | ||
pallet_contracts::Schedule { | ||
limits: pallet_contracts::Limits { | ||
runtime_memory: 1024 * 1024 * 1024, | ||
..Default::default() | ||
}, | ||
..Default::default() | ||
} | ||
pallet_contracts::Schedule { | ||
limits: pallet_contracts::Limits { | ||
runtime_memory: 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>(sp_std::marker::PhantomData<T>); | ||
|
||
impl<T: pallet_contracts::Config> Randomness<T::Hash, BlockNumberFor<T>> for DummyRandomness<T> { | ||
fn random(_subject: &[u8]) -> (T::Hash, BlockNumberFor<T>) { | ||
(Default::default(), Default::default()) | ||
} | ||
fn random(_subject: &[u8]) -> (T::Hash, BlockNumberFor<T>) { | ||
(Default::default(), Default::default()) | ||
} | ||
} | ||
|
||
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 const DefaultDepositLimit: Balance = deposit(1024, 1024 * 1024); | ||
pub const CodeHashLockupDepositPercent: Perbill = Perbill::from_percent(0); | ||
pub const MaxDelegateDependencies: u32 = 32; | ||
pub const DepositPerItem: Balance = deposit(1, 0); | ||
pub const DepositPerByte: Balance = deposit(0, 1); | ||
pub Schedule: pallet_contracts::Schedule<Runtime> = schedule::<Runtime>(); | ||
pub const DefaultDepositLimit: Balance = deposit(1024, 1024 * 1024); | ||
pub const CodeHashLockupDepositPercent: Perbill = Perbill::from_percent(0); | ||
pub const MaxDelegateDependencies: u32 = 32; | ||
} | ||
|
||
impl pallet_contracts::Config for Runtime { | ||
type Time = Timestamp; | ||
type Randomness = DummyRandomness<Self>; | ||
type Currency = Balances; | ||
type RuntimeEvent = RuntimeEvent; | ||
type RuntimeCall = RuntimeCall; | ||
type Time = Timestamp; | ||
type Randomness = DummyRandomness<Self>; | ||
type Currency = Balances; | ||
type RuntimeEvent = RuntimeEvent; | ||
type RuntimeCall = RuntimeCall; | ||
|
||
/// The safest default is to allow no calls at all. | ||
/// | ||
/// Runtimes should whitelist dispatchables that are allowed to be called from contracts | ||
/// and make sure they are stable. Dispatchables exposed to contracts are not allowed to | ||
/// change because that would break already deployed contracts. The `RuntimeCall` structure | ||
/// itself is not allowed to change the indices of existing pallets, too. | ||
type CallFilter = AllowBalancesCall; | ||
type DepositPerItem = DepositPerItem; | ||
type DepositPerByte = DepositPerByte; | ||
type CallStack = [pallet_contracts::Frame<Self>; 23]; | ||
type WeightPrice = pallet_transaction_payment::Pallet<Self>; | ||
type WeightInfo = pallet_contracts::weights::SubstrateWeight<Self>; | ||
type ChainExtension = (); | ||
type Schedule = Schedule; | ||
type AddressGenerator = pallet_contracts::DefaultAddressGenerator; | ||
// This node is geared towards development and testing of contracts. | ||
// We decided to increase the default allowed contract size for this | ||
// reason (the default is `128 * 1024`). | ||
// | ||
// Our reasoning is that the error code `CodeTooLarge` is thrown | ||
// 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 DefaultDepositLimit = DefaultDepositLimit; | ||
type MaxStorageKeyLen = ConstU32<128>; | ||
type MaxDebugBufferLen = ConstU32<{ 2 * 1024 * 1024 }>; | ||
type UnsafeUnstableInterface = ConstBool<true>; | ||
type CodeHashLockupDepositPercent = CodeHashLockupDepositPercent; | ||
type MaxDelegateDependencies = MaxDelegateDependencies; | ||
type RuntimeHoldReason = RuntimeHoldReason; | ||
/// The safest default is to allow no calls at all. | ||
/// | ||
/// Runtimes should whitelist dispatchables that are allowed to be called from contracts | ||
/// and make sure they are stable. Dispatchables exposed to contracts are not allowed to | ||
/// change because that would break already deployed contracts. The `RuntimeCall` structure | ||
/// itself is not allowed to change the indices of existing pallets, too. | ||
type CallFilter = AllowBalancesCall; | ||
type DepositPerItem = DepositPerItem; | ||
type DepositPerByte = DepositPerByte; | ||
type CallStack = [pallet_contracts::Frame<Self>; 23]; | ||
type WeightPrice = pallet_transaction_payment::Pallet<Self>; | ||
type WeightInfo = pallet_contracts::weights::SubstrateWeight<Self>; | ||
type ChainExtension = (); | ||
type Schedule = Schedule; | ||
type AddressGenerator = pallet_contracts::DefaultAddressGenerator; | ||
// This node is geared towards development and testing of contracts. | ||
// We decided to increase the default allowed contract size for this | ||
// reason (the default is `128 * 1024`). | ||
// | ||
// Our reasoning is that the error code `CodeTooLarge` is thrown | ||
// 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 DefaultDepositLimit = DefaultDepositLimit; | ||
type MaxStorageKeyLen = ConstU32<128>; | ||
type MaxDebugBufferLen = ConstU32<{ 2 * 1024 * 1024 }>; | ||
type UnsafeUnstableInterface = ConstBool<true>; | ||
type CodeHashLockupDepositPercent = CodeHashLockupDepositPercent; | ||
type MaxDelegateDependencies = MaxDelegateDependencies; | ||
type RuntimeHoldReason = RuntimeHoldReason; | ||
|
||
type Environment = (); | ||
type Debug = (); | ||
type Migrations = (); | ||
#[cfg(feature = "parachain")] | ||
type Xcm = pallet_xcm::Pallet<Self>; | ||
#[cfg(not(feature = "parachain"))] | ||
type Xcm = (); | ||
type Environment = (); | ||
type Debug = (); | ||
type Migrations = (); | ||
type Xcm = pallet_xcm::Pallet<Self>; | ||
} |