Skip to content

Commit

Permalink
Merge pull request #1125 from TempleDAO/stage
Browse files Browse the repository at this point in the history
feat: epoch-26b (#1124)
  • Loading branch information
frontier159 authored Nov 28, 2024
2 parents 09e8276 + f42b59b commit b83f180
Show file tree
Hide file tree
Showing 178 changed files with 55,251 additions and 24,890 deletions.
159 changes: 159 additions & 0 deletions .github/workflows/protocol-deep-invarianats.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
name: Protocol Deep Invariant Tests
on:
schedule:
- cron: "0 8 * * 0" # at 8:00pm UTC every Sunday
workflow_dispatch:
inputs:
invariantRuns:
default: "5000"
description: "Invariant runs: number of sequences of function calls generated and run."
required: false
invariantDepth:
default: "90"
description: "Invariant depth: number of function calls made in a given run."
required: false

jobs:
build:
name: Build Contracts
runs-on: ${{ matrix.os }}
permissions:
# required for all workflows
security-events: write
# only required for workflows in private repositories
actions: read
contents: read
strategy:
matrix:
os:
- ubuntu-latest
node_version:
- 20
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive

- name: Use Node.js ${{ matrix.node_version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node_version }}
cache: 'yarn'
cache-dependency-path: apps/protocol/yarn.lock

- name: Install yarn project
run: yarn install
working-directory: protocol

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly

- name: Show the Foundry CI config
run: forge config
env:
FOUNDRY_PROFILE: ci

- name: Show the Foundry version
run: forge --version
working-directory: protocol

- name: "Forge Build"
run: "forge build"
working-directory: protocol
env:
FOUNDRY_PROFILE: ci

- name: Increase swapfile
run: |
sudo swapoff -a
sudo fallocate -l 15G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo swapon --show
- name: "Cache the build and the node modules so that they can be re-used by the other jobs"
uses: "actions/cache/save@v3"
with:
key: "build-and-modules-${{ github.sha }}"
path: |
protocol/node_modules
protocol/cache-foundry
protocol/artifacts-foundry
- name: "Store the contract artifacts in CI"
uses: "actions/upload-artifact@v4"
with:
name: "contract-artifacts"
path: "protocol/artifacts-foundry"

- name: "Add build summary"
run: |
echo "## Build result" >> $GITHUB_STEP_SUMMARY
echo "✅ Passed" >> $GITHUB_STEP_SUMMARY
foundry-test-invariant:
name: Foundry Invariant Tests
needs: ["build"]
runs-on: ${{ matrix.os }}
permissions:
# required for all workflows
security-events: write
# only required for workflows in private repositories
actions: read
contents: read
strategy:
matrix:
os:
- ubuntu-latest
node_version:
- 20
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive

- name: Use Node.js ${{ matrix.node_version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node_version }}
cache: 'yarn'
cache-dependency-path: protocol/yarn.lock

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: "Restore the cached build and the node modules"
uses: "actions/cache/restore@v3"
with:
fail-on-cache-miss: true
key: "build-and-modules-${{ github.sha }}"
path: |
protocol/node_modules
protocol/cache-foundry
protocol/artifacts-foundry
- name: "Generate fuzz seed"
run: echo "FOUNDRY_FUZZ_SEED=$EPOCHSECONDS" >> $GITHUB_ENV

- name: "Log fuzz seed"
run: echo "FOUNDRY_FUZZ_SEED=$FOUNDRY_FUZZ_SEED"

- name: Foundry invariant tests
run: "forge test --match-path \"test/foundry/invariant/**/*.sol\""
working-directory: protocol
env:
FOUNDRY_PROFILE: ci
FOUNDRY_INVARIANT_DEPTH: ${{ inputs.invariantDepth || '90' }}
FOUNDRY_INVARIANT_RUNS: ${{ inputs.invariantRuns || '5000' }}
MAINNET_RPC_URL: ${{ secrets.TESTS_MAINNET_RPC_URL }}
POLYGON_RPC_URL: ${{ secrets.TESTS_POLYGON_RPC_URL }}

- name: "Add test summary"
run: |
echo "## Deep Invariant tests result" >> $GITHUB_STEP_SUMMARY
echo "✅ Passed" >> $GITHUB_STEP_SUMMARY
66 changes: 64 additions & 2 deletions .github/workflows/protocol-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ jobs:
working-directory: protocol
env:
TESTS_MAINNET_RPC_URL: ${{ secrets.TESTS_MAINNET_RPC_URL }}
ARBITRUM_ONE_RPC_URL: ${{ secrets.TESTS_ARBITRUM_ONE_RPC_URL }}

foundryTests:
name: Foundry Tests
Expand Down Expand Up @@ -100,12 +101,73 @@ jobs:
run: forge --version
working-directory: protocol

- name: Foundry tests
run: forge test --gas-report
- name: Foundry unit tests
run: forge test --match-path "test/forge/unit/**/*.t.sol"
working-directory: protocol
env:
FOUNDRY_PROFILE: ci
MAINNET_RPC_URL: ${{ secrets.TESTS_MAINNET_RPC_URL }}
ARBITRUM_ONE_RPC_URL: ${{ secrets.TESTS_ARBITRUM_ONE_RPC_URL }}

foundryInvariantTests:
name: Foundry Invariant Tests
runs-on: ${{ matrix.os }}
permissions:
# required for all workflows
security-events: write
# only required for workflows in private repositories
actions: read
contents: read
strategy:
matrix:
os:
- ubuntu-latest
node_version:
- 20

steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive

- name: Use Node.js ${{ matrix.node_version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node_version }}
cache: 'yarn'
cache-dependency-path: protocol/yarn.lock

- name: Install yarn project
run: yarn install
working-directory: protocol

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
# version: nightly-ca67d15f4abd46394b324c50e21e66f306a1162d
cache: true

- name: Show the Foundry CI config
run: forge config
env:
FOUNDRY_PROFILE: ci

- name: Show the Foundry version
run: forge --version
working-directory: protocol

- name: Foundry invariant tests
run: forge test --match-path "test/forge/invariant/**/*.sol"
working-directory: protocol
env:
FOUNDRY_PROFILE: ci
FOUNDRY_INVARIANT_RUNS: 150 # Defer larger runs for another pipeline
FOUNDRY_INVARIANT_DEPTH: 80
MAINNET_RPC_URL: ${{ secrets.TESTS_MAINNET_RPC_URL }}
ARBITRUM_ONE_RPC_URL: ${{ secrets.TESTS_ARBITRUM_ONE_RPC_URL }}


slither:
name: Slither
Expand Down
4 changes: 4 additions & 0 deletions apps/dapp/src/constants/env/production.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@ const env: Environment = {
name: 'Epoch 26a',
address: '0xf78d757da74d5f3a67599240eab918FC347f2BdE',
},
{
name: 'Epoch 26b',
address: '0xa493DaEeEb5BaDf74fdB872555090A7850ac49f0',
},
],
temple: '0x470ebf5f030ed85fc1ed4c2d36b9dd02e77cf1b7',
templeStaking: '0x4D14b24EDb751221B3Ff08BBB8bd91D4b1c8bc77',
Expand Down
5 changes: 4 additions & 1 deletion protocol/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,7 @@ lcov.info
report

# autogenerated fork args
scripts/deploys/localhost/deploymentArgs
scripts/deploys/localhost/deploymentArgs

# templegold scripts
test/forge/templegold/scripts/
2 changes: 1 addition & 1 deletion protocol/contracts/amo/AuraStaking.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.8.20;
pragma solidity ^0.8.20;
// SPDX-License-Identifier: AGPL-3.0-or-later
// Temple (amo/AuraStaking.sol)

Expand Down
2 changes: 1 addition & 1 deletion protocol/contracts/amo/Ramos.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.8.20;
pragma solidity ^0.8.20;
// SPDX-License-Identifier: AGPL-3.0-or-later
// Temple (amo/Ramos.sol)

Expand Down
3 changes: 1 addition & 2 deletions protocol/contracts/common/CommonEventsAndErrors.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.8.20;
pragma solidity ^0.8.20;
// SPDX-License-Identifier: AGPL-3.0-or-later
// Temple (common/CommonEventsAndErrors.sol)

Expand All @@ -12,5 +12,4 @@ library CommonEventsAndErrors {
error ExpectedNonZero();
error Unimplemented();
event TokenRecovered(address indexed to, address indexed token, uint256 amount);
error AccountBlacklisted(address account);
}
2 changes: 1 addition & 1 deletion protocol/contracts/common/SafeCast.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.8.20;
pragma solidity ^0.8.20;
// SPDX-License-Identifier: AGPL-3.0-or-later
// Temple (common/SafeCast.sol)

Expand Down
16 changes: 16 additions & 0 deletions protocol/contracts/common/TempleMath.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
pragma solidity ^0.8.20;
// SPDX-License-Identifier: AGPL-3.0-or-later
// Temple (common/TempleMath.sol)

import { mulDiv } from "@prb/math/src/Common.sol";

library TempleMath {
/// @notice mulDiv with an option to round the result up or down to the nearest wei
function mulDivRound(uint256 x, uint256 y, uint256 denominator, bool roundUp) internal pure returns (uint256 result) {
result = mulDiv(x, y, denominator);
// See OZ Math.sol for the equivalent mulDiv() with rounding.
if (roundUp && mulmod(x, y, denominator) > 0) {
result += 1;
}
}
}
Loading

0 comments on commit b83f180

Please sign in to comment.