From c72932763aeba7a3529d772640c42c67bf652bdb Mon Sep 17 00:00:00 2001 From: Kiril Mihaylov <80464733+KirilMihaylov@users.noreply.github.com> Date: Thu, 19 Sep 2024 13:41:35 +0300 Subject: [PATCH] ci testing --- .github/test-data/protocol.json | 12 + .github/test-data/topology.json | 293 ++++++ .github/workflows/smart_contracts.yaml | 1265 ++++++++++++------------ 3 files changed, 962 insertions(+), 608 deletions(-) create mode 100644 .github/test-data/protocol.json create mode 100644 .github/test-data/topology.json diff --git a/.github/test-data/protocol.json b/.github/test-data/protocol.json new file mode 100644 index 000000000..fa10f069c --- /dev/null +++ b/.github/test-data/protocol.json @@ -0,0 +1,12 @@ +{ + "dex": "osmosis", + "dex_network": "OSMOSIS", + "liquidity_provider_currency_ticker": "USDC_AXELAR", + "stable_currency_ticker": "ATOM", + "lease_currencies_tickers": [ + "ATOM", + "AKT", + "JUNO", + "OSMO" + ] +} diff --git a/.github/test-data/topology.json b/.github/test-data/topology.json new file mode 100644 index 000000000..c60a6bee8 --- /dev/null +++ b/.github/test-data/topology.json @@ -0,0 +1,293 @@ +{ + "host_network": { + "name": "NOLUS", + "currency": { + "id": "NLS", + "native": { + "name": "Nolus", + "symbol": "unls", + "decimal_digits": "6" + } + } + }, + "networks": { + "OSMOSIS": { + "currencies": { + "OSMO": { + "native": { + "name": "Osmosis OSMO", + "symbol": "uosmo", + "decimal_digits": "6" + }, + "icon": "https://nolus.io/currencies/osmosis-osmo.svg" + }, + "USDC_AXELAR": { + "ibc": { + "network": "AXELAR", + "currency": "USDC" + }, + "icon": "https://nolus.io/currencies/osmosis-usdc.svg" + }, + "ATOM": { + "ibc": { + "network": "COSMOS_HUB", + "currency": "ATOM" + }, + "icon": "https://nolus.io/currencies/osmosis-atom.svg" + }, + "NLS": { + "ibc": { + "network": "NOLUS", + "currency": "NLS" + }, + "icon": "https://nolus.io/currencies/osmosis-nls.svg" + }, + "AKT": { + "ibc": { + "network": "AKASH", + "currency": "AKT" + }, + "icon": "https://nolus.io/currencies/osmosis-akt.svg" + }, + "JUNO": { + "ibc": { + "network": "JUNO", + "currency": "JUNO" + }, + "icon": "https://nolus.io/currencies/osmosis-juno.svg" + } + }, + "dexes": { + "osmosis": { + "type": "osmosis", + "swap_pairs": { + "AKT": [ + "OSMO" + ], + "ATOM": [ + "OSMO" + ], + "OSMO": [ + "AKT", + "ATOM" + ], + "NLS": [ + "AKT", + "ATOM" + ], + "USDC_AXELAR": [ + "NLS", + "OSMO" + ] + } + } + } + }, + "AXELAR": { + "currencies": { + "USDC": { + "native": { + "name": "Usdc", + "symbol": "uausdc", + "decimal_digits": "6" + } + } + } + }, + "COSMOS_HUB": { + "currencies": { + "ATOM": { + "native": { + "name": "Cosmos Hub ATOM", + "symbol": "uatom", + "decimal_digits": "6" + } + } + } + }, + "AKASH": { + "currencies": { + "AKT": { + "native": { + "name": "Akash", + "symbol": "uakt", + "decimal_digits": "6" + } + } + } + }, + "JUNO": { + "currencies": { + "JUNO": { + "native": { + "name": "Juno", + "symbol": "ujunox", + "decimal_digits": "6" + } + } + } + }, + "NEUTRON": { + "currencies": { + "NTRN": { + "native": { + "name": "Neutron", + "symbol": "untrn", + "decimal_digits": "6" + }, + "icon": "https://nolus.io/currencies/neutron-ntrn.svg" + }, + "USDC_AXELAR": { + "ibc": { + "network": "AXELAR", + "currency": "USDC" + }, + "icon": "https://nolus.io/currencies/neutron-usdc.svg" + }, + "ATOM": { + "ibc": { + "network": "COSMOS_HUB", + "currency": "ATOM" + }, + "icon": "https://nolus.io/currencies/neutron-atom.svg" + }, + "NLS": { + "ibc": { + "network": "NOLUS", + "currency": "NLS" + }, + "icon": "https://nolus.io/currencies/neutron-nls.svg" + } + }, + "dexes": { + "astroport": { + "type": "astroport_test", + "swap_pairs": { + "NTRN": [ + "NLS" + ], + "NLS": [ + "NTRN" + ], + "USDC_AXELAR": [ + "ATOM", + "NTRN" + ] + } + } + } + } + }, + "channels": [ + { + "a": { + "network": "NOLUS", + "ch": "channel-0" + }, + "b": { + "network": "OSMOSIS", + "ch": "channel-1636" + } + }, + { + "a": { + "network": "OSMOSIS", + "ch": "channel-3" + }, + "b": { + "network": "AXELAR", + "ch": "channel-227" + } + }, + { + "a": { + "network": "OSMOSIS", + "ch": "channel-73" + }, + "b": { + "network": "AKASH", + "ch": "channel-1" + } + }, + { + "a": { + "network": "COSMOS_HUB", + "ch": "channel-2500" + }, + "b": { + "network": "OSMOSIS", + "ch": "channel-12" + } + }, + { + "a": { + "network": "OSMOSIS", + "ch": "channel-1" + }, + "b": { + "network": "JUNO", + "ch": "channel-190" + } + }, + { + "a": { + "network": "NOLUS", + "ch": "channel-116" + }, + "b": { + "network": "NEUTRON", + "ch": "channel-209" + } + }, + { + "a": { + "network": "NEUTRON", + "ch": "channel-8" + }, + "b": { + "network": "AXELAR", + "ch": "channel-237" + } + }, + { + "a": { + "network": "NEUTRON", + "ch": "channel-1" + }, + "b": { + "network": "COSMOS_HUB", + "ch": "channel-16" + } + } + ], + "definitions": [ + "This is the descriptor of the network topology and currencies of interest for the Nolus AMM protocol.", + "", + "The network topology is represented as a collection of networks and the ICS-20 transfer channels that connect them.", + "Some networks may have DEX services available. Each DEX is uniquely named and should have a type supported by Nolus.", + "The supported types are `osmosis`, `astroport_test`, and `astroport_main`.", + "", + "On a given network, each currency is identified by its 'ticker'. A currency with ticker NLS on a network NOLUS is required.", + "The Nolus network description should not contain other currencies. They are defined in the 'protocols' object.", + "", + "A currency is either native or ibc on a network. In the latter case it points to the 'burning' currency residing at a network", + "that is at one hop distance. In the former case it is described with name, symbol and number of decimal digits.", + "", + "The 'name' is a human-readable description of the currency", + "", + "The 'symbol' is the base denomination of the currency at its native chain.", + "", + "The 'decimal_digits' value represents the number of decimal digits this denomination has.", + "For example, '6' for OSMO means 10^6 units of its base denomination uosmo are equal to 1 OSMO", + "", + "The 'icon' is an optional currency attribute that provides a visual representation of the currency at that network and the others", + "where the currency might be sent over ibc. In other workds, if there is no icon attribute of an ibc originating currency then ", + "the icon is derived from the network and currency it points to. This might be applied multiple times traversing the ibc path ", + "toward its native network.", + "", + "The currency symbol at a given network is either equal to the currency 'symbol' if it is a native for that network, or ", + "'ibc/' + sha256('transfer' + '/' + ch[0] + '/' + ... + 'transfer' + '/' + ch[k] + '/' + symbol) if it is a native on ", + "network 'K' reachable through a sequence of channels with names 'ch[0]', 'ch[1]' ... 'ch[k]' at their minting side.", + "More info is available [here](https://github.com/cosmos/ibc-go/blob/c86d27fc280cfb342a9e4689b381e5823441b694/modules/apps/transfer/types/trace.go#L19)." + ] +} \ No newline at end of file diff --git a/.github/workflows/smart_contracts.yaml b/.github/workflows/smart_contracts.yaml index de61c85e5..0f32a5cbd 100644 --- a/.github/workflows/smart_contracts.yaml +++ b/.github/workflows/smart_contracts.yaml @@ -12,6 +12,7 @@ on: push: branches: - "main" + - "feat-currency-generation" tags: - "*" paths-ignore: @@ -44,628 +45,676 @@ env: ${{ toJSON(github.ref_type == 'tag' || (github.event_name == 'workflow_dispatch' && inputs.upload-artifacts)) }} jobs: - configuration: + checks: runs-on: "ubuntu-latest" - name: "Configuration" - outputs: - stable-rust-version: |- - ${{ steps.configuration.outputs.stable-rust-version }} - nightly-rust-version: |- - ${{ steps.configuration.outputs.nightly-rust-version }} - dev-profile-with-debug-assertions: |- - ${{ steps.configuration.outputs.dev-profile-with-debug-assertions }} - dev-profile-without-debug-assertions: |- - ${{ steps.configuration.outputs.dev-profile-without-debug-assertions }} - formatting-matrix-json: |- - ${{ steps.configuration.outputs.formatting-matrix-json }} - linting-matrix-json: |- - ${{ steps.configuration.outputs.linting-matrix-json }} - unused-deps-matrix-json: |- - ${{ steps.configuration.outputs.unused-deps-matrix-json }} - packages-tests-matrix-json: |- - ${{ steps.configuration.outputs.packages-tests-matrix-json }} - build-optimized-matrix-json: |- - ${{ steps.configuration.outputs.build-optimized-matrix-json }} - available-wasm-capabilities: |- - ${{ steps.configuration.outputs.available-wasm-capabilities }} - networks-and-protocols-json: |- - ${{ steps.configuration.outputs.networks-and-protocols-json }} steps: - uses: "actions/checkout@v4" - - id: "configuration" - uses: "./.github/actions/configuration" - install_crates-io_tooling: - runs-on: "ubuntu-latest" - strategy: - fail-fast: true - matrix: - tool: - # Add necessary tooling - - "cargo-audit" - - "cargo-nextest" - - "cargo-udeps" - - "cosmwasm-check" - name: |- - Install tool [${{ matrix.tool }}; crates.io] - steps: - - uses: "actions/checkout@v4" - - uses: "./.github/actions/install-tool" - with: - no-fetching: "true" - fail-on-cache-miss: "false" - tool: |- - ${{ matrix.tool }} - local: "false" - cache_stable_rust_toolchain: - runs-on: "ubuntu-latest" - needs: - - "configuration" - name: "Cache stable Rust toolchain" - steps: - - uses: "actions/checkout@v4" - - id: "restore-cache" - uses: "./.github/actions/cache-rust" - with: - cache-cargo: "false" - cache-rust-stable: "true" - rust-stable: |- - ${{ needs.configuration.outputs.stable-rust-version }} - cache-rust-nightly: "false" - no-fetching: "true" - fail-on-cache-miss: "false" - cache_nightly_rust_toolchain: - runs-on: "ubuntu-latest" - needs: - - "configuration" - name: "Cache nightly Rust toolchains" - steps: - - uses: "actions/checkout@v4" - - id: "restore-cache" - uses: "./.github/actions/cache-rust" - with: - cache-cargo: "false" - cache-rust-stable: "false" - cache-rust-nightly: "true" - rust-nightly: |- - ${{ needs.configuration.outputs.nightly-rust-version }} - no-fetching: "true" - fail-on-cache-miss: "false" - cache_cargo_and_vendor_deps: - runs-on: "ubuntu-latest" - needs: - - "configuration" - - "cache_stable_rust_toolchain" - strategy: - fail-fast: true - matrix: - working-directory: - - "platform" - - "protocol" - - "tests" - - "tools" - name: |- - Cache Cargo and vendor dependencies [${{ matrix.working-directory }}] - steps: - - uses: "actions/checkout@v4" - - id: "restore-cache" - uses: "./.github/actions/cache-rust" - with: - cache-cargo: "true" - working-directory: |- - ${{ matrix.working-directory }} - cache-rust-stable: "true" - rust-stable: |- - ${{ needs.configuration.outputs.stable-rust-version }} - cache-rust-nightly: "false" - no-fetching: "true" - fail-on-cache-miss: "false" - check_deps_versions: - runs-on: "ubuntu-latest" - needs: - - "configuration" - - "cache_stable_rust_toolchain" - strategy: - fail-fast: true - matrix: - working-directory: - - "platform" - - "protocol" - - "tests" - - "tools" - name: |- - Check dependencies' versions [${{ matrix.working-directory }}] - steps: - - if: |- - env.UPLOAD_ARTIFACTS == 'true' - uses: "actions/checkout@v4" - - uses: "./.github/actions/cache-rust" - if: |- - env.UPLOAD_ARTIFACTS == 'true' - with: - cache-cargo: "false" - cache-rust-stable: "true" - rust-stable: |- - ${{ needs.configuration.outputs.stable-rust-version }} - cache-rust-nightly: "false" - no-fetching: "false" - fail-on-cache-miss: "true" - - if: |- - env.UPLOAD_ARTIFACTS == 'true' - env: - stable_rust_version: |- - ${{ needs.configuration.outputs.stable-rust-version }} - run: |- - set -e - - "cargo" \ - "+${stable_rust_version:?}" \ - "update" \ - --locked - working-directory: |- - ${{ matrix.working-directory }} - audit_dependencies: - runs-on: "ubuntu-latest" - needs: - - "configuration" - - "cache_stable_rust_toolchain" - - "check_deps_versions" - - "install_crates-io_tooling" - strategy: - fail-fast: true - matrix: - working-directory: - - "platform" - - "protocol" - - "tests" - - "tools" - name: |- - Audit dependencies [${{ matrix.working-directory }}] - steps: - - uses: "actions/checkout@v4" - - uses: "./.github/actions/cache-rust" - with: - cache-cargo: "false" - cache-rust-stable: "true" - rust-stable: |- - ${{ needs.configuration.outputs.stable-rust-version }} - cache-rust-nightly: "false" - no-fetching: "false" - fail-on-cache-miss: "true" - - uses: "./.github/actions/install-tool" - with: - no-fetching: "false" - fail-on-cache-miss: "true" - tool: "cargo-audit" - local: "false" - - env: - working_directory: |- - ${{ matrix.working-directory }} - run: |- - set -eu - - if "[" "-f" "./.cargo/audit.toml" "]" - then - if ! "[" "-d" "${working_directory}/.cargo" "]" - then - "mkdir" "${working_directory:?}/.cargo" - fi - - "cp" \ - "./.cargo/audit.toml" \ - "${working_directory:?}/.cargo/audit.toml" - fi - - env: - stable_rust_version: |- - ${{ needs.configuration.outputs.stable-rust-version }} - run: |- - set -e - - "cargo" \ - "+${stable_rust_version:?}" \ - "audit" - working-directory: |- - ${{ matrix.working-directory }} - check_formatting: - runs-on: "ubuntu-latest" - needs: - - "configuration" - - "cache_stable_rust_toolchain" - strategy: - fail-fast: true - ### GitHub Actions escaped string - matrix: "${{ fromJSON(needs.configuration.outputs.formatting-matrix-json) }}" - name: |- - Check formatting [${{ matrix.working-directory }}; ${{ matrix.network }}; ${{ matrix.protocol }}] - steps: - - uses: "actions/checkout@v4" - - uses: "./.github/actions/cache-rust" - with: - cache-cargo: "false" - cache-rust-stable: "true" - rust-stable: |- - ${{ needs.configuration.outputs.stable-rust-version }} - cache-rust-nightly: "false" - no-fetching: "false" - fail-on-cache-miss: "true" - - env: - stable_rust_version: |- - ${{ needs.configuration.outputs.stable-rust-version }} - if: |- - matrix.working-directory != 'protocol' || ( - matrix.network != '@agnostic' && matrix.protocol != '@agnostic' - ) - run: |- - set -e - - "cargo" \ - "+${stable_rust_version:?}" \ - "fmt" \ - --check - working-directory: |- - ${{ matrix.working-directory }} - install_local_tooling: - runs-on: "ubuntu-latest" - needs: - - "configuration" - - "cache_stable_rust_toolchain" - - "cache_cargo_and_vendor_deps" - - "check_deps_versions" - - "check_formatting" - strategy: - fail-fast: true - matrix: - tool: - # Add necessary tooling - - "cargo-each" - name: |- - Install tool [${{ matrix.tool }}; local] - steps: - - uses: "actions/checkout@v4" - - uses: "./.github/actions/cache-rust" - with: - cache-cargo: "true" - working-directory: "tools" - cache-rust-stable: "true" - rust-stable: |- - ${{ needs.configuration.outputs.stable-rust-version }} - cache-rust-nightly: "false" - no-fetching: "false" - fail-on-cache-miss: "false" - - uses: "./.github/actions/install-tool" - with: - no-fetching: "true" - fail-on-cache-miss: "false" - tool: |- - ${{ matrix.tool }} - local: "true" - rust-version: |- - ${{ needs.configuration.outputs.stable-rust-version }} - tools-deps-restored: "true" - linting: - runs-on: 'ubuntu-latest' - needs: - - "configuration" - - "cache_stable_rust_toolchain" - - "cache_cargo_and_vendor_deps" - - "install_crates-io_tooling" - - "audit_dependencies" - - "check_formatting" - - "install_local_tooling" - strategy: - fail-fast: true - ### GitHub Actions escaped string - matrix: "${{ fromJSON(needs.configuration.outputs.linting-matrix-json) }}" - name: |- - Linting [${{ matrix.working-directory }}; ${{ matrix.network }}; ${{ matrix.protocol }}; ${{ matrix.profile }}] - steps: - - uses: "actions/checkout@v4" - - uses: "./.github/actions/linting" - with: - rust-version: |- - ${{ needs.configuration.outputs.stable-rust-version }} - working-directory: |- - ${{ matrix.working-directory }} - network: |- - ${{ matrix.network }} - protocol: |- - ${{ matrix.protocol }} - profile: |- - ${{ matrix.profile }} - unused_deps: - runs-on: 'ubuntu-latest' - needs: - - "configuration" - - "cache_stable_rust_toolchain" - - "cache_nightly_rust_toolchain" - - "cache_cargo_and_vendor_deps" - - "install_crates-io_tooling" - - "audit_dependencies" - - "check_formatting" - - "install_local_tooling" - strategy: - fail-fast: false - ### GitHub Actions escaped string - matrix: "${{ fromJSON(needs.configuration.outputs.unused-deps-matrix-json) }}" - name: |- - Check for unused dependencies [${{ matrix.working-directory }}; ${{ matrix.network }}; ${{ matrix.protocol }}] - steps: - - uses: "actions/checkout@v4" - - uses: "./.github/actions/unused-deps" - with: - stable-rust-version: |- - ${{ needs.configuration.outputs.stable-rust-version }} - nightly-rust-version: |- - ${{ needs.configuration.outputs.nightly-rust-version }} - working-directory: |- - ${{ matrix.working-directory }} - network: |- - ${{ matrix.network }} - protocol: |- - ${{ matrix.protocol }} - packages_tests: - runs-on: "ubuntu-latest" - needs: - - "configuration" - - "cache_stable_rust_toolchain" - - "cache_cargo_and_vendor_deps" - - "install_crates-io_tooling" - - "audit_dependencies" - - "check_formatting" - - "install_local_tooling" - strategy: - fail-fast: false - ### GitHub Actions escaped string - matrix: "${{ fromJSON(needs.configuration.outputs.packages-tests-matrix-json) }}" - name: |- - Run packages' tests [${{ matrix.working-directory }}; ${{ matrix.network }}; ${{ matrix.protocol }}] - steps: - - uses: "actions/checkout@v4" - - uses: "./.github/actions/run-tests" - with: - rust-version: |- - ${{ needs.configuration.outputs.stable-rust-version }} - working-directory: |- - ${{ matrix.working-directory }} - network: |- - ${{ matrix.network }} - protocol: |- - ${{ matrix.protocol }} - profile: |- - ${{ needs.configuration.outputs.dev-profile-with-debug-assertions }} - build_optimizer_image: - runs-on: "ubuntu-latest" - needs: - - "configuration" - - "cache_cargo_and_vendor_deps" - - "check_deps_versions" - - "audit_dependencies" - - "check_formatting" - name: "Build optimizer image" - outputs: - container-cache-id: |- - ${{ steps.container-cache-id.outputs.id }} - steps: - - uses: "actions/checkout@v4" - - id: "container-cache-id" - env: - file_hashes: |- - ${{ hashFiles( - './Containerfile', - './scripts/build-and-optimize.sh', - './tools/cargo-each/**', - './tools/Cargo.lock' - ) }} - stable_rust_version: |- - ${{ needs.configuration.outputs.stable-rust-version }} - run: |- - set -eu - - digest="$( - "sha256sum" \ - --tag \ - <>"${GITHUB_OUTPUT:?}" \ - <"./changelog" - - name: "Create draft release" - uses: "softprops/action-gh-release@v2" - with: - name: |- - ${{ github.ref_name }} - draft: true - body_path: "./changelog" - generate_release_notes: false - files: | - ./artifacts/*.zip + while read -r directory + do + "cp" \ + -R \ + "./.cargo" \ + "./${directory}/.cargo" + done \ + <>"${GITHUB_OUTPUT:?}" \ +# <"./changelog" +# - name: "Create draft release" +# uses: "softprops/action-gh-release@v2" +# with: +# name: |- +# ${{ github.ref_name }} +# draft: true +# body_path: "./changelog" +# generate_release_notes: false +# files: | +# ./artifacts/*.zip