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

State diff on root mismatch option #738

Merged
merged 17 commits into from
Oct 13, 2020
Merged

State diff on root mismatch option #738

merged 17 commits into from
Oct 13, 2020

Conversation

austinabell
Copy link
Contributor

@austinabell austinabell commented Oct 9, 2020

Summary of changes
Changes introduced in this pull request:

  • Prints a state diff if FOREST_DIFF=1 env variable is set and there is a state root mismatch
    • Resolves Ipld hash links recursively and the diff is in json

Looks something like:

Edit (looks like this now with the state tree resolve):
Screen Shot 2020-10-09 at 12 23 44 PM

Which can be useful sometimes but other times not extremely useful (reverted state doesn't get resolved and the hamt/ amt in ipld can be cryptic if you don't know what to look for)

Reference issue to close (if applicable)

Closes

Other information and links

Comment on lines 39 to 52
link @ Ipld::Link(_) => {
let resolved: Option<Ipld> = if let Ipld::Link(cid) = link {
if cid.codec != Codec::DagCBOR {
return Ok(());
}
bs.get(cid)?
} else {
unreachable!()
};

if let Some(ipld) = resolved {
*link = ipld;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
link @ Ipld::Link(_) => {
let resolved: Option<Ipld> = if let Ipld::Link(cid) = link {
if cid.codec != Codec::DagCBOR {
return Ok(());
}
bs.get(cid)?
} else {
unreachable!()
};
if let Some(ipld) = resolved {
*link = ipld;
}
}
Ipld::Link(cid) => {
if cid.codec == Codec::DagCBOR {
if let Some(x) = bs.get(cid)? {
*ipld = x;
}
}
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah ya oops, for some reason I thought ipld would not be able to be overwritten while cid was bound in the match

@austinabell austinabell merged commit cecf871 into main Oct 13, 2020
@austinabell austinabell deleted the austin/statediff branch October 13, 2020 15:09
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