From 43e2e7bcf9a6c7f241b236f525916afcb84c39d2 Mon Sep 17 00:00:00 2001 From: rabi-siddique Date: Tue, 17 Dec 2024 13:59:24 +0500 Subject: [PATCH 01/10] ci: initial setup for liquidation testing --- .github/workflows/liquidation.yml | 29 +++++++++++++++++++++++++++++ package.json | 1 + 2 files changed, 30 insertions(+) create mode 100644 .github/workflows/liquidation.yml diff --git a/.github/workflows/liquidation.yml b/.github/workflows/liquidation.yml new file mode 100644 index 00000000..60b82b6e --- /dev/null +++ b/.github/workflows/liquidation.yml @@ -0,0 +1,29 @@ +name: Liquidation Testing +on: + pull_request: + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Start A3P container + run: docker run -d -p 26657:26657 -p 1317:1317 -p 9090:9090 --name a3p ghcr.io/agoric/agoric-3-proposals:latest + + - run: corepack enable + shell: bash + + - name: Setup Node.js environment + uses: actions/setup-node@v4 + with: + node-version: 18 + cache: yarn + + - name: Install dependencies + run: yarn install + + - name: Start subql indexer + run: yarn dev:ci + env: + AGORIC_NET: docker diff --git a/package.json b/package.json index 2811b755..49b376ea 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "codegen": "subql codegen", "start:docker": "docker-compose pull && docker-compose up --remove-orphans", "dev": "subql codegen && subql build && docker-compose pull && docker-compose up --remove-orphans", + "dev:ci": "subql codegen && subql build && docker compose pull && docker compose up --remove-orphans --detach", "prepack": "rm -rf dist && npm run build", "test": "subql build && subql-node-cosmos test", "prettier:check": "prettier --list-different . --print-width 120", From 8ed0d81f085f7f0fab44b9a349efe732390121da Mon Sep 17 00:00:00 2001 From: rabi-siddique Date: Tue, 17 Dec 2024 14:30:41 +0500 Subject: [PATCH 02/10] ci: set ATOM price and create vaults --- .github/actions/createVault/action.yml | 48 ++++++++++++++++++++++++++ .github/workflows/liquidation.yml | 36 +++++++++++++++++-- package.json | 2 +- 3 files changed, 83 insertions(+), 3 deletions(-) create mode 100644 .github/actions/createVault/action.yml diff --git a/.github/actions/createVault/action.yml b/.github/actions/createVault/action.yml new file mode 100644 index 00000000..d0f4eea0 --- /dev/null +++ b/.github/actions/createVault/action.yml @@ -0,0 +1,48 @@ +name: 'Create Vault' +description: 'Creates a vault and broadcasts an offer within an A3P container' +inputs: + wantMinted: + description: 'Amount of currency to be minted by the vault' + required: true + giveCollateral: + description: 'Collateral amount to secure the minted currency' + required: true + userKey: + description: 'User key to authenticate the transaction' + required: true + agoricNet: + description: 'Agoric network configuration' + required: true + commandTimeout: + description: 'Maximum time in seconds for the command to complete' + required: true + containerName: + description: 'Name of the Docker container where the commands will be executed' + required: true + +runs: + using: 'composite' + steps: + - name: Create Vault + shell: bash + run: | + createVaultCommand="/usr/src/agoric-sdk/packages/agoric-cli/bin/agops vaults open --wantMinted \"${{ inputs.wantMinted }}\" --giveCollateral \"${{ inputs.giveCollateral }}\" > /tmp/want-ist.json" + echo "Executing create vault command in the container..." + output=$(docker exec ${{ inputs.containerName }} /bin/bash -c "env AGORIC_NET=${{ inputs.agoricNet }} timeout ${{ inputs.commandTimeout }} $createVaultCommand") + + if echo "$output" | grep -q 'Error'; then + echo "Error found during vault creation: $output" + exit 1 + fi + - name: Broadcast Offer + shell: bash + run: | + broadcastCommand="/usr/src/agoric-sdk/packages/agoric-cli/bin/agops perf satisfaction --executeOffer /tmp/want-ist.json --from \"${{ inputs.userKey }}\" --keyring-backend=test" + echo "Executing broadcast command in the container..." + output=$(docker exec ${{ inputs.containerName }} /bin/bash -c "env AGORIC_NET=${{ inputs.agoricNet }} timeout ${{ inputs.commandTimeout }} $broadcastCommand") + + if echo "$output" | grep -q 'Error'; then + echo "Error found during broadcast: $output" + exit 1 + else + echo "Broadcast successful: $output" diff --git a/.github/workflows/liquidation.yml b/.github/workflows/liquidation.yml index 60b82b6e..b4b3b56a 100644 --- a/.github/workflows/liquidation.yml +++ b/.github/workflows/liquidation.yml @@ -25,5 +25,37 @@ jobs: - name: Start subql indexer run: yarn dev:ci - env: - AGORIC_NET: docker + + - name: Set ATOM Price to 12.34 + run: | + docker exec a3p /usr/src/agoric-sdk/packages/agoric-cli/bin/agops oracle setPrice --keys gov1,gov2 --pair ATOM.USD --price 12.34 --keyring-backend=test + + - name: Create Vault with 100 Minted and 15 Collateral + uses: ./.github/actions/createVault + with: + wantMinted: '100' + giveCollateral: '15' + userKey: 'user1' + agoricNet: 'local' + commandTimeout: '120' + containerName: 'a3p' + + - name: Create Vault with 103 Minted and 15 Collateral + uses: ./.github/actions/createVault + with: + wantMinted: '103' + giveCollateral: '15' + userKey: 'user1' + agoricNet: 'local' + commandTimeout: '120' + containerName: 'a3p' + + - name: Create Vault with 105 Minted and 15 Collateral + uses: ./.github/actions/createVault + with: + wantMinted: '105' + giveCollateral: '15' + userKey: 'user1' + agoricNet: 'local' + commandTimeout: '120' + containerName: 'a3p' diff --git a/package.json b/package.json index 49b376ea..e9c7ec51 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "codegen": "subql codegen", "start:docker": "docker-compose pull && docker-compose up --remove-orphans", "dev": "subql codegen && subql build && docker-compose pull && docker-compose up --remove-orphans", - "dev:ci": "subql codegen && subql build && docker compose pull && docker compose up --remove-orphans --detach", + "dev:ci": "AGORIC_NET=docker subql codegen && subql build && docker compose pull && docker compose up --remove-orphans --detach", "prepack": "rm -rf dist && npm run build", "test": "subql build && subql-node-cosmos test", "prettier:check": "prettier --list-different . --print-width 120", From 998e5b4ade15e3f3c96bcfbd992a34fe81cecfd8 Mon Sep 17 00:00:00 2001 From: rabi-siddique Date: Tue, 17 Dec 2024 15:07:49 +0500 Subject: [PATCH 03/10] ci: place bids and set ATOM price to 9.99 --- .github/actions/createVault/action.yml | 14 ++------ .github/actions/placeBid/action.yml | 40 +++++++++++++++++++++++ .github/workflows/liquidation.yml | 45 +++++++++++++++++++++++--- 3 files changed, 84 insertions(+), 15 deletions(-) create mode 100644 .github/actions/placeBid/action.yml diff --git a/.github/actions/createVault/action.yml b/.github/actions/createVault/action.yml index d0f4eea0..3460914a 100644 --- a/.github/actions/createVault/action.yml +++ b/.github/actions/createVault/action.yml @@ -28,21 +28,13 @@ runs: run: | createVaultCommand="/usr/src/agoric-sdk/packages/agoric-cli/bin/agops vaults open --wantMinted \"${{ inputs.wantMinted }}\" --giveCollateral \"${{ inputs.giveCollateral }}\" > /tmp/want-ist.json" echo "Executing create vault command in the container..." - output=$(docker exec ${{ inputs.containerName }} /bin/bash -c "env AGORIC_NET=${{ inputs.agoricNet }} timeout ${{ inputs.commandTimeout }} $createVaultCommand") - if echo "$output" | grep -q 'Error'; then - echo "Error found during vault creation: $output" - exit 1 - fi + docker exec ${{ inputs.containerName }} /bin/bash -c "env AGORIC_NET=${{ inputs.agoricNet }} timeout ${{ inputs.commandTimeout }} $createVaultCommand" + - name: Broadcast Offer shell: bash run: | broadcastCommand="/usr/src/agoric-sdk/packages/agoric-cli/bin/agops perf satisfaction --executeOffer /tmp/want-ist.json --from \"${{ inputs.userKey }}\" --keyring-backend=test" echo "Executing broadcast command in the container..." - output=$(docker exec ${{ inputs.containerName }} /bin/bash -c "env AGORIC_NET=${{ inputs.agoricNet }} timeout ${{ inputs.commandTimeout }} $broadcastCommand") - if echo "$output" | grep -q 'Error'; then - echo "Error found during broadcast: $output" - exit 1 - else - echo "Broadcast successful: $output" + docker exec ${{ inputs.containerName }} /bin/bash -c "env AGORIC_NET=${{ inputs.agoricNet }} timeout ${{ inputs.commandTimeout }} $broadcastCommand" diff --git a/.github/actions/placeBid/action.yml b/.github/actions/placeBid/action.yml new file mode 100644 index 00000000..b8375a35 --- /dev/null +++ b/.github/actions/placeBid/action.yml @@ -0,0 +1,40 @@ +name: 'Place Bids' +description: 'Place bids by price or discount' +inputs: + fromAddress: + description: 'Address from which the bid is made' + required: true + giveAmount: + description: 'Amount to offer in the bid' + required: true + priceOrDiscount: + description: 'Price or discount to apply to the bid' + required: true + commandType: + description: 'Type of command to execute (by-price or by-discount)' + required: true + agoricNet: + description: 'Agoric network configuration' + required: true + commandTimeout: + description: 'Maximum time in seconds for the command to complete' + required: true + containerName: + description: 'Name of the Docker container where the commands will be executed' + required: true + +runs: + using: 'composite' + steps: + - name: Place Bid + shell: bash + run: | + if [ "${{ inputs.commandType }}" == "by-price" ]; then + commandType="bid by-price --price" + elif [ "${{ inputs.commandType }}" == "by-discount" ]; then + commandType="bid by-discount --discount" + fi + + command="/usr/src/agoric-sdk/packages/agoric-cli/bin/agops inter ${commandType} \"${{ inputs.priceOrDiscount }}\" --from \"${{ inputs.fromAddress }}\" --give \"${{ inputs.giveAmount }}\" --keyring-backend=test" + echo "Executing command in the container..." + docker exec ${{ inputs.containerName }} /bin/bash -c "env AGORIC_NET=${{ inputs.agoricNet }} timeout ${{ inputs.commandTimeout }} $command" diff --git a/.github/workflows/liquidation.yml b/.github/workflows/liquidation.yml index b4b3b56a..8247f147 100644 --- a/.github/workflows/liquidation.yml +++ b/.github/workflows/liquidation.yml @@ -1,4 +1,4 @@ -name: Liquidation Testing +name: Liquidation Indexing on: pull_request: @@ -35,7 +35,7 @@ jobs: with: wantMinted: '100' giveCollateral: '15' - userKey: 'user1' + userKey: 'gov3' agoricNet: 'local' commandTimeout: '120' containerName: 'a3p' @@ -45,7 +45,7 @@ jobs: with: wantMinted: '103' giveCollateral: '15' - userKey: 'user1' + userKey: 'gov3' agoricNet: 'local' commandTimeout: '120' containerName: 'a3p' @@ -55,7 +55,44 @@ jobs: with: wantMinted: '105' giveCollateral: '15' - userKey: 'user1' + userKey: 'gov3' agoricNet: 'local' commandTimeout: '120' containerName: 'a3p' + + - name: Place bid for 90IST + uses: ./.github/actions/placeBid + with: + fromAddress: 'gov1' + giveAmount: '90IST' + priceOrDiscount: '9' + commandType: 'by-price' + agoricNet: 'local' + commandTimeout: '120' + containerName: 'a3p' + + - name: Place bid for 80IST + uses: ./.github/actions/placeBid + with: + fromAddress: 'gov1' + giveAmount: '80IST' + priceOrDiscount: '10' + commandType: 'by-discount' + agoricNet: 'local' + commandTimeout: '120' + containerName: 'a3p' + + - name: Place bid for 150IST + uses: ./.github/actions/placeBid + with: + fromAddress: 'gov1' + giveAmount: '150IST' + priceOrDiscount: '15' + commandType: 'by-discount' + agoricNet: 'local' + commandTimeout: '120' + containerName: 'a3p' + + - name: Set ATOM Price to 9.99 + run: | + docker exec a3p /usr/src/agoric-sdk/packages/agoric-cli/bin/agops oracle setPrice --keys gov1,gov2 --pair ATOM.USD --price 9.99 --keyring-backend=test From 69a9a8207058192091e8cd26d797e5968433e4d9 Mon Sep 17 00:00:00 2001 From: rabi-siddique Date: Tue, 17 Dec 2024 16:34:51 +0500 Subject: [PATCH 04/10] ci: get active vaults --- .github/actions/createVault/action.yml | 40 -------- .github/actions/placeBid/action.yml | 40 -------- .github/scripts/changePrice.mjs | 36 +++++++ .github/scripts/createVault.mjs | 37 +++++++ .github/scripts/getActiveVaults.mjs | 55 ++++++++++ .github/scripts/placeBid.mjs | 47 +++++++++ .github/workflows/liquidation.yml | 80 ++++++++++----- docker-compose.yml | 34 +++++-- package.json | 4 +- project.ts | 6 ++ yarn.lock | 136 +++++++++++++++++++++++++ 11 files changed, 400 insertions(+), 115 deletions(-) delete mode 100644 .github/actions/createVault/action.yml delete mode 100644 .github/actions/placeBid/action.yml create mode 100644 .github/scripts/changePrice.mjs create mode 100644 .github/scripts/createVault.mjs create mode 100644 .github/scripts/getActiveVaults.mjs create mode 100644 .github/scripts/placeBid.mjs diff --git a/.github/actions/createVault/action.yml b/.github/actions/createVault/action.yml deleted file mode 100644 index 3460914a..00000000 --- a/.github/actions/createVault/action.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: 'Create Vault' -description: 'Creates a vault and broadcasts an offer within an A3P container' -inputs: - wantMinted: - description: 'Amount of currency to be minted by the vault' - required: true - giveCollateral: - description: 'Collateral amount to secure the minted currency' - required: true - userKey: - description: 'User key to authenticate the transaction' - required: true - agoricNet: - description: 'Agoric network configuration' - required: true - commandTimeout: - description: 'Maximum time in seconds for the command to complete' - required: true - containerName: - description: 'Name of the Docker container where the commands will be executed' - required: true - -runs: - using: 'composite' - steps: - - name: Create Vault - shell: bash - run: | - createVaultCommand="/usr/src/agoric-sdk/packages/agoric-cli/bin/agops vaults open --wantMinted \"${{ inputs.wantMinted }}\" --giveCollateral \"${{ inputs.giveCollateral }}\" > /tmp/want-ist.json" - echo "Executing create vault command in the container..." - - docker exec ${{ inputs.containerName }} /bin/bash -c "env AGORIC_NET=${{ inputs.agoricNet }} timeout ${{ inputs.commandTimeout }} $createVaultCommand" - - - name: Broadcast Offer - shell: bash - run: | - broadcastCommand="/usr/src/agoric-sdk/packages/agoric-cli/bin/agops perf satisfaction --executeOffer /tmp/want-ist.json --from \"${{ inputs.userKey }}\" --keyring-backend=test" - echo "Executing broadcast command in the container..." - - docker exec ${{ inputs.containerName }} /bin/bash -c "env AGORIC_NET=${{ inputs.agoricNet }} timeout ${{ inputs.commandTimeout }} $broadcastCommand" diff --git a/.github/actions/placeBid/action.yml b/.github/actions/placeBid/action.yml deleted file mode 100644 index b8375a35..00000000 --- a/.github/actions/placeBid/action.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: 'Place Bids' -description: 'Place bids by price or discount' -inputs: - fromAddress: - description: 'Address from which the bid is made' - required: true - giveAmount: - description: 'Amount to offer in the bid' - required: true - priceOrDiscount: - description: 'Price or discount to apply to the bid' - required: true - commandType: - description: 'Type of command to execute (by-price or by-discount)' - required: true - agoricNet: - description: 'Agoric network configuration' - required: true - commandTimeout: - description: 'Maximum time in seconds for the command to complete' - required: true - containerName: - description: 'Name of the Docker container where the commands will be executed' - required: true - -runs: - using: 'composite' - steps: - - name: Place Bid - shell: bash - run: | - if [ "${{ inputs.commandType }}" == "by-price" ]; then - commandType="bid by-price --price" - elif [ "${{ inputs.commandType }}" == "by-discount" ]; then - commandType="bid by-discount --discount" - fi - - command="/usr/src/agoric-sdk/packages/agoric-cli/bin/agops inter ${commandType} \"${{ inputs.priceOrDiscount }}\" --from \"${{ inputs.fromAddress }}\" --give \"${{ inputs.giveAmount }}\" --keyring-backend=test" - echo "Executing command in the container..." - docker exec ${{ inputs.containerName }} /bin/bash -c "env AGORIC_NET=${{ inputs.agoricNet }} timeout ${{ inputs.commandTimeout }} $command" diff --git a/.github/scripts/changePrice.mjs b/.github/scripts/changePrice.mjs new file mode 100644 index 00000000..707293b2 --- /dev/null +++ b/.github/scripts/changePrice.mjs @@ -0,0 +1,36 @@ +import { execa } from 'execa'; +import assert from 'assert'; + +const agops = '/usr/src/agoric-sdk/packages/agoric-cli/bin/agops'; + +const amount = process.env.amount; +const containerName = process.env.containerName; +const agoricNet = process.env.agoricNet; + +if (!amount || !containerName || !agoricNet) { + console.error('Error: Missing one or more required parameters:'); + if (!amount) console.error('Missing amount'); + if (!containerName) console.error('Missing containerName'); + if (!agoricNet) console.error('Missing agoricNet'); + process.exit(1); +} + +const setAtomPrice = async (amount, containerName, agoricNet) => { + try { + console.log(`Initiating price change to ${amount} for ATOM...`); + + const env = { + AGORIC_NET: agoricNet, + }; + + const command = `${agops} oracle setPrice --keys gov1,gov2 --pair ATOM.USD --price ${amount} --keyring-backend=test`; + const { stdout, stderr } = await execa('docker', ['exec', containerName, command], { env, shell: true }); + + assert.strictEqual(stderr, '', `Expected stderr to be empty, but received: '${stderr}'`); + console.log('Standard output:', stdout); + } catch (error) { + console.error('Error:', error); + } +}; + +setAtomPrice(amount, containerName, agoricNet); diff --git a/.github/scripts/createVault.mjs b/.github/scripts/createVault.mjs new file mode 100644 index 00000000..ad0bbff8 --- /dev/null +++ b/.github/scripts/createVault.mjs @@ -0,0 +1,37 @@ +import { execa } from 'execa'; +import assert from 'assert'; + +const agops = '/usr/src/agoric-sdk/packages/agoric-cli/bin/agops'; + +const createVault = async (containerName, agoricNet, userKey, wantMinted, giveCollateral) => { + console.log('Starting the vault creation process...'); + + try { + const env = { + AGORIC_NET: agoricNet, + }; + + const command = `${agops} vaults open --wantMinted ${wantMinted} --giveCollateral ${giveCollateral} > /tmp/want-ist.json`; + await execa('docker', ['exec', containerName, `bash -c "${command}"`], { env, shell: true }); + + const broadCastCommand = `${agops} perf satisfaction --executeOffer /tmp/want-ist.json --from ${userKey} --keyring-backend=test`; + const { stdout } = await execa('docker', ['exec', containerName, broadCastCommand], { + env, + shell: true, + }); + + assert.ok(!stdout.includes('Error'), `Expected 'stdout' not to contain 'Error'`); + console.log('Standard output:', stdout); + } catch (error) { + console.error('Error during vault creation:', error); + process.exit(1); + } +}; + +const containerName = process.env.containerName; +const agoricNet = process.env.agoricNet; +const userKey = process.env.userKey; +const wantMinted = process.env.wantMinted; +const giveCollateral = process.env.giveCollateral; + +createVault(containerName, agoricNet, userKey, wantMinted, giveCollateral); diff --git a/.github/scripts/getActiveVaults.mjs b/.github/scripts/getActiveVaults.mjs new file mode 100644 index 00000000..a62f48f9 --- /dev/null +++ b/.github/scripts/getActiveVaults.mjs @@ -0,0 +1,55 @@ +import fetch from 'node-fetch'; + +const delay = (ms) => { + return new Promise((resolve) => setTimeout(resolve, ms)); +}; +const getActiveVaults = async (apiUrl, expectedVaults) => { + console.log('Fetching the number of active vaults...'); + const maxRetries = 5; + let retries = 0; + + while (retries < maxRetries) { + try { + const graphqlQuery = { + query: `query { vaults(filter: {state: {equalTo: "active"}}) { totalCount } }`, + }; + + const response = await fetch(apiUrl, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + Accept: 'application/json', + }, + body: JSON.stringify(graphqlQuery), + }); + + const jsonResponse = await response.json(); + const activeVaults = jsonResponse.data.vaults.totalCount; + + console.log(`Attempt ${retries + 1}: Active vaults: ${activeVaults}`); + + if (activeVaults === expectedVaults) { + console.log(`Assertion passed: ${activeVaults} active vaults match the expected count.`); + return; + } + + console.log( + `Assertion failed on attempt ${retries + 1}: Expected ${expectedVaults} active vaults, but found ${activeVaults}. Retrying...`, + ); + retries++; + await delay(5000); + } catch (error) { + console.error(`Error on attempt ${retries + 1} fetching active vaults:`, error); + retries++; + await delay(5000); + } + } + + console.error('Maximum retry attempts reached. Exiting...'); + process.exit(1); +}; + +const apiUrl = process.env.apiUrl; +const expectedVaults = parseInt(process.env.expectedVaults, 10); + +getActiveVaults(apiUrl, expectedVaults); diff --git a/.github/scripts/placeBid.mjs b/.github/scripts/placeBid.mjs new file mode 100644 index 00000000..100081c5 --- /dev/null +++ b/.github/scripts/placeBid.mjs @@ -0,0 +1,47 @@ +import { execa } from 'execa'; +import assert from 'assert'; + +const agops = '/usr/src/agoric-sdk/packages/agoric-cli/bin/agops'; + +const placeBid = async ({ fromAddress, giveAmount, priceOrDiscount, commandType, agoricNet, containerName }) => { + console.log('Starting the bidding process...'); + + try { + const env = { + AGORIC_NET: agoricNet, + }; + + let commandTypeOption; + if (commandType === 'by-price') { + commandTypeOption = 'by-price --price'; + } else if (commandType === 'by-discount') { + commandTypeOption = 'by-discount --discount'; + } + + const command = `${agops} inter bid ${commandTypeOption} ${priceOrDiscount} --from ${fromAddress} --give ${giveAmount} --keyring-backend=test`; + + console.log('Executing command in the container...'); + const { stdout } = await execa('docker', ['exec', containerName, `bash -c "${command}"`], { + env, + shell: true, + }); + + assert.ok(stdout.includes('Your bid has been accepted')); + console.log('Standard output:', stdout); + } catch (error) { + console.error('Error during bid placement:', error); + process.exit(1); + } +}; + +const bidInfo = { + fromAddress: process.env.fromAddress, + giveAmount: process.env.giveAmount, + priceOrDiscount: process.env.priceOrDiscount, + commandType: process.env.commandType, + agoricNet: process.env.agoricNet, + commandTimeout: process.env.commandTimeout, + containerName: process.env.containerName, +}; + +placeBid(bidInfo); diff --git a/.github/workflows/liquidation.yml b/.github/workflows/liquidation.yml index 8247f147..cb0f38d8 100644 --- a/.github/workflows/liquidation.yml +++ b/.github/workflows/liquidation.yml @@ -9,7 +9,7 @@ jobs: - uses: actions/checkout@v4 - name: Start A3P container - run: docker run -d -p 26657:26657 -p 1317:1317 -p 9090:9090 --name a3p ghcr.io/agoric/agoric-3-proposals:latest + run: docker compose --profile ci up -d a3p - run: corepack enable shell: bash @@ -24,75 +24,101 @@ jobs: run: yarn install - name: Start subql indexer - run: yarn dev:ci + env: + AGORIC_NET: ci + run: yarn dev - - name: Set ATOM Price to 12.34 + - name: Print initial logs of all containers run: | - docker exec a3p /usr/src/agoric-sdk/packages/agoric-cli/bin/agops oracle setPrice --keys gov1,gov2 --pair ATOM.USD --price 12.34 --keyring-backend=test + echo "Fetching initial logs for all containers..." + containers=$(docker ps --format '{{.ID}}') + for container in $containers; do + echo "Fetching initial logs for container $container..." + docker logs $container + done + + - name: Set ATOM Price to 12.34 + run: node .github/scripts/changePrice.mjs + env: + amount: 12.34 + containerName: agd + agoricNet: local + + - name: Get active vaults + run: node .github/scripts/getActiveVaults.mjs + env: + apiUrl: 'http://localhost:3000/' + expectedVaults: '7' - name: Create Vault with 100 Minted and 15 Collateral - uses: ./.github/actions/createVault - with: + run: node .github/scripts/createVault.mjs + env: wantMinted: '100' giveCollateral: '15' userKey: 'gov3' agoricNet: 'local' commandTimeout: '120' - containerName: 'a3p' + containerName: 'agd' - name: Create Vault with 103 Minted and 15 Collateral - uses: ./.github/actions/createVault - with: + run: node .github/scripts/createVault.mjs + env: wantMinted: '103' giveCollateral: '15' userKey: 'gov3' agoricNet: 'local' commandTimeout: '120' - containerName: 'a3p' + containerName: 'agd' - name: Create Vault with 105 Minted and 15 Collateral - uses: ./.github/actions/createVault - with: + run: node .github/scripts/createVault.mjs + env: wantMinted: '105' giveCollateral: '15' userKey: 'gov3' agoricNet: 'local' commandTimeout: '120' - containerName: 'a3p' + containerName: 'agd' + + - name: Get active vaults + run: node .github/scripts/getActiveVaults.mjs + env: + apiUrl: 'http://localhost:3000/' + expectedVaults: 10 - name: Place bid for 90IST - uses: ./.github/actions/placeBid - with: + run: node .github/scripts/placeBid.mjs + env: fromAddress: 'gov1' giveAmount: '90IST' priceOrDiscount: '9' commandType: 'by-price' agoricNet: 'local' - commandTimeout: '120' - containerName: 'a3p' + containerName: 'agd' - name: Place bid for 80IST - uses: ./.github/actions/placeBid - with: + run: node .github/scripts/placeBid.mjs + env: fromAddress: 'gov1' giveAmount: '80IST' priceOrDiscount: '10' commandType: 'by-discount' agoricNet: 'local' - commandTimeout: '120' - containerName: 'a3p' + containerName: 'agd' - name: Place bid for 150IST - uses: ./.github/actions/placeBid - with: + run: node .github/scripts/placeBid.mjs + env: fromAddress: 'gov1' giveAmount: '150IST' priceOrDiscount: '15' commandType: 'by-discount' agoricNet: 'local' - commandTimeout: '120' - containerName: 'a3p' + containerName: 'agd' - name: Set ATOM Price to 9.99 - run: | - docker exec a3p /usr/src/agoric-sdk/packages/agoric-cli/bin/agops oracle setPrice --keys gov1,gov2 --pair ATOM.USD --price 9.99 --keyring-backend=test + run: node .github/scripts/changePrice.mjs + env: + amount: 9.99 + containerName: agd + agoricNet: local diff --git a/docker-compose.yml b/docker-compose.yml index ddd67f4f..e2ecc711 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,11 +14,14 @@ services: interval: 5s timeout: 5s retries: 5 + profiles: + - default + - ci subquery-node: image: subquerynetwork/subql-node-cosmos:v4.2.1 depends_on: - 'postgres': + postgres: condition: service_healthy restart: always environment: @@ -30,27 +33,28 @@ services: volumes: - ./:/app command: - - ${SUB_COMMAND:-} # set SUB_COMMAND env variable to "test" to run tests + - ${SUB_COMMAND:-} - -f=/app - --db-schema=app - --workers=4 - --batch-size=30 - # - --log-level=debug - # - --unfinalized-blocks=true healthcheck: test: ['CMD', 'curl', '-f', 'http://subquery-node:3000/ready'] interval: 3s timeout: 5s retries: 10 + profiles: + - default + - ci graphql-engine: image: onfinality/subql-query:v2.13.0 ports: - 3000:3000 depends_on: - 'postgres': + postgres: condition: service_healthy - 'subquery-node': + subquery-node: condition: service_healthy restart: always environment: @@ -63,3 +67,21 @@ services: - --name=app - --playground - --indexer=http://subquery-node:3000 + profiles: + - default + - ci + + a3p: + image: ghcr.io/agoric/agoric-3-proposals:latest + container_name: agd + ports: + - 26657:26657 + - 1317:1317 + - 9090:9090 + restart: always + profiles: + - ci + +networks: + default: + driver: bridge diff --git a/package.json b/package.json index e9c7ec51..4f8f205b 100644 --- a/package.json +++ b/package.json @@ -7,8 +7,7 @@ "build": "subql build", "codegen": "subql codegen", "start:docker": "docker-compose pull && docker-compose up --remove-orphans", - "dev": "subql codegen && subql build && docker-compose pull && docker-compose up --remove-orphans", - "dev:ci": "AGORIC_NET=docker subql codegen && subql build && docker compose pull && docker compose up --remove-orphans --detach", + "dev": "subql codegen && subql build && docker compose pull && docker compose --profile default up --remove-orphans --detach", "prepack": "rm -rf dist && npm run build", "test": "subql build && subql-node-cosmos test", "prettier:check": "prettier --list-different . --print-width 120", @@ -28,6 +27,7 @@ "@subql/cli": "^5.4.0", "@subql/node-cosmos": "4.2.1", "@subql/testing": "latest", + "execa": "^9.5.2", "prettier": "^3.4.2", "starknet": "6.11.0", "typescript": "^5.7.2" diff --git a/project.ts b/project.ts index a26e2303..5ed79c5d 100644 --- a/project.ts +++ b/project.ts @@ -44,6 +44,12 @@ const networkConfig = { chaintypes: chainTypesU18, startBlock: 1, }, + ci: { + chainId: 'agoriclocal', + endpoint: ['http://a3p:26657'], + chaintypes: chainTypesU18, + startBlock: 1, + }, main: { chainId: 'agoric-3', endpoint: ['https://main-a.rpc.agoric.net:443'], diff --git a/yarn.lock b/yarn.lock index 4c0e2d2d..c75cf26d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3156,6 +3156,13 @@ __metadata: languageName: node linkType: hard +"@sec-ant/readable-stream@npm:^0.4.1": + version: 0.4.1 + resolution: "@sec-ant/readable-stream@npm:0.4.1" + checksum: 10c0/64e9e9cf161e848067a5bf60cdc04d18495dc28bb63a8d9f8993e4dd99b91ad34e4b563c85de17d91ffb177ec17a0664991d2e115f6543e73236a906068987af + languageName: node + linkType: hard + "@sinclair/typebox@npm:^0.24.1": version: 0.24.51 resolution: "@sinclair/typebox@npm:0.24.51" @@ -3170,6 +3177,13 @@ __metadata: languageName: node linkType: hard +"@sindresorhus/merge-streams@npm:^4.0.0": + version: 4.0.0 + resolution: "@sindresorhus/merge-streams@npm:4.0.0" + checksum: 10c0/482ee543629aa1933b332f811a1ae805a213681ecdd98c042b1c1b89387df63e7812248bb4df3910b02b3cc5589d3d73e4393f30e197c9dde18046ccd471fc6b + languageName: node + linkType: hard + "@starknet-io/types-js@npm:^0.7.7, starknet-types-07@npm:@starknet-io/types-js@^0.7.7": version: 0.7.10 resolution: "@starknet-io/types-js@npm:0.7.10" @@ -4113,6 +4127,7 @@ __metadata: "@subql/utils": "npm:^2.17.0" "@types/node": "npm:^17.0.21" bech32: "npm:^2.0.0" + execa: "npm:^9.5.2" js-sha256: "npm:^0.11.0" pino: "npm:^7.8.0" prettier: "npm:^3.4.2" @@ -5892,6 +5907,26 @@ __metadata: languageName: node linkType: hard +"execa@npm:^9.5.2": + version: 9.5.2 + resolution: "execa@npm:9.5.2" + dependencies: + "@sindresorhus/merge-streams": "npm:^4.0.0" + cross-spawn: "npm:^7.0.3" + figures: "npm:^6.1.0" + get-stream: "npm:^9.0.0" + human-signals: "npm:^8.0.0" + is-plain-obj: "npm:^4.1.0" + is-stream: "npm:^4.0.1" + npm-run-path: "npm:^6.0.0" + pretty-ms: "npm:^9.0.0" + signal-exit: "npm:^4.1.0" + strip-final-newline: "npm:^4.0.0" + yoctocolors: "npm:^2.0.0" + checksum: 10c0/94782a6282e03253224406c29068d18f9095cc251a45d1f19ac3d8f2a9db2cbe32fb8ceb039db1451d8fce3531135a6c0c559f76d634f85416268fc4a6995365 + languageName: node + linkType: hard + "exponential-backoff@npm:^3.1.1": version: 3.1.1 resolution: "exponential-backoff@npm:3.1.1" @@ -6047,6 +6082,15 @@ __metadata: languageName: node linkType: hard +"figures@npm:^6.1.0": + version: 6.1.0 + resolution: "figures@npm:6.1.0" + dependencies: + is-unicode-supported: "npm:^2.0.0" + checksum: 10c0/9159df4264d62ef447a3931537de92f5012210cf5135c35c010df50a2169377581378149abfe1eb238bd6acbba1c0d547b1f18e0af6eee49e30363cedaffcfe4 + languageName: node + linkType: hard + "file-uri-to-path@npm:1.0.0": version: 1.0.0 resolution: "file-uri-to-path@npm:1.0.0" @@ -6307,6 +6351,16 @@ __metadata: languageName: node linkType: hard +"get-stream@npm:^9.0.0": + version: 9.0.1 + resolution: "get-stream@npm:9.0.1" + dependencies: + "@sec-ant/readable-stream": "npm:^0.4.1" + is-stream: "npm:^4.0.1" + checksum: 10c0/d70e73857f2eea1826ac570c3a912757dcfbe8a718a033fa0c23e12ac8e7d633195b01710e0559af574cbb5af101009b42df7b6f6b29ceec8dbdf7291931b948 + languageName: node + linkType: hard + "glob-parent@npm:^5.1.2": version: 5.1.2 resolution: "glob-parent@npm:5.1.2" @@ -6604,6 +6658,13 @@ __metadata: languageName: node linkType: hard +"human-signals@npm:^8.0.0": + version: 8.0.0 + resolution: "human-signals@npm:8.0.0" + checksum: 10c0/e4dac4f7d3eb791ed04129fc6a85bd454a9102d3e3b76c911d0db7057ebd60b2956b435b5b5712aec18960488ede3c21ef7c56e42cdd70760c0d84d3c05cd92e + languageName: node + linkType: hard + "humanize-number@npm:0.0.2": version: 0.0.2 resolution: "humanize-number@npm:0.0.2" @@ -6913,6 +6974,13 @@ __metadata: languageName: node linkType: hard +"is-plain-obj@npm:^4.1.0": + version: 4.1.0 + resolution: "is-plain-obj@npm:4.1.0" + checksum: 10c0/32130d651d71d9564dc88ba7e6fda0e91a1010a3694648e9f4f47bb6080438140696d3e3e15c741411d712e47ac9edc1a8a9de1fe76f3487b0d90be06ac9975e + languageName: node + linkType: hard + "is-plain-object@npm:^2.0.4": version: 2.0.4 resolution: "is-plain-object@npm:2.0.4" @@ -6929,6 +6997,13 @@ __metadata: languageName: node linkType: hard +"is-stream@npm:^4.0.1": + version: 4.0.1 + resolution: "is-stream@npm:4.0.1" + checksum: 10c0/2706c7f19b851327ba374687bc4a3940805e14ca496dc672b9629e744d143b1ad9c6f1b162dece81c7bfbc0f83b32b61ccc19ad2e05aad2dd7af347408f60c7f + languageName: node + linkType: hard + "is-typedarray@npm:^1.0.0": version: 1.0.0 resolution: "is-typedarray@npm:1.0.0" @@ -6943,6 +7018,13 @@ __metadata: languageName: node linkType: hard +"is-unicode-supported@npm:^2.0.0": + version: 2.1.0 + resolution: "is-unicode-supported@npm:2.1.0" + checksum: 10c0/a0f53e9a7c1fdbcf2d2ef6e40d4736fdffff1c9f8944c75e15425118ff3610172c87bf7bc6c34d3903b04be59790bb2212ddbe21ee65b5a97030fc50370545a5 + languageName: node + linkType: hard + "is-wsl@npm:^2.2.0": version: 2.2.0 resolution: "is-wsl@npm:2.2.0" @@ -8007,6 +8089,16 @@ __metadata: languageName: node linkType: hard +"npm-run-path@npm:^6.0.0": + version: 6.0.0 + resolution: "npm-run-path@npm:6.0.0" + dependencies: + path-key: "npm:^4.0.0" + unicorn-magic: "npm:^0.3.0" + checksum: 10c0/b223c8a0dcd608abf95363ea5c3c0ccc3cd877daf0102eaf1b0f2390d6858d8337fbb7c443af2403b067a7d2c116d10691ecd22ab3c5273c44da1ff8d07753bd + languageName: node + linkType: hard + "object-assign@npm:^4, object-assign@npm:^4.0.1, object-assign@npm:^4.1.1": version: 4.1.1 resolution: "object-assign@npm:4.1.1" @@ -8179,6 +8271,13 @@ __metadata: languageName: node linkType: hard +"parse-ms@npm:^4.0.0": + version: 4.0.0 + resolution: "parse-ms@npm:4.0.0" + checksum: 10c0/a7900f4f1ebac24cbf5e9708c16fb2fd482517fad353aecd7aefb8c2ba2f85ce017913ccb8925d231770404780df46244ea6fec598b3bde6490882358b4d2d16 + languageName: node + linkType: hard + "parse-package-name@npm:1.0.0": version: 1.0.0 resolution: "parse-package-name@npm:1.0.0" @@ -8224,6 +8323,13 @@ __metadata: languageName: node linkType: hard +"path-key@npm:^4.0.0": + version: 4.0.0 + resolution: "path-key@npm:4.0.0" + checksum: 10c0/794efeef32863a65ac312f3c0b0a99f921f3e827ff63afa5cb09a377e202c262b671f7b3832a4e64731003fa94af0263713962d317b9887bd1e0c48a342efba3 + languageName: node + linkType: hard + "path-parse@npm:^1.0.7": version: 1.0.7 resolution: "path-parse@npm:1.0.7" @@ -8481,6 +8587,15 @@ __metadata: languageName: node linkType: hard +"pretty-ms@npm:^9.0.0": + version: 9.2.0 + resolution: "pretty-ms@npm:9.2.0" + dependencies: + parse-ms: "npm:^4.0.0" + checksum: 10c0/ab6d066f90e9f77020426986e1b018369f41575674544c539aabec2e63a20fec01166d8cf6571d0e165ad11cfe5a8134a2a48a36d42ab291c59c6deca5264cbb + languageName: node + linkType: hard + "proc-log@npm:^5.0.0": version: 5.0.0 resolution: "proc-log@npm:5.0.0" @@ -9552,6 +9667,13 @@ __metadata: languageName: node linkType: hard +"strip-final-newline@npm:^4.0.0": + version: 4.0.0 + resolution: "strip-final-newline@npm:4.0.0" + checksum: 10c0/b0cf2b62d597a1b0e3ebc42b88767f0a0d45601f89fd379a928a1812c8779440c81abba708082c946445af1d6b62d5f16e2a7cf4f30d9d6587b89425fae801ff + languageName: node + linkType: hard + "strip-json-comments@npm:~2.0.1": version: 2.0.1 resolution: "strip-json-comments@npm:2.0.1" @@ -10043,6 +10165,13 @@ __metadata: languageName: node linkType: hard +"unicorn-magic@npm:^0.3.0": + version: 0.3.0 + resolution: "unicorn-magic@npm:0.3.0" + checksum: 10c0/0a32a997d6c15f1c2a077a15b1c4ca6f268d574cf5b8975e778bb98e6f8db4ef4e86dfcae4e158cd4c7e38fb4dd383b93b13eefddc7f178dea13d3ac8a603271 + languageName: node + linkType: hard + "unique-filename@npm:^4.0.0": version: 4.0.0 resolution: "unique-filename@npm:4.0.0" @@ -10664,6 +10793,13 @@ __metadata: languageName: node linkType: hard +"yoctocolors@npm:^2.0.0": + version: 2.1.1 + resolution: "yoctocolors@npm:2.1.1" + checksum: 10c0/85903f7fa96f1c70badee94789fade709f9d83dab2ec92753d612d84fcea6d34c772337a9f8914c6bed2f5fc03a428ac5d893e76fab636da5f1236ab725486d0 + languageName: node + linkType: hard + "zen-observable-ts@npm:^1.2.5": version: 1.2.5 resolution: "zen-observable-ts@npm:1.2.5" From 5dd221d381f3f28969aafe58e985dc219523618e Mon Sep 17 00:00:00 2001 From: rabi-siddique Date: Wed, 18 Dec 2024 16:24:12 +0500 Subject: [PATCH 05/10] ci: validate liquidating vaults --- .github/scripts/changePrice.mjs | 3 +- .github/scripts/checkLiquidation.mjs | 157 +++++++++++++++++++++++++++ .github/workflows/liquidation.yml | 13 ++- .github/workflows/pr.yaml | 2 +- package.json | 2 +- yarn.lock | 44 +++----- 6 files changed, 186 insertions(+), 35 deletions(-) create mode 100644 .github/scripts/checkLiquidation.mjs diff --git a/.github/scripts/changePrice.mjs b/.github/scripts/changePrice.mjs index 707293b2..913988c7 100644 --- a/.github/scripts/changePrice.mjs +++ b/.github/scripts/changePrice.mjs @@ -24,9 +24,8 @@ const setAtomPrice = async (amount, containerName, agoricNet) => { }; const command = `${agops} oracle setPrice --keys gov1,gov2 --pair ATOM.USD --price ${amount} --keyring-backend=test`; - const { stdout, stderr } = await execa('docker', ['exec', containerName, command], { env, shell: true }); + const { stdout } = await execa('docker', ['exec', containerName, command], { env, shell: true }); - assert.strictEqual(stderr, '', `Expected stderr to be empty, but received: '${stderr}'`); console.log('Standard output:', stdout); } catch (error) { console.error('Error:', error); diff --git a/.github/scripts/checkLiquidation.mjs b/.github/scripts/checkLiquidation.mjs new file mode 100644 index 00000000..7ac30d31 --- /dev/null +++ b/.github/scripts/checkLiquidation.mjs @@ -0,0 +1,157 @@ +// @ts-check +import fetch from 'node-fetch'; +import assert from 'assert'; +const delay = (ms) => { + return new Promise((resolve) => setTimeout(resolve, ms)); +}; + +const states = { + liquidated: 'liquidated', + liquidating: 'liquidating', +}; + +const expectedLiquidating = { + ids: [ + 'published.vaultFactory.managers.manager0.vaults.vault10-liquidating', + 'published.vaultFactory.managers.manager0.vaults.vault11-liquidating', + 'published.vaultFactory.managers.manager0.vaults.vault12-liquidating', + ], + debts: ['100500000', '103515000', '105525000'], + balance: ['15000000', '15000000', '15000000'], + denom: 'ATOM', +}; + +const expectedLiquidated = { + ids: [ + 'published.vaultFactory.managers.manager0.vaults.vault10-liquidated', + 'published.vaultFactory.managers.manager0.vaults.vault11-liquidated', + 'published.vaultFactory.managers.manager0.vaults.vault12-liquidated', + ], + debts: ['0', '0', '0'], + balance: ['3425146', '3077900', '2846403'], + denom: 'ATOM', +}; + +const validate = async ({ + apiUrl, + maxRetries, + retryDuration, + expectedIds, + expectedDebts, + expectedBalance, + expectedDenom, + filterState, +}) => { + console.log(`Checking ${filterState} vaults...`); + let retries = 0; + + while (retries < maxRetries) { + try { + const graphqlQuery = { + query: `query { + vaultLiquidations (filter: {state: {equalTo: "${filterState}"}}) { + nodes { + id + denom + debt + state + balance + } + } + }`, + }; + + const response = await fetch(apiUrl, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + Accept: 'application/json', + }, + body: JSON.stringify(graphqlQuery), + }); + + const jsonResponse = await response.json(); + console.log('Response:', JSON.stringify(jsonResponse)); + + const nodes = jsonResponse?.data?.vaultLiquidations?.nodes || []; + if (nodes.length !== 3) { + console.error(`Attempt ${retries + 1}: No data available`); + retries++; + await delay(retryDuration); + continue; + } + + nodes.sort((a, b) => a.id.localeCompare(b.id)); + console.log('Sorted Nodes:', JSON.stringify(nodes)); + + // Validate Ids + assert.strictEqual(nodes[0].id, expectedIds[0]); + assert.strictEqual(nodes[1].id, expectedIds[1]); + assert.strictEqual(nodes[2].id, expectedIds[2]); + + // Validate Debts + assert.strictEqual(nodes[0].debt, expectedDebts[0]); + assert.strictEqual(nodes[1].debt, expectedDebts[1]); + assert.strictEqual(nodes[2].debt, expectedDebts[2]); + + // Validate Denom + assert.strictEqual(nodes[0].denom, expectedDenom); + assert.strictEqual(nodes[1].denom, expectedDenom); + assert.strictEqual(nodes[2].denom, expectedDenom); + + // Validate Balance + assert.strictEqual(nodes[0].balance, expectedBalance[0]); + assert.strictEqual(nodes[1].balance, expectedBalance[1]); + assert.strictEqual(nodes[2].balance, expectedBalance[2]); + + console.log('All validations passed successfully.'); + return; + } catch (error) { + console.error(`Error on attempt ${retries + 1} fetching active vaults:`, error); + retries++; + await delay(retryDuration); + } + } + + console.error('Maximum retry attempts reached. Exiting...'); + process.exit(1); +}; + +const main = async () => { + console.log('Starting main process...'); + + const apiUrl = process.env.API_URL || 'http://localhost:3000/'; + console.log(`API URL set to: ${apiUrl}`); + + try { + console.log('Validating liquidating vaults...'); + await validate({ + apiUrl, + expectedIds: expectedLiquidating.ids, + expectedBalance: expectedLiquidating.balance, + expectedDenom: expectedLiquidating.denom, + expectedDebts: expectedLiquidating.debts, + maxRetries: 6, + retryDuration: 3 * 60 * 1000, + filterState: states.liquidating, + }); + console.log('Validation successful for liquidating vaults.'); + + console.log('Validating liquidated vaults...'); + await validate({ + apiUrl, + expectedIds: expectedLiquidated.ids, + expectedBalance: expectedLiquidated.balance, + expectedDenom: expectedLiquidated.denom, + expectedDebts: expectedLiquidated.debts, + maxRetries: 3, + retryDuration: 2 * 60 * 1000, + filterState: states.liquidated, + }); + console.log('Validation successful for liquidated vaults.'); + } catch (error) { + console.error('Validation failed:', error); + } +}; + +main(); diff --git a/.github/workflows/liquidation.yml b/.github/workflows/liquidation.yml index cb0f38d8..60e4aa38 100644 --- a/.github/workflows/liquidation.yml +++ b/.github/workflows/liquidation.yml @@ -48,7 +48,7 @@ jobs: run: node .github/scripts/getActiveVaults.mjs env: apiUrl: 'http://localhost:3000/' - expectedVaults: '7' + expectedVaults: 7 - name: Create Vault with 100 Minted and 15 Collateral run: node .github/scripts/createVault.mjs @@ -122,3 +122,14 @@ jobs: amount: 9.99 containerName: agd agoricNet: local + + - name: Check liquidation indexing + run: node .github/scripts/checkLiquidation.mjs + env: + apiUrl: 'http://localhost:3000/' + + - name: Get active vaults + run: node .github/scripts/getActiveVaults.mjs + env: + apiUrl: 'http://localhost:3000/' + expectedVaults: 7 diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 7e5e2084..c19f2b3a 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest services: a3p: - image: ghcr.io/agoric/agoric-3-proposals@sha256:644e09bf041e5588570ff9a49e6129cc468e9c8458417541027e8532cb91083b + image: ghcr.io/agoric/agoric-3-proposals:use-upgrade-17 ports: - 26657:26657 postgres: diff --git a/package.json b/package.json index 4f8f205b..e08a1b1f 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "devDependencies": { "@cosmjs/stargate": "^0.28.9", "@subql/cli": "^5.4.0", - "@subql/node-cosmos": "4.2.1", + "@subql/node-cosmos": "^4.2.1", "@subql/testing": "latest", "execa": "^9.5.2", "prettier": "^3.4.2", diff --git a/yarn.lock b/yarn.lock index c75cf26d..3e88d8c1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3228,9 +3228,9 @@ __metadata: languageName: node linkType: hard -"@subql/common-cosmos@npm:5.0.6": - version: 5.0.6 - resolution: "@subql/common-cosmos@npm:5.0.6" +"@subql/common-cosmos@npm:5.1.0": + version: 5.1.0 + resolution: "@subql/common-cosmos@npm:5.1.0" dependencies: "@cosmwasm/ts-codegen": "npm:^1.11.1" "@protobufs/cosmos": "npm:^0.1.0" @@ -3240,7 +3240,7 @@ __metadata: "@protobufs/google": "npm:^0.0.10" "@protobufs/ibc": "npm:^0.1.0" "@protobufs/tendermint": "npm:^0.0.10" - "@subql/common": "npm:^5.2.1" + "@subql/common": "npm:^5.2.2" "@subql/types-cosmos": "npm:4.0.0" "@subql/x-cosmology-telescope": "npm:^1.4.14" fs-extra: "npm:^11.1.1" @@ -3250,11 +3250,11 @@ __metadata: class-transformer: "*" class-validator: "*" ejs: "*" - checksum: 10c0/7c1b2beb1d0497d1aa4bbf987c2bd91ccbe4f13456259dcdd9dc6fae10e791e7efdf6e01061ce35e1e219dd41429fb639595053574b75f301d911061af268ca1 + checksum: 10c0/83f6eabcdf6dcf2d9d8e499201f7751eb2009ec0c501be2c58b0e269ee40d77d34db90090562afbf91ff10bf9adaec9e04aff025766829200c95f035eff58c4b languageName: node linkType: hard -"@subql/common@npm:5.2.2": +"@subql/common@npm:5.2.2, @subql/common@npm:^5.2.2": version: 5.2.2 resolution: "@subql/common@npm:5.2.2" dependencies: @@ -3271,22 +3271,6 @@ __metadata: languageName: node linkType: hard -"@subql/common@npm:^5.2.1": - version: 5.2.1 - resolution: "@subql/common@npm:5.2.1" - dependencies: - "@subql/types-core": "npm:2.0.0" - axios: "npm:^0.28.0" - class-transformer: "npm:^0.5.1" - class-validator: "npm:^0.14.1" - js-yaml: "npm:^4.1.0" - reflect-metadata: "npm:^0.1.14" - semver: "npm:^7.6.3" - update-notifier: "npm:^5.1.0" - checksum: 10c0/02ac5e46489e9eeb73f01c007e868d491f415462d654149bb296f1c4f0d74ff67b4881458a154f237a1e88df7f4a99fdf0ff44739b85ae44b871234642753fc6 - languageName: node - linkType: hard - "@subql/node-core@npm:^16.1.0": version: 16.1.0 resolution: "@subql/node-core@npm:16.1.0" @@ -3319,9 +3303,9 @@ __metadata: languageName: node linkType: hard -"@subql/node-cosmos@npm:4.2.1": - version: 4.2.1 - resolution: "@subql/node-cosmos@npm:4.2.1" +"@subql/node-cosmos@npm:^4.2.1": + version: 4.3.0 + resolution: "@subql/node-cosmos@npm:4.3.0" dependencies: "@cosmjs/cosmwasm-stargate": "npm:^0.32.4" "@cosmjs/proto-signing": "npm:^0.32.4" @@ -3333,9 +3317,9 @@ __metadata: "@nestjs/event-emitter": "npm:^2.0.0" "@nestjs/platform-express": "npm:^9.4.0" "@nestjs/schedule": "npm:^3.0.1" - "@subql/common": "npm:^5.2.1" - "@subql/common-cosmos": "npm:5.0.6" - "@subql/node-core": "npm:^15.0.2" + "@subql/common": "npm:^5.2.2" + "@subql/common-cosmos": "npm:5.1.0" + "@subql/node-core": "npm:^16.1.0" "@subql/types-cosmos": "npm:4.0.0" lodash: "npm:^4.17.21" protobufjs: "npm:^6.11.4" @@ -3346,7 +3330,7 @@ __metadata: "@subql/utils": "*" bin: subql-node-cosmos: ./bin/run - checksum: 10c0/950dc4aae8bbca6b47c8e618c44d2d7c63ea39206d748f3a4d57a105e88509447fa72c0f6d6fd92b0394aec030f1f9cf932715d864e031cf0ebe49adbf4dcd74 + checksum: 10c0/78cc7dbde1cb39465ec3d1f231105a69e33cd7eb98bcb06d8aa45264ee9eb3b64777147ead5d6d6b9ab92bcfed73dff6344fbb8b23233dc7fda0d5f2885d124a languageName: node linkType: hard @@ -4121,7 +4105,7 @@ __metadata: dependencies: "@cosmjs/stargate": "npm:^0.28.9" "@subql/cli": "npm:^5.4.0" - "@subql/node-cosmos": "npm:4.2.1" + "@subql/node-cosmos": "npm:^4.2.1" "@subql/testing": "npm:latest" "@subql/types-cosmos": "npm:^4.0.0" "@subql/utils": "npm:^2.17.0" From 88ebe86f49a2039ebf709aae6b29ad72e15220dd Mon Sep 17 00:00:00 2001 From: rabi-siddique Date: Wed, 18 Dec 2024 22:05:39 +0500 Subject: [PATCH 06/10] fixup! ci: validate liquidating vaults --- .github/scripts/changePrice.mjs | 35 --- .github/scripts/checkLiquidation.mjs | 157 ----------- .github/scripts/createVault.mjs | 37 --- .github/scripts/placeBid.mjs | 47 ---- .github/workflows/liquidation.yml | 40 +-- package.json | 1 + scripts/changePrice.mjs | 22 ++ scripts/checkLiquidation.mjs | 121 ++++++++ {.github/scripts => scripts}/ci.package.json | 0 {.github/scripts => scripts}/ci.tsconfig.json | 0 .../scripts => scripts}/copy-ts-config.sh | 0 scripts/createVault.mjs | 31 +++ .../scripts => scripts}/getActiveVaults.mjs | 3 +- scripts/placeBid.mjs | 37 +++ yarn.lock | 258 ++++++++++++++++++ 15 files changed, 492 insertions(+), 297 deletions(-) delete mode 100644 .github/scripts/changePrice.mjs delete mode 100644 .github/scripts/checkLiquidation.mjs delete mode 100644 .github/scripts/createVault.mjs delete mode 100644 .github/scripts/placeBid.mjs create mode 100644 scripts/changePrice.mjs create mode 100644 scripts/checkLiquidation.mjs rename {.github/scripts => scripts}/ci.package.json (100%) rename {.github/scripts => scripts}/ci.tsconfig.json (100%) rename {.github/scripts => scripts}/copy-ts-config.sh (100%) create mode 100644 scripts/createVault.mjs rename {.github/scripts => scripts}/getActiveVaults.mjs (97%) create mode 100644 scripts/placeBid.mjs diff --git a/.github/scripts/changePrice.mjs b/.github/scripts/changePrice.mjs deleted file mode 100644 index 913988c7..00000000 --- a/.github/scripts/changePrice.mjs +++ /dev/null @@ -1,35 +0,0 @@ -import { execa } from 'execa'; -import assert from 'assert'; - -const agops = '/usr/src/agoric-sdk/packages/agoric-cli/bin/agops'; - -const amount = process.env.amount; -const containerName = process.env.containerName; -const agoricNet = process.env.agoricNet; - -if (!amount || !containerName || !agoricNet) { - console.error('Error: Missing one or more required parameters:'); - if (!amount) console.error('Missing amount'); - if (!containerName) console.error('Missing containerName'); - if (!agoricNet) console.error('Missing agoricNet'); - process.exit(1); -} - -const setAtomPrice = async (amount, containerName, agoricNet) => { - try { - console.log(`Initiating price change to ${amount} for ATOM...`); - - const env = { - AGORIC_NET: agoricNet, - }; - - const command = `${agops} oracle setPrice --keys gov1,gov2 --pair ATOM.USD --price ${amount} --keyring-backend=test`; - const { stdout } = await execa('docker', ['exec', containerName, command], { env, shell: true }); - - console.log('Standard output:', stdout); - } catch (error) { - console.error('Error:', error); - } -}; - -setAtomPrice(amount, containerName, agoricNet); diff --git a/.github/scripts/checkLiquidation.mjs b/.github/scripts/checkLiquidation.mjs deleted file mode 100644 index 7ac30d31..00000000 --- a/.github/scripts/checkLiquidation.mjs +++ /dev/null @@ -1,157 +0,0 @@ -// @ts-check -import fetch from 'node-fetch'; -import assert from 'assert'; -const delay = (ms) => { - return new Promise((resolve) => setTimeout(resolve, ms)); -}; - -const states = { - liquidated: 'liquidated', - liquidating: 'liquidating', -}; - -const expectedLiquidating = { - ids: [ - 'published.vaultFactory.managers.manager0.vaults.vault10-liquidating', - 'published.vaultFactory.managers.manager0.vaults.vault11-liquidating', - 'published.vaultFactory.managers.manager0.vaults.vault12-liquidating', - ], - debts: ['100500000', '103515000', '105525000'], - balance: ['15000000', '15000000', '15000000'], - denom: 'ATOM', -}; - -const expectedLiquidated = { - ids: [ - 'published.vaultFactory.managers.manager0.vaults.vault10-liquidated', - 'published.vaultFactory.managers.manager0.vaults.vault11-liquidated', - 'published.vaultFactory.managers.manager0.vaults.vault12-liquidated', - ], - debts: ['0', '0', '0'], - balance: ['3425146', '3077900', '2846403'], - denom: 'ATOM', -}; - -const validate = async ({ - apiUrl, - maxRetries, - retryDuration, - expectedIds, - expectedDebts, - expectedBalance, - expectedDenom, - filterState, -}) => { - console.log(`Checking ${filterState} vaults...`); - let retries = 0; - - while (retries < maxRetries) { - try { - const graphqlQuery = { - query: `query { - vaultLiquidations (filter: {state: {equalTo: "${filterState}"}}) { - nodes { - id - denom - debt - state - balance - } - } - }`, - }; - - const response = await fetch(apiUrl, { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - Accept: 'application/json', - }, - body: JSON.stringify(graphqlQuery), - }); - - const jsonResponse = await response.json(); - console.log('Response:', JSON.stringify(jsonResponse)); - - const nodes = jsonResponse?.data?.vaultLiquidations?.nodes || []; - if (nodes.length !== 3) { - console.error(`Attempt ${retries + 1}: No data available`); - retries++; - await delay(retryDuration); - continue; - } - - nodes.sort((a, b) => a.id.localeCompare(b.id)); - console.log('Sorted Nodes:', JSON.stringify(nodes)); - - // Validate Ids - assert.strictEqual(nodes[0].id, expectedIds[0]); - assert.strictEqual(nodes[1].id, expectedIds[1]); - assert.strictEqual(nodes[2].id, expectedIds[2]); - - // Validate Debts - assert.strictEqual(nodes[0].debt, expectedDebts[0]); - assert.strictEqual(nodes[1].debt, expectedDebts[1]); - assert.strictEqual(nodes[2].debt, expectedDebts[2]); - - // Validate Denom - assert.strictEqual(nodes[0].denom, expectedDenom); - assert.strictEqual(nodes[1].denom, expectedDenom); - assert.strictEqual(nodes[2].denom, expectedDenom); - - // Validate Balance - assert.strictEqual(nodes[0].balance, expectedBalance[0]); - assert.strictEqual(nodes[1].balance, expectedBalance[1]); - assert.strictEqual(nodes[2].balance, expectedBalance[2]); - - console.log('All validations passed successfully.'); - return; - } catch (error) { - console.error(`Error on attempt ${retries + 1} fetching active vaults:`, error); - retries++; - await delay(retryDuration); - } - } - - console.error('Maximum retry attempts reached. Exiting...'); - process.exit(1); -}; - -const main = async () => { - console.log('Starting main process...'); - - const apiUrl = process.env.API_URL || 'http://localhost:3000/'; - console.log(`API URL set to: ${apiUrl}`); - - try { - console.log('Validating liquidating vaults...'); - await validate({ - apiUrl, - expectedIds: expectedLiquidating.ids, - expectedBalance: expectedLiquidating.balance, - expectedDenom: expectedLiquidating.denom, - expectedDebts: expectedLiquidating.debts, - maxRetries: 6, - retryDuration: 3 * 60 * 1000, - filterState: states.liquidating, - }); - console.log('Validation successful for liquidating vaults.'); - - console.log('Validating liquidated vaults...'); - await validate({ - apiUrl, - expectedIds: expectedLiquidated.ids, - expectedBalance: expectedLiquidated.balance, - expectedDenom: expectedLiquidated.denom, - expectedDebts: expectedLiquidated.debts, - maxRetries: 3, - retryDuration: 2 * 60 * 1000, - filterState: states.liquidated, - }); - console.log('Validation successful for liquidated vaults.'); - } catch (error) { - console.error('Validation failed:', error); - } -}; - -main(); diff --git a/.github/scripts/createVault.mjs b/.github/scripts/createVault.mjs deleted file mode 100644 index ad0bbff8..00000000 --- a/.github/scripts/createVault.mjs +++ /dev/null @@ -1,37 +0,0 @@ -import { execa } from 'execa'; -import assert from 'assert'; - -const agops = '/usr/src/agoric-sdk/packages/agoric-cli/bin/agops'; - -const createVault = async (containerName, agoricNet, userKey, wantMinted, giveCollateral) => { - console.log('Starting the vault creation process...'); - - try { - const env = { - AGORIC_NET: agoricNet, - }; - - const command = `${agops} vaults open --wantMinted ${wantMinted} --giveCollateral ${giveCollateral} > /tmp/want-ist.json`; - await execa('docker', ['exec', containerName, `bash -c "${command}"`], { env, shell: true }); - - const broadCastCommand = `${agops} perf satisfaction --executeOffer /tmp/want-ist.json --from ${userKey} --keyring-backend=test`; - const { stdout } = await execa('docker', ['exec', containerName, broadCastCommand], { - env, - shell: true, - }); - - assert.ok(!stdout.includes('Error'), `Expected 'stdout' not to contain 'Error'`); - console.log('Standard output:', stdout); - } catch (error) { - console.error('Error during vault creation:', error); - process.exit(1); - } -}; - -const containerName = process.env.containerName; -const agoricNet = process.env.agoricNet; -const userKey = process.env.userKey; -const wantMinted = process.env.wantMinted; -const giveCollateral = process.env.giveCollateral; - -createVault(containerName, agoricNet, userKey, wantMinted, giveCollateral); diff --git a/.github/scripts/placeBid.mjs b/.github/scripts/placeBid.mjs deleted file mode 100644 index 100081c5..00000000 --- a/.github/scripts/placeBid.mjs +++ /dev/null @@ -1,47 +0,0 @@ -import { execa } from 'execa'; -import assert from 'assert'; - -const agops = '/usr/src/agoric-sdk/packages/agoric-cli/bin/agops'; - -const placeBid = async ({ fromAddress, giveAmount, priceOrDiscount, commandType, agoricNet, containerName }) => { - console.log('Starting the bidding process...'); - - try { - const env = { - AGORIC_NET: agoricNet, - }; - - let commandTypeOption; - if (commandType === 'by-price') { - commandTypeOption = 'by-price --price'; - } else if (commandType === 'by-discount') { - commandTypeOption = 'by-discount --discount'; - } - - const command = `${agops} inter bid ${commandTypeOption} ${priceOrDiscount} --from ${fromAddress} --give ${giveAmount} --keyring-backend=test`; - - console.log('Executing command in the container...'); - const { stdout } = await execa('docker', ['exec', containerName, `bash -c "${command}"`], { - env, - shell: true, - }); - - assert.ok(stdout.includes('Your bid has been accepted')); - console.log('Standard output:', stdout); - } catch (error) { - console.error('Error during bid placement:', error); - process.exit(1); - } -}; - -const bidInfo = { - fromAddress: process.env.fromAddress, - giveAmount: process.env.giveAmount, - priceOrDiscount: process.env.priceOrDiscount, - commandType: process.env.commandType, - agoricNet: process.env.agoricNet, - commandTimeout: process.env.commandTimeout, - containerName: process.env.containerName, -}; - -placeBid(bidInfo); diff --git a/.github/workflows/liquidation.yml b/.github/workflows/liquidation.yml index 60e4aa38..e164a366 100644 --- a/.github/workflows/liquidation.yml +++ b/.github/workflows/liquidation.yml @@ -38,98 +38,98 @@ jobs: done - name: Set ATOM Price to 12.34 - run: node .github/scripts/changePrice.mjs + run: ./scripts/changePrice.mjs env: amount: 12.34 containerName: agd - agoricNet: local + AGORIC_NET: local - name: Get active vaults - run: node .github/scripts/getActiveVaults.mjs + run: ./scripts/getActiveVaults.mjs env: apiUrl: 'http://localhost:3000/' expectedVaults: 7 - name: Create Vault with 100 Minted and 15 Collateral - run: node .github/scripts/createVault.mjs + run: ./scripts/createVault.mjs env: wantMinted: '100' giveCollateral: '15' userKey: 'gov3' - agoricNet: 'local' + AGORIC_NET: 'local' commandTimeout: '120' containerName: 'agd' - name: Create Vault with 103 Minted and 15 Collateral - run: node .github/scripts/createVault.mjs + run: ./scripts/createVault.mjs env: wantMinted: '103' giveCollateral: '15' userKey: 'gov3' - agoricNet: 'local' + AGORIC_NET: 'local' commandTimeout: '120' containerName: 'agd' - name: Create Vault with 105 Minted and 15 Collateral - run: node .github/scripts/createVault.mjs + run: ./scripts/createVault.mjs env: wantMinted: '105' giveCollateral: '15' userKey: 'gov3' - agoricNet: 'local' + AGORIC_NET: 'local' commandTimeout: '120' containerName: 'agd' - name: Get active vaults - run: node .github/scripts/getActiveVaults.mjs + run: ./scripts/getActiveVaults.mjs env: apiUrl: 'http://localhost:3000/' expectedVaults: 10 - name: Place bid for 90IST - run: node .github/scripts/placeBid.mjs + run: ./scripts/placeBid.mjs env: fromAddress: 'gov1' giveAmount: '90IST' priceOrDiscount: '9' commandType: 'by-price' - agoricNet: 'local' + AGORIC_NET: 'local' containerName: 'agd' - name: Place bid for 80IST - run: node .github/scripts/placeBid.mjs + run: ./scripts/placeBid.mjs env: fromAddress: 'gov1' giveAmount: '80IST' priceOrDiscount: '10' commandType: 'by-discount' - agoricNet: 'local' + AGORIC_NET: 'local' containerName: 'agd' - name: Place bid for 150IST - run: node .github/scripts/placeBid.mjs + run: ./scripts/placeBid.mjs env: fromAddress: 'gov1' giveAmount: '150IST' priceOrDiscount: '15' commandType: 'by-discount' - agoricNet: 'local' + AGORIC_NET: 'local' containerName: 'agd' - name: Set ATOM Price to 9.99 - run: node .github/scripts/changePrice.mjs + run: ./scripts/changePrice.mjs env: amount: 9.99 containerName: agd - agoricNet: local + AGORIC_NET: local - name: Check liquidation indexing - run: node .github/scripts/checkLiquidation.mjs + run: ./scripts/checkLiquidation.mjs env: apiUrl: 'http://localhost:3000/' - name: Get active vaults - run: node .github/scripts/getActiveVaults.mjs + run: ./scripts/getActiveVaults.mjs env: apiUrl: 'http://localhost:3000/' expectedVaults: 7 diff --git a/package.json b/package.json index e08a1b1f..8c88226e 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "author": "Agoric OpCo", "license": "Apache-2.0", "devDependencies": { + "@agoric/internal": "0.4.0-u18.0", "@cosmjs/stargate": "^0.28.9", "@subql/cli": "^5.4.0", "@subql/node-cosmos": "^4.2.1", diff --git a/scripts/changePrice.mjs b/scripts/changePrice.mjs new file mode 100644 index 00000000..e72900b9 --- /dev/null +++ b/scripts/changePrice.mjs @@ -0,0 +1,22 @@ +#! /usr/bin/env node +import { execa } from 'execa'; +import { assertAllDefined } from '@agoric/internal'; + +const agops = '/usr/src/agoric-sdk/packages/agoric-cli/bin/agops'; +const { AGORIC_NET, amount, containerName } = process.env; + +assertAllDefined({ AGORIC_NET, amount, containerName }); + +try { + const env = { + AGORIC_NET, + }; + + console.log(`Initiating price change to ${amount} for ATOM...`); + const command = `${agops} oracle setPrice --keys gov1,gov2 --pair ATOM.USD --price ${amount} --keyring-backend=test`; + const { stdout } = await execa('docker', ['exec', containerName, command], { env, shell: true }); + + console.log('Standard output:', stdout); +} catch (error) { + console.error('Error:', error); +} diff --git a/scripts/checkLiquidation.mjs b/scripts/checkLiquidation.mjs new file mode 100644 index 00000000..9b8208ed --- /dev/null +++ b/scripts/checkLiquidation.mjs @@ -0,0 +1,121 @@ +#! /usr/bin/env node +/* eslint-env node */ +import { equal } from 'node:assert/strict'; +const delay = (ms) => { + return new Promise((resolve) => setTimeout(resolve, ms)); +}; + +const states = { + liquidated: 'liquidated', + liquidating: 'liquidating', +}; + +const expectedLiquidating = { + id: [ + 'published.vaultFactory.managers.manager0.vaults.vault10-liquidating', + 'published.vaultFactory.managers.manager0.vaults.vault11-liquidating', + 'published.vaultFactory.managers.manager0.vaults.vault12-liquidating', + ], + debt: ['100500000', '103515000', '105525000'], + balance: ['15000000', '15000000', '15000000'], + denom: ['ATOM', 'ATOM', 'ATOM'], +}; + +const expectedLiquidated = { + id: [ + 'published.vaultFactory.managers.manager0.vaults.vault10-liquidated', + 'published.vaultFactory.managers.manager0.vaults.vault11-liquidated', + 'published.vaultFactory.managers.manager0.vaults.vault12-liquidated', + ], + debt: ['0', '0', '0'], + balance: ['3425146', '3077900', '2846403'], + denom: ['ATOM', 'ATOM', 'ATOM'], +}; + +const validate = async ({ apiUrl, maxRetries, retryDuration, expectations, filterState }) => { + let retries = 0; + + while (retries < maxRetries) { + try { + const graphqlQuery = { + query: `query { + vaultLiquidations (filter: {state: {equalTo: "${filterState}"}}) { + nodes { + id + denom + debt + state + balance + } + } + }`, + }; + + const response = await fetch(apiUrl, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + Accept: 'application/json', + }, + body: JSON.stringify(graphqlQuery), + }); + + const jsonResponse = await response.json(); + console.log('Response:', JSON.stringify(jsonResponse)); + + const nodes = jsonResponse?.data?.vaultLiquidations?.nodes || []; + if (nodes.length !== 3) { + console.error(`Attempt ${retries + 1}: No data available`); + retries++; + await delay(retryDuration); + continue; + } + + nodes.sort((a, b) => a.id.localeCompare(b.id)); + console.log('Sorted Nodes:', JSON.stringify(nodes)); + + for (const key of Object.keys(expectations)) { + for (let i = 0; i < nodes.length; i++) { + equal(nodes[i][key], expectations[i].key); + } + } + + console.log('All validations passed successfully.'); + return; + } catch (error) { + console.error(`Error on attempt ${retries + 1} fetching active vaults:`, error); + retries++; + await delay(retryDuration); + } + } + + console.error('Maximum retry attempts reached. Exiting...'); + process.exit(1); +}; + +const apiUrl = process.env.API_URL || 'http://localhost:3000/'; +console.log(`API URL set to: ${apiUrl}`); + +try { + console.log('Validating liquidating vaults...'); + await validate({ + apiUrl, + expectations: expectedLiquidating, + maxRetries: 6, + retryDuration: 3 * 60 * 1000, + filterState: states.liquidating, + }); + console.log('Validation successful for liquidating vaults.'); + + console.log('Validating liquidated vaults...'); + await validate({ + apiUrl, + expectations: expectedLiquidated, + maxRetries: 3, + retryDuration: 2 * 60 * 1000, + filterState: states.liquidated, + }); + console.log('Validation successful for liquidated vaults.'); +} catch (error) { + console.error('Validation failed:', error); +} diff --git a/.github/scripts/ci.package.json b/scripts/ci.package.json similarity index 100% rename from .github/scripts/ci.package.json rename to scripts/ci.package.json diff --git a/.github/scripts/ci.tsconfig.json b/scripts/ci.tsconfig.json similarity index 100% rename from .github/scripts/ci.tsconfig.json rename to scripts/ci.tsconfig.json diff --git a/.github/scripts/copy-ts-config.sh b/scripts/copy-ts-config.sh similarity index 100% rename from .github/scripts/copy-ts-config.sh rename to scripts/copy-ts-config.sh diff --git a/scripts/createVault.mjs b/scripts/createVault.mjs new file mode 100644 index 00000000..241df2f2 --- /dev/null +++ b/scripts/createVault.mjs @@ -0,0 +1,31 @@ +#! /usr/bin/env node +import { execa } from 'execa'; +import assert from 'node:assert/strict'; +import { assertAllDefined } from '@agoric/internal'; + +const agops = '/usr/src/agoric-sdk/packages/agoric-cli/bin/agops'; + +const { AGORIC_NET, userKey, containerName, wantMinted, giveCollateral } = process.env; +assertAllDefined({ AGORIC_NET, userKey, containerName, wantMinted, giveCollateral }); + +try { + const env = { + AGORIC_NET, + }; + + console.log('Starting the vault creation process...'); + const command = `${agops} vaults open --wantMinted ${wantMinted} --giveCollateral ${giveCollateral} > /tmp/want-ist.json`; + await execa('docker', ['exec', containerName, `bash -c "${command}"`], { env, shell: true }); + + const broadCastCommand = `${agops} perf satisfaction --executeOffer /tmp/want-ist.json --from ${userKey} --keyring-backend=test`; + const { stdout } = await execa('docker', ['exec', containerName, broadCastCommand], { + env, + shell: true, + }); + + assert.ok(!stdout.includes('Error'), `Expected 'stdout' not to contain 'Error'`); + console.log('Standard output:', stdout); +} catch (error) { + console.error('Error during vault creation:', error); + process.exit(1); +} diff --git a/.github/scripts/getActiveVaults.mjs b/scripts/getActiveVaults.mjs similarity index 97% rename from .github/scripts/getActiveVaults.mjs rename to scripts/getActiveVaults.mjs index a62f48f9..4d4cb21c 100644 --- a/.github/scripts/getActiveVaults.mjs +++ b/scripts/getActiveVaults.mjs @@ -1,4 +1,5 @@ -import fetch from 'node-fetch'; +#! /usr/bin/env node +/* eslint-env node */ const delay = (ms) => { return new Promise((resolve) => setTimeout(resolve, ms)); diff --git a/scripts/placeBid.mjs b/scripts/placeBid.mjs new file mode 100644 index 00000000..8ee96e7a --- /dev/null +++ b/scripts/placeBid.mjs @@ -0,0 +1,37 @@ +#! /usr/bin/env node +import { execa } from 'execa'; +import assert from 'node:assert/strict'; +import { assertAllDefined } from '@agoric/internal'; + +const agops = '/usr/src/agoric-sdk/packages/agoric-cli/bin/agops'; + +const { AGORIC_NET, fromAddress, giveAmount, priceOrDiscount, commandType, containerName } = process.env; +assertAllDefined({ AGORIC_NET, fromAddress, giveAmount, priceOrDiscount, commandType, containerName }); + +try { + const env = { + AGORIC_NET, + }; + + let commandTypeOption; + if (commandType === 'by-price') { + commandTypeOption = 'by-price --price'; + } else if (commandType === 'by-discount') { + commandTypeOption = 'by-discount --discount'; + } + + console.log('Starting the bidding process...'); + const command = `${agops} inter bid ${commandTypeOption} ${priceOrDiscount} --from ${fromAddress} --give ${giveAmount} --keyring-backend=test`; + + console.log('Executing command in the container...'); + const { stdout } = await execa('docker', ['exec', containerName, `bash -c "${command}"`], { + env, + shell: true, + }); + + assert.ok(stdout.includes('Your bid has been accepted')); + console.log('Standard output:', stdout); +} catch (error) { + console.error('Error during bid placement:', error); + process.exit(1); +} diff --git a/yarn.lock b/yarn.lock index 3e88d8c1..9b3c15a8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5,6 +5,54 @@ __metadata: version: 8 cacheKey: 10c0 +"@agoric/base-zone@npm:^0.1.1-u18.0": + version: 0.1.1-upgrade-18-dev-ef001c0.0 + resolution: "@agoric/base-zone@npm:0.1.1-upgrade-18-dev-ef001c0.0" + dependencies: + "@agoric/store": "npm:0.9.3-upgrade-18-dev-ef001c0.0+ef001c0" + "@endo/common": "npm:^1.2.7" + "@endo/errors": "npm:^1.2.7" + "@endo/exo": "npm:^1.5.6" + "@endo/far": "npm:^1.1.8" + "@endo/pass-style": "npm:^1.4.6" + "@endo/patterns": "npm:^1.4.6" + checksum: 10c0/0df4eba4133cf41c8a3e4edbfe5ba74a0976fde58687c50a1fb32b932160538ec1af077495c375b3ee223df271086500e571b02086275c8ea5be2d5c6c658702 + languageName: node + linkType: hard + +"@agoric/internal@npm:0.4.0-u18.0": + version: 0.4.0-u18.0 + resolution: "@agoric/internal@npm:0.4.0-u18.0" + dependencies: + "@agoric/base-zone": "npm:^0.1.1-u18.0" + "@endo/common": "npm:^1.2.7" + "@endo/errors": "npm:^1.2.7" + "@endo/far": "npm:^1.1.8" + "@endo/init": "npm:^1.1.6" + "@endo/marshal": "npm:^1.6.1" + "@endo/pass-style": "npm:^1.4.6" + "@endo/patterns": "npm:^1.4.6" + "@endo/promise-kit": "npm:^1.1.7" + "@endo/stream": "npm:^1.2.7" + anylogger: "npm:^0.21.0" + jessie.js: "npm:^0.3.4" + checksum: 10c0/5a7d36cb8faf69eabf9d53f6ea79bcd10187d83782e6fa06d8debd5d5565ecdbf33ef85efbe8697e91eed09c21599ab03b8b746065611513cc54b467a87ce427 + languageName: node + linkType: hard + +"@agoric/store@npm:0.9.3-upgrade-18-dev-ef001c0.0+ef001c0": + version: 0.9.3-upgrade-18-dev-ef001c0.0 + resolution: "@agoric/store@npm:0.9.3-upgrade-18-dev-ef001c0.0" + dependencies: + "@endo/errors": "npm:^1.2.7" + "@endo/exo": "npm:^1.5.6" + "@endo/marshal": "npm:^1.6.1" + "@endo/pass-style": "npm:^1.4.6" + "@endo/patterns": "npm:^1.4.6" + checksum: 10c0/8ca7d3a1b4fe909b98146d6c91c0a79a812f1df27ce298d791a0a1b1224f344eacb756be7a6c5c5abc16a875855b99eeddb0d058bcdcea01a55ccf0e2b8bc8ff + languageName: node + linkType: hard + "@ampproject/remapping@npm:^2.1.0, @ampproject/remapping@npm:^2.2.0": version: 2.3.0 resolution: "@ampproject/remapping@npm:2.3.0" @@ -1954,6 +2002,163 @@ __metadata: languageName: node linkType: hard +"@endo/base64@npm:^1.0.9": + version: 1.0.9 + resolution: "@endo/base64@npm:1.0.9" + checksum: 10c0/63e487cf59b50a080fab389a8ab24d66264910ecf375dc19677c2ee7421d92a4be9c85e435b216b4adc9983384073a7eb753223f85ba77aec8d9fd3e0c1fe090 + languageName: node + linkType: hard + +"@endo/common@npm:^1.2.7, @endo/common@npm:^1.2.8": + version: 1.2.8 + resolution: "@endo/common@npm:1.2.8" + dependencies: + "@endo/errors": "npm:^1.2.8" + "@endo/eventual-send": "npm:^1.2.8" + "@endo/promise-kit": "npm:^1.1.8" + checksum: 10c0/c9465721095d9f06278b6550909a02c330c7a69223f11aff29759067586d41b86054127639fa2c2c0345d0d0aa43518e5b72d5c547b67bfe8e802cd21756d87b + languageName: node + linkType: hard + +"@endo/env-options@npm:^1.1.8": + version: 1.1.8 + resolution: "@endo/env-options@npm:1.1.8" + checksum: 10c0/2f519f48a5b966dbd9e66134d4abc89ff02b9791d21146b49031ceb694584f3f41c6119125b6bb4eb0d347f5bcd846473b5f3c4ae6bae3dac19402fcaf522520 + languageName: node + linkType: hard + +"@endo/errors@npm:^1.2.7, @endo/errors@npm:^1.2.8": + version: 1.2.8 + resolution: "@endo/errors@npm:1.2.8" + dependencies: + ses: "npm:^1.10.0" + checksum: 10c0/3f33fc7119ab840ad0f5bdfb70e73cc99630f09593c31928e30de4d9c8e898c85397c5170964d54c819a757a74d3b005f6275480ff8d0f1aa2aa8ef872852e97 + languageName: node + linkType: hard + +"@endo/eventual-send@npm:^1.2.8": + version: 1.2.8 + resolution: "@endo/eventual-send@npm:1.2.8" + dependencies: + "@endo/env-options": "npm:^1.1.8" + checksum: 10c0/d7c16c935441b67d029fcb6785f425a1194fb7f936e4b20dde21eb393266cb7366edf7a95d3fdfa96cd4a3246a3659a06d0dbb3c1217045e1718e1cf34c7a3bd + languageName: node + linkType: hard + +"@endo/exo@npm:^1.5.6": + version: 1.5.7 + resolution: "@endo/exo@npm:1.5.7" + dependencies: + "@endo/common": "npm:^1.2.8" + "@endo/env-options": "npm:^1.1.8" + "@endo/errors": "npm:^1.2.8" + "@endo/eventual-send": "npm:^1.2.8" + "@endo/far": "npm:^1.1.9" + "@endo/pass-style": "npm:^1.4.7" + "@endo/patterns": "npm:^1.4.7" + checksum: 10c0/0193de0606a7f07f207f3dd8bb71ec6be0acfb0ff5ef570f03cbbcaed888db68e451082c34764de8ee301f8d2d175e6c5a5405e76367c27151d644536bdf57a4 + languageName: node + linkType: hard + +"@endo/far@npm:^1.0.0, @endo/far@npm:^1.1.8, @endo/far@npm:^1.1.9": + version: 1.1.9 + resolution: "@endo/far@npm:1.1.9" + dependencies: + "@endo/errors": "npm:^1.2.8" + "@endo/eventual-send": "npm:^1.2.8" + "@endo/pass-style": "npm:^1.4.7" + checksum: 10c0/e0d95743c25183b961aa1f11dd81c067739fd2fb3deeab58520e949961eacba9ed109bb01b9ed820d596e8a043b6721d650d9624abf0263296cca647e7286a2e + languageName: node + linkType: hard + +"@endo/init@npm:^1.1.6": + version: 1.1.7 + resolution: "@endo/init@npm:1.1.7" + dependencies: + "@endo/base64": "npm:^1.0.9" + "@endo/eventual-send": "npm:^1.2.8" + "@endo/lockdown": "npm:^1.0.13" + "@endo/promise-kit": "npm:^1.1.8" + checksum: 10c0/6cfcc244f02da9883f65a8f34da9483a628d5350192983c53d5116b12403dc5693145c6349b6c3ca381b6b8d9590cee16f90440dc0e2da5f525e13079d6c9a2f + languageName: node + linkType: hard + +"@endo/lockdown@npm:^1.0.13": + version: 1.0.13 + resolution: "@endo/lockdown@npm:1.0.13" + dependencies: + ses: "npm:^1.10.0" + checksum: 10c0/9df04cc477595b368088a1d445f2241d8a152cb4dcf6a79d39d4804594dd8ff472380ab2bdf262adeb5b4b7cfc73effb6cc716c5a3aeca282801d57fe8a018a0 + languageName: node + linkType: hard + +"@endo/marshal@npm:^1.6.1, @endo/marshal@npm:^1.6.2": + version: 1.6.2 + resolution: "@endo/marshal@npm:1.6.2" + dependencies: + "@endo/common": "npm:^1.2.8" + "@endo/errors": "npm:^1.2.8" + "@endo/eventual-send": "npm:^1.2.8" + "@endo/nat": "npm:^5.0.13" + "@endo/pass-style": "npm:^1.4.7" + "@endo/promise-kit": "npm:^1.1.8" + checksum: 10c0/bdb634a77c2147c1359792531822aabe642a5e4d39f496dd57bb97367617a2f2d72edaaa50c51ed6a2ec1f2c08deab6a571c3dd8ffa260d441d25f53606902b1 + languageName: node + linkType: hard + +"@endo/nat@npm:^5.0.13": + version: 5.0.13 + resolution: "@endo/nat@npm:5.0.13" + checksum: 10c0/78578de4567c9bc4c6f50638c688886c07c38177a8d44192230d344221da06ccffc6d9ef8d423e27198d864ed7c57ef5ced9b1d05922eaa4e40bf82856b1aa11 + languageName: node + linkType: hard + +"@endo/pass-style@npm:^1.4.6, @endo/pass-style@npm:^1.4.7": + version: 1.4.7 + resolution: "@endo/pass-style@npm:1.4.7" + dependencies: + "@endo/env-options": "npm:^1.1.8" + "@endo/errors": "npm:^1.2.8" + "@endo/eventual-send": "npm:^1.2.8" + "@endo/promise-kit": "npm:^1.1.8" + "@fast-check/ava": "npm:^1.1.5" + checksum: 10c0/ee30e011fb08c292718a315f2ebd5ee2da6d918bf2cdaf2b269e123207c642fa1525493c41180db8c941e1a1959369730114b116656c99e8bb107ca5917f3f4e + languageName: node + linkType: hard + +"@endo/patterns@npm:^1.4.6, @endo/patterns@npm:^1.4.7": + version: 1.4.7 + resolution: "@endo/patterns@npm:1.4.7" + dependencies: + "@endo/common": "npm:^1.2.8" + "@endo/errors": "npm:^1.2.8" + "@endo/eventual-send": "npm:^1.2.8" + "@endo/marshal": "npm:^1.6.2" + "@endo/promise-kit": "npm:^1.1.8" + checksum: 10c0/358720438a019847406dfad9f23fc9b565c955ffd86d75693cea994c492dd46efaf189502f04b04f8870e6d50ffcb44ffa1e1dd3a0d6b2dfbbe57edeb994b83b + languageName: node + linkType: hard + +"@endo/promise-kit@npm:^1.1.7, @endo/promise-kit@npm:^1.1.8": + version: 1.1.8 + resolution: "@endo/promise-kit@npm:1.1.8" + dependencies: + ses: "npm:^1.10.0" + checksum: 10c0/3a51755822bd4112474bec584005b81f9ffe6a6b590faa16cff7a4994010d001d6d190f58a1e890d85b0feb0eb052d79ed2c5ed88977afb0e47ca53b6b199196 + languageName: node + linkType: hard + +"@endo/stream@npm:^1.2.7": + version: 1.2.8 + resolution: "@endo/stream@npm:1.2.8" + dependencies: + "@endo/eventual-send": "npm:^1.2.8" + "@endo/promise-kit": "npm:^1.1.8" + ses: "npm:^1.10.0" + checksum: 10c0/f435f7650020b32c10bb4cb139910b363b4d4f22bcf9e7a659d3d2eae694a3ea43c3af49c80370760a573370429e5fbe1619dec631251578d4c5eba9ff161613 + languageName: node + linkType: hard + "@ethersproject/address@npm:^5.6.0": version: 5.7.0 resolution: "@ethersproject/address@npm:5.7.0" @@ -2014,6 +2219,17 @@ __metadata: languageName: node linkType: hard +"@fast-check/ava@npm:^1.1.5": + version: 1.2.1 + resolution: "@fast-check/ava@npm:1.2.1" + dependencies: + fast-check: "npm:^3.0.0" + peerDependencies: + ava: ^4 || ^5 || ^6 + checksum: 10c0/3800098fd7e8098102544a2f7a595351d063a7ebaeca18ed4901df5ec2679da2330ba8c0db2c820721d4cbb3e23d817ba22fec6d058957930e229f44fa71a684 + languageName: node + linkType: hard + "@graphql-typed-document-node/core@npm:^3.1.1": version: 3.2.0 resolution: "@graphql-typed-document-node/core@npm:3.2.0" @@ -4103,6 +4319,7 @@ __metadata: version: 0.0.0-use.local resolution: "agoric-indexer@workspace:." dependencies: + "@agoric/internal": "npm:0.4.0-u18.0" "@cosmjs/stargate": "npm:^0.28.9" "@subql/cli": "npm:^5.4.0" "@subql/node-cosmos": "npm:^4.2.1" @@ -4254,6 +4471,13 @@ __metadata: languageName: node linkType: hard +"anylogger@npm:^0.21.0": + version: 0.21.0 + resolution: "anylogger@npm:0.21.0" + checksum: 10c0/1ca7fcf5bc2b78d1e1d9b8c8cc7ce50b5c6cc67a8da5a28c9c975b7b46fff255a04abab02de38a5139190c9d8b34b3d6c59af6724521b077f7d7dfbad9b47a9c + languageName: node + linkType: hard + "anymatch@npm:^3.0.3": version: 3.1.3 resolution: "anymatch@npm:3.1.3" @@ -5988,6 +6212,15 @@ __metadata: languageName: node linkType: hard +"fast-check@npm:^3.0.0": + version: 3.23.2 + resolution: "fast-check@npm:3.23.2" + dependencies: + pure-rand: "npm:^6.1.0" + checksum: 10c0/16fcff3c80321ee765e23c3aebd0f6427f175c9c6c1753104ec658970162365dc2d56bda046d815e8f2e90634c07ba7d6f0bcfd327fbd576d98c56a18a9765ed + languageName: node + linkType: hard + "fast-deep-equal@npm:^3.1.1": version: 3.1.3 resolution: "fast-deep-equal@npm:3.1.3" @@ -7133,6 +7366,15 @@ __metadata: languageName: node linkType: hard +"jessie.js@npm:^0.3.4": + version: 0.3.4 + resolution: "jessie.js@npm:0.3.4" + dependencies: + "@endo/far": "npm:^1.0.0" + checksum: 10c0/853ab3f8a0e30df11742882f5e11479d1303033a5a203a247d8ffbf4c6f3f3d4bcbefa53084ae4632e6ab106e348f23dc988280486cbeaaf5d16487fa3d40e96 + languageName: node + linkType: hard + "jest-haste-map@npm:^28.1.3": version: 28.1.3 resolution: "jest-haste-map@npm:28.1.3" @@ -8708,6 +8950,13 @@ __metadata: languageName: node linkType: hard +"pure-rand@npm:^6.1.0": + version: 6.1.0 + resolution: "pure-rand@npm:6.1.0" + checksum: 10c0/1abe217897bf74dcb3a0c9aba3555fe975023147b48db540aa2faf507aee91c03bf54f6aef0eb2bf59cc259a16d06b28eca37f0dc426d94f4692aeff02fb0e65 + languageName: node + linkType: hard + "qs@npm:6.11.0": version: 6.11.0 resolution: "qs@npm:6.11.0" @@ -9280,6 +9529,15 @@ __metadata: languageName: node linkType: hard +"ses@npm:^1.10.0": + version: 1.10.0 + resolution: "ses@npm:1.10.0" + dependencies: + "@endo/env-options": "npm:^1.1.8" + checksum: 10c0/83b92bc49e27af04eeb7ee01a2196a0c4b0906e4de51e70403aa9ffc82be1d27a0c3506f2d54da8d6d260be0855f2123a13a7e2c6896e81ec85899df1a428609 + languageName: node + linkType: hard + "set-cookie-parser@npm:^2.4.8": version: 2.7.1 resolution: "set-cookie-parser@npm:2.7.1" From 2390c50a23b24adcbeb56fd9387cc4460f61d38b Mon Sep 17 00:00:00 2001 From: rabi-siddique Date: Wed, 18 Dec 2024 22:10:51 +0500 Subject: [PATCH 07/10] ci: set execute permission for all .mjs files in scripts --- .github/workflows/liquidation.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/liquidation.yml b/.github/workflows/liquidation.yml index e164a366..54cb9d4c 100644 --- a/.github/workflows/liquidation.yml +++ b/.github/workflows/liquidation.yml @@ -37,6 +37,9 @@ jobs: docker logs $container done + - name: Set Execute Permission for All Scripts + run: chmod +x ./scripts/*.mjs + - name: Set ATOM Price to 12.34 run: ./scripts/changePrice.mjs env: From 18aafcf730bf73707dc12a81e0494410e10fc55e Mon Sep 17 00:00:00 2001 From: rabi-siddique Date: Wed, 18 Dec 2024 22:16:56 +0500 Subject: [PATCH 08/10] chore(deps): install ses --- package.json | 1 + scripts/changePrice.mjs | 1 + scripts/createVault.mjs | 1 + scripts/placeBid.mjs | 1 + yarn.lock | 1 + 5 files changed, 5 insertions(+) diff --git a/package.json b/package.json index 8c88226e..387ddbe3 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ "@subql/testing": "latest", "execa": "^9.5.2", "prettier": "^3.4.2", + "ses": "^1.10.0", "starknet": "6.11.0", "typescript": "^5.7.2" }, diff --git a/scripts/changePrice.mjs b/scripts/changePrice.mjs index e72900b9..e0939128 100644 --- a/scripts/changePrice.mjs +++ b/scripts/changePrice.mjs @@ -1,4 +1,5 @@ #! /usr/bin/env node +import 'ses'; import { execa } from 'execa'; import { assertAllDefined } from '@agoric/internal'; diff --git a/scripts/createVault.mjs b/scripts/createVault.mjs index 241df2f2..dce4e7fc 100644 --- a/scripts/createVault.mjs +++ b/scripts/createVault.mjs @@ -1,4 +1,5 @@ #! /usr/bin/env node +import 'ses'; import { execa } from 'execa'; import assert from 'node:assert/strict'; import { assertAllDefined } from '@agoric/internal'; diff --git a/scripts/placeBid.mjs b/scripts/placeBid.mjs index 8ee96e7a..223cb2b4 100644 --- a/scripts/placeBid.mjs +++ b/scripts/placeBid.mjs @@ -1,4 +1,5 @@ #! /usr/bin/env node +import 'ses'; import { execa } from 'execa'; import assert from 'node:assert/strict'; import { assertAllDefined } from '@agoric/internal'; diff --git a/yarn.lock b/yarn.lock index 9b3c15a8..93d0745a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4332,6 +4332,7 @@ __metadata: js-sha256: "npm:^0.11.0" pino: "npm:^7.8.0" prettier: "npm:^3.4.2" + ses: "npm:^1.10.0" starknet: "npm:6.11.0" typescript: "npm:^5.7.2" languageName: unknown From 9198abfa7ab8e91084f44602d2352d12566bbbd5 Mon Sep 17 00:00:00 2001 From: rabi-siddique Date: Wed, 18 Dec 2024 22:28:37 +0500 Subject: [PATCH 09/10] fixup! chore(deps): install ses --- package.json | 1 + scripts/changePrice.mjs | 2 +- scripts/createVault.mjs | 2 +- scripts/lockdown.mjs | 10 ++++++++++ scripts/placeBid.mjs | 2 +- yarn.lock | 1 + 6 files changed, 15 insertions(+), 3 deletions(-) mode change 100644 => 100755 scripts/changePrice.mjs create mode 100644 scripts/lockdown.mjs diff --git a/package.json b/package.json index 387ddbe3..8c7635f5 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "devDependencies": { "@agoric/internal": "0.4.0-u18.0", "@cosmjs/stargate": "^0.28.9", + "@endo/eventual-send": "^1.2.8", "@subql/cli": "^5.4.0", "@subql/node-cosmos": "^4.2.1", "@subql/testing": "latest", diff --git a/scripts/changePrice.mjs b/scripts/changePrice.mjs old mode 100644 new mode 100755 index e0939128..45fbaa7f --- a/scripts/changePrice.mjs +++ b/scripts/changePrice.mjs @@ -1,5 +1,5 @@ #! /usr/bin/env node -import 'ses'; +import './lockdown.mjs'; import { execa } from 'execa'; import { assertAllDefined } from '@agoric/internal'; diff --git a/scripts/createVault.mjs b/scripts/createVault.mjs index dce4e7fc..563e1f67 100644 --- a/scripts/createVault.mjs +++ b/scripts/createVault.mjs @@ -1,5 +1,5 @@ #! /usr/bin/env node -import 'ses'; +import './lockdown.mjs'; import { execa } from 'execa'; import assert from 'node:assert/strict'; import { assertAllDefined } from '@agoric/internal'; diff --git a/scripts/lockdown.mjs b/scripts/lockdown.mjs new file mode 100644 index 00000000..76a83b63 --- /dev/null +++ b/scripts/lockdown.mjs @@ -0,0 +1,10 @@ +import 'ses'; +import '@endo/eventual-send/shim.js'; + +const options = { + overrideTaming: 'severe', + stackFiltering: 'verbose', + errorTaming: 'unsafe', +}; + +lockdown(options); diff --git a/scripts/placeBid.mjs b/scripts/placeBid.mjs index 223cb2b4..a3e8f847 100644 --- a/scripts/placeBid.mjs +++ b/scripts/placeBid.mjs @@ -1,5 +1,5 @@ #! /usr/bin/env node -import 'ses'; +import './lockdown.mjs'; import { execa } from 'execa'; import assert from 'node:assert/strict'; import { assertAllDefined } from '@agoric/internal'; diff --git a/yarn.lock b/yarn.lock index 93d0745a..3d72bb34 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4321,6 +4321,7 @@ __metadata: dependencies: "@agoric/internal": "npm:0.4.0-u18.0" "@cosmjs/stargate": "npm:^0.28.9" + "@endo/eventual-send": "npm:^1.2.8" "@subql/cli": "npm:^5.4.0" "@subql/node-cosmos": "npm:^4.2.1" "@subql/testing": "npm:latest" From 0df995dfd6f9e09dd9028231847e0f50999c33e8 Mon Sep 17 00:00:00 2001 From: rabi-siddique Date: Thu, 19 Dec 2024 09:30:19 +0500 Subject: [PATCH 10/10] fixup! fixup! chore(deps): install ses --- scripts/checkLiquidation.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/checkLiquidation.mjs b/scripts/checkLiquidation.mjs index 9b8208ed..008f9ca6 100644 --- a/scripts/checkLiquidation.mjs +++ b/scripts/checkLiquidation.mjs @@ -76,7 +76,7 @@ const validate = async ({ apiUrl, maxRetries, retryDuration, expectations, filte for (const key of Object.keys(expectations)) { for (let i = 0; i < nodes.length; i++) { - equal(nodes[i][key], expectations[i].key); + equal(nodes[i][key], expectations[key][i]); } }