Snowbridge - Test pallet order (#3381)

- Adds a test to check the correct digest for Snowbridge outbound
messages. For the correct digest to be in the block, the the
MessageQueue pallet should be configured after the EthereumOutbound
queue pallet. The added test fails if the EthereumOutbound is configured
after the MessageQueue pallet.
- Adds a helper method `run_to_block_with_finalize` to simulate the
block finalizing. The existing `run_to_block` method does not finalize
and so it cannot successfully test this condition.

Closes: https://github.com/paritytech/polkadot-sdk/issues/3208

---------

Co-authored-by: claravanstaden <Cats 4 life!>
This commit is contained in:
Clara van Staden
2024-02-21 16:48:40 +02:00
committed by GitHub
parent bf7c49b33c
commit 5a06771ecc
16 changed files with 332 additions and 155 deletions
+80
View File
@@ -0,0 +1,80 @@
#!/bin/bash
# A script to cleanup the Snowfork fork of the polkadot-sdk to contribute it upstream back to parity/polkadot-sdk
# ./bridges/snowbridge/scripts/contribute-upstream.sh <branchname>
# show CLI help
function show_help() {
set +x
echo " "
echo Error: $1
echo "Usage:"
echo " ./bridges/snowbridge/scripts/contribute-upstream.sh <branchname> Exit with code 0 if pallets code is well decoupled from the other code in the repo"
exit 1
}
if [[ -z "$1" ]]; then
echo "Please provide a branch name you would like your upstream branch to be named"
exit 1
fi
branch_name=$1
set -eux
# let's avoid any restrictions on where this script can be called for - snowbridge repo may be
# plugged into any other repo folder. So the script (and other stuff that needs to be removed)
# may be located either in call dir, or one of it subdirs.
SNOWBRIDGE_FOLDER="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/../"
# Get the current Git branch name
current_branch=$(git rev-parse --abbrev-ref HEAD)
if [ "$current_branch" = "$branch_name" ] || git branch | grep -q "$branch_name"; then
echo "Already on requested branch or branch exists, not creating."
else
git branch "$branch_name"
fi
git checkout "$branch_name"
# remove everything we think is not required for our needs
rm -rf rust-toolchain.toml
rm -rf $SNOWBRIDGE_FOLDER/.cargo
rm -rf $SNOWBRIDGE_FOLDER/.github
rm -rf $SNOWBRIDGE_FOLDER/SECURITY.md
rm -rf $SNOWBRIDGE_FOLDER/.gitignore
rm -rf $SNOWBRIDGE_FOLDER/templates
rm -rf $SNOWBRIDGE_FOLDER/pallets/ethereum-client/fuzz
pushd $SNOWBRIDGE_FOLDER
# let's test if everything we need compiles
cargo check -p snowbridge-pallet-ethereum-client
cargo check -p snowbridge-pallet-ethereum-client --features runtime-benchmarks
cargo check -p snowbridge-pallet-ethereum-client --features try-runtime
cargo check -p snowbridge-pallet-inbound-queue
cargo check -p snowbridge-pallet-inbound-queue --features runtime-benchmarks
cargo check -p snowbridge-pallet-inbound-queue --features try-runtime
cargo check -p snowbridge-pallet-outbound-queue
cargo check -p snowbridge-pallet-outbound-queue --features runtime-benchmarks
cargo check -p snowbridge-pallet-outbound-queue --features try-runtime
cargo check -p snowbridge-pallet-system
cargo check -p snowbridge-pallet-system --features runtime-benchmarks
cargo check -p snowbridge-pallet-system --features try-runtime
# we're removing lock file after all checks are done. Otherwise we may use different
# Substrate/Polkadot/Cumulus commits and our checks will fail
rm -f $SNOWBRIDGE_FOLDER/Cargo.toml
rm -f $SNOWBRIDGE_FOLDER/Cargo.lock
popd
# Replace Parity's CI files, that we have overwritten in our fork, to run our own CI
rm -rf .github
git remote -v | grep -w parity || git remote add parity https://github.com/paritytech/polkadot-sdk
git fetch parity master
git checkout parity/master -- .github
git add -- .github
echo "OK"
@@ -1,116 +0,0 @@
#!/bin/bash
# A script to remove everything from snowbridge repository/subtree, except:
#
# - parachain
# - readme
# - license
set -eu
# show CLI help
function show_help() {
set +x
echo " "
echo Error: $1
echo "Usage:"
echo " ./scripts/verify-pallets-build.sh Exit with code 0 if pallets code is well decoupled from the other code in the repo"
echo "Options:"
echo " --no-revert Leaves only runtime code on exit"
echo " --ignore-git-state Ignores git actual state"
exit 1
}
# parse CLI args
NO_REVERT=
IGNORE_GIT_STATE=
for i in "$@"
do
case $i in
--no-revert)
NO_REVERT=true
shift
;;
--ignore-git-state)
IGNORE_GIT_STATE=true
shift
;;
*)
show_help "Unknown option: $i"
;;
esac
done
# the script is able to work only on clean git copy, unless we want to ignore this check
[[ ! -z "${IGNORE_GIT_STATE}" ]] || [[ -z "$(git status --porcelain)" ]] || { echo >&2 "The git copy must be clean"; exit 1; }
# let's avoid any restrictions on where this script can be called for - snowbridge repo may be
# plugged into any other repo folder. So the script (and other stuff that needs to be removed)
# may be located either in call dir, or one of it subdirs.
SNOWBRIDGE_FOLDER="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/../.."
# remove everything we think is not required for our needs
rm -rf $SNOWBRIDGE_FOLDER/.cargo
rm -rf $SNOWBRIDGE_FOLDER/.github
rm -rf $SNOWBRIDGE_FOLDER/contracts
rm -rf $SNOWBRIDGE_FOLDER/codecov.yml
rm -rf $SNOWBRIDGE_FOLDER/docs
rm -rf $SNOWBRIDGE_FOLDER/hooks
rm -rf $SNOWBRIDGE_FOLDER/relayer
rm -rf $SNOWBRIDGE_FOLDER/scripts
rm -rf $SNOWBRIDGE_FOLDER/SECURITY.md
rm -rf $SNOWBRIDGE_FOLDER/smoketest
rm -rf $SNOWBRIDGE_FOLDER/web
rm -rf $SNOWBRIDGE_FOLDER/.envrc-example
rm -rf $SNOWBRIDGE_FOLDER/.gitbook.yaml
rm -rf $SNOWBRIDGE_FOLDER/.gitignore
rm -rf $SNOWBRIDGE_FOLDER/.gitmodules
rm -rf $SNOWBRIDGE_FOLDER/_typos.toml
rm -rf $SNOWBRIDGE_FOLDER/_codecov.yml
rm -rf $SNOWBRIDGE_FOLDER/flake.lock
rm -rf $SNOWBRIDGE_FOLDER/flake.nix
rm -rf $SNOWBRIDGE_FOLDER/go.work
rm -rf $SNOWBRIDGE_FOLDER/go.work.sum
rm -rf $SNOWBRIDGE_FOLDER/polkadot-sdk
rm -rf $SNOWBRIDGE_FOLDER/rust-toolchain.toml
rm -rf $SNOWBRIDGE_FOLDER/parachain/rustfmt.toml
rm -rf $SNOWBRIDGE_FOLDER/parachain/.gitignore
rm -rf $SNOWBRIDGE_FOLDER/parachain/templates
rm -rf $SNOWBRIDGE_FOLDER/parachain/.cargo
rm -rf $SNOWBRIDGE_FOLDER/parachain/.config
rm -rf $SNOWBRIDGE_FOLDER/parachain/pallets/ethereum-client/fuzz
cd bridges/snowbridge/parachain
# fix polkadot-sdk paths in Cargo.toml files
find "." -name 'Cargo.toml' | while read -r file; do
replace=$(printf '../../' )
if [[ "$(uname)" = "Darwin" ]] || [[ "$(uname)" = *BSD ]]; then
sed -i '' "s|polkadot-sdk/|$replace|g" "$file"
else
sed -i "s|polkadot-sdk/|$replace|g" "$file"
fi
done
# let's test if everything we need compiles
cargo check -p snowbridge-pallet-ethereum-client
cargo check -p snowbridge-pallet-ethereum-client --features runtime-benchmarks
cargo check -p snowbridge-pallet-ethereum-client --features try-runtime
cargo check -p snowbridge-pallet-inbound-queue
cargo check -p snowbridge-pallet-inbound-queue --features runtime-benchmarks
cargo check -p snowbridge-pallet-inbound-queue --features try-runtime
cargo check -p snowbridge-pallet-outbound-queue
cargo check -p snowbridge-pallet-outbound-queue --features runtime-benchmarks
cargo check -p snowbridge-pallet-outbound-queue --features try-runtime
cargo check -p snowbridge-pallet-system
cargo check -p snowbridge-pallet-system --features runtime-benchmarks
cargo check -p snowbridge-pallet-system --features try-runtime
cd -
# we're removing lock file after all checks are done. Otherwise we may use different
# Substrate/Polkadot/Cumulus commits and our checks will fail
rm -f $SNOWBRIDGE_FOLDER/parachain/Cargo.toml
rm -f $SNOWBRIDGE_FOLDER/parachain/Cargo.lock
echo "OK"