From 0fb3b150eb05f927134aa523bd4551dcf519376b Mon Sep 17 00:00:00 2001 From: Denis Kolegov Date: Thu, 15 Feb 2024 12:22:18 +0100 Subject: [PATCH] draft mythril cd --- .github/workflows/contracts-mythril.yaml | 0 contracts/Makefile | 4 +- .../handlers/GatewayActorFacade.sol | 59 +++++++++++++++++++ 3 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/contracts-mythril.yaml create mode 100644 contracts/test/invariants/handlers/GatewayActorFacade.sol diff --git a/.github/workflows/contracts-mythril.yaml b/.github/workflows/contracts-mythril.yaml new file mode 100644 index 000000000..e69de29bb diff --git a/contracts/Makefile b/contracts/Makefile index c3a636446..b1ccae921 100644 --- a/contracts/Makefile +++ b/contracts/Makefile @@ -60,10 +60,10 @@ slither: slither . --config-file ./slither.config.json check-gateway: - docker run --rm -v $(shell pwd):/app -w /app mythril/myth:latest -v4 analyze --solc-json remappings.json ./src/Gateway.sol --solv 0.8.19 + docker run --rm -v $(shell pwd):/app -w /app mythril/myth:latest -v4 analyze --solc-json remappings.json ./test/invariants/handlers/GatewayActorFacade.sol --solv 0.8.19 check-subnet: - docker run --rm -v $(shell pwd):/app -w /app mythril/myth:latest -v4 analyze --solc-json remappings.json ./src/SubnetActor.sol --solv 0.8.19 + docker run --rm -v $(shell pwd):/app -w /app mythril/myth:latest -v4 analyze --solc-json remappings.json ./src/SubnetActorDiamond.sol --solv 0.8.19 # ============================================================================== # Development support diff --git a/contracts/test/invariants/handlers/GatewayActorFacade.sol b/contracts/test/invariants/handlers/GatewayActorFacade.sol new file mode 100644 index 000000000..b1e9ac273 --- /dev/null +++ b/contracts/test/invariants/handlers/GatewayActorFacade.sol @@ -0,0 +1,59 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.19; + +import "forge-std/StdUtils.sol"; +import "forge-std/StdCheats.sol"; +import {CommonBase} from "forge-std/Base.sol"; +import {FvmAddress} from "../../../src/structs/FvmAddress.sol"; +import {SubnetID} from "../../../src/structs/Subnet.sol"; +import {GatewayDiamond} from "../../../src/GatewayDiamond.sol"; +import {GatewayManagerFacet} from "../../../src/gateway/GatewayManagerFacet.sol"; +import {EnumerableSet} from "openzeppelin-contracts/utils/structs/EnumerableSet.sol"; + +uint256 constant ETH_SUPPLY = 129_590_000 ether; + +contract GatewayActorFacade is CommonBase, StdCheats, StdUtils { + GatewayManagerFacet managerFacet; + + uint256 private constant DEFAULT_MIN_VALIDATOR_STAKE = 10 ether; + + constructor(GatewayDiamond _gw) { + managerFacet = GatewayManagerFacet(address(_gw)); + + deal(address(this), ETH_SUPPLY); + } + + function register(uint256 amount) external payable { + managerFacet.register(amount); + } + + function addStake() external payable { + managerFacet.addStake(); + } + + function releaseStake(uint256 amount) external { + managerFacet.releaseStake(amount); + } + + function kill() external { + managerFacet.kill(); + } + + function fund(SubnetID calldata subnetId, FvmAddress calldata to) external payable { + managerFacet.fund(subnetId, to); + } + + function fundWithToken(SubnetID calldata subnetId, FvmAddress calldata to, uint256 amount) external { + managerFacet.fundWithToken(subnetId, to, amount); + } + + function release(FvmAddress calldata to) external payable { + managerFacet.release(to); + } + + function forward(address callee, bytes calldata _data) public { + callee.delegatecall(_data); + } + + receive() external payable {} +}