-
Notifications
You must be signed in to change notification settings - Fork 92
New Compounding Staking Strategy post Pectra upgrade #2559
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
Merged
+52,551
−572
Merged
Changes from 122 commits
Commits
Show all changes
440 commits
Select commit
Hold shift + click to select a range
ea66248
add proof for validator
clement-ux 21598a9
add deposit proofs
clement-ux 5944dc0
add balance proof for all validators
clement-ux b98ecde
Mock Beacon Roots (#2596)
sparrowDom 08fc474
Added requestValidatorWithdraw Hardhat task
naddison36 9df6cbe
Merge remote-tracking branch 'origin/nicka/pectra' into nicka/pectra
naddison36 c9b2d01
Merge remote-tracking branch 'origin/clement/pectra' into nicka/pectra
naddison36 4bb241c
Updated validator proofs
naddison36 073755f
add more validators data
clement-ux 30c14d8
add a last validator
clement-ux 43bd569
Add balance proof for 20 validators
clement-ux 00470ed
add a new validators
clement-ux a241689
add nex balance proof for 21 validators
clement-ux 42a6cf5
add support for hoodie when calling registerValidator
sparrowDom d3f5903
add check that validator ids are in ascending order
sparrowDom 211d97b
add a task for the initial 1 ETH deposit
sparrowDom e9232c4
Fix bug in verifyBalances when an active validator is exited
naddison36 ef388ba
Prettier
naddison36 67a20a5
Merge remote-tracking branch 'origin/nicka/pectra' into nicka/pectra
naddison36 1583cd9
sort the operator ids instead of throwing an error
sparrowDom 1557632
prettier
naddison36 c90a3e2
Changed requestConsolidation on the old staking strategy to only be c…
naddison36 978860e
Added getValidator Hardhat task
naddison36 29c975f
Merge remote-tracking branch 'origin/master' into nicka/pectra
naddison36 e14ab55
Remove log output
naddison36 cd3e20b
snapBalances changed to be external from public
naddison36 4036090
Added onlyRegistrator to snapBalances to prevent denial of calling ve…
naddison36 5ba173b
Removed onlyRegistrator from verifyBalances as its on snapBalances
naddison36 231c6eb
Added extra checks on the number of balance leaves and proofs in veri…
naddison36 1780fc2
Made Endian library MIT as its used by BeaconOracle which is also MIT
naddison36 0cfbb75
Changed the initial validator deposit to be 32 ETH
naddison36 c758cfd
Formatted the output of getValidator Hardhat task
naddison36 4d7a4bf
Added more data to getValidator hardhat task
naddison36 aaf3f1a
Updated validatorWithdrawal Natspec with new understanding of how ful…
naddison36 d675da1
Added Hoodi upgrade script for the staking strategy
naddison36 c331f4b
Removed reverts from BeaconRoots contract as the underlying beacon ro…
naddison36 e6e0679
Deployed new MockBeaconRoots
naddison36 a404f66
Upgraded the CompoundingStakingSSVStrategyProxy on Hoodi
naddison36 31fe160
Fixes to Hardhat tasks
naddison36 71d2471
add deployment files
sparrowDom 5013b4c
Changed the WETH contract for Hoodi
naddison36 4190566
Changed the Hoodi strategist and governor to be the Relayer
naddison36 aeed943
Merge remote-tracking branch 'origin/nicka/pectra' into nicka/pectra
naddison36 ff6a5ef
Governor spelling
naddison36 4c2ee7c
Upgraded the OETH Vault on Hoodi
naddison36 7467169
Upgrade the compounding staking strategy to use new WETH token
naddison36 3e5afdc
Added tenderlyUpload to verify a single contract
naddison36 1da4051
beacon proof generators to handle Hoodi
naddison36 2b24ba4
Deployed new BeaconProofs and CompoundingStakingSSVStrategy
naddison36 20652b3
Add 1 wei of value to validatorWithdrawal call
naddison36 e456a67
verifySlot can now be done from a block
naddison36 91e33e4
Renamed validatorContainerProof to balancesContainerProof
naddison36 d58f43d
Upgraded the native staking contract on Hoodi
naddison36 b231c15
Merge remote-tracking branch 'origin/master' into nicka/pectra
naddison36 c06d3ee
Renamed the ETH/WETH conversion functions
naddison36 f402e01
P2P API support for Hoodi
naddison36 c15416b
Updated verifySlot options
naddison36 1c71c56
Prettier
naddison36 6d505e9
Fix storage checker
naddison36 a64f644
Fix old Native Staking fork tests
naddison36 c8f6b57
bulk exit and remove validator (#2185)
naddison36 236b930
Changed verifyBalances so a slot before the first pending deposit can…
naddison36 3450a7a
Fixed check in verifyBalances
naddison36 d8939ea
Preparing HH tasks to be run as Actions
naddison36 ce743f7
Defender Action to verify slots
naddison36 2c36fe3
Deployed latest compounding staking strategy
naddison36 daa6334
Added getPendingDeposits view function
naddison36 f1e7f96
Updated snapStakingStrat HH task
naddison36 0bc74d8
Improved error message when generating verifyBalances proof
naddison36 a7761ea
Remove BeaconOracle from new staking strategy (#2608)
naddison36 c896a35
Merge branch 'nicka/pectra' of github.com:OriginProtocol/origin-dolla…
naddison36 7d633d4
add comment
sparrowDom 1108bc7
Nicka/pectra remove consolidation (#2609)
naddison36 32e21d6
Merge branch 'nicka/pectra' of github.com:OriginProtocol/origin-dolla…
naddison36 811fe79
Removed TargetStrategyAdded
naddison36 c59838a
Simplified verifyValidatorBalance
naddison36 8ea45b2
Cleaned up defender actions
naddison36 bc2032e
Merge remote-tracking branch 'origin/master' into nicka/pectra
naddison36 d1391f5
Deployed to Hoodi
naddison36 64e0409
Add setRegistrator HH task
naddison36 5d70361
add an in depth explanation of the accounting behaviour (#2610)
sparrowDom 9cf0db5
Updates to Hardhat tasks
naddison36 e171e9a
Natspec cleanup
naddison36 96703da
Merge remote-tracking branch 'origin/nicka/pectra' into nicka/pectra
naddison36 db247a0
Prettier
naddison36 45ad224
Changed validatorWithdrawal to be payable so the 1 wei fee can be paid
naddison36 c5ea7c6
Added deposit root to the getPendingDeposits output
naddison36 c398831
Fix verifyDeposit when the deposit queue is empty
naddison36 618abca
Updated OETH contracts diagram and staking transitions diagram
naddison36 daf600e
improved getValidator
naddison36 ff04605
Added more logging
naddison36 7d31f69
Validator task upgrades (#2614)
sparrowDom b6cf000
Changed verifyFirstPendingDepositSlot to return of the deposit queue …
naddison36 0a489fc
Prettier js
naddison36 71c2bf9
Check if slot of the pending deposit is zero
naddison36 d4154a6
Deployed new contracts to Hoodi
naddison36 cf30076
Added off-chain checks for zero value slots
naddison36 3631246
Added more logging to HH tasks
naddison36 d9da029
Fix linter
naddison36 719edd1
Fix full exit logic in HH task
naddison36 dd3e0f8
Fixed partial withdrawal in HH task
naddison36 89c7210
Improved snapStakingStrat HH task
naddison36 6d351b7
Added more checks to proof verifications
naddison36 346ca88
DEployed the latest contracts to Hoodi
naddison36 1f4ad68
Make sure the beacon chain data matches the block used in snapStaking…
naddison36 2f588d2
adjust comment
sparrowDom 512f2b2
Add pending beacon chain deposits info to snapStakingStrat
naddison36 270c8e2
added more validator info to snapStakingStrat
naddison36 a6140e1
Merge remote-tracking branch 'origin/nicka/pectra' into nicka/pectra
naddison36 f22e6ee
Merge remote-tracking branch 'origin/master' into nicka/pectra
naddison36 fb5e5a5
Updated Natspec
naddison36 823af48
Call safeApproveAllTokens from initialize function
naddison36 b01ccf1
Added comment on use of min in _transferWeth
naddison36 182b0ba
Added check of validator public key length to registerSsvValidator
naddison36 0a6add6
Fixed Natspec on validatorWithdrawal
naddison36 303b6e9
Fixed removeSsvValidator Natspec
naddison36 5e53450
Read depositsRoots.length into memory in getPendingDeposits
naddison36 3252df3
Fixed Slither
naddison36 0cdcb68
Upgraded the contracts on Hoodi
naddison36 0802243
Minor changes to request validator HH tasks
naddison36 347d06c
Add test coverage of getPendingDeposits
naddison36 6c1ce3d
Add test that collectRewardTokens is unsupported
naddison36 2a04afa
Fix off-chain verifyBalances when deposit queue is empty
naddison36 c20989a
Moved check of public key length into `_hashPubKey`
naddison36 8d2d0e3
Update HOODI API key
naddison36 395b9cd
Removed beaconOracle ABI as its no longer used
naddison36 4de19bc
Removed .out file
naddison36 09d4ee0
No longer need the optional provider in getSigner factory
naddison36 4508bbe
Prettier
naddison36 a77bc5b
Removed _asset from internal _withdraw function
naddison36 26c889f
Simplified setting of the lastVerifiedEthBalance in _convertEthToWeth
naddison36 0951ea4
Override setPTokenAddress and removePToken so they revert with "Unsup…
naddison36 fd21ed6
add comment
sparrowDom a287f1c
OZ C-01 - Postponed Pending Deposit Breaks verifyDeposit and verifyB…
naddison36 9afeaa9
Added nextDepositID to be a unique identifier of a deposit to a valid…
naddison36 7ae469d
Break from iterating over the deposits once the deposit has been foun…
naddison36 f5bf5f4
Added Compounding Validator State Diagram
naddison36 c2cc5aa
Improved Beacon Proof constants for readability (#2625)
naddison36 6b7d42f
Removed the unused SourceStrategyAdded event (#2626)
naddison36 a15c7db
Added EXITING validator state to help prevent deposits to exiting val…
naddison36 e460481
set validator status to exiting if such transition detected (#2629)
sparrowDom 1fb2bca
M-02 registrator protections (#2630)
naddison36 78e29f1
Fixed check of deposit being processed in verifyBalances
naddison36 5321b03
Merge remote-tracking branch 'origin/master' into nicka/pectra
naddison36 616be40
N-07 Code Simplifications (#2631)
clement-ux 8c5e78c
N-08 Missing, Incorrect, or Misleading Documentation (#2632)
clement-ux 3e24f63
Changed SNAP_BALANCES_DELAY to 1 epoch
naddison36 57951f2
Set zero governor on implementation contract
naddison36 8995fac
Deployed latest contracts on Hoodi
naddison36 307bfa9
Moved new deposit storage variables for backward compatibility with H…
naddison36 8a0466c
Redeployed CompoundingStakingSSVStrategy to Hoodi
naddison36 938a15e
Moved new deposit storage variables back up as now deploying a new st…
naddison36 f68d8f6
Deployed a new compounding staking contract to Hoodi
naddison36 1785c2d
Fixed snapStakingStrat
naddison36 786d22a
Fixed verifyBalances when a deposit is done to an exiting validator
naddison36 5075002
Skip failing unit test for now
naddison36 ec4834e
Deployed latest staking contract to Hoodi
naddison36 f078483
FIxed verifyBalances when there are no pending deposits
naddison36 bf5b447
Updated OETH contracts diagram
naddison36 ff92ae0
Updated verifyDeposit process flow
naddison36 7d5308c
simplify snapping balances (#2633)
sparrowDom ff1b017
OZ N-03 Checks Effects Interactions (CEI) Pattern (#2634)
naddison36 92d1465
various minor changes to SSV staking (#2635)
sparrowDom 9e98081
Redeployed latest staking contract to Hoodi
naddison36 bc96964
Fixed snapStakingStrat Hardhat task
naddison36 bc39b02
Removed root from VerifyBalances Hardhat task
naddison36 0bbb0e7
Added removeValidator Hardhat task
naddison36 3aac286
Fixed registration of new compounding validator
naddison36 314466c
Fixed verifyBalances Hardhat task
naddison36 b414887
verifyBalance to default validator slot for verification to the same …
naddison36 d130c6c
Fixed verifyDeposit Hardhat task
naddison36 7115e2c
Improve verifyBalances hardhat task when the deposit queue is empty
naddison36 a2401cf
Fixed validator status in snapStakingStrat HH task
naddison36 1600e4a
change snap balances delay to 35 slots (#2637)
sparrowDom 640c247
add comment (#2638)
sparrowDom 67d89e9
Added dryrun to stakeValidator HH task
naddison36 44f9516
Merge remote-tracking branch 'origin/nicka/pectra' into nicka/pectra
naddison36 a60971d
Fixed logging of the deposit ID from stakeValidator HH task
naddison36 a2fa014
add the support to verify BLS signature before depositing to validato…
sparrowDom 8b2609d
Merge remote-tracking branch 'origin/nicka/pectra' into nicka/pectra
naddison36 2b7ea1d
Removed withdrawable check from verifyDeposit (#2640)
naddison36 c475120
allow for multiple full/partial validator exits even if full exit req…
sparrowDom b65d08a
change validator index from uint64 to uint40 (#2642)
sparrowDom c7c7e29
account as early as possible for the loss because of the front run de…
sparrowDom 163fe89
[SP - 4] Verify validator type (#2644)
sparrowDom 96f6ad3
Deployed latest to Hoodi
naddison36 ac3dfe5
Fix verifyDeposit Hardhat task
naddison36 057c8d4
Redeployed both BeaconProofs and CompoundingStakingSSVStrategy to Hoodi
naddison36 d11d44a
Deployed new strategy to Hoodi
naddison36 36b587a
Restrict initial deposit to 1 ETH (#2646)
naddison36 f6eee53
fix slither
sparrowDom 8cfd0e0
Validator deposit and withdrawal amounts can have decimals
naddison36 4423d24
Format snapStakingStrat
naddison36 575ca56
Do not allow exiting a validator with a pending deposit (#2647)
naddison36 aa45d0f
Merge remote-tracking branch 'origin/nicka/pectra' into nicka/pectra
naddison36 ecb4edb
Merge remote-tracking branch 'origin/master' into nicka/pectra
naddison36 0fbdad6
prettier
sparrowDom 3d4e5f0
add check for zero padding in withdrawal credentials (#2645)
sparrowDom fcce858
ORGN-01 Array Element Skipping During Deposit Removal in verifyBalanc…
naddison36 ae47b8e
Fix for: Deposit Balance Undercount Due To Missing Timestamp Validati…
sparrowDom 8eb0228
Fixed unit test of verifyValidator proof
naddison36 9c7bfac
Deposits to withdrawn validator (#2652)
sparrowDom 68d6909
SP-12 Miscellaneous General Comments (#2657)
naddison36 70f9171
Fixed verificationEpoch calc to use the slot of the parent root (#2656)
naddison36 82e7acc
Added more unit tests for verifyBalances
naddison36 8d2bcc4
Fixed the unit tests
naddison36 5a7c4ae
Added unit test for removing an invalid validator
naddison36 ea4cace
Deploy to latest to Hoodi
naddison36 d262254
remove deposit count subtraction as it is no longer needed (#2660)
sparrowDom 23fe8e0
simplify withdrawal credential comparison (#2659)
sparrowDom 665bf52
correct the comment (#2663)
sparrowDom ba18006
Refactor verifyBalances to use inclusion proofs of pending deposits (…
naddison36 4367ae9
Restrict full withdrawals for non activateable validators (#2662)
sparrowDom 741062a
Logging and linter
naddison36 e7fc5d2
Fix to allow multiple full validator exits (#2667)
naddison36 90e247d
Increased the min balance to be active to over 32.25 ETH (#2668)
naddison36 e470ad7
Gas optimization in verifyBalances to only iterate over the deposits …
naddison36 2cf63a6
restrict pending deposit index to uint32 (#2670)
naddison36 9518a13
Can verify a deposit if the validator is exiting and the pending depo…
naddison36 6e722b7
Deployed the latest staking strategy to Hoodi
naddison36 6124f24
Fixed verifyDeposit Hardhat task
naddison36 546c47f
Fixed verifyBalances Hardhat task when there is a pending deposit
naddison36 20fb4bb
Added negative unit tests
naddison36 613ed9d
Added more unit tests
naddison36 e8cddb1
ORGN-02 can make a validator INVALID with an incorrect validator type…
naddison36 b64e305
Deployed the latest contracts to Hoodi
naddison36 ade07c3
Fixed the validator states in Hardhat task snapStakingStrat
naddison36 0528675
typo
sparrowDom 10bcaaa
typo
sparrowDom 66c9879
Improve getValidator Hardhat task output
naddison36 4e1a4fb
Merge remote-tracking branch 'origin/nicka/pectra' into nicka/pectra
naddison36 9f2eef7
remove comment
sparrowDom 357ed56
remove StakingMonitorChanged event from CompoundingValidatorManager (…
naddison36 8c3cf41
MAX_VERIFIED_VALIDATORS off by one (#2683)
naddison36 480333f
Fix comments (#2684)
naddison36 3e790c1
automated withdrawals from the staking strategy and validators (#2685)
naddison36 4b04f20
Remove upgrade of old native staking strategies (#2686)
naddison36 4370fc7
Merge remote-tracking branch 'origin/master' into nicka/pectra
naddison36 2e372d0
Added lodestar packages to lock file
naddison36 e85fcdd
Bumped deploy script numbers
naddison36 8c31937
auto deposits to validators (#2688)
naddison36 f173703
Fix auto deposits (#2689)
naddison36 181e571
fix the problem where prettier isn't able to load the plugin automati…
sparrowDom 0b7bca8
fix small bug
sparrowDom 612bcac
Added queue position to pending deposits in snapStakingStrat (#2691)
naddison36 63019be
Improve formatting of snapStakingStrat
naddison36 20143c4
Merge remote-tracking branch 'origin/master' into nicka/pectra
naddison36 512f6f7
Added unit tests address for CompoundingStakingStrategyProxy
naddison36 043b23e
Deployed the new staking strategy contracts to mainnet (#2692)
naddison36 28b7b0d
Added BEACON_PROVIDER_URL to CI for mainnet fork tests
naddison36 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 hidden or 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 |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| module.exports = { | ||
| env: { | ||
| es6: true, | ||
| es2020: true, | ||
| node: true, | ||
| browser: true, | ||
| amd: true, | ||
|
|
||
This file contains hidden or 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,37 @@ | ||
| // SPDX-License-Identifier: BUSL-1.1 | ||
| pragma solidity ^0.8.0; | ||
|
|
||
| library BeaconConsolidation { | ||
| /// @notice The address the validator consolidation requests are sent | ||
| /// See https://eips.ethereum.org/EIPS/eip-7251 | ||
| address internal constant CONSOLIDATION_REQUEST_ADDRESS = | ||
| 0x0000BBdDc7CE488642fb579F8B00f3a590007251; | ||
|
|
||
| function request(bytes calldata source, bytes calldata target) | ||
| internal | ||
| returns (uint256 fee_) | ||
| { | ||
| require(source.length == 48, "Invalid source byte length"); | ||
| require(target.length == 48, "Invalid target byte length"); | ||
|
|
||
| fee_ = fee(); | ||
|
|
||
| // Call the Consolidation Request contract with the public keys of the source and target | ||
| // validators packed together. | ||
| // This does not have a function signature, so we use a call | ||
| (bool success, ) = CONSOLIDATION_REQUEST_ADDRESS.call{ value: fee_ }( | ||
| abi.encodePacked(source, target) | ||
| ); | ||
|
|
||
| require(success, "Consolidation request failed"); | ||
| } | ||
|
|
||
| function fee() internal view returns (uint256) { | ||
| // Get fee from the consolidation request contract | ||
| (bool success, bytes memory result) = CONSOLIDATION_REQUEST_ADDRESS | ||
| .staticcall(""); | ||
|
|
||
| require(success && result.length > 0, "Failed to get fee"); | ||
| return abi.decode(result, (uint256)); | ||
| } | ||
| } | ||
This file contains hidden or 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,96 @@ | ||
| // SPDX-License-Identifier: MIT | ||
| pragma solidity ^0.8.0; | ||
|
|
||
| import { BeaconProofsLib } from "./BeaconProofsLib.sol"; | ||
| import { BeaconRoots } from "./BeaconRoots.sol"; | ||
|
|
||
| /// @title Beacon Chain Oracle | ||
| /// @notice An Oracle for mapping execution layer block numbers to beacon chain slots. | ||
| /// @author Origin Protocol Inc | ||
| contract BeaconOracle { | ||
| /// @notice Maps a block number to slot | ||
| mapping(uint64 => uint64) private _blockToSlot; | ||
| /// @notice Maps a slot to a number | ||
| mapping(uint64 => uint64) private _slotToBlock; | ||
| /// @notice Maps a slot to a beacon block root | ||
| mapping(uint64 => bytes32) private _slotToRoot; | ||
|
|
||
| event BlockToSlot( | ||
| bytes32 indexed blockRoot, | ||
| uint64 indexed blockNumber, | ||
| uint64 indexed slot | ||
| ); | ||
|
|
||
| /// @notice Uses merkle a proof against the beacon block root to link | ||
| /// an execution layer block number to a beacon chain slot. | ||
| /// @param nextBlockTimestamp The timestamp of the block after the one being proven. | ||
| /// @param blockNumber The execution layer block number. | ||
| /// @param slot The beacon chain slot. | ||
| /// @param slotProof The merkle proof witnesses for the slot against the beacon block root. | ||
| /// @param blockProof The merkle proof witnesses for the block number against the beacon block root. | ||
| function verifySlot( | ||
| uint64 nextBlockTimestamp, | ||
| uint64 blockNumber, | ||
| uint64 slot, | ||
| bytes calldata slotProof, | ||
| bytes calldata blockProof | ||
| ) external returns (bytes32 blockRoot) { | ||
| require(_blockToSlot[blockNumber] == 0, "Block already mapped"); | ||
|
|
||
| // Get the parent beacon block root for the given timestamp. | ||
| // This is the beacon block root of the previous slot. | ||
| blockRoot = BeaconRoots.parentBlockRoot(nextBlockTimestamp); | ||
|
|
||
| // Verify the slot to the beacon block root | ||
| BeaconProofsLib.verifySlot(blockRoot, slot, slotProof); | ||
|
|
||
| // Verify the block number to the beacon block root | ||
| BeaconProofsLib.verifyBlockNumber(blockRoot, blockNumber, blockProof); | ||
|
|
||
| // Store mappings | ||
| _blockToSlot[blockNumber] = slot; | ||
| _slotToBlock[slot] = blockNumber; | ||
| _slotToRoot[slot] = blockRoot; | ||
|
|
||
| emit BlockToSlot(blockRoot, blockNumber, slot); | ||
| } | ||
|
|
||
| /// @notice Returns the beacon chain slot for a given execution layer block number. | ||
| function blockToSlot(uint64 blockNumber) | ||
| external | ||
| view | ||
| returns (uint64 slot) | ||
| { | ||
| slot = _blockToSlot[blockNumber]; | ||
|
|
||
| require(slot != 0, "Block not mapped"); | ||
| } | ||
|
|
||
| /// @notice Returns the execution layer block number for a given beacon chain slot. | ||
| function slotToBlock(uint64 slot) | ||
| external | ||
| view | ||
| returns (uint64 blockNumber) | ||
| { | ||
| blockNumber = _slotToBlock[slot]; | ||
|
|
||
| require(blockNumber != 0, "Slot not mapped"); | ||
| } | ||
|
|
||
| /// @notice Returns the beacon block root for a given beacon chain slot. | ||
| function slotToRoot(uint64 slot) external view returns (bytes32 blockRoot) { | ||
| blockRoot = _slotToRoot[slot]; | ||
|
|
||
| require(blockRoot != 0, "Slot not mapped"); | ||
| } | ||
|
|
||
| /// @notice Returns true if an execution layer block number has been mapped to a beacon chain slot. | ||
| function isBlockMapped(uint64 blockNumber) external view returns (bool) { | ||
| return _blockToSlot[blockNumber] != 0; | ||
| } | ||
|
|
||
| /// @notice Returns true if a beacon chain slot has been mapped to an execution layer block number. | ||
| function isSlotMapped(uint64 slot) external view returns (bool) { | ||
| return _slotToBlock[slot] != 0; | ||
| } | ||
| } | ||
This file contains hidden or 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,120 @@ | ||
| // SPDX-License-Identifier: BUSL-1.1 | ||
| pragma solidity ^0.8.0; | ||
|
|
||
| import { BeaconProofsLib } from "./BeaconProofsLib.sol"; | ||
|
|
||
| contract BeaconProofs { | ||
| /// @notice Verifies the validator public key against the beacon block root | ||
| /// BeaconBlock.state.validators[validatorIndex].pubkey | ||
| /// @param beaconBlockRoot The root of the beacon block | ||
| /// @param pubKeyHash The beacon chain hash of the validator public key | ||
| /// @param validatorPubKeyProof The merkle proof for the validator public key to the beacon block root. | ||
| /// This is the witness hashes concatenated together starting from the leaf node. | ||
| /// @param validatorIndex The validator index | ||
| function verifyValidatorPubkey( | ||
| bytes32 beaconBlockRoot, | ||
| bytes32 pubKeyHash, | ||
| bytes calldata validatorPubKeyProof, | ||
| uint64 validatorIndex | ||
| ) external view { | ||
| BeaconProofsLib.verifyValidatorPubkey( | ||
| beaconBlockRoot, | ||
| pubKeyHash, | ||
| validatorPubKeyProof, | ||
| validatorIndex | ||
| ); | ||
| } | ||
|
|
||
| /// @notice Verifies the balances container against the beacon block root | ||
| /// BeaconBlock.state.balances | ||
| /// @param beaconBlockRoot The root of the beacon block | ||
| /// @param balancesContainerLeaf The leaf node containing the balances container | ||
| /// @param balancesContainerProof The merkle proof for the balances container to the beacon block root. | ||
| /// This is the witness hashes concatenated together starting from the leaf node. | ||
| function verifyBalancesContainer( | ||
| bytes32 beaconBlockRoot, | ||
| bytes32 balancesContainerLeaf, | ||
| bytes calldata balancesContainerProof | ||
| ) external view { | ||
| BeaconProofsLib.verifyBalancesContainer( | ||
| beaconBlockRoot, | ||
| balancesContainerLeaf, | ||
| balancesContainerProof | ||
| ); | ||
| } | ||
|
|
||
| /// @notice Verifies the validator balance against the root of the Balances container | ||
| /// or the beacon block root | ||
| /// @param root The root of the Balances container or the beacon block root | ||
| /// @param validatorBalanceLeaf The leaf node containing the validator balance with three other balances | ||
| /// @param balanceProof The merkle proof for the validator balance against the root. | ||
| /// This is the witness hashes concatenated together starting from the leaf node. | ||
| /// @param validatorIndex The validator index to verify the balance for | ||
| /// @param level The level of the balance proof, either Container or BeaconBlock | ||
| function verifyValidatorBalance( | ||
| bytes32 root, | ||
| bytes32 validatorBalanceLeaf, | ||
| bytes calldata balanceProof, | ||
| uint64 validatorIndex, | ||
| BeaconProofsLib.BalanceProofLevel level | ||
| ) external view returns (uint256 validatorBalance) { | ||
| validatorBalance = BeaconProofsLib.verifyValidatorBalance( | ||
| root, | ||
| validatorBalanceLeaf, | ||
| balanceProof, | ||
| validatorIndex, | ||
| level | ||
| ); | ||
| } | ||
|
|
||
| /// @notice Verifies the slot of the first pending deposit against the beacon block root | ||
| /// BeaconBlock.state.PendingDeposits[0].slot | ||
| /// @param beaconBlockRoot The root of the beacon block | ||
| /// @param slot The beacon chain slot to verify | ||
| /// @param firstPendingDepositSlotProof The merkle proof for the first pending deposit's slot | ||
| /// against the beacon block root. | ||
| /// This is the witness hashes concatenated together starting from the leaf node. | ||
| function verifyFirstPendingDepositSlot( | ||
| bytes32 beaconBlockRoot, | ||
| uint64 slot, | ||
| bytes calldata firstPendingDepositSlotProof | ||
| ) external view { | ||
| BeaconProofsLib.verifyFirstPendingDepositSlot( | ||
| beaconBlockRoot, | ||
| slot, | ||
| firstPendingDepositSlotProof | ||
| ); | ||
| } | ||
|
|
||
| /// @notice Verifies the block number to the the beacon block root | ||
| /// BeaconBlock.body.executionPayload.blockNumber | ||
| /// @param beaconBlockRoot The root of the beacon block | ||
| /// @param blockNumber The execution layer block number to verify | ||
| /// @param blockNumberProof The merkle proof for the block number against the beacon block | ||
| /// This is the witness hashes concatenated together starting from the leaf node. | ||
| function verifyBlockNumber( | ||
| bytes32 beaconBlockRoot, | ||
| uint256 blockNumber, | ||
| bytes calldata blockNumberProof | ||
| ) external view { | ||
| BeaconProofsLib.verifyBlockNumber( | ||
| beaconBlockRoot, | ||
| blockNumber, | ||
| blockNumberProof | ||
| ); | ||
| } | ||
|
|
||
| /// @notice Verifies the slot number against the beacon block root. | ||
| /// BeaconBlock.slot | ||
| /// @param beaconBlockRoot The root of the beacon block | ||
| /// @param slot The beacon chain slot to verify | ||
| /// @param slotProof The merkle proof for the slot against the beacon block root. | ||
| /// This is the witness hashes concatenated together starting from the leaf node. | ||
| function verifySlot( | ||
| bytes32 beaconBlockRoot, | ||
| uint256 slot, | ||
| bytes calldata slotProof | ||
| ) external view { | ||
| BeaconProofsLib.verifySlot(beaconBlockRoot, slot, slotProof); | ||
| } | ||
| } | ||
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.
Uh oh!
There was an error while loading. Please reload this page.