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

fix: expire all previous epochs #5279

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Conversation

j4m1ef0rd
Copy link
Contributor

Pull Request

Closes: PRO-1613

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

  • Changed the expire_epoch function to recursively expire all previous epochs that had not expired yet in chronological order. This should avoid the bug stated in the issue.
    • Added a test to make sure it expires as expected.
  • Renamed BlocksPerEpoch -> EpochDuration
    • Added a migration and migration test for the rename.

Non-Breaking changes

I think this is non breaking, i'll let you tag it @dandanlen

Copy link

codecov bot commented Sep 19, 2024

Codecov Report

Attention: Patch coverage is 92.42424% with 10 lines in your changes missing coverage. Please review.

Project coverage is 70%. Comparing base (bf785d5) to head (14ea562).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
state-chain/pallets/cf-validator/src/lib.rs 82% 4 Missing ⚠️
state-chain/runtime/src/lib.rs 0% 1 Missing and 3 partials ⚠️
state-chain/custom-rpc/src/lib.rs 0% 2 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff           @@
##            main   #5279    +/-   ##
======================================
- Coverage     70%     70%    -0%     
======================================
  Files        486     487     +1     
  Lines      87138   87051    -87     
  Branches   87138   87051    -87     
======================================
- Hits       61169   61030   -139     
- Misses     22687   22740    +53     
+ Partials    3282    3281     -1     

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

Copy link
Collaborator

@dandanlen dandanlen left a comment

Choose a reason for hiding this comment

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

@j4m1ef0rd I'll make the below changes.

Will wait for @acdibble and @marcellorigotti 's inputs re. api breakage before merging.

@@ -350,7 +350,7 @@ type RpcSuspensions = Vec<(Offence, Vec<(u32, state_chain_runtime::AccountId)>)>

#[derive(Serialize, Deserialize)]
pub struct RpcAuctionState {
blocks_per_epoch: u32,
epoch_duration: u32,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Unfortunately this is a breaking change 🙈
We could keep the old name around and flag it as deprecated... or maybe just keep the old name with a comment explaining that the name is for historical reasons...

@acdibble how much of a pain is it for you to change this?

state-chain/pallets/cf-validator/src/lib.rs Outdated Show resolved Hide resolved
@@ -27,7 +27,7 @@ pub struct BtcUtxos {

#[derive(Serialize, Deserialize, Encode, Decode, Eq, PartialEq, TypeInfo, Debug)]
pub struct EpochState {
pub blocks_per_epoch: u32,
pub epoch_duration: u32,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Also a breaking change here, fyi @marcellorigotti

Copy link
Contributor

Choose a reason for hiding this comment

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

Does this mean that after the next binary release until we run the runtime-upgrade this rpc won't be available?
Or will it still work right away but with the new field name (blocks_per_epoch -> epoch_duration)?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah it would mean that the binary release needs to be coordinated with the runtime upgrade. I think a better option would be to add a new field with the new name, and remove it in the following release (1.7 or 1.8).

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with the other option. If this RPC doesn't work then monitoring doesn't work as well (the majority of it at least)

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.

3 participants