Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSUB-552: test for panic after rebase #1165

Merged
merged 15 commits into from
Jul 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
155 changes: 146 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -277,16 +277,10 @@ jobs:
fail_ci_if_error: true
verbose: true

integration-test:
build-creditcoin-node:
runs-on: ubuntu-22.04
# checkov:skip=CKV2_GHA_1:We need this for creditcoin-js typedefs auto-commit
permissions: write-all
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 10
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}

- name: Set-Up
run: |
Expand All @@ -311,11 +305,43 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: build
args: --release
args: --release --features fast-runtime

- name: Upload creditcoin-node binary
uses: actions/upload-artifact@v3
with:
name: creditcoin-node
path: target/release/creditcoin-node

- name: Upload WASM runtime
uses: actions/upload-artifact@v3
with:
name: creditcoin_node_runtime.compact.compressed.wasm
path: target/release/wbuild/creditcoin-node-runtime/creditcoin_node_runtime.compact.compressed.wasm

integration-test-loan-cycle:
needs:
- build-creditcoin-node
runs-on: ubuntu-22.04
# checkov:skip=CKV2_GHA_1:We need this for creditcoin-js typedefs auto-commit
permissions: write-all
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 10
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}

- name: Download creditcoin-node binary
uses: actions/download-artifact@v3
with:
name: creditcoin-node
path: target/release

- name: Start SUT
run: |
cargo run --release -- --dev --mining-key 5DkPYq8hFiCeGxFBkz6DAwnTrvKevAJfTYrzFtr9hpDsEAU1 --monitor-nonce auto >~/creditcoin-node.log 2>&1 &
chmod a+x ./target/release/creditcoin-node
./target/release/creditcoin-node --dev --mining-key 5DkPYq8hFiCeGxFBkz6DAwnTrvKevAJfTYrzFtr9hpDsEAU1 --monitor-nonce auto >~/creditcoin-node.log 2>&1 &

- name: Start local Ethereum node
run: |
Expand Down Expand Up @@ -394,6 +420,117 @@ jobs:
# dangling processes
killall -9 creditcoin-node

integration-test-csub-552:
needs:
- build-creditcoin-node
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3

- name: Download creditcoin-node binary
uses: actions/download-artifact@v3
with:
name: creditcoin-node
path: target/release

- name: Download runtime
uses: actions/download-artifact@v3
with:
name: creditcoin_node_runtime.compact.compressed.wasm
path: target/release

- name: Install Subwasm
uses: actions-rs/cargo@v1
with:
command: install
args: --locked --git https://github.com/chevdor/subwasm --tag v0.17.1

- name: Import blocks
run: |
chmod a+x ./target/release/creditcoin-node
./target/release/creditcoin-node import-blocks \
--chain ./integration-tests/csub-552/reproSpec.json \
--base-path ./integration-tests/csub-552/chaindata/node1 \
--state-pruning archive --blocks-pruning archive \
--database paritydb ./integration-tests/csub-552/repro.blocks

- name: Start Node 1
run: |
./target/release/creditcoin-node \
--chain ./integration-tests/csub-552/reproSpec.json \
--validator --alice --mining-threads 1 --pruning archive \
--mining-key 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY \
--node-key 844794b5f1da387970d769debc3a30f729f3515841121ccecebed2582723e04d \
--base-path ./integration-tests/csub-552/chaindata/node1 >creditcoin-node1.log 2>&1 &

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 16
- run: npm install -g yarn

- name: switchToPos()
run: |
pushd ./creditcoin-js/ && yarn install && yarn pack && popd || exit 1
yarn --cwd ./scripts/js upgrade 'creditcoin-js'
yarn --cwd ./scripts/js runtimeUpgrade ws://127.0.0.1:9944 ../../target/release/creditcoin_node_runtime.compact.compressed.wasm //Alice 0
atodorov marked this conversation as resolved.
Show resolved Hide resolved
yarn --cwd ./scripts/js switchToPos ws://127.0.0.1:9944 //Alice 5

- name: Wait for finalized blocks to catch-up
run: |
./scripts/wait-for-finalized-blocks.sh

- name: Store info about the last finalized block
id: last-block-info
run: |
# store info about the last finalized block before the fork
LAST_BLOCK=$(curl --silent -H "Content-Type: application/json" \
-d '{"id": 1, "jsonrpc": "2.0", "method": "chain_getFinalizedHead", "params": [] }' \
http://127.0.0.1:9933 | jq -r .result)

while true; do
LAST_BLOCK_NUMBER=$(curl --silent -H "Content-Type: application/json" \
-d "{\"id\": 1, \"jsonrpc\": \"2.0\", \"method\": \"chain_getBlock\", \"params\": [\"$LAST_BLOCK\"] }" \
http://127.0.0.1:9933 | jq -r .result | jq -r .block.header.number)

if [ "$LAST_BLOCK_NUMBER" != "null" ]; then
break
else
echo "INFO: retry fetching block info for $LAST_BLOCK"
sleep 10
fi
done
echo "last_block_number=$LAST_BLOCK_NUMBER" >> "$GITHUB_OUTPUT"

- name: Start Node 2
run: |
./target/release/creditcoin-node \
--base-path integration-tests/csub-552/chaindata/node2 \
--chain integration-tests/csub-552/reproSpec.json \
--validator --mining-threads 1 --pruning archive \
--mining-key 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY \
--bootnodes '/ip4/127.0.0.1/tcp/30333/p2p/12D3KooWSrv5vZAh2Xr97BpyHLZ8scGqcaPr8CLYvm4EVtLwKiXy' \
--port 30332 --ws-port 9942 --rpc-port 9932 >creditcoin-node2.log 2>&1 &

- name: Wait for node2 to sync past block number ${{ steps.last-block-info.outputs.last_block_number }}
run: |
# Note: node2 will crash if a panic occurs and this script would fail
./scripts/wait-for-sync.sh ${{ steps.last-block-info.outputs.last_block_number }} http://127.0.0.1:9932

- name: Upload logs
uses: actions/upload-artifact@v3
if: always()
with:
name: csub-552-logs
path: "*.log"

- name: Kill SUT
run: |
# if all went well kill the node. Otherwise GitHub Actions would exit on the
# previous step killing everything and we don't have to worry about
# dangling processes
killall -9 creditcoin-node

javascript-lint:
name: javascript-lint / ${{ matrix.directory }}
runs-on: ubuntu-22.04
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/runtime-upgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
id: last-block-info
run: |
# store info about the last finalized block before the fork
# WARNING: using getBlockHash() instead of getFinalizedBlock() b/c PoW doesn't have finalization
# WARNING: using getBlockHash() instead of getFinalizedHead() b/c PoW doesn't have finalization
LAST_BLOCK=$(curl --silent -H "Content-Type: application/json" \
-d '{"id": 1, "jsonrpc": "2.0", "method": "chain_getBlockHash", "params": [] }' \
${{ env.HTTPS_RPC_URL }} | jq -r .result)
Expand Down Expand Up @@ -204,7 +204,7 @@ jobs:
id: last-block-info
run: |
# store info about the last finalized block before the fork
# WARNING: using getBlockHash() instead of getFinalizedBlock() b/c PoW doesn't have finalization
# WARNING: using getBlockHash() instead of getFinalizedHead() b/c PoW doesn't have finalization
LAST_BLOCK=$(curl --silent -H "Content-Type: application/json" \
-d '{"id": 1, "jsonrpc": "2.0", "method": "chain_getBlockHash", "params": [] }' \
http://127.0.0.1:9933 | jq -r .result)
Expand Down Expand Up @@ -284,14 +284,16 @@ jobs:
with:
name: creditcoin_node_runtime.compact.compressed.wasm

- name: Upgrade WASM
- name: Upgrade WASM & switchToPos
run: |
yarn --cwd ./scripts/js upgrade 'creditcoin-js'
echo "DEBUG: **** free memory before runtimeUpgrade ****"
free -m
ps aux --sort=-%mem | head -n 20
echo "DEBUG: *********************"
yarn --cwd ./scripts/js runtimeUpgrade ws://127.0.0.1:9944 ../../creditcoin_node_runtime.compact.compressed.wasm //Alice 0
sleep 10
yarn --cwd ./scripts/js switchToPos ws://127.0.0.1:9944 //Alice

# TODO: wait & confirm wasm upgrade has finished, incl. migrations
- name: Execute integration tests
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ justfile
docs/dev-guide/book

**/.yarn/cache

integration-tests/csub-552/chaindata/*
!integration-tests/csub-552/chaindata/.gitkeep
Loading