This repository has been archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 380
Add extrincic ordering check to CI #629
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
0cfce3a
Add extrincic ordering check to CI
chevdor ca86b39
Add missing script
chevdor 6ba910a
Fix default chain
chevdor 994d4c5
Ignore issues with pkill
chevdor ace7da6
Continue on error while trying to stop the node
chevdor 3b60a1f
Set embedded relay chain node
chevdor 8b4e43f
Fix formatting
chevdor File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# This workflow performs the Extrinsic Ordering Check on demand using a binary | ||
|
||
name: Extrinsic Ordering Check from Binary | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
reference_url: | ||
description: The WebSocket url of the reference node | ||
default: wss://kusama-statemine-rpc.paritytech.net | ||
required: true | ||
binary_url: | ||
description: A url to a Linux binary for the node containing the runtime to test | ||
default: https://github.com/paritytech/cumulus/releases/download/statemine_v3/polkadot-collator | ||
required: true | ||
chain: | ||
description: The name of the chain under test. Usually, you would pass a local chain | ||
default: statemine-local | ||
required: true | ||
|
||
jobs: | ||
check: | ||
name: Run check | ||
runs-on: ubuntu-latest | ||
env: | ||
CHAIN: ${{github.event.inputs.chain}} | ||
BIN_URL: ${{github.event.inputs.binary_url}} | ||
REF_URL: ${{github.event.inputs.reference_url}} | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Fetch binary | ||
run: | | ||
echo Fetching $BIN_URL | ||
wget $BIN_URL | ||
chmod a+x polkadot-collator | ||
./polkadot-collator --version | ||
|
||
- name: Start local node | ||
run: | | ||
echo Running on $CHAIN | ||
./polkadot-collator --chain=$CHAIN -- --chain polkadot-local & | ||
|
||
- name: Prepare output | ||
run: | | ||
VERSION=$(./polkadot-collator --version) | ||
echo "Metadata comparison:" >> output.txt | ||
echo "Date: $(date)" >> output.txt | ||
echo "Reference: $REF_URL" >> output.txt | ||
echo "Target version: $VERSION" >> output.txt | ||
echo "Chain: $CHAIN" >> output.txt | ||
echo "----------------------------------------------------------------------" >> output.txt | ||
|
||
- name: Pull polkadot-js-tools image | ||
run: docker pull jacogr/polkadot-js-tools | ||
|
||
- name: Compare the metadata | ||
run: | | ||
CMD="docker run --pull always --network host jacogr/polkadot-js-tools metadata $REF_URL ws://localhost:9944" | ||
echo -e "Running:\n$CMD" | ||
$CMD >> output.txt | ||
sed -z -i 's/\n\n/\n/g' output.txt | ||
cat output.txt | egrep -n -i '' | ||
SUMMARY=$(./scripts/extrinsic-ordering-filter.sh output.txt) | ||
echo -e $SUMMARY | ||
echo -e $SUMMARY >> output.txt | ||
|
||
- name: Show result | ||
run: | | ||
cat output.txt | ||
|
||
- name: Stop our local node | ||
run: | | ||
pkill polkadot-collator | ||
continue-on-error: true | ||
|
||
- name: Save output as artifact | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: ${{ env.CHAIN }} | ||
path: | | ||
output.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/usr/bin/env bash | ||
# This script is used in a Github Workflow. It helps filtering out what is interesting | ||
# when comparing metadata and spot what would require a tx version bump. | ||
|
||
# shellcheck disable=SC2002,SC2086 | ||
|
||
FILE=$1 | ||
|
||
# Higlight indexes that were deleted | ||
function find_deletions() { | ||
echo "\n## Deletions\n" | ||
RES=$(cat "$FILE" | grep -n '\[\-\]' | tr -s " ") | ||
if [ "$RES" ]; then | ||
echo "$RES" | awk '{ printf "%s\\n", $0 }' | ||
else | ||
echo "n/a" | ||
fi | ||
} | ||
|
||
# Highlight indexes that have been deleted | ||
function find_index_changes() { | ||
echo "\n## Index changes\n" | ||
RES=$(cat "$FILE" | grep -E -n -i 'idx:\s*([0-9]+)\s*(->)\s*([0-9]+)' | tr -s " ") | ||
if [ "$RES" ]; then | ||
echo "$RES" | awk '{ printf "%s\\n", $0 }' | ||
else | ||
echo "n/a" | ||
fi | ||
} | ||
|
||
# Highlight values that decreased | ||
function find_decreases() { | ||
echo "\n## Decreases\n" | ||
OUT=$(cat "$FILE" | grep -E -i -o '([0-9]+)\s*(->)\s*([0-9]+)' | awk '$1 > $3 { printf "%s;", $0 }') | ||
IFS=$';' LIST=("$OUT") | ||
unset RES | ||
for line in "${LIST[@]}"; do | ||
RES="$RES\n$(cat "$FILE" | grep -E -i -n \"$line\" | tr -s " ")" | ||
done | ||
|
||
if [ "$RES" ]; then | ||
echo "$RES" | awk '{ printf "%s\\n", $0 }' | sort -u -g | uniq | ||
else | ||
echo "n/a" | ||
fi | ||
} | ||
|
||
echo "\n------------------------------ SUMMARY -------------------------------" | ||
echo "\n⚠️ This filter is here to help spotting changes that should be reviewed carefully." | ||
echo "\n⚠️ It catches only index changes, deletions and value decreases". | ||
|
||
find_deletions "$FILE" | ||
find_index_changes "$FILE" | ||
find_decreases "$FILE" | ||
echo "\n----------------------------------------------------------------------\n" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is hard-coded to v3, we might want to default to latest?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just an example to show the pattern. In general, users will NOT use latest, they will want to point at a specific version so having the version show up makes it easier. Once we have v4 released, it will be obviouls how to change the default string. If I replace with latest, the user will not (easily) know whether to use
3
orv3
for instance.