Skip to content
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

test: payments spec #564

Open
wants to merge 12 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/cache
60 changes: 60 additions & 0 deletions .github/workflows/certora-prover-conf.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Certora Prover

on:
push:
branches:
- dev
- payments-spec
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/config/*.conf | 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: |
certoraRun ${{ matrix.params }}
env:
CERTORAKEY: ${{ secrets.CERTORAKEY }}

strategy:
fail-fast: false
max-parallel: 4
matrix:
params: ${{ fromJson(needs.list-scripts.outputs.matrix) }}
17 changes: 2 additions & 15 deletions .github/workflows/check-compilation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,6 @@ jobs:
- name: Build and validate
if: github.event_name == 'push'
run: |
sudo apt-get update
sudo apt-get install -y make curl git software-properties-common jq
sudo add-apt-repository -y ppa:longsleep/golang-backports
sudo apt-get update
sudo apt-get install -y golang-1.22
sudo update-alternatives --install /usr/local/bin/go go /usr/lib/go-1.22/bin/go 1
mkdir ~/.go
export GOPATH=~/.go
export PATH=$PATH:~/.go/bin
go install github.com/ethereum/go-ethereum/cmd/[email protected]
curl -L https://foundry.paradigm.xyz | bash
export PATH=$PATH:/home/runner/.config/.foundry/bin
source ~/.bashrc
foundryup
make bindings
make docker
docker run -v `pwd`:/build -w /build --rm -i eigenlayer-contracts:latest bash -c "make gha"
if [ ! -z "$(git status --porcelain)" ]; then git diff; git status; exit 1; fi
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM ubuntu:22.04

RUN apt-get update \
&& apt-get install -y make curl git software-properties-common jq \
&& add-apt-repository -y ppa:longsleep/golang-backports \
&& add-apt-repository -y ppa:ethereum/ethereum \
&& apt-get update \
&& apt-get install -y golang-1.22 ethereum \
&& curl -L https://foundry.paradigm.xyz | bash \
&& /root/.foundry/bin/foundryup

RUN cp -R /root/.foundry/bin/* /usr/local/bin/

41 changes: 34 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,46 @@

CONTAINER_NAME = eigenlayer-contracts

.PHONY: install-hooks
install-hooks:
cp scripts/pre-commit.sh .git/hooks/pre-commit
cp bin/pre-commit.sh .git/hooks/pre-commit

.PHONY: deps
deps: install-hooks
brew install libusb
go install github.com/ethereum/go-ethereum/cmd/abigen@latest
curl -L https://foundry.paradigm.xyz | bash
.PHONY: install-deps
install-deps:
./bin/install-deps.sh
foundryup

.PHONY: deps
deps: install-hooks install-deps

.PHONY: compile
compile:
forge b

.PHONY: bindings
bindings: compile
./scripts/compile-bindings.sh
./bin/compile-bindings.sh

.PHONY: all
all: compile bindings

gha:
git config --global --add safe.directory "*"
forge install
forge b
./bin/compile-bindings.sh

docker:
docker build --progress=plain -t ${CONTAINER_NAME}:latest .

compile-in-docker:
docker run -v $(PWD):/build -w /build --rm -it ${CONTAINER_NAME}:latest bash -c "make compile"

bindings-in-docker:
docker run -v $(PWD):/build -w /build --rm -it ${CONTAINER_NAME}:latest bash -c "make bindings"

all-in-docker:
docker run -v $(PWD):/build -w /build --rm -it ${CONTAINER_NAME}:latest bash -c "make all"

gha-docker:
docker run -v $(PWD):/build -w /build --rm -i ${CONTAINER_NAME}:latest bash -c "make gha"
27 changes: 13 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,6 @@ The main branches we use are:

## Documentation

### Setup

To set up this repo for the first time, run:

```bash
make deps
```

This will:
* Install the pre-commit hook
* Install foundry and its tools
* Install abigen

### Basics

To get a basic understanding of EigenLayer, check out [You Could've Invented EigenLayer](https://www.blog.eigenlayer.xyz/ycie/). Note that some of the document's content describes features that do not exist yet (like the Slasher). To understand more about how restakers and operators interact with EigenLayer, check out these guides:
Expand All @@ -54,10 +41,21 @@ foundryup

forge build
forge test
```

make bindings
### Contributor Setup

To set up this repo for the first time, run:

```bash
make deps
```

This will:
* Install the pre-commit hook
* Install foundry and its tools
* Install abigen

### Running Fork Tests

We have a few fork tests against ETH mainnet. Passing these requires the environment variable `RPC_MAINNET` to be set. See `.env.example` for an example. Once you've set up your environment, `forge test` should show these fork tests passing.
Expand Down Expand Up @@ -158,6 +156,7 @@ The current mainnet deployment is our M2 release. You can view the deployed cont
| -------- | -------- | -------- | -------- |
| [`Eigen`](https://github.com/Layr-Labs/eigenlayer-contracts/blob/mainnet/src/contracts/token/Eigen.sol) | [`0xec53bf9167f50cdeb3ae105f56099aaab9061f83`](https://etherscan.io/address/0xec53bf9167f50cdeb3ae105f56099aaab9061f83) | [`0x7ec3...700b`](https://etherscan.io/address/0x7ec354c84680112d3cff1544ec1eb19ca583700b) | Proxy: [`[email protected]`](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.9.0/contracts/proxy/transparent/TransparentUpgradeableProxy.sol) |
| [`Backing Eigen`](https://github.com/Layr-Labs/eigenlayer-contracts/blob/mainnet/src/contracts/token/BackingEigen.sol) | [`0x83E9115d334D248Ce39a6f36144aEaB5b3456e75`](https://etherscan.io/address/0x83E9115d334D248Ce39a6f36144aEaB5b3456e75) | [`0xB91c...FFE3`](https://etherscan.io/address/0xB91c69Af3eE022bd0a59Da082945914BFDcEFFE3) | Proxy: [`[email protected]`](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.9.0/contracts/proxy/transparent/TransparentUpgradeableProxy.sol) |
| [`SignedDistributor`](https://etherscan.io/address/0x035bdAeaB85E47710C27EdA7FD754bA80aD4ad02#code) | - | [`0x035b...ad02`](https://etherscan.io/address/0x035bdAeaB85E47710C27EdA7FD754bA80aD4ad02) | - |

###### Multisigs

Expand Down
10 changes: 9 additions & 1 deletion scripts/compile-bindings.sh → bin/compile-bindings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,15 @@ function create_binding {
--bin=$binding_out_dir/tmp.bin \
--abi=$binding_out_dir/tmp.abi \
--pkg="${contract_name}" \
--out=$BINDING_DIR/$contract_name/binding.go
--out=$BINDING_DIR/$contract_name/binding.go \
> /dev/null 2>&1

if [[ $? == "1" ]];
then
echo "Failed to generate binding for $contract_json_path"
fi
rm $binding_out_dir/tmp.abi
rm $binding_out_dir/tmp.bin
}

contracts=$(find src/contracts -type f -name "*.sol" )
Expand Down
19 changes: 19 additions & 0 deletions bin/install-deps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

OS=$(uname -s | tr '[:upper:]' '[:lower:]')

if [[ "$OS" == "linux" ]]; then
sudo apt-get update
sudo apt-get install -y make curl git software-properties-common jq
sudo add-apt-repository -y ppa:ethereum/ethereum
sudo apt-get update
sudo apt-get install abigen
curl -L https://foundry.paradigm.xyz | bash
elif [[ "$OS" == "darwin" ]]; then
brew tap ethereum/ethereum
brew install libusb ethereum
curl -L https://foundry.paradigm.xyz | bash
else
echo "Unsupported OS: $OS"
exit 1
fi
File renamed without changes.
28 changes: 28 additions & 0 deletions certora/config/paymentCoordinator.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"files": [
"lib/openzeppelin-contracts/contracts/token/ERC20/ERC20.sol",
"lib/openzeppelin-contracts/contracts/token/ERC20/presets/ERC20PresetFixedSupply.sol",
"certora/harnesses/PaymentCoordinatorHarness.sol"
],
"verify": "PaymentCoordinatorHarness:certora/specs/core/PaymentCoordinator.spec",
"loop_iter": "2",
"parametric_contracts": ["PaymentCoordinatorHarness"],
"packages": [
"@openzeppelin=lib/openzeppelin-contracts",
"@openzeppelin-upgrades=lib/openzeppelin-contracts-upgradeable"
],
"link": [],
"optimistic_fallback": true,
"optimistic_loop": true,
"optimistic_hashing": true,
"rule_sanity": "basic",
"exclude_rule": ["checkClaimNeverFalse"],
"mutations": {
"gambit": [
{
"filename" : "src/contracts/core/PaymentCoordinator.sol",
"num_mutants": 20
}
],
}
}
26 changes: 26 additions & 0 deletions certora/config/paymentCoordinatorWithoutSanity.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"files": [
"lib/openzeppelin-contracts/contracts/token/ERC20/ERC20.sol",
"lib/openzeppelin-contracts/contracts/token/ERC20/presets/ERC20PresetFixedSupply.sol",
"certora/harnesses/PaymentCoordinatorHarness.sol"
],
"verify": "PaymentCoordinatorHarness:certora/specs/core/PaymentCoordinator.spec",
"loop_iter": "2",
"parametric_contracts": ["PaymentCoordinatorHarness"],
"packages": [
"@openzeppelin=lib/openzeppelin-contracts",
"@openzeppelin-upgrades=lib/openzeppelin-contracts-upgradeable"
],
"link": [],
"optimistic_fallback": true,
"optimistic_loop": true,
"optimistic_hashing": true,
"mutations": {
"gambit": [
{
"filename" : "src/contracts/core/PaymentCoordinator.sol",
"num_mutants": 20
}
],
}
}
24 changes: 24 additions & 0 deletions certora/harnesses/PaymentCoordinatorHarness.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.12;

import "../../src/contracts/core/PaymentCoordinator.sol";

contract PaymentCoordinatorHarness is PaymentCoordinator {
constructor(
IDelegationManager _delegationManager,
IStrategyManager _strategyManager,
uint32 _CALCULATION_INTERVAL_SECONDS,
uint32 _MAX_PAYMENT_DURATION,
uint32 _MAX_RETROACTIVE_LENGTH,
uint32 _MAX_FUTURE_LENGTH,
uint32 _GENESIS_PAYMENT_TIMESTAMP
) PaymentCoordinator(
_delegationManager,
_strategyManager,
_CALCULATION_INTERVAL_SECONDS,
_MAX_PAYMENT_DURATION,
_MAX_RETROACTIVE_LENGTH,
_MAX_FUTURE_LENGTH,
_GENESIS_PAYMENT_TIMESTAMP
) {}
}
Loading
Loading