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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion contracts/.eslintrc.js
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,
Expand Down
37 changes: 37 additions & 0 deletions contracts/contracts/beacon/BeaconConsolidation.sol
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)

Check warning on line 10 in contracts/contracts/beacon/BeaconConsolidation.sol

View check run for this annotation

Codecov / codecov/patch

contracts/contracts/beacon/BeaconConsolidation.sol#L10

Added line #L10 was not covered by tests
internal
returns (uint256 fee_)
{
require(source.length == 48, "Invalid source byte length");
require(target.length == 48, "Invalid target byte length");

fee_ = fee();

Check warning on line 17 in contracts/contracts/beacon/BeaconConsolidation.sol

View check run for this annotation

Codecov / codecov/patch

contracts/contracts/beacon/BeaconConsolidation.sol#L17

Added line #L17 was not covered by tests

// 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_ }(

Check warning on line 22 in contracts/contracts/beacon/BeaconConsolidation.sol

View check run for this annotation

Codecov / codecov/patch

contracts/contracts/beacon/BeaconConsolidation.sol#L22

Added line #L22 was not covered by tests
abi.encodePacked(source, target)
);

require(success, "Consolidation request failed");
}

function fee() internal view returns (uint256) {

Check warning on line 29 in contracts/contracts/beacon/BeaconConsolidation.sol

View check run for this annotation

Codecov / codecov/patch

contracts/contracts/beacon/BeaconConsolidation.sol#L29

Added line #L29 was not covered by tests
// Get fee from the consolidation request contract
(bool success, bytes memory result) = CONSOLIDATION_REQUEST_ADDRESS

Check warning on line 31 in contracts/contracts/beacon/BeaconConsolidation.sol

View check run for this annotation

Codecov / codecov/patch

contracts/contracts/beacon/BeaconConsolidation.sol#L31

Added line #L31 was not covered by tests
.staticcall("");

require(success && result.length > 0, "Failed to get fee");
return abi.decode(result, (uint256));

Check warning on line 35 in contracts/contracts/beacon/BeaconConsolidation.sol

View check run for this annotation

Codecov / codecov/patch

contracts/contracts/beacon/BeaconConsolidation.sol#L35

Added line #L35 was not covered by tests
}
}
96 changes: 96 additions & 0 deletions contracts/contracts/beacon/BeaconOracle.sol
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(

Check warning on line 31 in contracts/contracts/beacon/BeaconOracle.sol

View check run for this annotation

Codecov / codecov/patch

contracts/contracts/beacon/BeaconOracle.sol#L31

Added line #L31 was not covered by tests
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);

Check warning on line 42 in contracts/contracts/beacon/BeaconOracle.sol

View check run for this annotation

Codecov / codecov/patch

contracts/contracts/beacon/BeaconOracle.sol#L42

Added line #L42 was not covered by tests

// Verify the slot to the beacon block root
BeaconProofsLib.verifySlot(blockRoot, slot, slotProof);

Check warning on line 45 in contracts/contracts/beacon/BeaconOracle.sol

View check run for this annotation

Codecov / codecov/patch

contracts/contracts/beacon/BeaconOracle.sol#L45

Added line #L45 was not covered by tests

// Verify the block number to the beacon block root
BeaconProofsLib.verifyBlockNumber(blockRoot, blockNumber, blockProof);

Check warning on line 48 in contracts/contracts/beacon/BeaconOracle.sol

View check run for this annotation

Codecov / codecov/patch

contracts/contracts/beacon/BeaconOracle.sol#L48

Added line #L48 was not covered by tests

// Store mappings
_blockToSlot[blockNumber] = slot;
_slotToBlock[slot] = blockNumber;
_slotToRoot[slot] = blockRoot;

Check warning on line 53 in contracts/contracts/beacon/BeaconOracle.sol

View check run for this annotation

Codecov / codecov/patch

contracts/contracts/beacon/BeaconOracle.sol#L51-L53

Added lines #L51 - L53 were not covered by tests

emit BlockToSlot(blockRoot, blockNumber, slot);

Check warning on line 55 in contracts/contracts/beacon/BeaconOracle.sol

View check run for this annotation

Codecov / codecov/patch

contracts/contracts/beacon/BeaconOracle.sol#L55

Added line #L55 was not covered by tests
}

/// @notice Returns the beacon chain slot for a given execution layer block number.
function blockToSlot(uint64 blockNumber)

Check warning on line 59 in contracts/contracts/beacon/BeaconOracle.sol

View check run for this annotation

Codecov / codecov/patch

contracts/contracts/beacon/BeaconOracle.sol#L59

Added line #L59 was not covered by tests
external
view
returns (uint64 slot)
{
slot = _blockToSlot[blockNumber];

Check warning on line 64 in contracts/contracts/beacon/BeaconOracle.sol

View check run for this annotation

Codecov / codecov/patch

contracts/contracts/beacon/BeaconOracle.sol#L64

Added line #L64 was not covered by tests

require(slot != 0, "Block not mapped");
}

/// @notice Returns the execution layer block number for a given beacon chain slot.
function slotToBlock(uint64 slot)

Check warning on line 70 in contracts/contracts/beacon/BeaconOracle.sol

View check run for this annotation

Codecov / codecov/patch

contracts/contracts/beacon/BeaconOracle.sol#L70

Added line #L70 was not covered by tests
external
view
returns (uint64 blockNumber)
{
blockNumber = _slotToBlock[slot];

Check warning on line 75 in contracts/contracts/beacon/BeaconOracle.sol

View check run for this annotation

Codecov / codecov/patch

contracts/contracts/beacon/BeaconOracle.sol#L75

Added line #L75 was not covered by tests

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];

Check warning on line 82 in contracts/contracts/beacon/BeaconOracle.sol

View check run for this annotation

Codecov / codecov/patch

contracts/contracts/beacon/BeaconOracle.sol#L81-L82

Added lines #L81 - L82 were not covered by tests

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;

Check warning on line 89 in contracts/contracts/beacon/BeaconOracle.sol

View check run for this annotation

Codecov / codecov/patch

contracts/contracts/beacon/BeaconOracle.sol#L88-L89

Added lines #L88 - L89 were not covered by tests
}

/// @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;

Check warning on line 94 in contracts/contracts/beacon/BeaconOracle.sol

View check run for this annotation

Codecov / codecov/patch

contracts/contracts/beacon/BeaconOracle.sol#L93-L94

Added lines #L93 - L94 were not covered by tests
}
}
120 changes: 120 additions & 0 deletions contracts/contracts/beacon/BeaconProofs.sol
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(

Check warning on line 14 in contracts/contracts/beacon/BeaconProofs.sol

View check run for this annotation

Codecov / codecov/patch

contracts/contracts/beacon/BeaconProofs.sol#L14

Added line #L14 was not covered by tests
bytes32 beaconBlockRoot,
bytes32 pubKeyHash,
bytes calldata validatorPubKeyProof,
uint64 validatorIndex
) external view {
BeaconProofsLib.verifyValidatorPubkey(

Check warning on line 20 in contracts/contracts/beacon/BeaconProofs.sol

View check run for this annotation

Codecov / codecov/patch

contracts/contracts/beacon/BeaconProofs.sol#L20

Added line #L20 was not covered by tests
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(

Check warning on line 34 in contracts/contracts/beacon/BeaconProofs.sol

View check run for this annotation

Codecov / codecov/patch

contracts/contracts/beacon/BeaconProofs.sol#L34

Added line #L34 was not covered by tests
bytes32 beaconBlockRoot,
bytes32 balancesContainerLeaf,
bytes calldata balancesContainerProof
) external view {
BeaconProofsLib.verifyBalancesContainer(

Check warning on line 39 in contracts/contracts/beacon/BeaconProofs.sol

View check run for this annotation

Codecov / codecov/patch

contracts/contracts/beacon/BeaconProofs.sol#L39

Added line #L39 was not covered by tests
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(

Check warning on line 54 in contracts/contracts/beacon/BeaconProofs.sol

View check run for this annotation

Codecov / codecov/patch

contracts/contracts/beacon/BeaconProofs.sol#L54

Added line #L54 was not covered by tests
bytes32 root,
bytes32 validatorBalanceLeaf,
bytes calldata balanceProof,
uint64 validatorIndex,
BeaconProofsLib.BalanceProofLevel level
) external view returns (uint256 validatorBalance) {
validatorBalance = BeaconProofsLib.verifyValidatorBalance(

Check warning on line 61 in contracts/contracts/beacon/BeaconProofs.sol

View check run for this annotation

Codecov / codecov/patch

contracts/contracts/beacon/BeaconProofs.sol#L61

Added line #L61 was not covered by tests
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(

Check warning on line 77 in contracts/contracts/beacon/BeaconProofs.sol

View check run for this annotation

Codecov / codecov/patch

contracts/contracts/beacon/BeaconProofs.sol#L77

Added line #L77 was not covered by tests
bytes32 beaconBlockRoot,
uint64 slot,
bytes calldata firstPendingDepositSlotProof
) external view {
BeaconProofsLib.verifyFirstPendingDepositSlot(

Check warning on line 82 in contracts/contracts/beacon/BeaconProofs.sol

View check run for this annotation

Codecov / codecov/patch

contracts/contracts/beacon/BeaconProofs.sol#L82

Added line #L82 was not covered by tests
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(

Check warning on line 95 in contracts/contracts/beacon/BeaconProofs.sol

View check run for this annotation

Codecov / codecov/patch

contracts/contracts/beacon/BeaconProofs.sol#L95

Added line #L95 was not covered by tests
bytes32 beaconBlockRoot,
uint256 blockNumber,
bytes calldata blockNumberProof
) external view {
BeaconProofsLib.verifyBlockNumber(

Check warning on line 100 in contracts/contracts/beacon/BeaconProofs.sol

View check run for this annotation

Codecov / codecov/patch

contracts/contracts/beacon/BeaconProofs.sol#L100

Added line #L100 was not covered by tests
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(

Check warning on line 113 in contracts/contracts/beacon/BeaconProofs.sol

View check run for this annotation

Codecov / codecov/patch

contracts/contracts/beacon/BeaconProofs.sol#L113

Added line #L113 was not covered by tests
bytes32 beaconBlockRoot,
uint256 slot,
bytes calldata slotProof
) external view {
BeaconProofsLib.verifySlot(beaconBlockRoot, slot, slotProof);

Check warning on line 118 in contracts/contracts/beacon/BeaconProofs.sol

View check run for this annotation

Codecov / codecov/patch

contracts/contracts/beacon/BeaconProofs.sol#L118

Added line #L118 was not covered by tests
}
}
Loading
Loading