polkadot-js / apps

Basic Polkadot/Substrate UI for interacting with a Polkadot and Substrate node. This is the main user-facing application, allowing access to all features available on Substrate chains.
https://dotapps.io
Apache License 2.0
1.74k stars 1.54k forks source link

Incorrect Deposit value displayed - Parathread registration #10668

Closed DrW3RK closed 3 months ago

DrW3RK commented 3 months ago

Due to the issue discussed here https://github.com/paritytech/polkadot-sdk/pull/2372 the deposit needed defaults to MAX_CODE_SIZE https://github.com/paritytech/polkadot-sdk/pull/3020

The fee for this transaction is hefty, with around 5 KSM and 40 DOT simply lost because the UI shows a lower value. More info here https://substrate.stackexchange.com/questions/11588/how-to-calculate-required-reserved-deposit-to-register-a-parachain-on-kusama-w

image
TarikGul commented 3 months ago

This is the current code that calculates the "reserve deposit":

  const reservedDeposit = useMemo(
    () => (api.consts.registrar.paraDeposit as BalanceOf)
      .add((api.consts.registrar.dataDepositPerByte as BalanceOf).muln(wasm ? wasm.length : 0))
      .iadd((api.consts.registrar.dataDepositPerByte as BalanceOf).muln(genesisState ? genesisState.length : 0)),
    [api, wasm, genesisState]
  );

Also can be seen here. So If I am understand this correctly, we can replace all this logic with just MAX_CODE_SIZE?

DrW3RK commented 3 months ago

That is correct.

TarikGul commented 3 months ago

Okay, cool thanks for the input, will get this adjusted!

DrW3RK commented 3 months ago

On a closer look, the MAX_CODE_SIZE applies only to wasm. The genesis state length can vary. https://github.com/paritytech/polkadot-sdk/blob/ae0b3bf6733e7b9e18badb16128a6b25bef1923b/polkadot/runtime/common/src/paras_registrar/mod.rs#L682

TarikGul commented 3 months ago

Ahh okay so we're just replacing the wasm.length! Thanks

polkadot-js-bot commented 3 months ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue if you think you have a related problem or query.