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

add pallet::call to hotfix sufficients for non-zero nonce accounts #619

Merged
merged 12 commits into from
Jun 2, 2022

Conversation

nbaztec
Copy link
Contributor

@nbaztec nbaztec commented Apr 1, 2022

  • Adds a pallet HotfixSufficients with call hotfix_inc_account_sufficients to patch existing accounts with a non-zero nonce but a zero sufficients value. The value needs to be non-zero to be consistent with our current runtime logic.
  • Fixes existing benchmarks.
  • Adds a benchmarking script that allows selection from available benchmarks when ran without arguments.
$ ./scripts/benchmark.sh
1) pallet_evm, runner_execute
2) pallet_evm, hotfix_inc_account_sufficients
3) EXIT
#? 2

The signed extrinsic call can be called by any account.

@nbaztec nbaztec requested a review from sorpaas as a code owner April 1, 2022 08:56
@nbaztec nbaztec force-pushed the nish-upstream-hotfix branch from 6ca3149 to fc65741 Compare April 1, 2022 08:57
#[pallet::weight(
<T as pallet::Config>::WeightInfo::hotfix_inc_account_sufficients(addresses.len().try_into().unwrap_or(u32::MAX))
)]
pub fn hotfix_inc_account_sufficients(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you put this under a feature flag?

Copy link
Contributor Author

@nbaztec nbaztec Apr 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried it out but seems the generated code (pallet::call procedural macro) still contains references to this code even though the function body is omitted - thereby breaking compilation. Are you aware of a better way to put it behind a feature flag?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems it's discouraged to conditional compile pallet calls since that can break an API quite easily. We could conditionally compile and return an unimplemented error on invocation, but I'm unsure how useful that might be.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry to jump in like this:
But should this not rather be a storage migration instead of an extrinsic?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah if you don't have too many accounts in the state already, a migration will be preferred. Alternatively, I believe you just need this call in one single runtime upgrade (which you manually call all addresses yourself), and then it can be removed. Given that this was a bug in Frontier that probably some other chains will also need it for fixing, we may include that in a Frontier release. We'd need to prepare a changelog and announce it though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall I add a basic version of a CHANGELOG.md ?

@nbaztec nbaztec requested a review from sorpaas April 1, 2022 13:56
@crystalin
Copy link
Collaborator

Isn't it possible to have the pallet separate from the existing one, so that parachain needing it could include it in their runtime, but it wouldn't mess default pallets ?
(Ideally this hotfix extrinsic is only part of 1 runtime version and removed in the next one)

@sorpaas
Copy link
Member

sorpaas commented May 11, 2022

Please change this to either a migration script or to put the hotfix in a standalone pallet.

Copy link
Contributor

@tgmichel tgmichel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall lgtm, please check the comment on the dispatchable function body.

frame/hotfix-sufficients/src/tests.rs Outdated Show resolved Hide resolved
template/runtime/src/lib.rs Outdated Show resolved Hide resolved
frame/hotfix-sufficients/src/lib.rs Outdated Show resolved Hide resolved
Comment on lines 87 to 89
let refs = frame_system::Pallet::<T>::consumers(&account_id)
+ frame_system::Pallet::<T>::providers(&account_id)
+ frame_system::Pallet::<T>::sufficients(&account_id);
Copy link
Contributor

@tgmichel tgmichel Jun 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might want to use safe math here

(That amount of references would be absurd, but better safe than sorry :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@sorpaas sorpaas merged commit 2ceaa68 into polkadot-evm:master Jun 2, 2022
@nbaztec nbaztec deleted the nish-upstream-hotfix branch June 2, 2022 09:04
abhijeetbhagat pushed a commit to web3labs/frontier that referenced this pull request Jan 11, 2023
…olkadot-evm#619)

* add pallet::call to hotfix sufficients for non-zero nonce accounts

* make hotfix to fix sufficients payable

* cargo fmt

* use distinct pallet for hotfix

* cleanup traces from pallet evm

* add pallet-hotfix-sufficients

* fix description

* fix benchmarking

* update test condition, add docs

* use safe add

Co-authored-by: tgmichel <telmo@purestake.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants