Skip to content

feat: updated certora rules #236

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

Closed
wants to merge 42 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
aaeb54c
fix: setup certora script
8sunyuan Jan 23, 2024
ea82243
fix: updating contracts
8sunyuan Jan 23, 2024
20df08a
refactor: minWithdrawalDelayBLocks from core
8sunyuan Jan 24, 2024
00a527a
fix: compiling spec now
8sunyuan Jan 25, 2024
f007cf8
fix: specs and add delegation to script
8sunyuan Jan 25, 2024
cb10d60
update: change core submodule branch
ypatil12 Jan 26, 2024
a479bfc
fix: core contracts commit and tests
8sunyuan Jan 29, 2024
0d64eeb
feat: add avs directory to service manager
ypatil12 Jan 26, 2024
7d0ee2d
fix: rebase off updated bls sig checker; update integration tests
ypatil12 Jan 26, 2024
31554ff
Merge branch 'm2-mainnet-fixes' of https://github.com/Layr-Labs/eigen…
8sunyuan Jan 29, 2024
f6cd875
fix: setup certora script
8sunyuan Jan 23, 2024
e7153ed
fix: updating contracts
8sunyuan Jan 23, 2024
84de64d
fix: compiling spec now
8sunyuan Jan 25, 2024
5deb2fc
fix: specs and add delegation to script
8sunyuan Jan 25, 2024
67f0b32
Merge branch 'updated-certora-rules' of https://github.com/Layr-Labs/…
8sunyuan Jan 30, 2024
a5a2499
fix: make commit hook executable again (#160)
stevennevins Jan 30, 2024
23dbbf7
ci: add ci to run on PRs to m2-mainnet-fixes (#159)
stevennevins Jan 30, 2024
5c55896
refactor: update minWithdrawalDelayBLocks variable (#152)
8sunyuan Jan 30, 2024
00e3f14
fix: churner (#157)
0x0aa0 Jan 30, 2024
cc086d3
fix: submodule (#164)
0x0aa0 Jan 30, 2024
1807458
test: fix flaky tests by removing bogosort (#163)
wadealexc Jan 31, 2024
6e51369
chore: storage gaps and nits (#155)
stevennevins Jan 31, 2024
4e41195
chore: eigenlayer-contracts (#168)
0x0aa0 Feb 1, 2024
32afa68
test/refactor: gas scenarios for updateOperators (#170)
8sunyuan Feb 6, 2024
69396da
fix: updated core contracts
8sunyuan Feb 7, 2024
95afcfb
Merge branch 'm2-mainnet-fixes' into updated-certora-rules
8sunyuan Feb 7, 2024
983a4cd
fix: build
8sunyuan Feb 7, 2024
695f8f1
test: certora config
8sunyuan Feb 12, 2024
fdee9f2
fix: slight modifications
8sunyuan Feb 14, 2024
5ae5b3e
test: current changes
8sunyuan Feb 21, 2024
af8a09f
test: certora specs
8sunyuan Mar 8, 2024
15327c8
Ghost summaries for BitmapUtils and cleanup (#207)
teryanarmen Mar 15, 2024
d36225a
test: setup.spec
8sunyuan Mar 18, 2024
3d27b5f
test: verified oneIdPerOperator
8sunyuan Mar 29, 2024
9959d57
fix: invariant progress
8sunyuan Apr 1, 2024
9a29513
test: registeredOperatorsHaveNonzeroBitmaps
8sunyuan Apr 5, 2024
0b4258d
test: progress
8sunyuan Apr 15, 2024
d566cd6
fix: registeredOperatorsHaveNonzeroBitmaps verified
8sunyuan Apr 18, 2024
66071b6
chore: cleanup
8sunyuan Apr 18, 2024
cd24190
Merge branch 'dev' into updated-certora-rules
8sunyuan Apr 18, 2024
784a363
chore: certora cleanup
8sunyuan Apr 18, 2024
f1008f7
fix: remove registered status check
8sunyuan Apr 18, 2024
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
63 changes: 63 additions & 0 deletions .github/workflows/certora-prover.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Certora Prover

on:
push:
branches:
- master
- release-v*
- formal-verification
pull_request: {}
workflow_dispatch: {}

jobs:
list-scripts:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v2
- id: set-matrix
run: echo ::set-output name=matrix::$(ls certora/scripts/*.sh | grep -v '\WnoCI\W' | jq -Rsc 'split("\n")[:-1]')
verify:
runs-on: ubuntu-latest
needs: list-scripts
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: Install forge dependencies
run: forge install
- name: Install python
uses: actions/setup-python@v2
with:
python-version: '3.10'
cache: 'pip'
- name: Install java
uses: actions/setup-java@v2
with:
distribution: temurin
java-version: '17'
- name: Install certora
run: pip install certora-cli
- name: Install solc
run: |
wget https://github.com/ethereum/solidity/releases/download/v0.8.12/solc-static-linux
sudo mv solc-static-linux /usr/local/bin/solc
chmod +x /usr/local/bin/solc
- name: Verify rule ${{ matrix.params }}
run: |
touch certora/applyHarness.patch
make -C certora munged
bash ${{ matrix.params }}
env:
CERTORAKEY: ${{ secrets.CERTORAKEY }}

strategy:
fail-fast: false
max-parallel: 4
matrix:
params: ${{ fromJson(needs.list-scripts.outputs.matrix) }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@ node_modules/
# Dotenv file
.env

# Certora Outputs
.certora_internal/
.certora_recent_jobs.json

*.DS_Store
31 changes: 31 additions & 0 deletions certora/config/setup.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"files": [
"certora/harnesses/RegistryCoordinatorHarness.sol",
"certora/harnesses/StakeRegistryHarness.sol",
"certora/harnesses/BLSApkRegistryHarness.sol",
"certora/harnesses/IndexRegistryHarness.sol",
"lib/openzeppelin-contracts/contracts/mocks/ERC1271WalletMock.sol",
"test/mocks/ServiceManagerMock.sol",
"lib/eigenlayer-contracts/src/contracts/core/Slasher.sol",
"lib/eigenlayer-contracts/src/contracts/core/AVSDirectory.sol"
],
"verify": "RegistryCoordinatorHarness:certora/specs/setup.spec",
"loop_iter": "2",
"parametric_contracts": ["RegistryCoordinatorHarness"],
"packages": [
"@openzeppelin=lib/openzeppelin-contracts",
"@openzeppelin-upgrades=lib/openzeppelin-contracts-upgradeable",
"eigenlayer-contracts=lib/eigenlayer-contracts"
],
"link": [
"RegistryCoordinatorHarness:serviceManager=ServiceManagerMock",
"ServiceManagerMock:_avsDirectory=AVSDirectory",
"RegistryCoordinatorHarness:blsApkRegistry=BLSApkRegistryHarness",
"RegistryCoordinatorHarness:indexRegistry=IndexRegistryHarness",
"RegistryCoordinatorHarness:stakeRegistry=StakeRegistryHarness"
],
"optimistic_fallback": true,
"optimistic_loop": true,
"optimistic_hashing": true,
"rule_sanity": "basic"
}
14 changes: 14 additions & 0 deletions certora/harnesses/BLSApkRegistryHarness.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity =0.8.12;

import "src/BLSApkRegistry.sol";

contract BLSApkRegistryHarness is BLSApkRegistry {
constructor(
IRegistryCoordinator _registryCoordinator
) BLSApkRegistry(_registryCoordinator) {}

function getApkHistory(uint8 quorumNumber) public view returns (ApkUpdate[] memory) {
return apkHistory[quorumNumber];
}
}
18 changes: 18 additions & 0 deletions certora/harnesses/IndexRegistryHarness.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity =0.8.12;

import "src/IndexRegistry.sol";

contract IndexRegistryHarness is IndexRegistry {
constructor(
IRegistryCoordinator _registryCoordinator
) IndexRegistry(_registryCoordinator) {}

function operatorIndexHistory(uint8 quorumNumber, uint32 operatorIndex) public view returns (OperatorUpdate[] memory) {
return _operatorIndexHistory[quorumNumber][operatorIndex];
}

function operatorCountHistory(uint8 quorumNumber) public view returns (QuorumUpdate[] memory) {
return _operatorCountHistory[quorumNumber];
}
}
59 changes: 59 additions & 0 deletions certora/harnesses/RegistryCoordinatorHarness.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity =0.8.12;

import "src/RegistryCoordinator.sol";

contract RegistryCoordinatorHarness is RegistryCoordinator {
constructor(
IServiceManager _serviceManager,
IStakeRegistry _stakeRegistry,
IBLSApkRegistry _blsApkRegistry,
IIndexRegistry _indexRegistry
) RegistryCoordinator(_serviceManager, _stakeRegistry, _blsApkRegistry, _indexRegistry) {}

// @notice function based upon `BitmapUtils.bytesArrayToBitmap`, used to determine if an array contains any duplicates
function bytesArrayContainsDuplicates(bytes memory bytesArray) public pure returns (bool) {
// sanity-check on input. a too-long input would fail later on due to having duplicate entry(s)
if (bytesArray.length > 256) {
return false;
}

// initialize the empty bitmap, to be built inside the loop
uint256 bitmap;
// initialize an empty uint256 to be used as a bitmask inside the loop
uint256 bitMask;

// loop through each byte in the array to construct the bitmap
for (uint256 i = 0; i < bytesArray.length; ++i) {
// construct a single-bit mask from the numerical value of the next byte out of the array
bitMask = uint256(1 << uint8(bytesArray[i]));
// check that the entry is not a repeat
if (bitmap & bitMask != 0) {
return false;
}
// add the entry to the bitmap
bitmap = (bitmap | bitMask);
}

// if the loop is completed without returning early, then the array contains no duplicates
return true;
}

// @notice verifies that a bytes array is a (non-strict) subset of a bitmap
function bytesArrayIsSubsetOfBitmap(uint256 referenceBitmap, bytes memory arrayWhichShouldBeASubsetOfTheReference) public pure returns (bool) {
uint256 arrayWhichShouldBeASubsetOfTheReferenceBitmap = BitmapUtils.orderedBytesArrayToBitmap(arrayWhichShouldBeASubsetOfTheReference);
if (referenceBitmap | arrayWhichShouldBeASubsetOfTheReferenceBitmap == referenceBitmap) {
return true;
} else {
return false;
}
}

function quorumInBitmap(uint256 bitmap, uint8 numberToCheckForInclusion) public pure returns (bool) {
return BitmapUtils.isSet(bitmap, numberToCheckForInclusion);
}

function hashToG1Harness(bytes32 x) public pure returns (BN254.G1Point memory) {
return BN254.G1Point(uint256(keccak256(abi.encodePacked(x))), 2);
}
}
15 changes: 15 additions & 0 deletions certora/harnesses/StakeRegistryHarness.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity =0.8.12;

import "src/StakeRegistry.sol";

contract StakeRegistryHarness is StakeRegistry {
constructor(
IRegistryCoordinator _registryCoordinator,
IDelegationManager _delegationManager
) StakeRegistry(_registryCoordinator, _delegationManager) {}

function totalStakeHistory(uint8 quorumNumber) public view returns (StakeUpdate[] memory) {
return _totalStakeHistory[quorumNumber];
}
}
Loading
Loading