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

[1/n] feat(deposits): merkle tree machinery to support deposit inclusion verification #2265

Open
wants to merge 22 commits into
base: main
Choose a base branch
from

Conversation

calbera
Copy link
Contributor

@calbera calbera commented Dec 14, 2024

Copy link
Contributor

coderabbitai bot commented Dec 14, 2024

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

codecov bot commented Dec 14, 2024

Codecov Report

Attention: Patch coverage is 46.17414% with 204 lines in your changes missing coverage. Please review.

Project coverage is 31.49%. Comparing base (502deb9) to head (5bb9a9b).

Files with missing lines Patch % Lines
storage/deposit/merkle/node.go 38.46% 73 Missing and 15 partials ⚠️
storage/deposit/merkle/tree.go 45.36% 51 Missing and 2 partials ⚠️
storage/deposit/merkle/helpers.go 51.35% 33 Missing and 3 partials ⚠️
storage/deposit/merkle/snapshot.go 77.08% 7 Missing and 4 partials ⚠️
primitives/math/u64.go 0.00% 5 Missing ⚠️
primitives/math/pow/pow.go 0.00% 4 Missing ⚠️
beacon/blockchain/finalize_block.go 0.00% 2 Missing ⚠️
consensus-types/types/deposits.go 33.33% 2 Missing ⚠️
primitives/common/consensus.go 0.00% 2 Missing ⚠️
beacon/blockchain/deposit.go 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2265      +/-   ##
==========================================
+ Coverage   31.11%   31.49%   +0.37%     
==========================================
  Files         333      337       +4     
  Lines       15386    15757     +371     
  Branches       20       20              
==========================================
+ Hits         4788     4962     +174     
- Misses      10272    10445     +173     
- Partials      326      350      +24     
Files with missing lines Coverage Δ
primitives/math/errors.go 0.00% <ø> (ø)
beacon/blockchain/deposit.go 0.00% <0.00%> (ø)
beacon/blockchain/finalize_block.go 0.00% <0.00%> (ø)
consensus-types/types/deposits.go 41.17% <33.33%> (ø)
primitives/common/consensus.go 32.14% <0.00%> (-2.48%) ⬇️
primitives/math/pow/pow.go 80.00% <0.00%> (-12.31%) ⬇️
primitives/math/u64.go 89.13% <0.00%> (-10.87%) ⬇️
storage/deposit/merkle/snapshot.go 77.08% <77.08%> (ø)
storage/deposit/merkle/helpers.go 51.35% <51.35%> (ø)
storage/deposit/merkle/tree.go 45.36% <45.36%> (ø)
... and 1 more

@calbera calbera changed the title [WIP] fix(state): deposits hash tree root [WIP] feat(deposits): merkle tree machinery to support deposit inclusion verification Dec 16, 2024
@@ -39,7 +39,7 @@ func (s *Service[
ctx context.Context,
blockNum math.U64,
) {
if blockNum < s.eth1FollowDistance {
if blockNum <= s.eth1FollowDistance {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

note: never necessary to fetch logs for block height 0

@calbera calbera changed the title [WIP] feat(deposits): merkle tree machinery to support deposit inclusion verification [1/n] feat(deposits): merkle tree machinery to support deposit inclusion verification Dec 17, 2024
@calbera calbera marked this pull request as ready for review December 17, 2024 03:51
@@ -53,7 +53,7 @@ license-fix:

nilaway:
@echo "--> Running nilaway"
(go run go.uber.org/nilaway/cmd/nilaway -exclude-errors-in-files "geth-primitives/deposit/" -v ./...) || exit 1;
(go run go.uber.org/nilaway/cmd/nilaway -exclude-pkgs "github.com/berachain/beacon-kit/storage/deposit/merkle" -exclude-errors-in-files "geth-primitives/deposit/" -v ./...) || exit 1;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

not useful for now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will revive in subsequent PR when deposit/merkle package is being used

Comment on lines +201 to +202
leftDeposits, result := n.left.GetFinalized(result)
rightDeposits, result := n.right.GetFinalized(result)
Copy link
Contributor

Choose a reason for hiding this comment

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

this is reusing the result passed as param to GetFinalized, and not creating a new shadow variable?

Copy link
Contributor Author

@calbera calbera Dec 17, 2024

Choose a reason for hiding this comment

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

All node types' GetFinalized are either appending to result or returning result itself. So effectively this is just in-place modification of result.

@@ -44,7 +44,7 @@ fi
# Find all .go files in the project directory and its subdirectories, ignoring .pb.go and .pb_encoding.go files
find "${ROOT_DIR}" -type f -name "*.go" ! -name "*.pb.go" ! -name "*.pb_encoding.go" | while read -r file; do
echo "Processing $file..."
golines --reformat-tags --shorten-comments --write-output --max-len=80 "$file"
golines --reformat-tags --shorten-comments --write-output --max-len=140 "$file"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@fridrik01 I found the culprit. This was shortening lines whenever I ran make format locally which runs this golines script

@calbera calbera requested a review from fridrik01 December 17, 2024 16:11
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