Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Runtime: Avoid panics in apply_extrinsic #130

Closed
gavofyork opened this issue Apr 16, 2018 · 0 comments
Closed

Runtime: Avoid panics in apply_extrinsic #130

gavofyork opened this issue Apr 16, 2018 · 0 comments
Assignees

Comments

@gavofyork
Copy link
Member

NOTE: This is specific to the Polkadot/Demo implementations, NOT Substrate.

The native runtime should be able to just the validity of including an extrinsic upon only the information in the extrinsic and basic balance/index information of the sender account. This makes the implementation of the tx queue more straightforward and efficient and also helps make clear arguments against DoS vectors.

Basically, the only conditions upon which apply_extrinsic may panic are:

  • the free balance of the sender account is less than cost_xt_basic + cost_xt_byte * xt.encode().len(); or
  • the index of the sender account is not equal to xt.index.

If these "panic" conditions are not met then apply_extrinsic must never panic. To panic thereafter would cause a DoS vector for the miner at best, and will cause the miner to create invalid blocks at worst.

Directly it is determined that apply_extrinsic will not panic, the balance should be reduced by the fee and the sender index incremented. Any further "higher-level" criteria that are not met (and would thus cause a panic in the current code) should be reworked to ensure they return instead without changing any storage items (except, of course, the balance reduction and index increment).

@gavofyork gavofyork added this to the PoC-2 (Co-finalisation) milestone Apr 16, 2018
@gavofyork gavofyork changed the title Avoid panics in apply_extrinsic Runtime: Avoid panics in apply_extrinsic Apr 16, 2018
@gavofyork gavofyork self-assigned this May 29, 2018
lamafab pushed a commit to lamafab/substrate that referenced this issue Jun 16, 2020
* update to latest substrate - protocol API update

* nits

* remove the wait on a future

* use std mpsc for oneshot
JoshOrndorff pushed a commit to moonbeam-foundation/substrate that referenced this issue Apr 21, 2021
* Fixes CI to execute on PR branch instead of base

* Remove unused checkout for PR
liuchengxu added a commit to chainx-org/substrate that referenced this issue Aug 23, 2021
* Make the methods in AssetChanged trait clearer

* Nits

* .
liuchengxu pushed a commit to subspace/substrate that referenced this issue Jun 3, 2022
Refactor store root block extrinsic from unsigned into inherent
helin6 pushed a commit to boolnetwork/substrate that referenced this issue Jul 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant