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: upgrade to foundry #76

Merged
merged 6 commits into from
Aug 27, 2024
Merged
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
44 changes: 24 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,34 @@ on:
- develop
- master
pull_request:
branches:
branches:
- develop
- master

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Update Path
run: echo "$RUNNER_WORKSPACE/$(basename $GITHUB_REPOSITORY)" >> $GITHUB_PATH # Make it accessible from runner
- name: Install solc
run: |
set -x
wget -c https://github.com/ethereum/solidity/releases/download/v0.5.17/solc-static-linux
mv solc-static-linux solc
chmod +x solc
solc --version
- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version: '16'
registry-url: 'https://registry.npmjs.org'
- name: Generate genesis file
run: bash generate.sh 15001 heimdall-15001
- name: Run tests
run: npm run test:ci
- uses: actions/checkout@v3
- name: Update Path
run: echo "$RUNNER_WORKSPACE/$(basename $GITHUB_REPOSITORY)" >> $GITHUB_PATH # Make it accessible from runner
- name: Install solc
run: |
set -x
wget -c https://github.com/ethereum/solidity/releases/download/v0.5.17/solc-static-linux
mv solc-static-linux solc
chmod +x solc
solc --version
- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version: '16'
registry-url: 'https://registry.npmjs.org'
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: Generate genesis file
run: bash generate.sh 15001 heimdall-15001
- name: Run tests
run: forge build && forge test -vvv
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,11 @@ logs
genesis.json

.idea

/out
/target
/cache
/coverage
lcov.info
.env
.password
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "matic-contracts"]
path = matic-contracts
url = https://github.com/maticnetwork/contracts.git
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
21 changes: 12 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
# genesis-contracts

> NOTE (IMPORTANT!)
> If you modify contracts, run `forge build` before testing/deploying/etc, or Foundry may not recompile them!

#### Setup genesis

Setup genesis whenever contracts get changed
### 1. Install dependencies and submodules
```bash
$ npm install
$ git submodule init
$ git submodule update
npm install
git submodule init
git submodule update
```

### 2. Compile Matic contracts
```bash
$ cd matic-contracts
$ npm install
$ node scripts/process-templates.js --bor-chain-id <bor-chain-id>
$ npm run truffle:compile
$ cd ..
cd matic-contracts
npm install
node scripts/process-templates.js --bor-chain-id <bor-chain-id>
npm run truffle:compile
cd ..
```

### 3. Generate Bor validator set sol file
Expand Down Expand Up @@ -44,7 +47,7 @@ Following command will generate `genesis.json` file from `genesis-template.json`

```bash
# Generate genesis file
$ node generate-genesis.js --bor-chain-id <bor-chain-id> --heimdall-chain-id <heimdall-chain-id>
node generate-genesis.js --bor-chain-id <bor-chain-id> --heimdall-chain-id <heimdall-chain-id>
```

### 7. Run Tests
Expand Down
45 changes: 45 additions & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
[profile.default]
src = "contracts"
out = "out"
libs = ["lib"]
optimizer = true
optimizer_runs = 999999
via_ir = true
verbosity = 2
ffi = true
fs_permissions = [{ access = "read", path = "./out/"}]

remappings = [
"forge-std=lib/forge-std/src",
"openzeppelin-solidity/=node_modules/openzeppelin-solidity/",
"solidity-rlp/=node_modules/solidity-rlp/"
]

[profile.intense.fuzz]
runs = 10000
max_test_rejects = 999999

[fmt]
line_length = 160
number_underscore = "thousands"

[rpc_endpoints]
anvil = "http://127.0.0.1:8545"
mainnet = "https://mainnet.infura.io/v3/${INFURA_KEY}"
goerli = "https://goerli.infura.io/v3/${INFURA_KEY}"
sepolia = "https://sepolia.infura.io/v3/${INFURA_KEY}"
polygon_pos = "https://polygon-mainnet.infura.io/v3/${INFURA_KEY}"
mumbai = "https://polygon-mumbai.infura.io/v3/${INFURA_KEY}"
polygon_zkevm = "https://zkevm-rpc.com"
polygon_zkevm_testnet = "https://rpc.public.zkevm-test.net"

[etherscan]
mainnet = { key = "${ETHERSCAN_API_KEY}" }
goerli = { key = "${ETHERSCAN_API_KEY}" }
sepolia = { key = "${ETHERSCAN_API_KEY}" }
polygon_pos = { key = "${POLYGONSCAN_API_KEY}" }
mumbai = { key = "${POLYGONSCAN_API_KEY}" }
polygon_zkevm = { key = "${POLYGONSCAN_ZKEVM_API_KEY}" }
polygon_zkevm_testnet = { key = "${POLYGONSCAN_ZKEVM_API_KEY}" }

# See more config options https://github.com/foundry-rs/foundry/tree/master/config
1 change: 1 addition & 0 deletions lib/forge-std
Submodule forge-std added at 978ac6
Loading
Loading