forked from etherfi-protocol/smart-contracts
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Gad/setup #18
Draft
Roy-Certora
wants to merge
29
commits into
staging-2.5-fork
Choose a base branch
from
gad/setup
base: staging-2.5-fork
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.
Draft
Gad/setup #18
Changes from 16 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
9b40087
Auction manager initial setup
GadElbazCertora 711e083
Merge pull request #12 from Certora/staging-2.5-fork
GadElbazCertora f93dcfe
auctionManager new rules
GadElbazCertora 6ca9193
add eeth and weeth
GadElbazCertora 576f37d
update weeth spec
GadElbazCertora 07577f9
update weeth
GadElbazCertora dddb740
.
GadElbazCertora d9cb4ed
Merge pull request #13 from etherfi-protocol/staging-2.5
GadElbazCertora fcbef39
update setups - stakingManager
GadElbazCertora 45a5491
update rules
GadElbazCertora 92a2ad7
Merge pull request #17 from Certora/staging-2.5-fork
GadElbazCertora 9cb729b
align spec with new code
GadElbazCertora c0fece6
update nfts rules
GadElbazCertora 2fab56e
update auction manager spec
GadElbazCertora 20749f2
update staking manager spec
GadElbazCertora b7255fe
etherfi node specs
GadElbazCertora 3f55802
auction manager update
GadElbazCertora 13e0a1f
AuctionManager
GadElbazCertora 0aacea5
Auction Manager Setup remove redundant
GadElbazCertora 718c8b0
EETH update
GadElbazCertora f011de7
nft dispatch update
GadElbazCertora 46135db
update staking manager
GadElbazCertora 4eb3a2f
add oracle and remove redundant
GadElbazCertora c54a0be
add EtherFi interface
GadElbazCertora d361f5a
update etherfi node spec
GadElbazCertora b0f8ccd
add etherfi nodes manager specs
GadElbazCertora df1b9bb
remove redundant
GadElbazCertora 5ab7b00
update comments and documentation
GadElbazCertora 705ae29
small update
GadElbazCertora 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"files": [ | ||
"src/AuctionManager.sol", | ||
"src/NodeOperatorManager.sol" | ||
], | ||
"link": [ | ||
"AuctionManager:nodeOperatorManager=NodeOperatorManager" | ||
], | ||
"packages": [ | ||
"@openzeppelin=lib/openzeppelin-contracts", | ||
"forge-std=lib/forge-std/src" | ||
], | ||
"verify": "AuctionManager:certora/specs/AuctionManager.spec", | ||
"optimistic_loop": true, | ||
"optimistic_fallback": true, | ||
"loop_iter": "3", | ||
"solc": "solc8.24", | ||
"msg": "all AuctionManager", | ||
} |
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,18 @@ | ||
{ | ||
"files": [ | ||
"src/EETH.sol" | ||
], | ||
"link": [ | ||
], | ||
"packages": [ | ||
"@openzeppelin=lib/openzeppelin-contracts", | ||
"forge-std=lib/forge-std/src" | ||
], | ||
"verify": "EETH:certora/specs/EETH.spec", | ||
"parametric_contracts": ["EETH"], | ||
"optimistic_loop": true, | ||
"optimistic_fallback": true, | ||
"loop_iter": "3", | ||
"solc": "solc8.24", | ||
"msg": "EETH setup" | ||
} |
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,21 @@ | ||
{ | ||
"files": [ | ||
"src/EtherFiNode.sol", | ||
], | ||
"link": [ | ||
], | ||
"packages": [ | ||
"@openzeppelin=lib/openzeppelin-contracts", | ||
"forge-std=lib/forge-std/src" | ||
], | ||
"verify": "EtherFiNode:certora/specs/EtherFiNode.spec", | ||
"optimistic_loop": true, | ||
"optimistic_fallback": true, | ||
"optimistic_hashing": true, | ||
// "parametric_contracts":["EtherFiNode"], | ||
"build_cache": true, | ||
"loop_iter": "3", | ||
"solc": "solc8.24", | ||
"msg": "EtherFiNode", | ||
"rule": ["registerValidatorThenUnregisteringNeverReverts", "associatedValidatorIdsLengthEqNumOfValidators"], | ||
} |
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,31 @@ | ||
{ | ||
"files": [ | ||
"src/StakingManager.sol", | ||
"src/AuctionManager.sol", | ||
"src/NodeOperatorManager.sol", | ||
"src/TNFT.sol", | ||
"src/BNFT.sol", | ||
"src/RoleRegistry.sol", | ||
"test/DepositContract.sol" | ||
], | ||
"link": [ | ||
"StakingManager:auctionManager=AuctionManager", | ||
"AuctionManager:nodeOperatorManager=NodeOperatorManager", | ||
"StakingManager:roleRegistry=RoleRegistry", | ||
"StakingManager:depositContractEth2=DepositContract", | ||
], | ||
"packages": [ | ||
"@openzeppelin=lib/openzeppelin-contracts", | ||
"forge-std=lib/forge-std/src" | ||
], | ||
"verify": "StakingManager:certora/specs/StakingManager.spec", | ||
"optimistic_loop": true, | ||
"optimistic_fallback": true, | ||
"optimistic_hashing": true, | ||
// "parametric_contracts":["StakingManager"], | ||
"build_cache": true, | ||
"loop_iter": "3", | ||
"solc": "solc8.24", | ||
"msg": "all StakingManager", | ||
"rule": ["whoLeaveEth"], | ||
} |
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,20 @@ | ||
{ | ||
"files": [ | ||
"src/WeETH.sol", | ||
"src/EETH.sol" | ||
], | ||
"link": [ | ||
"WeETH:eETH=EETH" | ||
], | ||
"packages": [ | ||
"@openzeppelin=lib/openzeppelin-contracts", | ||
"forge-std=lib/forge-std/src" | ||
], | ||
"verify": "WeETH:certora/specs/WeETH.spec", | ||
"parametric_contracts": ["WeETH"], | ||
"optimistic_loop": true, | ||
"optimistic_fallback": true, | ||
"loop_iter": "3", | ||
"solc": "solc8.24", | ||
"msg": "EETH setup" | ||
} |
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,59 @@ | ||
methods { | ||
function _.upgradeToAndCall(address,bytes) external => NONDET; | ||
} | ||
|
||
/// Is persistent because it mirrors the PoolManager storage. | ||
persistent ghost mapping(uint256 => uint256) bids_amount { | ||
init_state axiom forall uint256 bid_id . bids_amount[bid_id] == 0; | ||
} | ||
|
||
ghost mathint sum_of_bids { | ||
init_state axiom sum_of_bids == 0; | ||
} | ||
|
||
ghost mathint sum_of_active_bids { | ||
init_state axiom sum_of_active_bids == 0; | ||
} | ||
|
||
ghost mathint sum_of_all_bids_amounts { | ||
init_state axiom sum_of_all_bids_amounts == 0; | ||
} | ||
|
||
ghost mathint sum_of_all_active_bids_amounts { | ||
init_state axiom sum_of_all_active_bids_amounts == 0; | ||
} | ||
|
||
ghost uint256 latest_bid_id; | ||
|
||
ghost mapping(uint256 => bool) bids_is_active { | ||
init_state axiom forall uint256 bid_id . bids_is_active[bid_id] == false; | ||
} | ||
|
||
ghost mapping(address => uint256) user_last_bid_id_index { | ||
init_state axiom forall address user . user_last_bid_id_index[user] == 0; | ||
} | ||
|
||
hook Sstore bids[KEY uint256 bid_id].amount uint256 new_amount (uint256 old_amount) { | ||
bids_amount[bid_id] = new_amount; | ||
sum_of_bids = sum_of_bids + 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. Is it possible to reset the bid? In that case when new_amount = 0 the sum_of_bids should reduce by 1. |
||
sum_of_all_bids_amounts = sum_of_all_bids_amounts + new_amount; | ||
} | ||
|
||
hook Sload uint256 _amount bids[KEY uint256 bid_id].amount { | ||
require _amount == bids_amount[bid_id]; | ||
} | ||
|
||
hook Sstore bids[KEY uint256 bid_id].isActive bool new_acitive (bool old_active) { | ||
if (new_acitive) { | ||
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. why not |
||
sum_of_active_bids = sum_of_active_bids + 1; | ||
sum_of_all_active_bids_amounts = sum_of_all_active_bids_amounts + bids_amount[bid_id]; | ||
} else if (!new_acitive && old_active) { | ||
sum_of_active_bids = sum_of_active_bids - 1; | ||
sum_of_all_active_bids_amounts = sum_of_all_active_bids_amounts - bids_amount[bid_id]; | ||
} | ||
bids_is_active[bid_id] = new_acitive; | ||
} | ||
|
||
hook Sload bool _isActive bids[KEY uint256 bid_id].isActive { | ||
require _isActive == bids_is_active[bid_id]; | ||
} |
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,130 @@ | ||
import "./AuctionManageSetup.spec"; | ||
|
||
using NodeOperatorManager as NodeOperatorManager; | ||
/* Verification of `AuctionManager` */ | ||
methods { | ||
|
||
// Getters: | ||
function whitelistEnabled() external returns (bool) envfree; | ||
function whitelistBidAmount() external returns (uint128) envfree; | ||
function minBidAmount() external returns (uint64) envfree; | ||
function maxBidAmount() external returns (uint64) envfree; | ||
function numberOfActiveBids() external returns (uint256) envfree; | ||
function numberOfBids() external returns (uint256) envfree; | ||
function bids(uint256) external returns (uint256, uint64, address, bool) envfree; | ||
function getBidOwner(uint256) external returns (address) envfree; | ||
function isBidActive(uint256) external returns (bool) envfree; | ||
function accumulatedRevenue() external returns (uint128) envfree; | ||
function accumulatedRevenueThreshold() external returns (uint128) envfree; | ||
|
||
function NodeOperatorManager.getUserTotalKeys(address) external returns (uint64) envfree; | ||
function NodeOperatorManager.getNumKeysRemaining(address) external returns (uint64) envfree; | ||
} | ||
|
||
// Functions filtered out since they use `delegatecall`. | ||
definition isFilteredFunc(method f) returns bool = ( | ||
f.selector == sig:upgradeToAndCall(address, bytes).selector | ||
); | ||
|
||
// numberOfActiveBids equals the sum of active bids. | ||
invariant numberOfActiveBidsCorrect() | ||
sum_of_active_bids == to_mathint(numberOfActiveBids()) | ||
filtered {f -> !isFilteredFunc(f)} | ||
|
||
// numberOfBids equals the sum of all bids. | ||
invariant numberOfBidsEqTheSumOfAllBids() | ||
sum_of_bids == to_mathint(numberOfBids()) | ||
filtered {f -> !isFilteredFunc(f) && f.selector != sig:initialize(address).selector} | ||
|
||
// solvency invariant - contract should hold atleast sumOfAllActiveBidAmounts amount of eth. | ||
invariant activeBidsSolvency() | ||
to_mathint(nativeBalances[currentContract]) >= sum_of_all_active_bids_amounts | ||
filtered {f -> !isFilteredFunc(f)} | ||
{ | ||
preserved with (env e) { | ||
require e.msg.sender != currentContract; | ||
} | ||
preserved processAuctionFeeTransfer(uint256 bidId) with (env e) { | ||
// bidId must be inactive (because there is a stacker that is not address zero). | ||
require isBidActive(bidId) == false; | ||
} | ||
} | ||
|
||
// the sum of all used keys equals num of bids. | ||
// invariant numOfAllUsedKeysEqNumOfBids() {} | ||
|
||
// chack for all bids to see if the key index is unique per user. / not same user with same keyIndex on different bids: | ||
// rule bidderPubKeyIndexIsUniqePerUser() {} | ||
|
||
rule bidImmutability(method f, uint256 bid_id) filtered {f -> !isFilteredFunc(f)} { | ||
env e; | ||
calldataarg args; | ||
|
||
require bid_id < numberOfBids(); | ||
|
||
uint256 AmountBefore; | ||
uint64 bidderPubKeyIndexBefore; | ||
address bidderAddressBefore; | ||
uint256 AmountAfter; | ||
uint64 bidderPubKeyIndexAfter; | ||
address bidderAddressAfter; | ||
|
||
AmountBefore, bidderPubKeyIndexBefore, bidderAddressBefore, _ = bids(bid_id); | ||
|
||
f(e, args); | ||
|
||
AmountAfter, bidderPubKeyIndexAfter, bidderAddressAfter, _ = bids(bid_id); | ||
|
||
assert AmountBefore == AmountAfter, "bid amount was changed"; | ||
assert bidderPubKeyIndexBefore == bidderPubKeyIndexAfter, "bidder key index was changed"; | ||
assert bidderAddressBefore == bidderAddressAfter, "bidder address was changed"; | ||
} | ||
|
||
/// @title The contact is set as initialized in the constructor -- seems a bug? | ||
invariant alwaysInitialized() | ||
currentContract._initialized == max_uint8 | ||
filtered {f -> !isFilteredFunc(f)} | ||
|
||
rule integrityOfCreateBid(uint256 _bidSize, uint256 _bidAmountPerBid) { | ||
env e; | ||
uint256 newBidId; | ||
mathint msgValue = e.msg.value; | ||
mathint numberOfBidsBefore = numberOfBids(); | ||
mathint numberOfActiveBidsBefore = numberOfActiveBids(); | ||
mathint bidIndexInBatch = newBidId - numberOfBidsBefore; | ||
mathint senderFirstKeyIndex = NodeOperatorManager.getUserTotalKeys(e.msg.sender) - NodeOperatorManager.getNumKeysRemaining(e.msg.sender); | ||
|
||
require to_mathint(newBidId) < numberOfBidsBefore + _bidSize; | ||
require to_mathint(newBidId) >= numberOfBidsBefore; | ||
|
||
// new bid fields: | ||
uint256 amount; | ||
uint64 bidderPubKeyIndex; | ||
address bidderAddress; | ||
bool isActive; | ||
|
||
createBid(e, _bidSize, _bidAmountPerBid); | ||
|
||
// get one of the new bids: | ||
amount, bidderPubKeyIndex, bidderAddress, isActive = bids(e, newBidId); | ||
|
||
mathint numberOfBidsAfter = numberOfBids(); | ||
mathint numberOfActiveBidsAfter = numberOfActiveBids(); | ||
mathint senderLastKeyIndex = NodeOperatorManager.getUserTotalKeys(e.msg.sender) - NodeOperatorManager.getNumKeysRemaining(e.msg.sender); | ||
|
||
// trivial due to requires: | ||
assert msgValue == _bidSize * _bidAmountPerBid, "function should have reverted"; | ||
// number of bids update correctly | ||
assert numberOfBidsAfter == numberOfBidsBefore + _bidSize, "ammount of bids updated incorrectly"; | ||
assert numberOfActiveBidsAfter == numberOfActiveBidsBefore + _bidSize, "ammount of active bids updated incorrectly"; | ||
assert senderLastKeyIndex == senderFirstKeyIndex + _bidSize, "amount of used keys updated incorrectly"; | ||
// the right bids were added: | ||
assert amount == _bidAmountPerBid; | ||
assert bidderPubKeyIndex == assert_uint64(senderFirstKeyIndex + bidIndexInBatch); | ||
assert bidderAddress == e.msg.sender; | ||
assert isActive; | ||
} | ||
|
||
// rule integrityOfCancelBid(uint256 bidId) { | ||
// env e; | ||
// } |
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,20 @@ | ||
methods { | ||
// IERC721Upgradeable: | ||
function balanceOf(address) external returns (uint256) envfree; | ||
function ownerOf(uint256) external returns (address) envfree; | ||
function safeTransferFrom(address, address, uint256, bytes) external; | ||
function safeTransferFrom(address, address, uint256) external; | ||
function transferFrom(address, address, uint256) external; | ||
function approve(address, uint256) external; | ||
function setApprovalForAll(address, bool) external; | ||
function getApproved(uint256 tokenId) external view returns (address operator); | ||
function isApprovedForAll(address, address) external returns (bool) envfree; | ||
|
||
// BNFT: | ||
function burnFromWithdrawal(uint256) external; | ||
function initialize() external; | ||
function initializeOnUpgrade(address) external; | ||
function mint(address, uint256) external; | ||
function burnFromCancelBNftFlow(uint256) external; | ||
function upgradeTo(address) external; | ||
} |
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.
When a copy-paste gives you away :)
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.
its inspiration