diff --git a/.github/test-api-use/.gitignore b/.github/test-api-use/.gitignore new file mode 100644 index 00000000..e8c12ff4 --- /dev/null +++ b/.github/test-api-use/.gitignore @@ -0,0 +1,17 @@ +node_modules +.env + +# Hardhat files +/cache +/artifacts + +# TypeChain files +/typechain +/typechain-types + +# solidity-coverage files +/coverage +/coverage.json + +# Hardhat Ignition default folder for deployments against a local node +ignition/deployments/chain-31337 diff --git a/.github/test-api-use/README.md b/.github/test-api-use/README.md new file mode 100644 index 00000000..35ee8a1c --- /dev/null +++ b/.github/test-api-use/README.md @@ -0,0 +1,3 @@ +# Hardhat project example + +Used for testing the API install and imports. \ No newline at end of file diff --git a/.github/test-api-use/contracts/API-Inclusion.sol b/.github/test-api-use/contracts/API-Inclusion.sol new file mode 100644 index 00000000..f955b388 --- /dev/null +++ b/.github/test-api-use/contracts/API-Inclusion.sol @@ -0,0 +1,73 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity ^0.8.18; + +import {FilAddresses} from "filecoin-solidity-api/contracts/v0.8/utils/FilAddresses.sol"; +import {CommonTypes} from "filecoin-solidity-api/contracts/v0.8/types/CommonTypes.sol"; + +import {AccountTypes} from "filecoin-solidity-api/contracts/v0.8/types/AccountTypes.sol"; +import {DataCapTypes} from "filecoin-solidity-api/contracts/v0.8/types/DataCapTypes.sol"; +import {MarketTypes} from "filecoin-solidity-api/contracts/v0.8/types/MarketTypes.sol"; +import {MinerTypes} from "filecoin-solidity-api/contracts/v0.8/types/MinerTypes.sol"; +import {PowerTypes} from "filecoin-solidity-api/contracts/v0.8/types/PowerTypes.sol"; +import {VerifRegTypes} from "filecoin-solidity-api/contracts/v0.8/types/VerifRegTypes.sol"; + +import {AccountAPI} from "filecoin-solidity-api/contracts/v0.8/AccountAPI.sol"; +import {DataCapAPI} from "filecoin-solidity-api/contracts/v0.8/DataCapAPI.sol"; +import {MarketAPI} from "filecoin-solidity-api/contracts/v0.8/MarketAPI.sol"; +import {MinerAPI} from "filecoin-solidity-api/contracts/v0.8/MinerAPI.sol"; +import {PowerAPI} from "filecoin-solidity-api/contracts/v0.8/PowerAPI.sol"; +import {PrecompilesAPI} from "filecoin-solidity-api/contracts/v0.8/PrecompilesAPI.sol"; +import {SendAPI} from "filecoin-solidity-api/contracts/v0.8/SendAPI.sol"; +import {VerifRegAPI} from "filecoin-solidity-api/contracts/v0.8/VerifRegAPI.sol"; + +contract API_Inclusion { + //AccountAPI + function account_authenticate_message(CommonTypes.FilActorId target, AccountTypes.AuthenticateMessageParams memory params) public view { + AccountAPI.authenticateMessage(target, params); + } + + //AddressAPI + function actorid_conversion() public pure { + uint64 actorID = 1; + CommonTypes.FilAddress memory result = FilAddresses.fromActorID(actorID); + } + //DatacapAPI + function bundle(DataCapTypes.TransferParams memory params) internal returns (int256, DataCapTypes.TransferReturn memory) { + DataCapAPI.name(); + DataCapAPI.symbol(); + } + + //MarketAPI + function withdraw_balance(MarketTypes.WithdrawBalanceParams memory params) public returns (CommonTypes.BigInt memory) { + (int256 exit_code, CommonTypes.BigInt memory result) = MarketAPI.withdrawBalance(params); + + return result; + } + + //MinerAPI + function get_owner(CommonTypes.FilActorId target) external view returns (int256, MinerTypes.GetOwnerReturn memory) { + MinerAPI.getOwner(target); + } + + //PowerAPI + function create_miner(PowerTypes.CreateMinerParams memory params, uint256 value) internal returns (int256, PowerTypes.CreateMinerReturn memory) { + PowerAPI.createMiner(params, value); + } + + //PrecompilesAPI + function resolve_address(CommonTypes.FilAddress memory addr) internal view returns (uint64) { + PrecompilesAPI.resolveAddress(addr); + } + + //SendAPI + function send(CommonTypes.FilAddress memory target, uint256 value) internal returns (int256) { + SendAPI.send(target, value); + } + + //VerifregAPI + function remove_expired_claims( + VerifRegTypes.RemoveExpiredClaimsParams memory params + ) public returns (int256, VerifRegTypes.RemoveExpiredClaimsReturn memory) { + VerifRegAPI.removeExpiredClaims(params); + } +} diff --git a/.github/test-api-use/hardhat.config.js b/.github/test-api-use/hardhat.config.js new file mode 100644 index 00000000..71524bb6 --- /dev/null +++ b/.github/test-api-use/hardhat.config.js @@ -0,0 +1,6 @@ +require("@nomicfoundation/hardhat-toolbox") + +/** @type import('hardhat/config').HardhatUserConfig */ +module.exports = { + solidity: "0.8.18", +} diff --git a/.github/test-api-use/package.json b/.github/test-api-use/package.json new file mode 100644 index 00000000..919aa14b --- /dev/null +++ b/.github/test-api-use/package.json @@ -0,0 +1,33 @@ +{ + "name": "fil-sol-use", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "", + "license": "ISC", + "dependencies": { + "@nomicfoundation/hardhat-chai-matchers": "^2.0.0", + "@nomicfoundation/hardhat-ethers": "^3.0.0", + "@nomicfoundation/hardhat-ignition": "^0.15.4", + "@nomicfoundation/hardhat-ignition-ethers": "^0.15.0", + "@nomicfoundation/hardhat-network-helpers": "^1.0.0", + "@nomicfoundation/hardhat-verify": "^2.0.0", + "@typechain/ethers-v6": "^0.5.0", + "@typechain/hardhat": "^9.0.0", + "@types/mocha": ">=9.1.0", + "chai": "^4.2.0", + "hardhat": "^2.22.4", + "hardhat-gas-reporter": "^1.0.8", + "solidity-coverage": "^0.8.1", + "ts-node": ">=8.0.0", + "typechain": "^8.3.0", + "typescript": ">=4.5.0" + }, + "devDependencies": { + "@nomicfoundation/hardhat-toolbox": "^5.0.0" + } +} diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index f14ca41e..8acdcb1c 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -1,977 +1,95 @@ -name: "Build contracts" +name: "Main" on: - push: - branches: - - master - - milestone-1 - pull_request: - branches: - - master - - milestone-1 + pull_request: + branches: + - master jobs: - smoke-tests: - name: "Run smoke tests" - timeout-minutes: 30 - runs-on: ubuntu-22.04 - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - submodules: 'true' - - name: Install dependencies - run: | - sudo apt install zsh -y - make install_solc_linux - yarn install - - name: Compile contracts - run: ./testing/smoke_tests.sh - - build-mock: - name: "Build Mock API" - timeout-minutes: 30 - runs-on: ubuntu-22.04 - needs: [smoke-tests] - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - submodules: 'true' - - name: Install node - uses: actions/setup-node@v2 - with: - node-version: '16.16.0' - - name: Install yarn - run: npm install -g yarn - - name: Install dependencies - run: | - yarn install - make install_solc_linux - - name: Compile contract files - run: make build_mock_api - - simplecoin-checks: - name: "SimpleCoin: end-to-end tests" - timeout-minutes: 30 - runs-on: ubuntu-22.04 - needs: [smoke-tests] - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - submodules: 'true' - - name: Install node - uses: actions/setup-node@v2 - with: - node-version: '16.16.0' - - name: Install yarn - run: npm install -g yarn - - name: Install dependencies - run: cd hardhat && yarn install - - name: Deploy contract - run: | - make deploy_simple_coin > deploy.log - cat deploy.log - env: - PRIVATE_KEY: ${{ secrets.WALLET_PRIVATE_KEY }} - - name: Test contract - run: | - WALLET_ADDRESS=$(awk '/Wallet Ethereum Address:/{print $NF}' deploy.log) - CONTRACT_ADDRESS=$(sed -nr 's/.*deployed at ([^ ]+).*/\1/p' deploy.log) - echo $WALLET_ADDRESS - echo $CONTRACT_ADDRESS - cd hardhat && yarn hardhat get-balance --contract $CONTRACT_ADDRESS --account $WALLET_ADDRESS - env: - PRIVATE_KEY: ${{ secrets.WALLET_PRIVATE_KEY }} - - api-deploy: - name: "Filecoin APIs: deploy" - timeout-minutes: 30 - runs-on: ubuntu-22.04 - needs: [smoke-tests] - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - submodules: 'true' - - name: Install node - uses: actions/setup-node@v2 - with: - node-version: '16.16.0' - - name: Install yarn - run: npm install -g yarn - - name: Install dependencies - run: | - yarn install - cd hardhat && yarn install - - name: Deploy contracts - run: | - make deploy_miner_api > deploy_miner.log - make deploy_market_api > deploy_market.log - make deploy_verifreg_api > deploy_verifreg.log - make deploy_power_api > deploy_power.log - cat deploy_miner.log - cat deploy_market.log - cat deploy_verifreg.log - cat deploy_power.log - env: - PRIVATE_KEY: ${{ secrets.WALLET_PRIVATE_KEY }} - - miner-integration: - name: "Miner API: integration tests" - timeout-minutes: 30 - runs-on: ubuntu-22.04 - needs: [smoke-tests] - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - submodules: 'true' - - name: Instal deps - run: make install-opencl - - name: Install node - uses: actions/setup-node@v2 - with: - node-version: '16.16.0' - - name: Install yarn - run: npm install -g yarn - - name: Install latest stable - uses: actions-rs/toolchain@v1 - with: - toolchain: nightly - override: true - - name: Install dependencies - run: | - yarn install - make install_solc_linux - - name: Restore crates - uses: actions/cache@v3 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - key: ${{ runner.os }}-cargo-${{ hashFiles('./testing/Cargo.lock') }} - - name: Restore previous compilation - uses: actions/cache@v3 - with: - path: | - ./testing/target - key: ${{ runner.os }}-testing-${{ hashFiles('./testing/Cargo.lock') }} - - name: Restore builtin-actors - uses: actions/cache@v3 - with: - path: | - ./testing/builtin-actors/target - key: ${{ runner.os }}-actors-${{ hashFiles('./testing/builtin-actors/Cargo.lock') }} - - name: Build builtin-actors - run: make build_builtin_actors - - name: Build contracts - run: make - - name: Run tests on miner - run: | - cd testing - rustup target add wasm32-unknown-unknown - cargo test miner_test - - uses: actions/upload-artifact@v3 - with: - name: gas_results_miner.csv - path: testing/gas_results_miner.csv - - market-integration: - name: "Market API: integration tests" - timeout-minutes: 30 - runs-on: ubuntu-22.04 - needs: [smoke-tests] - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - submodules: 'true' - - name: Instal deps - run: make install-opencl - - name: Install node - uses: actions/setup-node@v2 - with: - node-version: '16.16.0' - - name: Install yarn - run: npm install -g yarn - - name: Install latest stable - uses: actions-rs/toolchain@v1 - with: - toolchain: nightly - override: true - - name: Install dependencies - run: | - yarn install - make install_solc_linux - - name: Restore crates - uses: actions/cache@v3 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - key: ${{ runner.os }}-cargo-${{ hashFiles('./testing/Cargo.lock') }} - - name: Restore previous compilation - uses: actions/cache@v3 - with: - path: | - ./testing/target - key: ${{ runner.os }}-testing-${{ hashFiles('./testing/Cargo.lock') }} - - name: Restore builtin-actors - uses: actions/cache@v3 - with: - path: | - ./testing/builtin-actors/target - key: ${{ runner.os }}-actors-${{ hashFiles('./testing/builtin-actors/Cargo.lock') }} - - name: Build builtin-actors - run: make build_builtin_actors - - name: Build contracts - run: make - - name: Run tests on market - run: | - cd testing - rustup target add wasm32-unknown-unknown - cargo test market_test - - uses: actions/upload-artifact@v3 - with: - name: gas_results_market.csv - path: testing/gas_results_market.csv - - power-integration: - name: "Power API: integration tests" - timeout-minutes: 30 - runs-on: ubuntu-22.04 - needs: [smoke-tests] - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - submodules: 'true' - - name: Instal deps - run: make install-opencl - - name: Install node - uses: actions/setup-node@v2 - with: - node-version: '16.16.0' - - name: Install yarn - run: npm install -g yarn - - name: Install latest stable - uses: actions-rs/toolchain@v1 - with: - toolchain: nightly - override: true - - name: Install dependencies - run: | - yarn install - make install_solc_linux - - name: Restore crates - uses: actions/cache@v3 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - key: ${{ runner.os }}-cargo-${{ hashFiles('./testing/Cargo.lock') }} - - name: Restore previous compilation - uses: actions/cache@v3 - with: - path: | - ./testing/target - key: ${{ runner.os }}-testing-${{ hashFiles('./testing/Cargo.lock') }} - - name: Restore builtin-actors - uses: actions/cache@v3 - with: - path: | - ./testing/builtin-actors/target - key: ${{ runner.os }}-actors-${{ hashFiles('./testing/builtin-actors/Cargo.lock') }} - - name: Build builtin-actors - run: make build_builtin_actors - - name: Build contracts - run: make - - name: Run tests on power - run: | - cd testing - rustup target add wasm32-unknown-unknown - cargo test power_test - - uses: actions/upload-artifact@v3 - with: - name: gas_results_power.csv - path: testing/gas_results_power.csv - - verifreg-integration: - name: "VerifReg API: integration tests" - timeout-minutes: 30 - runs-on: ubuntu-22.04 - needs: [smoke-tests] - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - submodules: 'true' - - name: Instal deps - run: make install-opencl - - name: Install node - uses: actions/setup-node@v2 - with: - node-version: '16.16.0' - - name: Install yarn - run: npm install -g yarn - - name: Install latest stable - uses: actions-rs/toolchain@v1 - with: - toolchain: nightly - override: true - - name: Install dependencies - run: | - yarn install - make install_solc_linux - - name: Restore crates - uses: actions/cache@v3 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - key: ${{ runner.os }}-cargo-${{ hashFiles('./testing/Cargo.lock') }} - - name: Restore previous compilation - uses: actions/cache@v3 - with: - path: | - ./testing/target - key: ${{ runner.os }}-testing-${{ hashFiles('./testing/Cargo.lock') }} - - name: Restore builtin-actors - uses: actions/cache@v3 - with: - path: | - ./testing/builtin-actors/target - key: ${{ runner.os }}-actors-${{ hashFiles('./testing/builtin-actors/Cargo.lock') }} - - name: Build builtin-actors - run: make build_builtin_actors - - name: Build contracts - run: make - - name: Run tests on verifreg - run: | - cd testing - rustup target add wasm32-unknown-unknown - cargo test verifreg_test - - uses: actions/upload-artifact@v3 - with: - name: gas_results_verifreg.csv - path: testing/gas_results_verifreg.csv - - datacap-integration: - name: "DataCap API: integration tests" - timeout-minutes: 30 - runs-on: ubuntu-22.04 - needs: [smoke-tests] - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - submodules: 'true' - - name: Instal deps - run: make install-opencl - - name: Install node - uses: actions/setup-node@v2 - with: - node-version: '16.16.0' - - name: Install yarn - run: npm install -g yarn - - name: Install latest stable - uses: actions-rs/toolchain@v1 - with: - toolchain: nightly - override: true - - name: Install dependencies - run: | - yarn install - make install_solc_linux - - name: Restore crates - uses: actions/cache@v3 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - key: ${{ runner.os }}-cargo-${{ hashFiles('./testing/Cargo.lock') }} - - name: Restore previous compilation - uses: actions/cache@v3 - with: - path: | - ./testing/target - key: ${{ runner.os }}-testing-${{ hashFiles('./testing/Cargo.lock') }} - - name: Restore builtin-actors - uses: actions/cache@v3 - with: - path: | - ./testing/builtin-actors/target - key: ${{ runner.os }}-actors-${{ hashFiles('./testing/builtin-actors/Cargo.lock') }} - - name: Build builtin-actors - run: make build_builtin_actors - - name: Build contracts - run: make - - name: Run tests on datacap - run: | - cd testing - rustup target add wasm32-unknown-unknown - cargo test datacap_test - - uses: actions/upload-artifact@v3 - with: - name: gas_results_datacap.csv - path: testing/gas_results_datacap.csv - - account-integration: - name: "Account API: integration tests" - timeout-minutes: 30 - runs-on: ubuntu-22.04 - needs: [smoke-tests] - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - submodules: 'true' - - name: Instal deps - run: make install-opencl - - name: Install node - uses: actions/setup-node@v2 - with: - node-version: '16.16.0' - - name: Install yarn - run: npm install -g yarn - - name: Install latest stable - uses: actions-rs/toolchain@v1 - with: - toolchain: nightly - override: true - - name: Install dependencies - run: | - yarn install - make install_solc_linux - - name: Restore crates - uses: actions/cache@v3 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - key: ${{ runner.os }}-cargo-${{ hashFiles('./testing/Cargo.lock') }} - - name: Restore previous compilation - uses: actions/cache@v3 - with: - path: | - ./testing/target - key: ${{ runner.os }}-testing-${{ hashFiles('./testing/Cargo.lock') }} - - name: Restore builtin-actors - uses: actions/cache@v3 - with: - path: | - ./testing/builtin-actors/target - key: ${{ runner.os }}-actors-${{ hashFiles('./testing/builtin-actors/Cargo.lock') }} - - name: Build builtin-actors - run: make build_builtin_actors - - name: Build contracts - run: make - - name: Run tests on account - run: | - cd testing - rustup target add wasm32-unknown-unknown - cargo test account_test - - uses: actions/upload-artifact@v3 - with: - name: gas_results_account.csv - path: testing/gas_results_account.csv - - precompiles-integration: - name: "Precompiles API: integration tests" - timeout-minutes: 30 - runs-on: ubuntu-22.04 - needs: [smoke-tests] - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - submodules: 'true' - - name: Instal deps - run: make install-opencl - - name: Install node - uses: actions/setup-node@v2 - with: - node-version: '16.16.0' - - name: Install yarn - run: npm install -g yarn - - name: Install latest stable - uses: actions-rs/toolchain@v1 - with: - toolchain: nightly - override: true - - name: Install dependencies - run: | - yarn install - make install_solc_linux - - name: Restore crates - uses: actions/cache@v3 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - key: ${{ runner.os }}-cargo-${{ hashFiles('./testing/Cargo.lock') }} - - name: Restore previous compilation - uses: actions/cache@v3 - with: - path: | - ./testing/target - key: ${{ runner.os }}-testing-${{ hashFiles('./testing/Cargo.lock') }} - - name: Restore builtin-actors - uses: actions/cache@v3 - with: - path: | - ./testing/builtin-actors/target - key: ${{ runner.os }}-actors-${{ hashFiles('./testing/builtin-actors/Cargo.lock') }} - - name: Build builtin-actors - run: make build_builtin_actors - - name: Build contracts - run: make - - name: Run tests on precompiles - run: | - cd testing - rustup target add wasm32-unknown-unknown - cargo test precompiles_test - - uses: actions/upload-artifact@v3 - with: - name: gas_results_precompiles.csv - path: testing/gas_results_precompiles.csv - - send-integration: - name: "Send API: integration tests" - timeout-minutes: 30 - runs-on: ubuntu-22.04 - needs: [smoke-tests] - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - submodules: 'true' - - name: Instal deps - run: make install-opencl - - name: Install node - uses: actions/setup-node@v2 - with: - node-version: '16.16.0' - - name: Install yarn - run: npm install -g yarn - - name: Install latest stable - uses: actions-rs/toolchain@v1 - with: - toolchain: nightly - override: true - - name: Install dependencies - run: | - yarn install - make install_solc_linux - - name: Restore crates - uses: actions/cache@v3 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - key: ${{ runner.os }}-cargo-${{ hashFiles('./testing/Cargo.lock') }} - - name: Restore previous compilation - uses: actions/cache@v3 - with: - path: | - ./testing/target - key: ${{ runner.os }}-testing-${{ hashFiles('./testing/Cargo.lock') }} - - name: Restore builtin-actors - uses: actions/cache@v3 - with: - path: | - ./testing/builtin-actors/target - key: ${{ runner.os }}-actors-${{ hashFiles('./testing/builtin-actors/Cargo.lock') }} - - name: Build builtin-actors - run: make build_builtin_actors - - name: Build contracts - run: make - - name: Run tests on send - run: | - cd testing - rustup target add wasm32-unknown-unknown - cargo test send_test - - uses: actions/upload-artifact@v3 - with: - name: gas_results_send.csv - path: testing/gas_results_send.csv - - frc0042-check: - name: "Check FRC0042 method number" - runs-on: ubuntu-22.04 - needs: [smoke-tests] - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - submodules: 'false' - - name: Instal deps - run: make install-opencl - - name: Install latest stable - uses: actions-rs/toolchain@v1 - with: - toolchain: nightly - override: true - - name: Check FRC0042 using rust script - run: make test_frc0042 - - cbor-decode-integration: - name: "CBOR Decode Tests" - timeout-minutes: 30 - runs-on: ubuntu-22.04 - needs: [smoke-tests] - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - submodules: 'true' - - name: Instal deps - run: make install-opencl - - name: Install node - uses: actions/setup-node@v2 - with: - node-version: '16.16.0' - - name: Install yarn - run: npm install -g yarn - - name: Install latest stable - uses: actions-rs/toolchain@v1 - with: - toolchain: nightly - override: true - - name: Install dependencies - run: | - yarn install - make install_solc_linux - - name: Restore crates - uses: actions/cache@v3 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - key: ${{ runner.os }}-cargo-${{ hashFiles('./testing/Cargo.lock') }} - - name: Restore previous compilation - uses: actions/cache@v3 - with: - path: | - ./testing/target - key: ${{ runner.os }}-testing-${{ hashFiles('./testing/Cargo.lock') }} - - name: Restore builtin-actors - uses: actions/cache@v3 - with: - path: | - ./testing/builtin-actors/target - key: ${{ runner.os }}-actors-${{ hashFiles('./testing/builtin-actors/Cargo.lock') }} - - name: Build builtin-actors - run: make build_builtin_actors - - name: Build contracts - run: make - - name: Run tests on cbor decode lib - run: | - cd testing - rustup target add wasm32-unknown-unknown - cargo test cbor_decode_test - - bigints-integration: - name: "BigInt Tests" - timeout-minutes: 30 - runs-on: ubuntu-22.04 - needs: [smoke-tests] - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - submodules: 'true' - - name: Instal deps - run: make install-opencl - - name: Install node - uses: actions/setup-node@v2 - with: - node-version: '16.16.0' - - name: Install yarn - run: npm install -g yarn - - name: Install latest stable - uses: actions-rs/toolchain@v1 - with: - toolchain: nightly - override: true - - name: Install dependencies - run: | - yarn install - make install_solc_linux - - name: Restore crates - uses: actions/cache@v3 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - key: ${{ runner.os }}-cargo-${{ hashFiles('./testing/Cargo.lock') }} - - name: Restore previous compilation - uses: actions/cache@v3 - with: - path: | - ./testing/target - key: ${{ runner.os }}-testing-${{ hashFiles('./testing/Cargo.lock') }} - - name: Restore builtin-actors - uses: actions/cache@v3 - with: - path: | - ./testing/builtin-actors/target - key: ${{ runner.os }}-actors-${{ hashFiles('./testing/builtin-actors/Cargo.lock') }} - - name: Build builtin-actors - run: make build_builtin_actors - - name: Build contracts - run: make - - name: Run tests on bigints lib - run: | - cd testing - rustup target add wasm32-unknown-unknown - cargo test bigints_test - - leb128-test: - name: "Leb128 Tests" - timeout-minutes: 30 - runs-on: ubuntu-22.04 - needs: [smoke-tests] - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - submodules: 'true' - - name: Instal deps - run: make install-opencl - - name: Install node - uses: actions/setup-node@v2 - with: - node-version: '16.16.0' - - name: Install yarn - run: npm install -g yarn - - name: Install latest stable - uses: actions-rs/toolchain@v1 - with: - toolchain: nightly - override: true - - name: Install dependencies - run: | - yarn install - make install_solc_linux - - name: Restore crates - uses: actions/cache@v3 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - key: ${{ runner.os }}-cargo-${{ hashFiles('./testing/Cargo.lock') }} - - name: Restore previous compilation - uses: actions/cache@v3 - with: - path: | - ./testing/target - key: ${{ runner.os }}-testing-${{ hashFiles('./testing/Cargo.lock') }} - - name: Restore builtin-actors - uses: actions/cache@v3 - with: - path: | - ./testing/builtin-actors/target - key: ${{ runner.os }}-actors-${{ hashFiles('./testing/builtin-actors/Cargo.lock') }} - - name: Build builtin-actors - run: make build_builtin_actors - - name: Build contracts - run: make - - name: Run tests for leb128 - run: | - cd testing - rustup target add wasm32-unknown-unknown - cargo test leb128_test - - address-test: - name: "Address Tests" - timeout-minutes: 30 - runs-on: ubuntu-22.04 - needs: [smoke-tests] - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - submodules: 'true' - - name: Instal deps - run: make install-opencl - - name: Install node - uses: actions/setup-node@v2 - with: - node-version: '16.16.0' - - name: Install yarn - run: npm install -g yarn - - name: Install latest stable - uses: actions-rs/toolchain@v1 - with: - toolchain: nightly - override: true - - name: Install dependencies - run: | - yarn install - make install_solc_linux - - name: Restore crates - uses: actions/cache@v3 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - key: ${{ runner.os }}-cargo-${{ hashFiles('./testing/Cargo.lock') }} - - name: Restore previous compilation - uses: actions/cache@v3 - with: - path: | - ./testing/target - key: ${{ runner.os }}-testing-${{ hashFiles('./testing/Cargo.lock') }} - - name: Restore builtin-actors - uses: actions/cache@v3 - with: - path: | - ./testing/builtin-actors/target - key: ${{ runner.os }}-actors-${{ hashFiles('./testing/builtin-actors/Cargo.lock') }} - - name: Build builtin-actors - run: make build_builtin_actors - - name: Build contracts - run: make - - name: Run tests for address - run: | - cd testing - rustup target add wasm32-unknown-unknown - cargo test address - - deserialize-test: - name: "Deserialize Params Tests" - timeout-minutes: 30 - runs-on: ubuntu-22.04 - needs: [smoke-tests] - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - submodules: 'true' - - name: Instal deps - run: make install-opencl - - name: Install node - uses: actions/setup-node@v2 - with: - node-version: '16.16.0' - - name: Install yarn - run: npm install -g yarn - - name: Install latest stable - uses: actions-rs/toolchain@v1 - with: - toolchain: nightly - override: true - - name: Install dependencies - run: | - yarn install - make install_solc_linux - - name: Restore crates - uses: actions/cache@v3 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - key: ${{ runner.os }}-cargo-${{ hashFiles('./testing/Cargo.lock') }} - - name: Restore previous compilation - uses: actions/cache@v3 - with: - path: | - ./testing/target - key: ${{ runner.os }}-testing-${{ hashFiles('./testing/Cargo.lock') }} - - name: Restore builtin-actors - uses: actions/cache@v3 - with: - path: | - ./testing/builtin-actors/target - key: ${{ runner.os }}-actors-${{ hashFiles('./testing/builtin-actors/Cargo.lock') }} - - name: Build builtin-actors - run: make build_builtin_actors - - name: Build contracts - run: make - - name: Run tests for deserialize params - run: | - cd testing - rustup target add wasm32-unknown-unknown - cargo test deserialize_params_tests - - comment-result: - name: "Comment the result on PR" - runs-on: ubuntu-22.04 - if: github.event_name == 'pull_request' - needs: [smoke-tests, account-integration, datacap-integration, market-integration, miner-integration, power-integration, precompiles-integration, send-integration, verifreg-integration] - steps: - - name: "Get gas_results_account.csv" - uses: actions/download-artifact@v3 - with: - name: gas_results_account.csv - - name: "Get gas_results_datacap.csv" - uses: actions/download-artifact@v3 - with: - name: gas_results_datacap.csv - - name: "Get gas_results_miner.csv" - uses: actions/download-artifact@v3 - with: - name: gas_results_miner.csv - - name: "Get gas_results_market.csv" - uses: actions/download-artifact@v3 - with: - name: gas_results_market.csv - - name: "Get gas_results_power.csv" - uses: actions/download-artifact@v3 - with: - name: gas_results_power.csv - - name: "Get gas_results_precompiles.csv" - uses: actions/download-artifact@v3 - with: - name: gas_results_precompiles.csv - - name: "Get gas_results_send.csv" - uses: actions/download-artifact@v3 - with: - name: gas_results_send.csv - - name: "Get gas_results_verifreg.csv" - uses: actions/download-artifact@v3 - with: - name: gas_results_verifreg.csv - - name: "Comment results" - env: - URL: ${{ github.event.pull_request.comments_url }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - pip install csv2md - MKD=$(( echo "## Account actor"; csv2md gas_results_account.csv; echo "## Miner actor"; csv2md gas_results_miner.csv; echo "## Datacap actor"; csv2md gas_results_datacap.csv; echo "## Market actor"; csv2md gas_results_market.csv; echo "## Power actor"; csv2md gas_results_power.csv; echo "## Precompiles actor"; csv2md gas_results_precompiles.csv; echo "## Send actor"; csv2md gas_results_send.csv; echo "## Verifreg actor"; csv2md gas_results_verifreg.csv ) | cat) - BODY=$(jq --null-input --arg body "# Gas results 🚀📝 - ${MKD}" '{"body": $body}') - curl \ - -X POST \ - $URL \ - -H "Content-Type: application/json" \ - -H "Authorization: token $GITHUB_TOKEN" \ - --data "$BODY" + api-tests: + name: "API tests" + timeout-minutes: 30 + runs-on: ubuntu-latest + container: + image: golang:1.21.7-bullseye + + steps: + - name: Install node + uses: actions/setup-node@v2 + with: + node-version: "20.0.0" + + - name: Install yarn + run: npm install -g yarn + + - name: Checkout repo + uses: actions/checkout@main + with: + submodules: "true" + + - name: Install other dependencies + run: | + rm /bin/sh && ln -s /bin/bash /bin/sh + cat /etc/os-release + apt-get update + apt-get -y install hwloc jq pkg-config bzr ocl-icd-opencl-dev + apt install zsh -y + make install_solc_linux + yarn install + ls -1 /usr/lib/*/libhwloc.so.* | head -n 1 | xargs -n1 -I {} ln -s {} /usr/lib/libhwloc.so + + - name: Install Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: nightly + override: true + + - name: Build Contracts + run: make build + + - name: Compilation + run: | + cd testing + rustup target add wasm32-unknown-unknown + cargo build + + - name: Test-Account + run: cd testing && cargo test account -- --nocapture + + - name: Test-Address + run: cd testing && cargo test address -- --nocapture + + - name: Test-Send + run: cd testing && cargo test send_test -- --nocapture + + - name: Test-BigInts + run: cd testing && cargo test bigints_test -- --nocapture + + - name: Test-Leb128 + run: cd testing && cargo test leb128 -- --nocapture + + - name: Test-Deserialize + run: cd testing && cargo test deserialize_params_tests -- --nocapture + + - name: Test-MarketCbor + run: cd testing && cargo test market_cbor_tests -- --nocapture + + - name: Test-CborDecode + run: cd testing && cargo test cbor_decode_test -- --nocapture + + - name: Test-FRC0042 + run: cd testing && cargo run --example methodnum + + - name: Test-VerifReg + run: cd testing && cargo test verifreg_test -- --nocapture + + - name: Test-Power + run: cd testing && cargo test power_test -- --nocapture + + - name: Test-Miner + run: cd testing && cargo test miner_test -- --nocapture + + - name: Test-Market + run: cd testing && cargo test market_test -- --nocapture + + - name: Test-SolcVersions + run: chmod +x ./testing/smoke_tests.sh && ./testing/smoke_tests.sh diff --git a/.github/workflows/publish-and-use.yaml b/.github/workflows/publish-and-use.yaml new file mode 100644 index 00000000..7a29fb41 --- /dev/null +++ b/.github/workflows/publish-and-use.yaml @@ -0,0 +1,44 @@ +name: "Publish & use NPM package" + +on: + release: + types: + - created + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v3 + with: + node-version: "20" + - name: Install dependencies + run: | + yarn install + make install_solc_linux + - name: Compile contract file + run: make + - uses: JS-DevTools/npm-publish@v3 + with: + token: ${{ secrets.NPM_TOKEN }} + + lib-install-use: + runs-on: ubuntu-latest + needs: ["publish"] + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v3 + with: + node-version: "20" + - name: Checkout repo + uses: actions/checkout@main + with: + submodules: "true" + - name: Install from NPM registry + run: | + rm -rf hardhat.config.ts package.json + cd .github/test-api-use + yarn add filecoin-solidity-api + yarn install + npx hardhat compile diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml deleted file mode 100644 index ba0da51a..00000000 --- a/.github/workflows/publish.yaml +++ /dev/null @@ -1,40 +0,0 @@ -name: "Publish package" - -on: - release: - types: - - created - tags: - - "v[0-9]+(\\.[0-9]+)*" - -jobs: - publish: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Install node - uses: actions/setup-node@v2 - with: - node-version: '16.13.0' - registry-url: "https://registry.npmjs.org" - scope: "@zondax" - - name: Install dependencies - run: | - yarn install - make install_solc_linux - - name: Compile contract file - run: make - - name: Install yarn - run: npm install -g yarn - - name: Get latest release version number - id: get_version - uses: battila7/get-version-action@v2 - - name: Update tag - run: | - echo Publishing as ${{ steps.get_version.outputs.version }} - npm --allow-same-version --no-git-tag-version version ${{ steps.get_version.outputs.version }} - - name: Publish package - run: npm publish - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN_PUBLISH_AUTO }} diff --git a/.github/workflows/security.yaml b/.github/workflows/security.yaml index 54c32fdf..6f7f05b6 100644 --- a/.github/workflows/security.yaml +++ b/.github/workflows/security.yaml @@ -1,121 +1,86 @@ name: "Security checks" on: - push: - branches: - - master - pull_request: - branches: - - master + pull_request: + branches: + - master jobs: - account: - name: "Account API: security checks" - timeout-minutes: 20 - runs-on: ubuntu-22.04 - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - submodules: 'false' - - name: Install mythril - run: pip3 install mythril - - name: Run checks - run: make security_account_api - - power: - name: "Power API: security checks" - timeout-minutes: 20 - runs-on: ubuntu-22.04 - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - submodules: 'false' - - name: Install mythril - run: pip3 install mythril - - name: Run checks - run: make security_power_api - - verifreg: - name: "VerifReg API: security checks" - timeout-minutes: 20 - runs-on: ubuntu-22.04 - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - submodules: 'false' - - name: Install mythril - run: pip3 install mythril - - name: Run checks - run: make security_verifreg_api - - market: - name: "Market API: security checks" - timeout-minutes: 20 - runs-on: ubuntu-22.04 - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - submodules: 'false' - - name: Install mythril - run: pip3 install mythril - - name: Run checks - run: make security_market_api - - miner: - name: "Miner API: security checks" - timeout-minutes: 20 - runs-on: ubuntu-22.04 - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - submodules: 'false' - - name: Install mythril - run: pip3 install mythril - - name: Run checks - run: make security_miner_api - - datacap: - name: "DataCap API: security checks" - timeout-minutes: 20 - runs-on: ubuntu-22.04 - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - submodules: 'false' - - name: Install mythril - run: pip3 install mythril - - name: Run checks - run: make security_datacap_api - - send: - name: "Send API: security checks" - timeout-minutes: 20 - runs-on: ubuntu-22.04 - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - submodules: 'false' - - name: Install mythril - run: pip3 install mythril - - name: Run checks - run: make security_send_api - - precompiles: - name: "Precompiles API: security checks" - timeout-minutes: 20 - runs-on: ubuntu-22.04 - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - submodules: 'false' - - name: Install mythril - run: pip3 install mythril - - name: Run checks - run: make security_precompiles_api + security-tests-part-1: + name: "API Security tests - part 1" + timeout-minutes: 30 + runs-on: ubuntu-latest + steps: + - name: Install node + uses: actions/setup-node@v2 + with: + node-version: "20.0.0" + + - name: Install yarn + run: npm install -g yarn + + - name: Checkout repo + uses: actions/checkout@main + with: + submodules: "true" + + - name: Install other dependencies + run: | + sudo apt-get update + sudo apt-get -y install hwloc jq pkg-config bzr ocl-icd-opencl-dev + sudo apt install zsh -y + yarn install + + - name: Install mythril + run: pip3 install mythril + + - name: Run checks on Account API + run: make security_account_api + + - name: Run checks on Market API + run: make security_market_api + + - name: Run checks on Miner API + run: make security_miner_api + + - name: Run checks on VerifReg API + run: make security_verifreg_api + + security-tests-part-2: + name: "API Security tests - part 2" + timeout-minutes: 30 + runs-on: ubuntu-latest + steps: + - name: Install node + uses: actions/setup-node@v2 + with: + node-version: "20.0.0" + + - name: Install yarn + run: npm install -g yarn + + - name: Checkout repo + uses: actions/checkout@main + with: + submodules: "true" + + - name: Install other dependencies + run: | + sudo apt-get update + sudo apt-get -y install hwloc jq pkg-config bzr ocl-icd-opencl-dev + sudo apt install zsh -y + yarn install + + - name: Install mythril + run: pip3 install mythril + + - name: Run checks on Power API + run: make security_power_api + + - name: Run checks on Datacap API + run: make security_datacap_api + + - name: Run checks on Send API + run: make security_send_api + + - name: Run checks on Precompiles API + run: make security_precompiles_api