-
Notifications
You must be signed in to change notification settings - Fork 165
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
calbera
wants to merge
22
commits into
main
Choose a base branch
from
fix-deps-htr2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 11 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
dd54258
[WIP] fix(state): deposits hash tree root
calbera ea02520
Merge branch 'main' of github.com:berachain/beacon-kit into fix-deps-…
calbera 3f84c30
handle edge case for eth1FollowDistance
calbera 4401503
nits
calbera c4ff5b6
nit e2e tests
calbera fcbedc9
merkle machinery pt 1
calbera f9b225d
snapshot machinery
calbera e400806
lint
calbera 1af579b
remove zero test
calbera 7919783
constants refactor
calbera dfe96cd
exclude from nilaway
calbera b3534bb
tree node unit tests
calbera 8dd4fab
bet
calbera 6bf0482
gosec
calbera 672c6e6
Merge branch 'main' of github.com:berachain/beacon-kit into fix-deps-…
calbera fef7fd2
undo
calbera aa85e49
golines increase line length
calbera a312bc2
golines skips test files
calbera 7336132
lint
calbera c7b6fd8
Merge branch 'main' of github.com:berachain/beacon-kit into fix-deps-…
calbera 8c699f9
nit
calbera 5bb9a9b
Merge branch 'main' into fix-deps-htr2
calbera File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
calbera marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not useful for now There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will revive in subsequent PR when deposit/merkle package is being used |
||
@printf "Nilaway check complete\n" | ||
|
||
################# | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Deposit Merkle Tree | ||
|
||
This package implements the [EIP-4881 spec](https://eips.ethereum.org/EIPS/eip-4881) for a minimal sparse Merkle tree. | ||
|
||
The format proposed by the EIP allows for the pruning of deposits that are no longer needed to participate fully in consensus. | ||
|
||
Thanks to [Prysm](https://github.com/prysmaticlabs/prysm/blob/develop/beacon-chain/cache/depositsnapshot/deposit_tree.go) and Mark Mackey ([@ethDreamer](https://github.com/ethDreamer)) for the reference implementation. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
// | ||
// Copyright (C) 2024, Berachain Foundation. All rights reserved. | ||
// Use of this software is governed by the Business Source License included | ||
// in the LICENSE file of this repository and at www.mariadb.com/bsl11. | ||
// | ||
// ANY USE OF THE LICENSED WORK IN VIOLATION OF THIS LICENSE WILL AUTOMATICALLY | ||
// TERMINATE YOUR RIGHTS UNDER THIS LICENSE FOR THE CURRENT AND ALL OTHER | ||
// VERSIONS OF THE LICENSED WORK. | ||
// | ||
// THIS LICENSE DOES NOT GRANT YOU ANY RIGHT IN ANY TRADEMARK OR LOGO OF | ||
// LICENSOR OR ITS AFFILIATES (PROVIDED THAT YOU MAY USE A TRADEMARK OR LOGO OF | ||
// LICENSOR AS EXPRESSLY REQUIRED BY THIS LICENSE). | ||
// | ||
// TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON | ||
// AN “AS IS” BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, | ||
// EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF | ||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND | ||
// TITLE. | ||
|
||
package merkle | ||
|
||
import "github.com/berachain/beacon-kit/errors" | ||
|
||
var ( | ||
// ErrFinalizedNodeCannotPushLeaf may occur when attempting to push a leaf | ||
// to a finalized node. | ||
// When a node is finalized, it cannot be modified or changed. | ||
ErrFinalizedNodeCannotPushLeaf = errors.New( | ||
"can't push a leaf to a finalized node", | ||
) | ||
|
||
// ErrLeafNodeCannotPushLeaf may occur when attempting to push a leaf to a | ||
// leaf node. | ||
ErrLeafNodeCannotPushLeaf = errors.New("can't push a leaf to a leaf node") | ||
|
||
// ErrZeroLevel occurs when the value of level is 0. | ||
ErrZeroLevel = errors.New("level should be greater than 0") | ||
|
||
// ErrZeroDepth occurs when the value of depth is 0. | ||
ErrZeroDepth = errors.New("depth should be greater than 0") | ||
) | ||
|
||
var ( | ||
// ErrInvalidSnapshotRoot occurs when the snapshot root does not match the | ||
// calculated root. | ||
ErrInvalidSnapshotRoot = errors.New("snapshot root is invalid") | ||
|
||
// ErrInvalidDepositCount occurs when the value for mix in length is 0. | ||
ErrInvalidDepositCount = errors.New( | ||
"deposit count should be greater than 0", | ||
) | ||
|
||
// ErrInvalidIndex occurs when the index is less than the number of | ||
// finalized deposits. | ||
ErrInvalidIndex = errors.New( | ||
"index should be greater than finalizedDeposits - 1", | ||
) | ||
|
||
// ErrTooManyDeposits occurs when the number of deposits exceeds the | ||
// capacity of the tree. | ||
ErrTooManyDeposits = errors.New( | ||
"number of deposits should not be greater than the capacity of the tree", | ||
) | ||
) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
note: never necessary to fetch logs for block height 0