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

Add composite type leaves to proof #110

Merged
merged 4 commits into from
May 19, 2021
Merged

Conversation

wemeetagain
Copy link
Member

@wemeetagain wemeetagain commented May 19, 2021

When creating a proof with a path to a composite type, include all
leaves of the type in the proof.

  • Add CompositeType#tree_getLeafGindices(tree?: Tree, root?: Gindex): Gindex[]
    • This is where the magic happens. Composite types are recursively traversed to the terminal types to get leaf gindices.
    • The tree is included for 'length' information for variable-length objects. (otherwise we wouldn't know which gindices to include for eg: state.validators)
    • A "root" gindex is included to allow for deeply nested types to return gindices relative to the root type
  • CompositeType#createProof is extended to call tree_getLeafGindices when the type at a path is a composite type.

When creating a proof with a path to a composite type, include all
leaves of the type in the proof.
@lgtm-com
Copy link

lgtm-com bot commented May 19, 2021

This pull request introduces 1 alert when merging b89df8b into 8c31f3e - view on LGTM.com

new alerts:

  • 1 for Unused variable, import, function or class

}
const gindices = super.tree_getLeafGindices(target, root);
// include the length chunk
gindices.push(concatGindices([root, BigInt(3)]));
Copy link
Contributor

Choose a reason for hiding this comment

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

Why 3 here? Could you add a comment explaining

Copy link
Member Author

@wemeetagain wemeetagain May 19, 2021

Choose a reason for hiding this comment

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

The comment on the line above is an attempt to explain 😅 open to any suggestions to make it clearer

}
} else {
for (let i = 0, gindex = extendedStartIndex; i < chunkCount; i++, gindex++) {
gindices.push(...this.elementType.tree_getLeafGindices(undefined, gindex));
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

@dapplion dapplion left a comment

Choose a reason for hiding this comment

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

Looks great! 🔥 Can't wait to deploy this to the lightclient demo site

@lgtm-com
Copy link

lgtm-com bot commented May 19, 2021

This pull request introduces 1 alert when merging a8546a0 into 8c31f3e - view on LGTM.com

new alerts:

  • 1 for Unused variable, import, function or class

@dapplion dapplion merged commit 3f1cfd4 into master May 19, 2021
@dapplion dapplion deleted the cayman/composite-type-proof branch May 19, 2021 20:30
@wemeetagain wemeetagain mentioned this pull request May 24, 2021
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.

2 participants