-
Notifications
You must be signed in to change notification settings - Fork 778
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
mpt: adjust verifyMPTProof naming and restructure index file #3730
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files
Flags with carried forward coverage won't be shown. Click here to find out more. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thanks for tackling so quickly! 🤩
Two somewhat additional things, can you maybe do in a follow-up PR if you agree with the updates?
} | ||
} | ||
} | ||
export * from './proof.js' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should re-export the range proof functionality as well.
proof, | ||
opts?.useKeyHashingFunction ?? keccak256, | ||
) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, ok, just seeing that this is included here! 🤯 Then on-top request, can we please:
- Move this fully over to
range.ts
and have one documented method here, likely kill offverifyRangeProof
- And then re-export
verifyMerkleRangeProof
fromrange.ts
from withinindex.ts
@@ -240,7 +240,7 @@ export async function verifyMerkleStateProof( | |||
const storageProof = stProof.proof.map((value: PrefixedHexString) => hexToBytes(value)) | |||
const storageValue = setLengthLeft(hexToBytes(stProof.value), 32) | |||
const storageKey = hexToBytes(stProof.key) | |||
const proofValue = await verifyMPTProof(storageKey, storageProof, { | |||
const proofValue = await verifyMerkleProof(storageKey, storageProof, { | |||
useKeyHashing: true, | |||
}) | |||
const reportedValue = setLengthLeft( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Path related comment (so not for this file): can we align the proof directories from mpt and statemanager, and so (my suggestion) call this one here also:
statemanager/src/proofs
->statemanager/src/proof
(we have a lot of stuff in singular - e.g. also test
(instead of tests
), so this feels somewhat more as our "convention" here)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at the paths from mpt, it seems like we can actually do without src/proof
and src/db
.
- Proof only exports two files
- DB only exports one
So I moved them over to the src directory (renamed range.ts to rangeProof.ts). This flattens the repo structure and has the benefit of limiting the amount of nested index files.
This addresses the comment here: #3719 (comment)