Skip to content

Commit

Permalink
Re-new MantaPay precomputed coins and re-enable tests (#1015)
Browse files Browse the repository at this point in the history
* Update precomputed coins and re-enable disabled tests

Signed-off-by: Georgi Zlatarev <[email protected]>

* Add the script for inserting the coins into a network

Signed-off-by: Georgi Zlatarev <[email protected]>

* Update start_iterations to 14000

Signed-off-by: Georgi Zlatarev <[email protected]>

* Update the data folder

Signed-off-by: Georgi Zlatarev <[email protected]>

* Clean up

Signed-off-by: Georgi Zlatarev <[email protected]>

* Clean up insert_coins script

Signed-off-by: Georgi Zlatarev <[email protected]>

* Fix logging in insert_coins.js

Signed-off-by: Georgi Zlatarev <[email protected]>

---------

Signed-off-by: Georgi Zlatarev <[email protected]>
  • Loading branch information
ghzlatarev authored Feb 17, 2023
1 parent ceba9fc commit 6719c8a
Show file tree
Hide file tree
Showing 7 changed files with 172 additions and 81 deletions.
77 changes: 37 additions & 40 deletions .github/workflows/integration_test_calamari.yml
Original file line number Diff line number Diff line change
Expand Up @@ -360,46 +360,43 @@ jobs:
name: test - calamari alice peered successfully
run: |
grep '\[Parachain\] 💤 Idle (${{ matrix.chain-spec.expected.peer-count.para }} peers)' ${{ github.workspace }}/polkadot-launch/9921.log
# Add the manta-pay, asset-manager and assets storage items and run stress test separately,
# in order to not break the logic of the other integration tests, which don't work with real data yet.
# NOTE: STRESS TEST TO BE FIXED/REENABLED IN https://github.com/Manta-Network/Manta/pull/984
# - name: append manta-pay storage
# run: |
# wget -P ${{ github.workspace }}/Manta/tests/data https://manta-ops.s3.amazonaws.com/integration-tests-data/storage.json
# mv $HOME/.local/share/calamari-pc/${{ matrix.chain-spec.id }}-${GITHUB_SHA:0:7}-spec.json ${{ github.workspace }}/Manta/tests/data/fork.json
# cd ${{ github.workspace }}/Manta/tests
# yarn install
# yarn
# node append_storage.js
# cd ../../
# mv ${{ github.workspace }}/Manta/tests/data/fork.json $HOME/.local/share/calamari-pc/${{ matrix.chain-spec.id }}-${GITHUB_SHA:0:7}-spec.json
# - name: launch testnet
# run: |
# cd ${{ github.workspace }}/polkadot-launch
# yarn install
# yarn build
# pm2 start dist/cli.js \
# --name polkadot-launch \
# --output ${{ github.workspace }}/polkadot-launch-for-${{ matrix.chain-spec.id }}-stdout.log \
# --error ${{ github.workspace }}/polkadot-launch-for-${{ matrix.chain-spec.id }}-stderr.log \
# --no-autorestart \
# -- $HOME/.local/share/calamari-pc/${{ matrix.chain-spec.id }}-${GITHUB_SHA:0:7}-launch-config.json
# - name: run stress test
# run: |
# sleep 720
# cd ${{ github.workspace }}/Manta/tests
# yarn install
# yarn
# yarn stress_benchmark_test --address=ws://127.0.0.1:9921 --exit
# - name: stop testnet
# run: |
# cd ${{ github.workspace }}/polkadot-launch
# pm2 stop polkadot-launch
# - if: always()
# uses: actions/upload-artifact@v2
# with:
# name: ${{ matrix.chain-spec.id }}-alice-stress.log
# path: ${{ github.workspace }}/polkadot-launch/9921.log
- name: append manta-pay storage
run: |
wget -P ${{ github.workspace }}/Manta/tests/data https://manta-ops.s3.amazonaws.com/integration-tests-data/storage.json
mv $HOME/.local/share/calamari-pc/${{ matrix.chain-spec.id }}-${GITHUB_SHA:0:7}-spec.json ${{ github.workspace }}/Manta/tests/data/fork.json
cd ${{ github.workspace }}/Manta/tests
yarn install
yarn
node append_storage.js
cd ../../
mv ${{ github.workspace }}/Manta/tests/data/fork.json $HOME/.local/share/calamari-pc/${{ matrix.chain-spec.id }}-${GITHUB_SHA:0:7}-spec.json
- name: launch testnet
run: |
cd ${{ github.workspace }}/polkadot-launch
yarn install
yarn build
pm2 start dist/cli.js \
--name polkadot-launch \
--output ${{ github.workspace }}/polkadot-launch-for-${{ matrix.chain-spec.id }}-stdout.log \
--error ${{ github.workspace }}/polkadot-launch-for-${{ matrix.chain-spec.id }}-stderr.log \
--no-autorestart \
-- $HOME/.local/share/calamari-pc/${{ matrix.chain-spec.id }}-${GITHUB_SHA:0:7}-launch-config.json
- name: run stress test
run: |
sleep 720
cd ${{ github.workspace }}/Manta/tests
yarn install
yarn
yarn stress_benchmark_test --address=ws://127.0.0.1:9921 --exit
- name: stop testnet
run: |
cd ${{ github.workspace }}/polkadot-launch
pm2 stop polkadot-launch
- if: always()
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.chain-spec.id }}-alice-stress.log
path: ${{ github.workspace }}/polkadot-launch/9921.log
docker-image-test:
if: contains(github.event.pull_request.labels.*.name, 'A-calamari' || github.ref == 'refs/heads/manta')
needs: [build-node-current, start-docker-image-tester]
Expand Down
77 changes: 37 additions & 40 deletions .github/workflows/integration_test_dolphin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -355,46 +355,43 @@ jobs:
name: test - dolphin alice peered successfully
run: |
grep '\[Parachain\] 💤 Idle (${{ matrix.chain-spec.expected.peer-count.para }} peers)' ${{ github.workspace }}/polkadot-launch/9921.log
# Add the manta-pay, asset-manager and assets storage items and run stress test separately,
# in order to not break the logic of the other integration tests, which don't work with real data yet.
# NOTE: STRESS TEST TO BE FIXED/REENABLED IN https://github.com/Manta-Network/Manta/pull/984
# - name: append manta-pay storage
# run: |
# wget -P ${{ github.workspace }}/Manta/tests/data https://manta-ops.s3.amazonaws.com/integration-tests-data/storage.json
# mv $HOME/.local/share/calamari-pc/${{ matrix.chain-spec.id }}-${GITHUB_SHA:0:7}-spec.json ${{ github.workspace }}/Manta/tests/data/fork.json
# cd ${{ github.workspace }}/Manta/tests
# yarn install
# yarn
# node append_storage.js
# cd ../../
# mv ${{ github.workspace }}/Manta/tests/data/fork.json $HOME/.local/share/calamari-pc/${{ matrix.chain-spec.id }}-${GITHUB_SHA:0:7}-spec.json
# - name: launch testnet
# run: |
# cd ${{ github.workspace }}/polkadot-launch
# yarn install
# yarn build
# pm2 start dist/cli.js \
# --name polkadot-launch \
# --output ${{ github.workspace }}/polkadot-launch-for-${{ matrix.chain-spec.id }}-stdout.log \
# --error ${{ github.workspace }}/polkadot-launch-for-${{ matrix.chain-spec.id }}-stderr.log \
# --no-autorestart \
# -- $HOME/.local/share/calamari-pc/${{ matrix.chain-spec.id }}-${GITHUB_SHA:0:7}-launch-config.json
# - name: run stress test
# run: |
# sleep 720
# cd ${{ github.workspace }}/Manta/tests
# yarn install
# yarn
# yarn stress_benchmark_test --address=ws://127.0.0.1:9921 --exit
# - name: stop testnet
# run: |
# cd ${{ github.workspace }}/polkadot-launch
# pm2 stop polkadot-launch
# - if: always()
# uses: actions/upload-artifact@v2
# with:
# name: ${{ matrix.chain-spec.id }}-alice-stress.log
# path: ${{ github.workspace }}/polkadot-launch/9921.log
- name: append manta-pay storage
run: |
wget -P ${{ github.workspace }}/Manta/tests/data https://manta-ops.s3.amazonaws.com/integration-tests-data/storage.json
mv $HOME/.local/share/calamari-pc/${{ matrix.chain-spec.id }}-${GITHUB_SHA:0:7}-spec.json ${{ github.workspace }}/Manta/tests/data/fork.json
cd ${{ github.workspace }}/Manta/tests
yarn install
yarn
node append_storage.js
cd ../../
mv ${{ github.workspace }}/Manta/tests/data/fork.json $HOME/.local/share/calamari-pc/${{ matrix.chain-spec.id }}-${GITHUB_SHA:0:7}-spec.json
- name: launch testnet
run: |
cd ${{ github.workspace }}/polkadot-launch
yarn install
yarn build
pm2 start dist/cli.js \
--name polkadot-launch \
--output ${{ github.workspace }}/polkadot-launch-for-${{ matrix.chain-spec.id }}-stdout.log \
--error ${{ github.workspace }}/polkadot-launch-for-${{ matrix.chain-spec.id }}-stderr.log \
--no-autorestart \
-- $HOME/.local/share/calamari-pc/${{ matrix.chain-spec.id }}-${GITHUB_SHA:0:7}-launch-config.json
- name: run stress test
run: |
sleep 720
cd ${{ github.workspace }}/Manta/tests
yarn install
yarn
yarn stress_benchmark_test --address=ws://127.0.0.1:9921 --exit
- name: stop testnet
run: |
cd ${{ github.workspace }}/polkadot-launch
pm2 stop polkadot-launch
- if: always()
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.chain-spec.id }}-alice-stress.log
path: ${{ github.workspace }}/polkadot-launch/9921.log
# HELPER JOBS BELOW
start-node-builder-current:
if: contains(github.event.pull_request.labels.*.name, 'A-dolphin' || github.ref == 'refs/heads/manta')
Expand Down
Binary file modified tests/data/precomputed_mints
Binary file not shown.
Binary file modified tests/data/precomputed_reclaims
Binary file not shown.
Binary file modified tests/data/precomputed_transfers
Binary file not shown.
97 changes: 97 additions & 0 deletions tests/insert_coins.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
const fs = require('fs').promises;

const keyring = new Keyring({
type: 'sr25519'
});
const nodeAddress = "ws://127.0.0.1:9801";

async function createPromiseApi(nodeAddress) {
const wsProvider = new WsProvider(nodeAddress);
const api = await ApiPromise.create({
provider: wsProvider
});
await api.isReady;
return api;
}

async function main() {
const api = await createPromiseApi(nodeAddress);
const sender = keyring.addFromMnemonic("bottom drive obey lake curtain smoke basket hold race lonely fit walk//Alice");

const mints_file = '/home/georgi/Desktop/workspace/Manta/precomputed-15k-iterations/precomputed_mints_v3-5';
const transfers_file = '/home/georgi/Desktop/workspace/Manta/precomputed-15k-iterations/precomputed_transfers_v3-5';
const reclaims_file = '/home/georgi/Desktop/workspace/Manta/precomputed-15k-iterations/precomputed_reclaims_v3-5';

const mints_buffer = await fs.readFile(mints_file);
const transfers_buffer = await fs.readFile(transfers_file);
const reclaims_buffer = await fs.readFile(reclaims_file);

const mints_offset = 2;
const transfers_offset = 4;
const reclaims_offset = 4;
const total_iterations = 15000;
const mint_size = 552;
const transfer_size = 100;

let batches_sent = 0;
const transactions = [];

for (let i = 0; i < total_iterations; i++) {
const mints_start = mints_offset + i * mint_size;
const mint = api.tx.mantaPay.toPrivate(mints_buffer.subarray(mints_start, mint_size + mints_start));
transactions.push(mint);

const transfers_start = transfers_offset + i * (2 * mint_size + transfer_size);
const transfer_mint_1 = api.tx.mantaPay.toPrivate(transfers_buffer.subarray(transfers_start, transfers_start + mint_size));
const transfer_mint_2 = api.tx.mantaPay.toPrivate(transfers_buffer.subarray(transfers_start + mint_size, transfers_start + 2 * mint_size));
const transfer = api.tx.mantaPay.privateTransfer(transfers_buffer.subarray(transfers_start + 2 * mint_size, transfers_start + 2 * mint_size + transfer_size));
transactions.push(transfer_mint_1);
transactions.push(transfer_mint_2);
transactions.push(transfer);

await api.tx.utility.forceBatch(transactions).signAndSend(sender, {
nonce: -1
}, ({
events = [],
status
}) => {
if (status.isFinalized) {
console.log("tx %i success.", status.nonce);
}
if (status.isDropped || status.isUsurped || status.isFinalityTimeout || status.isRetracted) {
console.err(`tx %i ${status.type}.`, status.nonce);
}
});

await new Promise(resolve => setTimeout(resolve, 10000));
transactions.length = 0;

const reclaims_start = reclaims_offset + i * (2 * mint_size + transfer_size);
const reclaim_mint_1 = api.tx.mantaPay.toPrivate(reclaims_buffer.subarray(reclaims_start, reclaims_start + mint_size));
const reclaim_mint_2 = api.tx.mantaPay.toPrivate(reclaims_buffer.subarray(reclaims_start, reclaims_start + mint_size));
const reclaim = api.tx.mantaPay.toPrivate(reclaims_buffer.subarray(reclaims_start, reclaims_start + mint_size));
transactions.push(reclaim_mint_1);
transactions.push(reclaim_mint_2);
transactions.push(reclaim);

await api.tx.utility.forceBatch(transactions).signAndSend(sender, {
nonce: -1
}, ({
events = [],
status
}) => {
if (status.isFinalized) {
console.log("tx %i success.", status.nonce);
}
if (status.isDropped || status.isUsurped || status.isFinalityTimeout || status.isRetracted) {
console.err(`tx %i ${status.type}.`, status.nonce);
}
});

await new Promise(resolve => setTimeout(resolve, 10000));
transactions.length = 0;

}
}

main().catch(console.error);
2 changes: 1 addition & 1 deletion tests/stress_benchmark_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const test_config = {
transfers_offset: 4,
reclaims_offset: 4,
total_iterations: 15000,
start_iteration: 13500,
start_iteration: 14000,
tests_iterations: 100,
mint_size: 552,
transfer_size: 1290,
Expand Down

0 comments on commit 6719c8a

Please sign in to comment.