Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make contract storage cheaper #945

Merged
merged 3 commits into from
Feb 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions bin/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,11 @@ pub const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);
pub const MAX_BLOCK_WEIGHT: Weight =
Weight::from_ref_time(WEIGHT_REF_TIME_PER_MILLIS.saturating_mul(400));

// The storage deposit is roughly 1 TOKEN per 1kB
pub const DEPOSIT_PER_BYTE: Balance = MILLI_AZERO;
// The storage deposit is roughly 1 TOKEN per 1kB -- this is the legacy value, used for pallet Identity and Multisig.
pub const LEGACY_DEPOSIT_PER_BYTE: Balance = MILLI_AZERO;

// The storage per one byte of contract storage: 4*10^{-5} AZERO per byte.
pub const CONTRACT_DEPOSIT_PER_BYTE: Balance = 4 * (TOKEN / 100_000);

parameter_types! {
pub const Version: RuntimeVersion = VERSION;
Expand Down Expand Up @@ -580,9 +583,9 @@ impl pallet_vesting::Config for Runtime {

parameter_types! {
// One storage item; key size is 32+32; value is size 4+4+16+32 bytes = 56 bytes.
pub const DepositBase: Balance = 120 * DEPOSIT_PER_BYTE;
pub const DepositBase: Balance = 120 * LEGACY_DEPOSIT_PER_BYTE;
// Additional storage item size of 32 bytes.
pub const DepositFactor: Balance = 32 * DEPOSIT_PER_BYTE;
pub const DepositFactor: Balance = 32 * LEGACY_DEPOSIT_PER_BYTE;
pub const MaxSignatories: u16 = 100;
}

Expand Down Expand Up @@ -659,9 +662,9 @@ const CONTRACTS_DEBUG_OUTPUT: bool = true;

parameter_types! {
// Refundable deposit per storage item
pub const DepositPerItem: Balance = 32 * DEPOSIT_PER_BYTE;
pub const DepositPerItem: Balance = 32 * CONTRACT_DEPOSIT_PER_BYTE;
// Refundable deposit per byte of storage
pub const DepositPerByte: Balance = DEPOSIT_PER_BYTE;
pub const DepositPerByte: Balance = CONTRACT_DEPOSIT_PER_BYTE;
// How much weight of each block can be spent on the lazy deletion queue of terminated contracts
pub DeletionWeightLimit: Weight = Perbill::from_percent(10) * BlockWeights::get().max_block; // 40ms
// Maximum size of the lazy deletion queue of terminated contracts.
Expand Down Expand Up @@ -696,9 +699,9 @@ impl pallet_contracts::Config for Runtime {
parameter_types! {
// bytes count taken from:
// https://github.com/paritytech/polkadot/blob/016dc7297101710db0483ab6ef199e244dff711d/runtime/kusama/src/lib.rs#L995
pub const BasicDeposit: Balance = 258 * DEPOSIT_PER_BYTE;
pub const FieldDeposit: Balance = 66 * DEPOSIT_PER_BYTE;
pub const SubAccountDeposit: Balance = 53 * DEPOSIT_PER_BYTE;
pub const BasicDeposit: Balance = 258 * LEGACY_DEPOSIT_PER_BYTE;
pub const FieldDeposit: Balance = 66 * LEGACY_DEPOSIT_PER_BYTE;
pub const SubAccountDeposit: Balance = 53 * LEGACY_DEPOSIT_PER_BYTE;
pub const MaxSubAccounts: u32 = 100;
pub const MaxAdditionalFields: u32 = 100;
pub const MaxRegistrars: u32 = 20;
Expand Down