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

Relayer: Implement prover rules #105

Merged
merged 4 commits into from
Oct 9, 2023
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
23 changes: 23 additions & 0 deletions .github/workflows/prover-relayer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Prover Relayer

env:
CI: true

on:
pull_request:
branches: "*"
paths:
- packages/relayer/**

jobs:
prove:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Prove
uses: ./.github/actions/certora
with:
workspace: '@mimic-fi/v3-relayer'
certora-key: ${{ secrets.CERTORA_KEY }}
github-token: ${{ secrets.GITHUB_TOKEN }}
26 changes: 26 additions & 0 deletions packages/relayer/certora/conf/relayer.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"files": [
"certora/harnesses/RelayerHarness.sol",
"certora/helpers/Helpers.sol",
"certora/helpers/Depositor.sol"
],
"verify": "RelayerHarness:certora/specs/Relayer.spec",
"loop_iter": "3",
"rule_sanity": "basic",
"send_only": true,
"optimistic_hashing": true,
"prover_args": [
"-copyLoopUnroll 8",
"-optimisticFallback true"
],
"optimistic_loop": true,
"packages": [
"@mimic-fi/v3-authorizer=../../node_modules/@mimic-fi/v3-authorizer",
"@mimic-fi/v3-smart-vault=../../node_modules/@mimic-fi/v3-smart-vault",
"@mimic-fi/v3-tasks=../../node_modules/@mimic-fi/v3-tasks",
"@openzeppelin=../../node_modules/@openzeppelin"
],
"solc_allow_path": ".",
"process": "emv",
"msg": "RelayerHarness"
}
15 changes: 15 additions & 0 deletions packages/relayer/certora/harnesses/RelayerHarness.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// SPDX-License-Identifier: GPL-3.0-or-later

pragma solidity ^0.8.17;

import '../../contracts/Relayer.sol';

contract RelayerHarness is Relayer {
constructor(address executor, address collector, address owner) Relayer(executor, collector, owner) {
// solhint-disable-previous-line no-empty-blocks
}

function payTransactionGasToRelayer(address smartVault, uint256 amount) external {
_payTransactionGasToRelayer(smartVault, amount);
}
}
9 changes: 9 additions & 0 deletions packages/relayer/certora/helpers/Depositor.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// SPDX-License-Identifier: GPL-3.0-or-later

pragma solidity ^0.8.0;

contract Depositor {
fallback() external payable {
// solhint-disable-previous-line no-empty-blocks
}
}
28 changes: 28 additions & 0 deletions packages/relayer/certora/helpers/Helpers.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// SPDX-License-Identifier: GPL-3.0-or-later

pragma solidity ^0.8.0;

import '@mimic-fi/v3-smart-vault/contracts/interfaces/ISmartVault.sol';
import '@mimic-fi/v3-tasks/contracts/interfaces/ITask.sol';

contract Helpers {
function balanceOf(address account) external view returns (uint256) {
return address(account).balance;
}

function areValidTasks(address[] memory tasks) external view returns (bool) {
if (tasks.length == 0) return false;

address smartVault = ITask(tasks[0]).smartVault();

for (uint256 i = 0; i < tasks.length; i++) {
address taskSmartVault = ITask(tasks[i]).smartVault();
if (taskSmartVault != smartVault) return false;

bool hasPermissions = ISmartVault(smartVault).hasPermissions(tasks[i]);
if (!hasPermissions) return false;
}

return true;
}
}
6 changes: 6 additions & 0 deletions packages/relayer/certora/specs/General.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
rule sanity(method f) good_description "Sanity" {
env e;
calldataarg args;
f(e, args);
assert false;
}
Loading
Loading