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 BatchMerkleProof + PoPow Interlink vector verification #538

Merged
merged 45 commits into from
Apr 28, 2022

Conversation

SethDusek
Copy link
Collaborator

@SethDusek SethDusek commented Jan 21, 2022

Closes #536

@coveralls
Copy link

coveralls commented Jan 21, 2022

Pull Request Test Coverage Report for Build 2235024812

  • 462 of 484 (95.45%) changed or added relevant lines in 14 files are covered.
  • 9 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.2%) to 87.894%

Changes Missing Coverage Covered Lines Changed/Added Lines %
ergo-chain-generation/src/chain_generation.rs 13 14 92.86%
ergo-chain-generation/src/lib.rs 4 5 80.0%
ergo-chain-types/src/extensioncandidate.rs 6 7 85.71%
ergo-merkle-tree/src/merkletree.rs 174 175 99.43%
ergo-merkle-tree/src/batchmerkleproof.rs 88 93 94.62%
ergo-nipopow/src/nipopow_algos.rs 72 78 92.31%
ergo-merkle-tree/src/json.rs 33 40 82.5%
Files with Coverage Reduction New Missed Lines %
ergotree-ir/src/serialization/types.rs 4 84.08%
ergotree-ir/src/chain/token.rs 5 71.67%
Totals Coverage Status
Change from base Build 2233555057: 0.2%
Covered Lines: 14905
Relevant Lines: 16958

💛 - Coveralls

@greenhat
Copy link
Member

Sounds great! Good call! I appreciate you did benchmarks!

@SethDusek SethDusek force-pushed the batchmerkle branch 3 times, most recently from 4ed32ef to 64a5053 Compare January 26, 2022 07:32
Copy link
Member

@greenhat greenhat left a comment

Choose a reason for hiding this comment

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

Looking great! Just a few minor comments.

ergo-merkle-tree/src/batchmerkleproof.rs Show resolved Hide resolved
ergo-merkle-tree/src/batchmerkleproof.rs Outdated Show resolved Hide resolved
ergo-merkle-tree/src/lib.rs Outdated Show resolved Hide resolved
ergo-merkle-tree/src/lib.rs Outdated Show resolved Hide resolved
ergo-merkle-tree/src/merkletree.rs Outdated Show resolved Hide resolved
@SethDusek SethDusek force-pushed the batchmerkle branch 3 times, most recently from c801a60 to bee6ca5 Compare April 26, 2022 02:04
@SethDusek
Copy link
Collaborator Author

SethDusek commented Apr 27, 2022

@greenhat Hi, do you happen to know why the Github workflow isn't running proptests for BatchMerkleProof? I noticed that they aren't included in the tests. While running proptests, I believe I've found a bug that leads to a stack overflow in both the Rust and Scala implementations of BatchMerkleProof::valid, it should be simple enough to fix however (If a/e are empty, BatchMerkleProof::validate will keep being called, a misbehaving node could send a bad proof for a header and cause a stack oveflow). I've attached an example that replicates the issue in Scala

val batch = BatchMerkleProof(Seq(), Seq((Digest32 @@ Array.fill[Byte](32)(0),MerkleProof.LeftSide)))
batch.valid(Digest32 @@ Array.fill[Byte](32)(0))

@greenhat
Copy link
Member

@greenhat Hi, do you happen to know why the Github workflow isn't running proptests for BatchMerkleProof? I noticed that they aren't included in the tests.

Maybe because of #[cfg(feature = "arbitrary")] on mod test it's not included in the build?

While running proptests, I believe I've found a bug that leads to a stack overflow in both the Rust and Scala implementations of BatchMerkleProof::valid, it should be simple enough to fix however (If a/e are empty, BatchMerkleProof::validate will keep being called, a misbehaving node could send a bad proof for a header and cause a stack oveflow). I've attached an example that replicates the issue in Scala

val batch = BatchMerkleProof(Seq(), Seq((Digest32 @@ Array.fill[Byte](32)(0),MerkleProof.LeftSide)))
batch.valid(Digest32 @@ Array.fill[Byte](32)(0))

Great catch! Could you please make an issue in scrypto repo? Thanks.

…tion

The old code for validating indices would cause issues if a tree has an odd number of nodes, and a user requests the last node (empty node)
@SethDusek
Copy link
Collaborator Author

SethDusek commented Apr 27, 2022

Figured out how to get proptests to run by default (added the feature in ergo-lib dev-dependencies). Here's the scrypto issue input-output-hk/scrypto#96. I've fixed it in the Rust version

Copy link
Member

@greenhat greenhat left a comment

Choose a reason for hiding this comment

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

Looking great! Thank you!

@greenhat greenhat merged commit 2cfeacc into ergoplatform:develop Apr 28, 2022
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.

[1000 SigmaUSD] PoPowHeader Interlink Batch Merkle Proof verification
3 participants