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: new command for inspecting state-root mismatches #3589

Merged
merged 11 commits into from
Oct 18, 2023

Conversation

lemmih
Copy link
Contributor

@lemmih lemmih commented Oct 12, 2023

Summary of changes

Changes introduced in this pull request:

  • forest-tool archive diff replaces forest-cli state diff.
  • The new command is more ergonomic and doesn't require copy&pasting CIDs.

Example output (with Forest modified to use an incorrect base-fee):

$ forest-tool archive diff forest_snapshot_calibnet_2023-10-11_height_989049.forest.car.zst --epoch 989000
- Expected state hash: bafy2bzaceaujrn4wf72j6ojgnka47lkdxzttxv22brjteaexs76vtgfptebfe
+ Computed state hash: bafy2bzacecgggv4fd27pfs3xzxg764kcaj6otf5sar5ypt7r22qn66xmotb74
Address t099 changed: 
 ActorState(ActorState { code: Cid(bafk2bzacebor5mnjnsav34cmm5pcd3dy4wubbv4wtcrvba7depy3sct7ie4sy)
  state: Cid(bafy2bzacedpuk5ggwoq3s2wixsyjjnexpsjstdlyntio76vs2lt2jvy3o6mau)
  sequence: 0
- balance: TokenAmount(13369711.247500476309337237)
+ balance: TokenAmount(13369711.247500461221402237)
  delegated_address: None })
V11(State { address: Address { payload: ID(99) } })
Address t035181 changed: 
 {
  "code": {
    "/": "bafk2bzacedrbpvjvyzif2cjxosm4pliyq2m6wzndvrg7r6hzdhixplzvgubbw"
  }
   "sequence": 33965
-  "balance": "165.580950032976185226"
+  "balance": "165.580950048064120226"
   "state": []
}

Reference issue to close (if applicable)

Closes #3586

Other information and links

There is no testing since there are no convenient ways of triggering state-root mismatches.

Change checklist

  • I have performed a self-review of my own code,
  • I have made corresponding changes to the documentation,
  • I have added tests that prove my fix is effective or that my feature works (if possible),
  • I have made sure the CHANGELOG is up-to-date. All user-facing changes should be reflected in this document.

@lemmih lemmih marked this pull request as ready for review October 17, 2023 11:24
@lemmih lemmih requested a review from a team as a code owner October 17, 2023 11:24
@lemmih lemmih requested review from ruseinov and jdjaustin and removed request for a team October 17, 2023 11:24
Copy link
Contributor

@jdjaustin jdjaustin left a comment

Choose a reason for hiding this comment

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

It would be nice to have some documentation of this feature in the developer documentation

Copy link
Member

@LesnyRumcajs LesnyRumcajs left a comment

Choose a reason for hiding this comment

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

Can you contrive some test cases, or would that be too time-consuming or complex?

@lemmih
Copy link
Contributor Author

lemmih commented Oct 17, 2023

Can you contrive some test cases, or would that be too time-consuming or complex?

I have no idea how to test this. We have tests for pretty-printing diffs but I don't see an easy way of doing end-to-end testing.

@ruseinov
Copy link
Contributor

Looks good to me. As a follow-up would be great to have this tool more exposed by means of public-facing docs.
There are also no tests, but it's not a blocker.

2. Download a recent snapshot dated _before_ the failing epoch.
3. Import the snapshot into Lotus and sync to HEAD.
4. Export a new snapshot 100 epochs _after_ the failing epoch.
5. Convert the `.car.zst` file to `.forest.car.zst`.
Copy link
Member

Choose a reason for hiding this comment

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

For completeness, let's write how to perform this conversion.

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.

Comment on lines +98 to +99
#[arg(long)]
depth: Option<u64>,
Copy link
Member

Choose a reason for hiding this comment

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

We could document this as well.

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.

@lemmih lemmih enabled auto-merge October 18, 2023 11:30
@lemmih lemmih added this pull request to the merge queue Oct 18, 2023
Merged via the queue into main with commit ecb5461 Oct 18, 2023
23 checks passed
@lemmih lemmih deleted the lemmih/hoist-forest-cli-state-diff branch October 18, 2023 12:42
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.

forest-cli state diff should move to forest-tool state diff
4 participants