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(ProcessProposal)!: Check for message inclusion using subtree roots #747

Merged
merged 7 commits into from
Sep 21, 2022

Conversation

evan-forbes
Copy link
Member

@evan-forbes evan-forbes commented Sep 20, 2022

This PR updates ProcessProposal to use subtree roots to check for message inclusion, instead of only relying on comparing the commitments.

This is last non-interactive defaults PR 🎉

closes #383

@evan-forbes evan-forbes added C: Celestia app consensus breaking modifies block validity rules in a way that will break consensus unless all nodes update their rules labels Sep 20, 2022
@evan-forbes evan-forbes self-assigned this Sep 20, 2022
@evan-forbes evan-forbes marked this pull request as draft September 20, 2022 22:39
@evan-forbes
Copy link
Member Author

evan-forbes commented Sep 20, 2022

still have to rebase to fix the git history, so leaving as a draft

@evan-forbes evan-forbes force-pushed the evan/NID-ProcessProposalRefactor branch from b127e43 to 555c436 Compare September 20, 2022 23:02
@codecov-commenter
Copy link

codecov-commenter commented Sep 20, 2022

Codecov Report

Merging #747 (cc8d10c) into main (e18de88) will decrease coverage by 0.09%.
The diff coverage is 15.00%.

@@            Coverage Diff             @@
##             main     #747      +/-   ##
==========================================
- Coverage   42.16%   42.07%   -0.10%     
==========================================
  Files          42       42              
  Lines        4383     4383              
==========================================
- Hits         1848     1844       -4     
- Misses       2387     2390       +3     
- Partials      148      149       +1     
Impacted Files Coverage Δ
app/process_proposal.go 0.00% <0.00%> (ø)
x/payment/types/payfordata.go 76.69% <50.00%> (-2.10%) ⬇️
pkg/inclusion/nmt_caching.go 80.00% <100.00%> (ø)
pkg/prove/proof.go 82.08% <100.00%> (-0.40%) ⬇️
pkg/shares/utils.go 28.00% <100.00%> (+1.46%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Comment on lines -153 to +160
tree := wrapper.NewErasuredNamespacedMerkleTree(appconsts.MaxSquareSize)
// create the nmt todo(evan) use nmt wrapper
tree := nmt.New(sha256.New())
for _, leaf := range set {
nsLeaf := append(make([]byte, 0), append(namespace, leaf...)...)
// here we hardcode pushing as axis 0 cell 0 because we never want
// to add the parity namespace to our shares when we create roots.
tree.Push(nsLeaf, rsmt2d.SquareIndex{Axis: 0, Cell: 0})
err := tree.Push(nsLeaf)
if err != nil {
return nil, err
}
Copy link
Member Author

Choose a reason for hiding this comment

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

had to revert this change from #618 to get the commitments to match, which was really weird. I'm still unsure why this is and requires further debugging. We are using the nmt wrapper to create row and col roots, so it only makes sense to use them when we create commitment so that they match.

Comment on lines +12 to +14
func DelimLen(size uint64) int {
lenBuf := make([]byte, binary.MaxVarintLen64)
return binary.PutUvarint(lenBuf, size)
Copy link
Member Author

Choose a reason for hiding this comment

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

reverted this change to calculate the delim len how we used to, as the new way wasn't doing what we thought. We still need to add a unit test to make sure we don't make the same mistake again. This is implicitly tested in the new fuzzer added in this PR, and message inclusion checks.

@evan-forbes evan-forbes marked this pull request as ready for review September 20, 2022 23:09
rootulp
rootulp previously approved these changes Sep 21, 2022
Co-authored-by: Rootul P <[email protected]>
@evan-forbes evan-forbes merged commit 8f4fd81 into main Sep 21, 2022
@evan-forbes evan-forbes deleted the evan/NID-ProcessProposalRefactor branch September 21, 2022 19:40
evan-forbes added a commit that referenced this pull request Sep 28, 2022
as noticed in
#804 (comment),
I forgot to delete the old `DelimLen` function after fixing a bug in
#747.
rach-id pushed a commit to rach-id/celestia-app that referenced this pull request Nov 16, 2022
rach-id pushed a commit to rach-id/celestia-app that referenced this pull request Nov 16, 2022
as noticed in
celestiaorg#804 (comment),
I forgot to delete the old `DelimLen` function after fixing a bug in
celestiaorg#747.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
consensus breaking modifies block validity rules in a way that will break consensus unless all nodes update their rules
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

RefactorProcessProposal to check that subtree roots are actually part of data root
3 participants