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

feat: Governance extrinsic to recover Solana Durable Nonces #5130

Merged
merged 2 commits into from
Aug 12, 2024

Conversation

syan095
Copy link
Contributor

@syan095 syan095 commented Aug 8, 2024

Pull Request

Closes: PRO-1533

Checklist

Please conduct a thorough self-review before opening the PR.

  • I am confident that the code works.
  • I have written sufficient tests.
  • I have written and tested required migrations.
  • I have updated documentation where appropriate.

Summary

Added a new Governance Extrinsic that recovers used DurableNonce.

Nonce status Hash is Some() Hash is None
Unavailable Reset to given Hash Reset with original hash
Available Update to new Hash Return Error

The given Nonce account must be either Available or Unavailable (i.e. New Nonce accounts are not accepted).

Copy link

codecov bot commented Aug 8, 2024

Codecov Report

Attention: Patch coverage is 98.41270% with 3 lines in your changes missing coverage. Please review.

Project coverage is 71%. Comparing base (1a3cadb) to head (12ff438).
Report is 1 commits behind head on main.

Files Patch % Lines
state-chain/pallets/cf-environment/src/lib.rs 90% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@          Coverage Diff          @@
##            main   #5130   +/-   ##
=====================================
- Coverage     71%     71%   -0%     
=====================================
  Files        460     460           
  Lines      81649   81647    -2     
  Branches   81649   81647    -2     
=====================================
- Hits       58169   58102   -67     
- Misses     20390   20442   +52     
- Partials    3090    3103   +13     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

#[pallet::call_index(7)]
// Todo
#[pallet::weight(Weight::zero())]
pub fn update_sol_nonce(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just realised there's no benchmark for this...

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we please add one, or open an issue to add one (if it doesn't already exist)

Copy link
Contributor

Choose a reason for hiding this comment

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

Comment on lines +504 to +509
.iter()
.position(|(account, _)|*account == nonce_account)
.map(|idx| {
durable_nonces[idx] = (nonce_account, new_hash);
new_hash
})
Copy link
Collaborator

Choose a reason for hiding this comment

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

iter_mut is generally a better idea than using indices do update a map mid-iteration (even though I think it's ok here).

durable_nonces
	.iter_mut()
	.find(|(account, _)|*account == nonce_account)
	.map(|(_account, hash)| {
		*hash = new_hash;
		new_hash
	})
	.ok_or::<DispatchError>(Error::<T>::NonceAccountNotBeingUsedOrDoesNotExist.into())

@albert-llimos albert-llimos added this pull request to the merge queue Aug 12, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 12, 2024
@albert-llimos albert-llimos added this pull request to the merge queue Aug 12, 2024
github-merge-queue bot pushed a commit that referenced this pull request Aug 12, 2024
* Added a new Governance Extrinsic that recovers used DurableNonce

* Updated extrinsic docs
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 12, 2024
@albert-llimos albert-llimos added this pull request to the merge queue Aug 12, 2024
Merged via the queue into main with commit 270839f Aug 12, 2024
47 of 48 checks passed
@albert-llimos albert-llimos deleted the feat/solana-gov-nonce-recovery branch August 12, 2024 16:19
syan095 added a commit that referenced this pull request Aug 12, 2024
…tracker

* origin/main:
  Rename PrimaryOrBackup (#5139)
  feat: Governance extrinsic to recover Solana Durable Nonces (#5130)
  fix: pallet versions should match release + bump old dylib version to 1.5.1 (#5142)

# Conflicts:
#	state-chain/pallets/cf-ingress-egress/src/migrations.rs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants