Skip to content

Commit

Permalink
Merge branch 'main' into ethereum-headers-on-demand
Browse files Browse the repository at this point in the history
  • Loading branch information
claravanstaden authored Jul 3, 2024
2 parents b818954 + b900992 commit 13a5538
Show file tree
Hide file tree
Showing 10 changed files with 244 additions and 35 deletions.
30 changes: 28 additions & 2 deletions .github/changelog-processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,39 @@
help="Print the changelog from the last release.",
action="store_true"
)
group.add_argument(
"--validate-changelog",
dest="validate_changelog",
help="Validates that the changelog uses the correct syntax",
action="store_true"
)

args = parser.parse_args()

with open(args.changelog, "r") as changelog:
lines = changelog.readlines()

if args.validate_changelog:
for line in lines:
if line.startswith("##"):
if line.startswith("###"):
continue
elif not line.startswith("## ["):
print("Line starting with `##` needs to be followed by ` [`, e.g.: `## [Unreleased]`, `## [400.2.1]`")
print(line)
sys.exit(-1)
elif line.strip().removeprefix("## [").split("]")[0].count(".") != 2 and not "unreleased" in line.lower():
print("Only Major.Minor.Patch are supported as versioning")
print(line)
sys.exit(-1)
elif line.startswith("#"):
if line.strip() != "# Changelog":
print("Line starting with `#` is only allowed for `# Changelog`")
print(line)
sys.exit(-1)

sys.exit(0)

changelog_last_release = ""
found_last_version = False

Expand All @@ -53,7 +80,6 @@
else:
break


if args.changelog_last_release:
print(changelog_last_release, end = "")
sys.exit(0)
Expand All @@ -63,7 +89,7 @@
elif args.should_release:
if version.lower() == "unreleased":
print("0", end = "")
sys.exit(-1)
sys.exit(0)
elif version.count(".") != 2:
print("0", end = "")
sys.exit(-1)
Expand Down
47 changes: 41 additions & 6 deletions .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
name: Modify Changelog
name: Verify Changelog

# If you modify more test jobs, ensure that you add them as required to the job "confirmTestPassed"
# which is located at the end of this file (more info in the job)

on:
pull_request_target:
types:
- synchronize
- edited
push:
branches: ["main", "release-*"]
pull_request:
types: [opened, reopened, synchronize, edited]
workflow_dispatch:

# cancel previous runs
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:

verifyChangelog:
verify-changelog-updated:
name: Verify that Changelog is Updated
runs-on: ubuntu-latest
env:
Expand All @@ -22,3 +31,29 @@ jobs:
- name: Set error
if: steps.changed.outputs.matched != 'true' && !contains(github.event.pull_request.body, '[x] Does not require a CHANGELOG entry')
run: echo "::error::CHANGELOG.md has not been modified. Either modify the file or check the checkbox in the body" && exit 1

verify-changelog-valid:
name: Verify that Changelog is valid
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ github.token }}
steps:
- name: Checkout sources
uses: actions/checkout@v3

- name: Verify
run: .github/changelog-processor.py CHANGELOG.md --validate-changelog

# This will only run if all the tests in its "needs" array passed.
# Add this as your required job, becuase if the matrix changes size (new things get added)
# it will still require all the steps to succeed.
# If you add more jobs, remember to add them to the "needs" array.
confirmChangelogChecksPassed:
runs-on: ubuntu-latest
name: All tests passed
# If any new job gets added, be sure to add it to this list
needs:
- verify-changelog-updated
- verify-changelog-valid
steps:
- run: echo '### Good job! All the tests passed 🚀' >> $GITHUB_STEP_SUMMARY
3 changes: 2 additions & 1 deletion .github/workflows/check-migrations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ jobs:
fi
# Disable the spec version check when we dont want to release.
if ! .github/changelog-processor.py CHANGELOG.md --should-release ; then
# The program prints either `1` or `0`.
if [ "$(.github/changelog-processor.py CHANGELOG.md --should-release)" = "0" ]; then
EXTRA_FLAGS+=" --disable-spec-version-check"
echo "Disabling the spec version check since we are not releasing"
else
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/fmt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ on:
pull_request:
workflow_dispatch:

# Cancel a currently running workflow from the same PR, branch or tag when a new workflow is
# triggered (ref https://stackoverflow.com/a/72408109)
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
rustfmt:
runs-on: ubuntu-22.04
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/review-trigger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ on:
- review_request_removed
- ready_for_review
pull_request_review:
pull_request:
workflow_dispatch:

jobs:
trigger-review-bot:
Expand All @@ -36,7 +38,7 @@ jobs:
github.event_name == 'pull_request_target' &&
github.event.action == 'synchronize' &&
github.event.sender.login == github.event.pull_request.user.login &&
contains(steps.fellows.outputs.github-handles, github.event.pull_request.user.login)
!contains(steps.fellows.outputs.github-handles, github.event.pull_request.user.login)
run: |
# We get the list of reviewers who approved the PR
REVIEWERS=$(gh api repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/reviews \
Expand Down
5 changes: 0 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,6 @@ jobs:
matrix:
runtime: ${{ fromJSON(needs.runtime-matrix.outputs.runtime) }}
steps:
- name: Cancel previous runs
uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 # v0.11.0
with:
access_token: ${{ github.token }}

- name: Install updates and protobuf-compiler
run: sudo apt update && sudo apt install --assume-yes cmake protobuf-compiler

Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Changelog for the runtimes governed by the Polkadot Fellowship.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## Unreleased
## [Unreleased]

### Changed

Expand Down
38 changes: 21 additions & 17 deletions integration-tests/bridges/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,30 @@ The tests are designed to be run manually.

To start a test, you need to:

- download latest [zombienet release](https://github.com/paritytech/zombienet/releases) to
`~/local_bridge_testing/bin/zombienet`.

- build Polkadot binary by running `cargo build -p polkadot --release` command in the
[`polkadot-sdk`](https://github.com/paritytech/polkadot-sdk) repository clone.

- download latest [zombienet release](https://github.com/paritytech/zombienet/releases) to `~/local_bridge_testing/bin/zombienet`.
- build Polkadot binaries by running commands in the [`polkadot-sdk`](https://github.com/paritytech/polkadot-sdk) repository clone:
```
cargo build -p polkadot --release
cargo build --bin polkadot-prepare-worker --release
cargo build --bin polkadot-execute-worker --release
```
Copy the binaries to:
```
~/local_bridge_testing/bin/polkadot
~/local_bridge_testing/bin/polkadot-prepare-worker
~/local_bridge_testing/bin/polkadot-execute-worker
```
- build Polkadot Parachain binary by running `cargo build -p polkadot-parachain-bin --release` command in the
[`polkadot-sdk`](https://github.com/paritytech/polkadot-sdk) repository clone.

[`polkadot-sdk`](https://github.com/paritytech/polkadot-sdk) repository clone. Copy the binary to `~/local_bridge_testing/bin/polkadot-parachain`.
- ensure that you have [`node`](https://nodejs.org/en) installed. Additionally, we'll need globally installed
`polkadot/api-cli` package (use `yarn global add @polkadot/api-cli` to install it).

`polkadot/api-cli` / `polkadot/api` packages (use `yarn global add @polkadot/api-cli` to install it).
- build Substrate relay by running `cargo build -p substrate-relay --release` command in the
[`parity-bridges-common`](https://github.com/paritytech/parity-bridges-common) repository clone. Copy the binary to `~/local_bridge_testing/bin/substrate-relay`.

- add the `sudo` pallet to the Polkadot and Kusama runtimes and give sudo rights to Alice. With this change build
the chain spec generator by running `cargo build --release -p chain-spec-generator --features fast-runtime`
[`parity-bridges-common`](https://github.com/paritytech/parity-bridges-common) repository clone. Copy the binary to `~/local_bridge_testing/bin/substrate-relay`.
- build chain spec generator:
- add the `sudo` pallet to the Polkadot and Kusama runtimes and give sudo rights to Alice, e.g. by running `git apply ./integration-tests/bridges/sudo-relay.patch` from the fellows root dir.
- with this change build the chain spec generator by running `cargo build --release -p chain-spec-generator --features fast-runtime`
command. Copy the binary to `~/local_bridge_testing/bin/chain-spec-generator`.

- change the `POLKADOT_BINARY` and `POLKADOT_PARACHAIN_BINARY` paths (and ensure that the nearby variables
- check/change the `POLKADOT_BINARY` and `POLKADOT_PARACHAIN_BINARY` paths (and ensure that the nearby variables
have correct values) in the `./run-test.sh`.

After that, you can run `./run-tests.sh <test_name>` command.
After that, you can run `./run-tests.sh <test_name>` command. E.g. `./run-test.sh 0001-polkadot-kusama-asset-transfer`.
4 changes: 2 additions & 2 deletions integration-tests/bridges/run-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ export FRAMEWORK_PATH=$framework_repo_path/bridges/testing/framework
echo

export ZOMBIENET_BINARY=$LOCAL_BRIDGE_TESTING_PATH/bin/zombienet
export POLKADOT_BINARY=/home/serban/workplace/sources/polkadot-sdk/target/release/polkadot
export POLKADOT_PARACHAIN_BINARY=/home/serban/workplace/sources/polkadot-sdk/target/release/polkadot-parachain
export POLKADOT_BINARY=$LOCAL_BRIDGE_TESTING_PATH/bin/polkadot
export POLKADOT_PARACHAIN_BINARY=$LOCAL_BRIDGE_TESTING_PATH/bin/polkadot-parachain
export CHAIN_SPEC_GEN_BINARY=$LOCAL_BRIDGE_TESTING_PATH/bin/chain-spec-generator
export SUBSTRATE_RELAY_BINARY=$LOCAL_BRIDGE_TESTING_PATH/bin/substrate-relay

Expand Down
140 changes: 140 additions & 0 deletions integration-tests/bridges/sudo-relay.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
diff --git a/Cargo.lock b/Cargo.lock
index 3873911e9..69bcc63be 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -10914,6 +10914,7 @@ dependencies = [
"pallet-staking-reward-fn",
"pallet-staking-runtime-api",
"pallet-state-trie-migration",
+ "pallet-sudo",
"pallet-timestamp",
"pallet-transaction-payment",
"pallet-transaction-payment-rpc-runtime-api",
@@ -16003,6 +16004,7 @@ dependencies = [
"pallet-society",
"pallet-staking",
"pallet-staking-runtime-api",
+ "pallet-sudo",
"pallet-timestamp",
"pallet-transaction-payment",
"pallet-transaction-payment-rpc-runtime-api",
diff --git a/chain-spec-generator/src/relay_chain_specs.rs b/chain-spec-generator/src/relay_chain_specs.rs
index e8c2fa3c8..3b90f7a54 100644
--- a/chain-spec-generator/src/relay_chain_specs.rs
+++ b/chain-spec-generator/src/relay_chain_specs.rs
@@ -223,6 +223,9 @@ pub fn polkadot_testnet_genesis(
})
.collect::<Vec<_>>(),
},
+ "sudo": {
+ "key": Some(_root_key),
+ },
"staking": {
"minimumValidatorCount": 1,
"validatorCount": initial_authorities.len() as u32,
@@ -286,6 +289,9 @@ pub fn kusama_testnet_genesis(
})
.collect::<Vec<_>>(),
},
+ "sudo": {
+ "key": Some(_root_key),
+ },
"staking": {
"minimumValidatorCount": 1,
"validatorCount": initial_authorities.len() as u32,
diff --git a/relay/kusama/Cargo.toml b/relay/kusama/Cargo.toml
index 9f4601f92..9785cb124 100644
--- a/relay/kusama/Cargo.toml
+++ b/relay/kusama/Cargo.toml
@@ -104,6 +104,8 @@ xcm-builder = { workspace = true }

sp-debug-derive = { workspace = true }

+pallet-sudo = { workspace = true }
+
[dev-dependencies]
sp-keyring = { workspace = true }
sp-trie = { workspace = true }
@@ -174,6 +176,7 @@ std = [
"pallet-society/std",
"pallet-staking-runtime-api/std",
"pallet-staking/std",
+ "pallet-sudo/std",
"pallet-timestamp/std",
"pallet-transaction-payment-rpc-runtime-api/std",
"pallet-transaction-payment/std",
diff --git a/relay/kusama/src/lib.rs b/relay/kusama/src/lib.rs
index 05724aee5..7d8f60205 100644
--- a/relay/kusama/src/lib.rs
+++ b/relay/kusama/src/lib.rs
@@ -1641,6 +1641,12 @@ impl pallet_im_online::Config for Runtime {
type ValidatorSet = Historical;
}

+impl pallet_sudo::Config for Runtime {
+ type RuntimeEvent = RuntimeEvent;
+ type RuntimeCall = RuntimeCall;
+ type WeightInfo = ();
+}
+
construct_runtime! {
pub enum Runtime
{
@@ -1771,6 +1777,9 @@ construct_runtime! {

// Pallet for migrating Identity to a parachain. To be removed post-migration.
IdentityMigrator: identity_migrator = 248,
+
+ // Sudo.
+ Sudo: pallet_sudo = 255,
}
}

diff --git a/relay/polkadot/Cargo.toml b/relay/polkadot/Cargo.toml
index c7f8c92b6..53c87f0e8 100644
--- a/relay/polkadot/Cargo.toml
+++ b/relay/polkadot/Cargo.toml
@@ -101,6 +101,8 @@ xcm-builder = { workspace = true }

sp-debug-derive = { workspace = true }

+pallet-sudo = { workspace = true }
+
[dev-dependencies]
sp-keyring = { workspace = true }
sp-trie = { workspace = true }
@@ -168,6 +170,7 @@ std = [
"pallet-staking-runtime-api/std",
"pallet-staking/std",
"pallet-state-trie-migration/std",
+ "pallet-sudo/std",
"pallet-timestamp/std",
"pallet-transaction-payment-rpc-runtime-api/std",
"pallet-transaction-payment/std",
diff --git a/relay/polkadot/src/lib.rs b/relay/polkadot/src/lib.rs
index b31948725..39d62fe20 100644
--- a/relay/polkadot/src/lib.rs
+++ b/relay/polkadot/src/lib.rs
@@ -1650,6 +1650,12 @@ impl pallet_im_online::Config for Runtime {
type ValidatorSet = Historical;
}

+impl pallet_sudo::Config for Runtime {
+ type RuntimeEvent = RuntimeEvent;
+ type RuntimeCall = RuntimeCall;
+ type WeightInfo = ();
+}
+
construct_runtime! {
pub enum Runtime
{
@@ -1759,6 +1765,9 @@ construct_runtime! {
// refer to block<N>. See issue #160 for details.
Mmr: pallet_mmr = 201,
BeefyMmrLeaf: pallet_beefy_mmr = 202,
+
+ // Sudo.
+ Sudo: pallet_sudo = 255,
}
}

0 comments on commit 13a5538

Please sign in to comment.