Skip to content

Commit dbdfca2

Browse files
LUM-1117, LUM-1118: Implement Job fees mechanism (#23)
* update .gitignore for repomix * connect stakeManager and JobsManager to use proxy addresses * Update deployment script * differentiate roles from single admin role * nit: spacing * Add github actions config for the repo * Update .gitignore * add prettier config; package contract in yarn * run CI on PR * rename the repo secret * Update Constants.sol * fix testcases for jobs and stake manager * keep version to prevent warning and build error * Update solidity version * add slither report to .gitignore * run forge build before running slither checks * Add deployment to the pipeline * add remappings for correctly using imports * Update imports to not use relative path * Update imports to not use relative path * Update gitmodules and method for dependency installation * remove default module * fix testcases that were broken * Add gas snapshot; update config * don't exit procses on snapshot * remove codecov app * remove --use solc; update .gitignore * fix indent * remove debug flag * nit: stlye * remove codecov app * Add remappings.txt * Update upgradable contracts version * remove remappings forge * reinitialize mappings * remove uploading sarif file * remove lib from git repo * add lib to repo * reset readme * remove initial files
1 parent 392da46 commit dbdfca2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+399
-26213
lines changed

.gas-snapshot

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
JobsManagerTest:testCreateJob() (gas: 197562)
2+
JobsManagerTest:testCreateMultipleJobs() (gas: 789598)
3+
JobsManagerTest:testGetActiveJobs() (gas: 484465)
4+
JobsManagerTest:testInitialization() (gas: 20413)
5+
JobsManagerTest:testJobDetailsRetrieval() (gas: 195057)
6+
JobsManagerTest:testNonExistentJobDetails() (gas: 14082)
7+
JobsManagerTest:testUpdateJobStatus() (gas: 401370)
8+
JobsManagerTest:testUpdateJobStatusInvalidTransition() (gas: 324846)
9+
JobsManagerTest:testUpdateJobStatusUnauthorized() (gas: 191908)
10+
JobsManagerTest:testUpdateNonExistentJob() (gas: 14142)
11+
StakeManagerTest:testInitialization() (gas: 17084)
12+
StakeManagerTest:testStake() (gas: 147646)
13+
StakeManagerTest:testStakeInsufficientAmount() (gas: 22857)
14+
StakeManagerTest:testUnstake() (gas: 191933)
15+
StakeManagerTest:testWithdraw() (gas: 163469)
16+
StakeManagerTest:testWithdrawBeforeUnlock() (gas: 190212)
17+
StateManagerTest:testBufferState() (gas: 9526)
18+
StateManagerTest:testCommitState() (gas: 9998)
19+
StateManagerTest:testNonBufferState() (gas: 9894)
20+
StateManagerTest:testProposeState() (gas: 10306)
21+
StateManagerTest:testRevealState() (gas: 10203)

.github/codecov.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
codecov:
2+
require_ci_to_pass: yes
3+
notify:
4+
wait_for_ci: yes
5+
6+
coverage:
7+
precision: 2
8+
round: down
9+
range: "70...100"
10+
status:
11+
project:
12+
default:
13+
target: 80% # minimum coverage ratio
14+
threshold: 1% # allow coverage to drop by 1% and still succeed
15+
patch:
16+
default:
17+
target: 80%
18+
threshold: 1%
19+
changes: no
20+
21+
parsers:
22+
gcov:
23+
branch_detection:
24+
conditional: yes
25+
loop: yes
26+
method: no
27+
macro: no
28+
29+
comment:
30+
layout: "reach,diff,flags,files,footer"
31+
behavior: default
32+
require_changes: no

.github/workflows/test.yml

Lines changed: 145 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,28 @@
1-
name: test
1+
name: Lumino Protocol CI/CD
22

3-
on: workflow_dispatch
3+
on:
4+
pull_request:
5+
branches:
6+
- "**"
7+
- '!main'
8+
workflow_dispatch:
9+
inputs:
10+
environment:
11+
description: 'Environment to deploy to'
12+
required: true
13+
default: 'testnet'
14+
type: choice
15+
options:
16+
- testnet
417

518
env:
619
FOUNDRY_PROFILE: ci
20+
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
21+
ETHERSCAN_API_KEY: ${{ secrets.ETHERSCAN_API_KEY }}
22+
TESTNET_RPC_URL: ${{ secrets.TESTNET_RPC_URL }}
723

824
jobs:
9-
check:
10-
strategy:
11-
fail-fast: true
12-
25+
unit-tests:
1326
name: Foundry project
1427
runs-on: ubuntu-latest
1528
steps:
@@ -22,13 +35,134 @@ jobs:
2235
with:
2336
version: nightly
2437

25-
- name: Run Forge build
38+
- name: Install Dependencies
2639
run: |
27-
forge --version
28-
forge build --sizes
40+
forge install OpenZeppelin/openzeppelin-contracts --no-commit
41+
forge install OpenZeppelin/openzeppelin-contracts-upgradeable --no-commit
42+
43+
- name: Check contract sizes
44+
run: forge build --sizes
2945
id: build
3046

31-
- name: Run Forge tests
47+
- name: Check gas snapshots
3248
run: |
33-
forge test -vvv
49+
forge snapshot --check || (
50+
echo "Gas snapshot check failed. Generating new snapshot for reference..."
51+
forge snapshot
52+
echo "Please commit the updated .gas-snapshot file"
53+
)
54+
id: snapshot
55+
56+
- name: Run tests
57+
run: forge test -vvv
3458
id: test
59+
60+
- name: Run coverage
61+
run: forge coverage --report lcov --report summary
62+
--report debug
63+
--optimize
64+
--optimizer-runs 200
65+
--no-auto-detect
66+
id: coverage
67+
68+
# - name: Upload coverage to Codecov
69+
# uses: codecov/codecov-action@v3
70+
# with:
71+
# token: ${{ secrets.CODECOV_TOKEN }}
72+
# files: ./lcov.info
73+
# fail_ci_if_error: true
74+
# verbose: true
75+
76+
slither:
77+
name: Slither Analysis
78+
runs-on: ubuntu-latest
79+
steps:
80+
- uses: actions/checkout@v4
81+
with:
82+
submodules: recursive
83+
84+
- name: Install Foundry
85+
uses: foundry-rs/foundry-toolchain@v1
86+
with:
87+
version: nightly
88+
89+
- name: Install Python
90+
uses: actions/setup-python@v4
91+
with:
92+
python-version: '3.10'
93+
94+
- name: Install Slither
95+
run: |
96+
python -m pip install --upgrade pip
97+
pip3 install slither-analyzer
98+
99+
- name: Run Slither
100+
run: |
101+
forge build
102+
slither . --sarif slither-results.sarif || true
103+
104+
# - name: Upload SARIF file
105+
# uses: github/codeql-action/upload-sarif@v2
106+
# with:
107+
# sarif_file: slither-results.sarif
108+
# token: ${{ secrets.GITHUB_TOKEN }}
109+
110+
lint:
111+
name: Format Check
112+
runs-on: ubuntu-latest
113+
steps:
114+
- uses: actions/checkout@v4
115+
with:
116+
submodules: recursive
117+
118+
- name: Install Foundry
119+
uses: foundry-rs/foundry-toolchain@v1
120+
with:
121+
version: nightly
122+
123+
- name: Install Node.js
124+
uses: actions/setup-node@v3
125+
with:
126+
node-version: 18.x
127+
128+
- name: Install Prettier and Solidity Plugin
129+
run: |
130+
npm install --save-dev prettier prettier-plugin-solidity
131+
132+
- name: Check formatting
133+
run: npx prettier --check "src/**/*.sol" "test/**/*.sol"
134+
135+
deploy-testnet:
136+
name: Deploy to Testnet
137+
needs: [unit-tests, slither, lint]
138+
if: |
139+
(github.ref == 'refs/heads/develop' && github.event_name == 'push') ||
140+
(github.event_name == 'workflow_dispatch' && github.event.inputs.environment == 'testnet')
141+
runs-on: ubuntu-latest
142+
environment: testnet
143+
steps:
144+
- uses: actions/checkout@v4
145+
with:
146+
submodules: recursive
147+
148+
- name: Install Foundry
149+
uses: foundry-rs/foundry-toolchain@v1
150+
with:
151+
version: nightly
152+
153+
- name: Deploy to Testnet
154+
env:
155+
RPC_URL: ${{ env.TESTNET_RPC_URL }}
156+
run: |
157+
forge script script/DeployUpgradeableLuminoProtocol.s.sol:DeployUpgradeableLuminoProtocol \
158+
--rpc-url $RPC_URL \
159+
--broadcast \
160+
--verify \
161+
-vvvv
162+
163+
- name: Save deployment artifacts
164+
uses: actions/upload-artifact@v3
165+
with:
166+
name: testnet-deployment
167+
path: broadcast/
168+
if-no-files-found: error

.gitignore

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ docs/
1414
.env
1515

1616
.vscode
17-
/lib/*
1817
.idea
1918

20-
repopack-output.txt
19+
slither-results.sarif
20+
21+
node_modules
22+
lcov.info
23+
24+
repomix-output.txt

.gitmodules

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
[submodule "contracts/lib/forge-std"]
2-
path = contracts/lib/forge-std
1+
[submodule "lib/forge-std"]
2+
path = lib/forge-std
33
url = https://github.com/foundry-rs/forge-std
4-
[submodule "lib/openzeppelin-contracts"]
5-
path = lib/openzeppelin-contracts
6-
url = https://github.com/OpenZeppelin/openzeppelin-contracts
74
[submodule "lib/openzeppelin-contracts-upgradeable"]
85
path = lib/openzeppelin-contracts-upgradeable
96
url = https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable
7+
[submodule "lib/openzeppelin-contracts"]
8+
path = lib/openzeppelin-contracts
9+
url = https://github.com/OpenZeppelin/openzeppelin-contracts

.prettierrc

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"overrides": [
3+
{
4+
"files": "*.sol",
5+
"options": {
6+
"printWidth": 100,
7+
"tabWidth": 4,
8+
"useTabs": false,
9+
"singleQuote": false,
10+
"bracketSpacing": false
11+
}
12+
}
13+
],
14+
"printWidth": 100,
15+
"tabWidth": 2,
16+
"useTabs": false,
17+
"semi": true,
18+
"singleQuote": false,
19+
"trailingComma": "es5"
20+
}

foundry.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,17 @@ src = "src"
33
out = "out"
44
libs = ["lib"]
55

6+
[profile.default.fuzz]
7+
runs = 1000
8+
9+
[profile.ci]
10+
fuzz_runs = 10000
11+
verbosity = 4
12+
13+
[profile.gas]
14+
gas_reports = ["*"]
15+
16+
617
[etherscan]
718
holesky = { key = "<your-etherscan-api-key>", url = "https://api-holesky.etherscan.io/api" }
819

lib/forge-std

Submodule forge-std added at b93cf4b

lib/forge-std/.gitattributes

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)