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

SYS-3801 Adds state migration for summary pallet #343

Merged
merged 2 commits into from
Dec 19, 2023

Conversation

nahuseyoum
Copy link
Contributor

@nahuseyoum nahuseyoum commented Dec 19, 2023

Proposed changes

This PR adds a state migration to the summary pallet to avoid corrupting the roots data storage

Type of change/Merge

🚨What type of change is this PR?

Put an x in the boxes that apply

  • Release
    • Increase versions
    • Baseline tests passed
    • Release type:
      • Major release
      • Minor release
      • Patch release

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR.

  • You describe the purpose of the PR, e.g.:
    • What does it do?
    • Highlight what important points reviewers should know about;
    • Indicates if there is something left for follow-up PRs.
  • Documentation updated
  • Business logic tested successfully
  • Verify First, Write Last: In Substrate development, it is important that you always ensure preconditions are met and return errors at the beginning. After these checks have completed, then you may begin the function's computation.

Further comments

@@ -16,7 +16,7 @@ codec = { package = "parity-scale-codec", version = "3.0.0", default-features =
hex = { version = "0.4.3", default-features = false, features = ["alloc"] }
hex-literal = { version = "0.3.4", default-features = false }
scale-info = { version = "2.0", default-features = false, features = ["derive"] }

log = { version = "0.4.17", default-features = false }
Copy link
Contributor

Choose a reason for hiding this comment

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

add to std?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think we need to, its only used in a migration file.

let current = Pallet::<T>::current_storage_version();
let onchain = Pallet::<T>::on_chain_storage_version();

if onchain == 2 && current == 3 {
Copy link
Contributor

Choose a reason for hiding this comment

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

its not shown on the PR, what is the storage version atm for parachain staking?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the same guard as the one used in the actual code that runs it. On Mainnet onchain is 2.

new_transaction_id,
);

counter += 1;
Copy link
Contributor

@thadouk thadouk Dec 19, 2023

Choose a reason for hiding this comment

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

consider using saturated add

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We only have a few hundred items on mainnet and this will be removed soon.

Comment on lines +225 to +232
let current = pallet_eth_bridge::Pallet::<Runtime>::current_storage_version();

if current == 1 {
let next_tx_id: u32 = pallet_eth_bridge::Pallet::<Runtime>::get_next_tx_id();
let expiry = <pallet_eth_bridge::Pallet<Runtime> as pallet_eth_bridge::Store>::EthTxLifetimeSecs::get();
assert_eq!((next_tx_id as u64).encode(), new_transaction_id_bytes);
assert_eq!(expiry, 7200);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

can we discuss this offline? Not that familiar with the pre/post upgrade of the try-runtime.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nahuseyoum nahuseyoum merged commit 251dbb3 into main Dec 19, 2023
5 of 8 checks passed
@nahuseyoum nahuseyoum deleted the nahu-sys3801_summaryStateMigrationBug branch December 19, 2023 23:51
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