Trait pallet_contracts::pallet::DefaultConfig
source · pub trait DefaultConfig: DefaultConfig {
Show 27 associated items
type Time: Time;
type Randomness;
type RuntimeEvent;
type RuntimeCall;
type RuntimeHoldReason;
type CallFilter;
type WeightPrice;
type WeightInfo: WeightInfo;
type ChainExtension;
type DepositPerByte;
type DefaultDepositLimit;
type DepositPerItem;
type CodeHashLockupDepositPercent: Get<Perbill>;
type AddressGenerator;
type MaxCodeLen: Get<u32>;
type MaxStorageKeyLen: Get<u32>;
type MaxTransientStorageSize: Get<u32>;
type MaxDelegateDependencies: Get<u32>;
type UnsafeUnstableInterface: Get<bool>;
type MaxDebugBufferLen: Get<u32>;
type UploadOrigin;
type InstantiateOrigin;
type Migrations: MigrateSequence;
type Debug;
type Environment;
type ApiVersion;
type Xcm;
}
Expand description
Based on Config
. Auto-generated by
#[pallet::config(with_default)]
.
Can be used in tandem with
#[register_default_config]
and
#[derive_impl]
to derive test config traits
based on existing pallet config traits in a safe and developer-friendly way.
See here for more information and caveats about
the auto-generated DefaultConfig
trait and how it is generated.
Required Associated Types§
sourcetype Time: Time
type Time: Time
The time implementation used to supply timestamps to contracts through seal_now
.
sourcetype Randomness
type Randomness
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 RuntimeEvent
type RuntimeEvent
The overarching event type.
sourcetype RuntimeCall
type RuntimeCall
The overarching call type.
sourcetype RuntimeHoldReason
type RuntimeHoldReason
Overarching hold reason.
sourcetype CallFilter
type CallFilter
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.
This filter does not apply to XCM transact calls. To impose restrictions on XCM transact calls, you must configure them separately within the XCM pallet itself.
sourcetype WeightPrice
type WeightPrice
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
type ChainExtension
Type that allows the runtime authors to add new host functions for a contract to call.
sourcetype DepositPerByte
type DepositPerByte
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 DefaultDepositLimit
type DefaultDepositLimit
Fallback value to limit the storage deposit if it’s not being set by the caller.
sourcetype DepositPerItem
type DepositPerItem
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 CodeHashLockupDepositPercent: Get<Perbill>
type CodeHashLockupDepositPercent: Get<Perbill>
The percentage of the storage deposit that should be held for using a code hash.
Instantiating a contract, or calling chain_extension::Ext::lock_delegate_dependency
protects the code from being removed. In order to prevent abuse these actions are
protected with a percentage of the code deposit.
sourcetype AddressGenerator
type AddressGenerator
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.
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 MaxTransientStorageSize: Get<u32>
type MaxTransientStorageSize: Get<u32>
The maximum size of the transient storage in bytes. This includes keys, values, and previous entries used for storage rollback.
sourcetype MaxDelegateDependencies: Get<u32>
type MaxDelegateDependencies: Get<u32>
The maximum number of delegate_dependencies that a contract can lock with
chain_extension::Ext::lock_delegate_dependency
.
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.
sourcetype UploadOrigin
type UploadOrigin
Origin allowed to upload code.
By default, it is safe to set this to EnsureSigned
, allowing anyone to upload contract
code.
sourcetype InstantiateOrigin
type InstantiateOrigin
Origin allowed to instantiate code.
§Note
This is not enforced when a contract instantiates another contract. The
Self::UploadOrigin
should make sure that no code is deployed that does unwanted
instantiations.
By default, it is safe to set this to EnsureSigned
, allowing anyone to instantiate
contract code.
sourcetype Migrations: MigrateSequence
type Migrations: MigrateSequence
The sequence of migration steps that will be applied during a migration.
§Examples
use pallet_contracts::migration::{v10, v11};
type Migrations = (v10::Migration<Runtime, Currency>, v11::Migration<Runtime>);
If you have a single migration step, you can use a tuple with a single element:
use pallet_contracts::migration::v10;
type Migrations = (v10::Migration<Runtime, Currency>,);
sourcetype Debug
type Debug
§Note
For most production chains, it’s recommended to use the ()
implementation of this
trait. This implementation offers additional logging when the log target
“runtime::contracts” is set to trace.
sourcetype Environment
type Environment
Type that bundles together all the runtime configurable interface types.
This is not a real config. We just mention the type here as constant so that
its type appears in the metadata. Only valid value is ()
.
sourcetype ApiVersion
type ApiVersion
The version of the HostFn APIs that are available in the runtime.
Only valid value is ()
.