Trait pallet_contracts::pallet::Config
source · pub trait Config: Config {
Show 20 associated items
type Time: Time;
type Randomness: Randomness<Self::Hash, Self::BlockNumber>;
type Currency: ReservableCurrency<Self::AccountId> + Inspect<Self::AccountId, Balance = <<Self as Config>::Currency as Currency<<Self as Config>::AccountId>>::Balance>;
type RuntimeEvent: From<Event<Self>> + IsType<<Self as Config>::RuntimeEvent>;
type RuntimeCall: Dispatchable<RuntimeOrigin = Self::RuntimeOrigin, PostInfo = PostDispatchInfo> + GetDispatchInfo + Decode + IsType<<Self as Config>::RuntimeCall>;
type CallFilter: Contains<<Self as Config>::RuntimeCall>;
type WeightPrice: Convert<Weight, <<Self as Config>::Currency as Currency<<Self as Config>::AccountId>>::Balance>;
type WeightInfo: WeightInfo;
type ChainExtension: ChainExtension<Self> + Default;
type Schedule: Get<Schedule<Self>>;
type CallStack: Array<Item = Frame<Self>>;
type DeletionQueueDepth: Get<u32>;
type DeletionWeightLimit: Get<Weight>;
type DepositPerByte: Get<<<Self as Config>::Currency as Currency<<Self as Config>::AccountId>>::Balance>;
type DepositPerItem: Get<<<Self as Config>::Currency as Currency<<Self as Config>::AccountId>>::Balance>;
type AddressGenerator: AddressGenerator<Self>;
type MaxCodeLen: Get<u32>;
type MaxStorageKeyLen: Get<u32>;
type UnsafeUnstableInterface: Get<bool>;
type MaxDebugBufferLen: Get<u32>;
}
Expand description
Configuration trait of this pallet.
Implement this type for a runtime in order to customize this pallet.
Required Associated Types
sourcetype Time: Time
type Time: Time
The time implementation used to supply timestamps to contracts through seal_now
.
sourcetype Randomness: Randomness<Self::Hash, Self::BlockNumber>
type Randomness: Randomness<Self::Hash, Self::BlockNumber>
The generator used to supply randomness to contracts through seal_random
.
Deprecated
Codes using the randomness functionality cannot be uploaded. Neither can contracts
be instantiated from existing codes that use this deprecated functionality. It will
be removed eventually. Hence for new pallet-contracts
deployments it is okay
to supply a dummy implementation for this type (because it is never used).
sourcetype Currency: ReservableCurrency<Self::AccountId> + Inspect<Self::AccountId, Balance = <<Self as Config>::Currency as Currency<<Self as Config>::AccountId>>::Balance>
type Currency: ReservableCurrency<Self::AccountId> + Inspect<Self::AccountId, Balance = <<Self as Config>::Currency as Currency<<Self as Config>::AccountId>>::Balance>
The currency in which fees are paid and contract balances are held.
sourcetype RuntimeEvent: From<Event<Self>> + IsType<<Self as Config>::RuntimeEvent>
type RuntimeEvent: From<Event<Self>> + IsType<<Self as Config>::RuntimeEvent>
The overarching event type.
sourcetype RuntimeCall: Dispatchable<RuntimeOrigin = Self::RuntimeOrigin, PostInfo = PostDispatchInfo> + GetDispatchInfo + Decode + IsType<<Self as Config>::RuntimeCall>
type RuntimeCall: Dispatchable<RuntimeOrigin = Self::RuntimeOrigin, PostInfo = PostDispatchInfo> + GetDispatchInfo + Decode + IsType<<Self as Config>::RuntimeCall>
The overarching call type.
sourcetype CallFilter: Contains<<Self as Config>::RuntimeCall>
type CallFilter: Contains<<Self as Config>::RuntimeCall>
Filter that is applied to calls dispatched by contracts.
Use this filter to control which dispatchables are callable by contracts.
This is applied in addition to frame_system::Config::BaseCallFilter
.
It is recommended to treat this as a whitelist.
Stability
The runtime must make sure that all dispatchables that are callable by
contracts remain stable. In addition Self::RuntimeCall
itself must remain stable.
This means that no existing variants are allowed to switch their positions.
Note
Note that dispatchables that are called via contracts do not spawn their own wasm instance for each call (as opposed to when called via a transaction). Therefore please make sure to be restrictive about which dispatchables are allowed in order to not introduce a new DoS vector like memory allocation patterns that can be exploited to drive the runtime into a panic.
sourcetype WeightPrice: Convert<Weight, <<Self as Config>::Currency as Currency<<Self as Config>::AccountId>>::Balance>
type WeightPrice: Convert<Weight, <<Self as Config>::Currency as Currency<<Self as Config>::AccountId>>::Balance>
Used to answer contracts’ queries regarding the current weight price. This is not used to calculate the actual fee and is only for informational purposes.
sourcetype WeightInfo: WeightInfo
type WeightInfo: WeightInfo
Describes the weights of the dispatchables of this module and is also used to construct a default cost schedule.
sourcetype ChainExtension: ChainExtension<Self> + Default
type ChainExtension: ChainExtension<Self> + Default
Type that allows the runtime authors to add new host functions for a contract to call.
sourcetype CallStack: Array<Item = Frame<Self>>
type CallStack: Array<Item = Frame<Self>>
The type of the call stack determines the maximum nesting depth of contract calls.
The allowed depth is CallStack::size() + 1
.
Therefore a size of 0
means that a contract cannot use call or instantiate.
In other words only the origin called “root contract” is allowed to execute then.
This setting along with MaxCodeLen
directly affects
memory usage of your runtime.
sourcetype DeletionQueueDepth: Get<u32>
type DeletionQueueDepth: Get<u32>
The maximum number of contracts that can be pending for deletion.
When a contract is deleted by calling seal_terminate
it becomes inaccessible
immediately, but the deletion of the storage items it has accumulated is performed
later. The contract is put into the deletion queue. This defines how many
contracts can be queued up at the same time. If that limit is reached seal_terminate
will fail. The action must be retried in a later block in that case.
The reasons for limiting the queue depth are:
- The queue is in storage in order to be persistent between blocks. We want to limit the amount of storage that can be consumed.
- The queue is stored in a vector and needs to be decoded as a whole when reading it at the end of each block. Longer queues take more weight to decode and hence limit the amount of items that can be deleted per block.
sourcetype DeletionWeightLimit: Get<Weight>
type DeletionWeightLimit: Get<Weight>
The maximum amount of weight that can be consumed per block for lazy trie removal.
The amount of weight that is dedicated per block to work on the deletion queue. Larger
values allow more trie keys to be deleted in each block but reduce the amount of
weight that is left for transactions. See Self::DeletionQueueDepth
for more
information about the deletion queue.
sourcetype DepositPerByte: Get<<<Self as Config>::Currency as Currency<<Self as Config>::AccountId>>::Balance>
type DepositPerByte: Get<<<Self as Config>::Currency as Currency<<Self as Config>::AccountId>>::Balance>
The amount of balance a caller has to pay for each byte of storage.
Note
Changing this value for an existing chain might need a storage migration.
sourcetype DepositPerItem: Get<<<Self as Config>::Currency as Currency<<Self as Config>::AccountId>>::Balance>
type DepositPerItem: Get<<<Self as Config>::Currency as Currency<<Self as Config>::AccountId>>::Balance>
The amount of balance a caller has to pay for each storage item.
Note
Changing this value for an existing chain might need a storage migration.
sourcetype AddressGenerator: AddressGenerator<Self>
type AddressGenerator: AddressGenerator<Self>
The address generator used to generate the addresses of contracts.
sourcetype MaxCodeLen: Get<u32>
type MaxCodeLen: Get<u32>
The maximum length of a contract code in bytes. This limit applies to the instrumented
version of the code. Therefore instantiate_with_code
can fail even when supplying
a wasm binary below this maximum size.
The value should be chosen carefully taking into the account the overall memory limit
your runtime has, as well as the maximum allowed callstack
depth. Look into the integrity_test()
for some insights.
sourcetype MaxStorageKeyLen: Get<u32>
type MaxStorageKeyLen: Get<u32>
The maximum allowable length in bytes for storage keys.
sourcetype UnsafeUnstableInterface: Get<bool>
type UnsafeUnstableInterface: Get<bool>
Make contract callable functions marked as #[unstable]
available.
Contracts that use #[unstable]
functions won’t be able to be uploaded unless
this is set to true
. This is only meant for testnets and dev nodes in order to
experiment with new features.
Warning
Do not set to true
on productions chains.
sourcetype MaxDebugBufferLen: Get<u32>
type MaxDebugBufferLen: Get<u32>
The maximum length of the debug buffer in bytes.