Skip to content

Commit

Permalink
feat: pectra compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
ypatil12 committed Nov 15, 2024
1 parent 2992704 commit e88b185
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 9 deletions.
1 change: 1 addition & 0 deletions lib/openzeppelin-contracts
Submodule openzeppelin-contracts added at 3b8b4b
1 change: 1 addition & 0 deletions lib/openzeppelin-contracts-upgradeable
Submodule openzeppelin-contracts-upgradeable added at 6b9807
1 change: 1 addition & 0 deletions lib/zeus-templates
Submodule zeus-templates added at 66f7f7
5 changes: 3 additions & 2 deletions src/contracts/interfaces/IEigenPodManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,14 @@ interface IEigenPodManager is IEigenPodManagerErrors, IEigenPodManagerEvents, IS

/**
* @notice The Pectra hard fork timestamp used to determine which proof config to use for a checkpoint proof.
* @dev This function returns type(uint64).max if the fork timestamp has not been set. The timestamp can never be set to 0.
* @dev This function returns type(uint64).max if the fork timestamp has not been set.
*/
function getPectraForkTimestamp() external view returns (uint64);

/**
* @notice Sets the pectra hard fork timestamp by the eigenPodManager owner
* @dev This function is callable only by the owner of the eigenPodManager only once
* @dev This function can only be called by the eigenPodManager owner
* @dev This function can only be called once
*/
function setPectraForkTimestamp(uint64 pectraForkTimestamp) external;
}
6 changes: 3 additions & 3 deletions src/contracts/libraries/BeaconChainProofs.sol
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,9 @@ library BeaconChainProofs {
}

/// @dev Gets the height of the beacon state tree based on the pectraForkTimestamp
/// @dev We subtract one from the pectraForkTimestamp to ensure that a `proofTimestamp` at the `pectraForkTimestamp`
/// is considered to be Pre-Pectra given the EIP-4788 returns the parent block.
/// @dev We check if the proofTimestamp is <= pectraForkTimestamp because a `proofTimestamp` at the `pectraForkTimestamp`
/// is considered to be Pre-Pectra given the EIP-4788 oracle returns the parent block.
function getBeaconStateTreeHeight(uint64 proofTimestamp, uint64 pectraForkTimestamp) internal pure returns (uint256) {
return proofTimestamp < pectraForkTimestamp - 1 ? DENEB_BEACON_STATE_TREE_HEIGHT : PECTRA_BEACON_STATE_TREE_HEIGHT;
return proofTimestamp <= pectraForkTimestamp ? DENEB_BEACON_STATE_TREE_HEIGHT : PECTRA_BEACON_STATE_TREE_HEIGHT;
}
}
8 changes: 4 additions & 4 deletions src/contracts/pods/EigenPodManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -216,13 +216,13 @@ contract EigenPodManager is
}

/// @inheritdoc IEigenPodManager
function setPectraForkTimestamp(uint64 newPectraForkTimestamp) external onlyOwner {
function setPectraForkTimestamp(uint64 pectraForkTimestamp) external onlyOwner {
uint64 currentPectraForkTimestamp = getPectraForkTimestamp();
require(currentPectraForkTimestamp == type(uint64).max, ForkTimestampAlreadySet());
require(newPectraForkTimestamp != 0, InvalidForkTimestamp());
require(pectraForkTimestamp != type(uint64).max, InvalidForkTimestamp());

_pectraForkTimestamp = newPectraForkTimestamp;
emit PectraForkTimestampSet(newPectraForkTimestamp);
_pectraForkTimestamp = pectraForkTimestamp;
emit PectraForkTimestampSet(pectraForkTimestamp);
}

/// @inheritdoc IEigenPodManager
Expand Down

0 comments on commit e88b185

Please sign in to comment.