diff --git a/.github/workflows/scheduled_lints.yml b/.github/workflows/scheduled_lints.yml index b1cb9dc8e..4f7b01186 100644 --- a/.github/workflows/scheduled_lints.yml +++ b/.github/workflows/scheduled_lints.yml @@ -12,11 +12,16 @@ jobs: run: | git checkout -f $(git -c user.name=x -c user.email=x@x commit-tree $(git hash-object -t tree /dev/null) < /dev/null) || : - name: Clone the repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Test mainnet - run: cargo make --profile mainnet test + run: cargo make --profile mainnet test-flow - name: Test testnet - run: cargo make --profile testnet test + run: cargo make --profile testnet test-flow + - name: Test mainnet silo + run: cargo make --profile mainnet-silo test-flow + - name: Test testnet silo + run: cargo make --profile testnet-silo test-flow + checks: name: Run checks runs-on: [self-hosted, heavy] @@ -25,5 +30,5 @@ jobs: run: | git checkout -f $(git -c user.name=x -c user.email=x@x commit-tree $(git hash-object -t tree /dev/null) < /dev/null) || : - name: Clone the repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - run: cargo make check diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 7a12850a4..6d9e04b00 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -9,76 +9,79 @@ on: name: Tests jobs: test: - name: Test suite (mainnet, testnet) - runs-on: [self-hosted, heavy] + name: Test suite ${{ matrix.profile }} + runs-on: github-hosted-heavy-runner + strategy: + matrix: + profile: [ mainnet, testnet, mainnet-silo, testnet-silo ] steps: - name: Potential broken submodules fix run: | git checkout -f $(git -c user.name=x -c user.email=x@x commit-tree $(git hash-object -t tree /dev/null) < /dev/null) || : - name: Clone the repository - uses: actions/checkout@v3 - - name: Restore cache - run: cache-util restore cargo_git cargo_registry yarn_cache rocksdb:/root/rocksdb - - name: Preparing rocksdb library - run: scripts/ci/build_rocksdb.sh - - name: Test mainnet - run: cargo make --profile mainnet test-flow - - name: Test testnet - run: cargo make --profile testnet test-flow - - name: Save cache - run: cache-util save cargo_git cargo_registry yarn_cache - - test_silo: - name: Test Silo suite (mainnet-silo, testnet-silo) - runs-on: [ self-hosted, heavy ] - steps: - - name: Potential broken submodules fix + uses: actions/checkout@v4 + - name: Cargo Cache + uses: actions/cache@v3 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ matrix.profile }}-cargo-test + - name: Setup Node and cache + uses: actions/setup-node@v3 + with: + node-version: 16 + cache: 'yarn' + cache-dependency-path: | + etc/eth-contracts + etc/tests/uniswap + - name: Install dependencies + run: cargo make -V || cargo install cargo-make + - name: Build main contract run: | - git checkout -f $(git -c user.name=x -c user.email=x@x commit-tree $(git hash-object -t tree /dev/null) < /dev/null) || : - - name: Clone the repository - uses: actions/checkout@v3 - - name: Restore cache - run: cache-util restore cargo_git cargo_registry yarn_cache rocksdb:/root/rocksdb - - name: Preparing rocksdb library - run: scripts/ci/build_rocksdb.sh - - name: Test mainnet - run: | - cargo make --profile mainnet build-test - cargo make --profile mainnet-silo test-flow - - name: Test testnet - run: | - cargo make --profile testnet build-test - cargo make --profile testnet-silo test-flow - - name: Save cache - run: cache-util save cargo_git cargo_registry yarn_cache + case ${{ matrix.profile }} in + mainnet-silo) + cargo make --profile mainnet build-test + ;; + testnet-silo) + cargo make --profile testnet build-test + ;; + *) + ;; + esac + - name: Tests ${{ matrix.profile }} + run: cargo make --profile ${{ matrix.profile }} test-flow test_modexp: - name: Test modexp suite (mainnet, testnet) - runs-on: [ self-hosted, heavy ] + name: Test modexp suite ${{ matrix.profile }} + runs-on: github-hosted-heavy-runner + strategy: + matrix: + profile: [ mainnet, testnet ] steps: - name: Potential broken submodules fix run: | git checkout -f $(git -c user.name=x -c user.email=x@x commit-tree $(git hash-object -t tree /dev/null) < /dev/null) || : - name: Clone the repository - uses: actions/checkout@v3 - - name: Restore cache - run: | - cache-util restore cargo_git cargo_registry yarn_cache rocksdb:/root/rocksdb - cache-util restore aurora-engine-target@modexp@${{ hashFiles('**/Cargo.lock') }}:target - - name: Preparing rocksdb library - run: scripts/ci/build_rocksdb.sh - - name: Test mainnet bench-modexp - run: cargo make --profile mainnet bench-modexp - - name: Test testnet bench-modexp - run: cargo make --profile testnet bench-modexp - - name: Save cache - run: | - cache-util save cargo_git cargo_registry yarn_cache - cache-util msave aurora-engine-target@modexp@${{ hashFiles('**/Cargo.lock') }}:target + uses: actions/checkout@v4 + - name: Cargo Cache + uses: actions/cache@v3 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ matrix.profile }}-cargo-modexp-test + - name: Install dependencies + run: cargo make -V || cargo install cargo-make + - name: Test ${{ matrix.profile }} bench-modexp + run: cargo make --profile ${{ matrix.profile }} bench-modexp env: CARGO_TERM_COLOR: always CARGO_INCREMENTAL: 0 - ROCKSDB_INCLUDE_DIR: /root/rocksdb/include - ROCKSDB_LIB_DIR: /root/rocksdb/lib - ROCKSDB_STATIC: 1 diff --git a/README.md b/README.md index 4fa4120f5..d95093c52 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ cargo install --force cargo-make ### Branches - [`master`] is the current stable branch. - It must be ready, anytime, to deployed on chain at a moment's notice. + It must be ready, at all times, to be deployed on chain at a moment's notice. - [`develop`] is our bleeding-edge development branch. In general, kindly target all pull requests to this branch. @@ -53,37 +53,38 @@ cargo install --force cargo-make Every task with `cargo make` must have a `--profile` argument. The current available `profile`s are: -- `mainnet`, suitable for mainnet. -- `mainnet-silo`, silo contract suitable for mainnet. -- `testnet`, suitable for testnet. -- `testnet-silo`, silo contract suitable for testnet. -- `local`, suitable for local development. -- `custom`, suitable for custom environments, see note below. - -A custom environment may be required depending on the circumstances. This can +- `mainnet`: suitable for mainnet. +- `mainnet-silo`: silo contract suitable for mainnet. +- `testnet`: suitable for testnet. +- `testnet-silo`: silo contract suitable for testnet. +- `local`: suitable for local development. +- `custom`: suitable for custom environments, see note below. + +In some circumstances, you may require a custom environment. This can be created in the `.env` folder as `custom.env` following the structure of the other `.env` files. See `bin/local-custom.env` for more details. -Every make must follow the following pattern, though `--profile` is not required -for all such as cleanup: +Every `make` invocation must follow the following pattern, though `--profile` is +not required in all cases (such as cleanup): + ```sh cargo make [--profile ] ``` #### Building the engine and contracts -To build the binaries there are a few commands to do such following the format. +There are several commands that can be used to build the binaries. The currently supported parameters +for the `task` field are listed below: -The current available build `task`s are: -- `default`, does not need to be specified, runs `build`. Requires a `--profile` +- `default`: does not need to be specified, runs `build`. Requires a `--profile` argument. -- `build`, builds all engine smart contract and produces the +- `build`: builds all engine smart contract and produces the `aurora--test.wasm` in the `bin` folder. Requires `build-contracts`. Requires a `--profile` argument. -- `build-test`, builds all the below using test features. Requires a `--profile` +- `build-test`: builds all the below using test features. Requires a `--profile` argument. -- `build-contracts`, builds all the ETH contracts. -- `build-docker`, builds the `aurora--test.wasm` in the `bin` folder using docker build environment. The purpose of this task is to produce reproducible binaries. +- `build-contracts`: builds all the ETH contracts. +- `build-docker`: builds the `aurora--test.wasm` in the `bin` folder using docker build environment. The purpose of this task is to produce reproducible binaries. For example, the following will build the mainnet debug binary: ```sh @@ -92,7 +93,7 @@ cargo make --profile mainnet build #### Verifying binary hash -To verify that a deployed binary matches the source code, you may want build it reproducibly and then check that their hashes match. The motivation behind that is to prevent malicious code from being deployed. +To verify that a deployed binary matches the source code, you may want build it reproducibly and then verify that the SHA256 hash matches that of the deployed binary. The motivation behind this is to prevent malicious code from being deployed. Run these commands to produce the binary hash: ```sh @@ -103,11 +104,12 @@ shasum -a 256 bin/aurora-.wasm #### Running unit & integration tests To run tests, there are a few cargo make tasks we can run: -- `test`, tests the whole cargo workspace, ETH contracts and runs modexp benchmarks. Requires a `--profile` argument. -- `test-flow`, tests the whole cargo workspace and ETH contracts. Requires a `--profile` argument. -- `bench-modexp`, runs modexp benchmarks. Requires a `--profile` argument. -- `test-workspace`, tests only the cargo workspace. -- `test-contracts`, tests only the contracts. +- `test`: tests the whole cargo workspace and ETH contracts. Requires a `--profile` argument. +- `test-workspace`: tests only the cargo workspace. +- `test-contracts`: tests only the contracts. +- `test`: tests the whole cargo workspace, ETH contracts and runs modexp benchmarks. Requires a `--profile` argument. +- `test-flow`: tests the whole cargo workspace and ETH contracts. Requires a `--profile` argument. +- `bench-modexp`: runs modexp benchmarks. Requires a `--profile` argument. For example, the following will test the whole workspace and ETH contracts: ```sh @@ -116,13 +118,14 @@ cargo make --profile mainnet test #### Running checks & lints -To run lints and checks, the following tasks are available: -- `check`, checks the format, clippy and ETH contracts. -- `check-contracts`, runs yarn lints on the ETH contracts. -- `check-fmt`, checks the workspace Rust format only. -- `clippy`, checks the Rust workspace with clippy only. +The following tasks are available to run lints and checks: + +- `check`: checks the format, clippy and ETH contracts. +- `check-contracts` runs yarn lints on the ETH contracts. +- `check-fmt`: checks the workspace Rust format only. +- `clippy`: checks the Rust workspace with clippy only. -For example the following command will run the checks. `profile` is not required +For example, the following command will run the checks. `profile` is not required here: ``` cargo make check @@ -130,14 +133,16 @@ cargo make check #### Cleanup -To clean up the workspace, the following tasks are available: -- `clean`, cleans all built binaries and ETH contracts. -- `clean-cargo`, cleans with cargo. -- `clean-contracts`, cleans the ETH contracts. -- `clean-bin`, cleans the binaries. +The following tasks are available to clean up the workspace: + +- `clean`: cleans all built binaries and ETH contracts. +- `clean-cargo`: cleans with cargo. +- `clean-contracts`: cleans the ETH contracts. +- `clean-bin`: cleans the binaries. Additionally, there is also but not included in the `clean` task: -- `sweep`, sweeps the set amount of days in the ENV, default at 30 days. + +- `sweep`: sweeps the set amount of days in the ENV, default at 30 days. For example, the following command will clean everything. `profile` is not required: @@ -150,5 +155,5 @@ cargo make clean ## License **aurora-engine** has multiple licenses: -* all crates except `engine-test` has **CCO-1.0** license +* All crates except `engine-test` has **CCO-1.0** license * `engine-test` has **GPL-v3** license diff --git a/engine-tests/src/tests/uniswap.rs b/engine-tests/src/tests/uniswap.rs index ae4dfe522..ed97ae29f 100644 --- a/engine-tests/src/tests/uniswap.rs +++ b/engine-tests/src/tests/uniswap.rs @@ -38,7 +38,7 @@ fn test_uniswap_input_multihop() { let (_amount_out, _evm_gas, profile) = context.exact_input(&tokens, INPUT_AMOUNT.into()); - assert_eq!(114, profile.all_gas() / 1_000_000_000_000); + assert_eq!(115, profile.all_gas() / 1_000_000_000_000); } #[test] diff --git a/scripts/ci/build_rocksdb.sh b/scripts/ci/build_rocksdb.sh deleted file mode 100755 index 955a6735a..000000000 --- a/scripts/ci/build_rocksdb.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env bash - -ROCKSDB_VER=v8.1.1 -INSTALL_PATH=/root/rocksdb -LIB_PATH=$INSTALL_PATH/lib/librocksdb.a - -if [[ ! -f $LIB_PATH ]]; then - apt -y install cmake libgflags-dev libsnappy-dev libbz2-dev liblz4-dev libzstd-dev - git clone --branch $ROCKSDB_VER https://github.com/facebook/rocksdb - cd rocksdb && mkdir build && cd build - cmake -DCMAKE_BUILD_TYPE=Release -DWITH_ZLIB=1 -DWITH_SNAPPY=1 -DWITH_LZ4=1 -DWITH_ZSTD=1 -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH .. - make -j32 install - cache-util save rocksdb:$INSTALL_PATH - cd $HOME -fi