referrerpolicy=no-referrer-when-downgrade

Trait Config

Source
pub trait Config: Config + Config<RuntimeEvent: From<Event<Self>>> {
Show 27 associated items type Time: Time<Moment: Into<U256>>; type Balance: Balance + TryFrom<U256> + Into<U256> + Bounded + UniqueSaturatedInto<u64> + UniqueSaturatedFrom<u64> + UniqueSaturatedInto<u128>; type Currency: Inspect<Self::AccountId, Balance = Self::Balance> + Mutate<Self::AccountId> + MutateHold<Self::AccountId, Reason = Self::RuntimeHoldReason> + Balanced<Self::AccountId>; type RuntimeEvent: From<Event<Self>> + IsType<<Self as Config>::RuntimeEvent>; type RuntimeCall: Parameter + Dispatchable<RuntimeOrigin = OriginFor<Self>, Info = DispatchInfo, PostInfo = PostDispatchInfo> + IsType<<Self as Config>::RuntimeCall> + From<Call<Self>> + IsSubType<Call<Self>> + GetDispatchInfo; type RuntimeOrigin: IsType<OriginFor<Self>> + From<Origin<Self>> + Into<Result<Origin<Self>, OriginFor<Self>>>; type RuntimeHoldReason: From<HoldReason>; type WeightInfo: WeightInfo; type Precompiles: Precompiles<Self>; type FindAuthor: FindAuthor<Self::AccountId>; type DepositPerByte: Get<BalanceOf<Self>>; type DepositPerItem: Get<BalanceOf<Self>>; type DepositPerChildTrieItem: Get<BalanceOf<Self>>; type CodeHashLockupDepositPercent: Get<Perbill>; type AddressMapper: AddressMapper<Self>; type UnsafeUnstableInterface: Get<bool>; type AllowEVMBytecode: Get<bool>; type UploadOrigin: EnsureOrigin<OriginFor<Self>, Success = Self::AccountId>; type InstantiateOrigin: EnsureOrigin<OriginFor<Self>, Success = Self::AccountId>; type RuntimeMemory: Get<u32>; type PVFMemory: Get<u32>; type ChainId: Get<u64>; type NativeToEthRatio: Get<u32>; type FeeInfo: FeeInfo<Self>; type MaxEthExtrinsicWeight: Get<FixedU128>; type DebugEnabled: Get<bool>; type GasScale: Get<u32>;
}
Expand description

Configuration trait of this pallet.

The main purpose of this trait is to act as an interface between this pallet and the runtime in which it is embedded in. A type, function, or constant in this trait is essentially left to be configured by the runtime that includes this pallet.

Consequently, a runtime that wants to include this pallet must implement this trait.

Required Associated Types§

Source

type Time: Time<Moment: Into<U256>>

The time implementation used to supply timestamps to contracts through seal_now.

Source

type Balance: Balance + TryFrom<U256> + Into<U256> + Bounded + UniqueSaturatedInto<u64> + UniqueSaturatedFrom<u64> + UniqueSaturatedInto<u128>

The balance type of Self::Currency.

Just added here to add additional trait bounds.

Source

type Currency: Inspect<Self::AccountId, Balance = Self::Balance> + Mutate<Self::AccountId> + MutateHold<Self::AccountId, Reason = Self::RuntimeHoldReason> + Balanced<Self::AccountId>

The fungible in which fees are paid and contract balances are held.

Source

type RuntimeEvent: From<Event<Self>> + IsType<<Self as Config>::RuntimeEvent>

The overarching event type.

Source

type RuntimeCall: Parameter + Dispatchable<RuntimeOrigin = OriginFor<Self>, Info = DispatchInfo, PostInfo = PostDispatchInfo> + IsType<<Self as Config>::RuntimeCall> + From<Call<Self>> + IsSubType<Call<Self>> + GetDispatchInfo

The overarching call type.

Source

type RuntimeOrigin: IsType<OriginFor<Self>> + From<Origin<Self>> + Into<Result<Origin<Self>, OriginFor<Self>>>

The overarching origin type.

Source

type RuntimeHoldReason: From<HoldReason>

Overarching hold reason.

Source

type WeightInfo: WeightInfo

Describes the weights of the dispatchables of this module and is also used to construct a default cost schedule.

Source

type Precompiles: Precompiles<Self>

Type that allows the runtime authors to add new host functions for a contract to call.

Pass in a tuple of types that implement precompiles::Precompile.

Source

type FindAuthor: FindAuthor<Self::AccountId>

Find the author of the current block.

Source

type DepositPerByte: Get<BalanceOf<Self>>

The amount of balance a caller has to pay for each byte of storage.

§Note

It is safe to change this value on a live chain as all refunds are pro rata.

Source

type DepositPerItem: Get<BalanceOf<Self>>

The amount of balance a caller has to pay for each storage item.

§Note

It is safe to change this value on a live chain as all refunds are pro rata.

Source

type DepositPerChildTrieItem: Get<BalanceOf<Self>>

The amount of balance a caller has to pay for each child trie storage item.

Those are the items created by a contract. In Solidity each value is a single storage item. This is why we need to set a lower value here than for the main trie items. Otherwise the storage deposit is too high.

§Note

It is safe to change this value on a live chain as all refunds are pro rata.

Source

type CodeHashLockupDepositPercent: Get<Perbill>

The percentage of the storage deposit that should be held for using a code hash. Instantiating a contract, protects the code from being removed. In order to prevent abuse these actions are protected with a percentage of the code deposit.

Source

type AddressMapper: AddressMapper<Self>

Use either valid type is address::AccountId32Mapper or [address::H160Mapper].

Source

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.

Source

type AllowEVMBytecode: Get<bool>

Allow EVM bytecode to be uploaded and instantiated.

Source

type UploadOrigin: EnsureOrigin<OriginFor<Self>, Success = Self::AccountId>

Origin allowed to upload code.

By default, it is safe to set this to EnsureSigned, allowing anyone to upload contract code.

Source

type InstantiateOrigin: EnsureOrigin<OriginFor<Self>, Success = Self::AccountId>

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.

Source

type RuntimeMemory: Get<u32>

The amount of memory in bytes that parachain nodes a lot to the runtime.

This is used in Pallet::integrity_test to make sure that the runtime has enough memory to support this pallet if set to the correct value.

Source

type PVFMemory: Get<u32>

The amount of memory in bytes that relay chain validators a lot to the PoV.

This is used in Pallet::integrity_test to make sure that the runtime has enough memory to support this pallet if set to the correct value.

This value is usually higher than Self::RuntimeMemory to account for the fact that validators have to hold all storage items in PvF memory.

Source

type ChainId: Get<u64>

The EIP-155 chain ID.

This is a unique identifier assigned to each blockchain network, preventing replay attacks.

Source

type NativeToEthRatio: Get<u32>

The ratio between the decimal representation of the native token and the ETH token.

Source

type FeeInfo: FeeInfo<Self>

Set to crate::evm::fees::Info for a production runtime.

For mock runtimes that do not need to interact with any eth compat functionality the default value of () will suffice.

Source

type MaxEthExtrinsicWeight: Get<FixedU128>

The fraction the maximum extrinsic weight eth_transact extrinsics are capped to.

This is not a security measure but a requirement due to how we map gas to (Weight, StorageDeposit). The mapping might derive a Weight that is too large to fit into an extrinsic. In this case we cap it to the limit specified here.

eth_transact transactions that use more weight than specified will fail with an out of gas error during execution. Larger fractions will allow more transactions to run. Smaller values waste less block space: Choose as small as possible and as large as necessary.

Default: 0.5.

Source

type DebugEnabled: Get<bool>

Allows debug-mode configuration, such as enabling unlimited contract size.

Source

type GasScale: Get<u32>

This determines the relative scale of our gas price and gas estimates.

By default, the gas price (in wei) is FeeInfo::next_fee_multiplier() multiplied by NativeToEthRatio. GasScale allows to scale this value: the actual gas price is the default gas price multiplied by GasScale.

As a consequence, gas cost (gas estimates and actual gas usage during transaction) is scaled down by the same factor. Thus, the total transaction cost is not affected by GasScale – apart from rounding differences: the transaction cost is always a multiple of the gas price and is derived by rounded up, so that with higher GasScales this can lead to higher gas cost as the rounding difference would be larger.

The main purpose of changing the GasScale is to tune the gas cost so that it is closer to standard EVM gas cost and contracts will not run out of gas when tools or code assume hard coded gas limits.

Requirement: GasScale must not be 0

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§