5

As you're aware, the latest version of substrate removed the need for manual memory management, hence when creating the new SC - tokens are automatically reserved from caller's balance.

To my understanding one has to adjust the following function in order to change the maths related to all runtime modules.

Currently, it costs around 13k native tokens to be reserved to deploy 100kb codehash. However, when comparing the constants file, Polkadot defines the deposit function to use 60 times less tokens.

  1. Is my understanding of relation between deposit function and contract creation cost (reserve amount) correct?
  2. If yes, what are the risks of adjusting the function?
  3. If there are no risks, what is the best way to derive the sounding constants (CENTS, MILLICENTS) and formula for deposit function?

Thanks,

Raid

1
  • Anyone has any advice on this topic?
    – Raid Ateir
    Feb 1, 2023 at 14:10

1 Answer 1

2

To my understanding one has to adjust the following function in order to change the maths related to all runtime modules.

Whatever you pass into DepositPer{Byte, Item} is what is being used to calculate the deposit. That said, most runtimes define a deposit function (the one you linked is from polkadot) and pass it into all pallets that are charging deposits. This way it is uniform across the whole runtime. But it doesn't have to be this way.

Currently, it costs around 13k native tokens to be reserved to deploy 100kb codehash.

This is impossible to answer/verify if you don't specify the runtime/chain you are talking about.

However, when comparing the constants file, Polkadot defines the deposit function to use 60 times less tokens.

Less than what?

  1. Somewhat. See above.
  2. pallet-contracts handles the change of this value gracefully. Apart from this: Choosing a too low value can leave your chain open to DoS. A value to high might make your chain unattractive.
  3. You essentially want to price it at exactly the value storing a value at all full nodes has to a user. Knowing this value is impossible. It is an economic question. Note that the deposit should be much lower for parachains than for the relaychain. Hence I recommend to just take inspiration from other runtimes or do your own research.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.