Skip to content

Commit

Permalink
added read functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Sidu28 committed Nov 18, 2023
1 parent d804820 commit 10af55f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/contracts/pods/EigenPod.sol
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,16 @@ contract EigenPod is IEigenPod, Initializable, ReentrancyGuardUpgradeable, Eigen
return abi.encodePacked(bytes1(uint8(1)), bytes11(0), address(this));
}

function _validatorPubkeyHash(bytes memory validatorPubkey) internal view returns(bytes32){
bytes memory paddedPubkey = new bytes(data.length + 16);

// Copy original data to the new array
for (uint i = 0; i < validatorPubkey.length; i++) {
paddedPubkey[i] = validatorPubkey[i];
}
return sha256(paddedData);
}

/**
* Calculates delta between two share amounts and returns as an int256
*/
Expand Down Expand Up @@ -786,6 +796,17 @@ contract EigenPod is IEigenPod, Initializable, ReentrancyGuardUpgradeable, Eigen
return _validatorPubkeyHashToInfo[pubkeyHash].status;
}

function validatorPubkeyToInfo(bytes calldata validatorPubkey) external view returns (ValidatorInfo memory) {
require(validatorPubkey.length == 48, "EigenPod.validatorPubkeyHashToInfo must be a 48-byte BLS public key");

return _validatorPubkeyHash[_validatorPubkeyHash(validatorPubkey)]
}

function validatorStatus(bytes calldata validatorPubkey) external view returns (ValidatorInfo memory) {
require(validatorPubkey.length == 48, "EigenPod.validatorPubkeyHashToInfo must be a 48-byte BLS public key");
return _validatorPubkeyHashToInfo[_validatorPubkeyHash(validatorPubkey)].status;
}


/**
* @dev This empty reserved space is put in place to allow future versions to add new
Expand Down
12 changes: 12 additions & 0 deletions src/test/EigenPod.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -1380,6 +1380,18 @@ contract EigenPodTests is ProofParsing, EigenPodPausingConstants {
cheats.stopPrank();
}

function test_validatorPubkeyToInfo() external {
bytes memory pubkey = hex"93a0dd04ccddf3f1b419fdebf99481a2182c17d67cf14d32d6e50fc4bf8effc8db4a04b7c2f3a5975c1b9b74e2841888";

setJSON("./src/test/test-data/withdrawal_credential_proof_302913.json");
_testDeployAndVerifyNewEigenPod(podOwner, signature, depositDataRoot);
IEigenPod pod = eigenPodManager.getPod(podOwner);

IEigenPod.ValidatorInfo memory info = pod.validatorPubkeyToInfo(pubkey);


}

/* TODO: reimplement similar tests
function testQueueBeaconChainETHWithdrawalWithoutProvingFullWithdrawal() external {
// ./solidityProofGen -newBalance=32000115173 "ValidatorFieldsProof" 302913 true "data/withdrawal_proof_goerli/goerli_block_header_6399998.json" "data/withdrawal_proof_goerli/goerli_slot_6399998.json" "withdrawal_credential_proof_302913.json"
Expand Down

0 comments on commit 10af55f

Please sign in to comment.