Skip to content

Commit

Permalink
Merge branch 'master' into ao-fix-issue-64
Browse files Browse the repository at this point in the history
* master: (28 commits)
  `substrate-node`: removed excessive polkadot-sdk features (#5925)
  Rename QueueEvent::StartWork (#6015)
  [ci] Remove quick-benchmarks-omni from GitLab (#6014)
  Set larger timeout for cmd.yml (#6006)
  Fix `0003-beefy-and-mmr` test (#6003)
  Remove redundant XCMs from dry run's forwarded xcms (#5913)
  Add RadiumBlock bootnodes to Coretime Polkadot Chain spec (#5967)
  Bump strum from 0.26.2 to 0.26.3 (#5943)
  Add PVF execution priority (#4837)
  Snowbridge V2 docs (#5902)
  Fix u256 conversion in BABE (#5994)
  [ci] Move test-linux-stable-no-try-runtime to GHA (#5979)
  Bump PoV request timeout (#5924)
  [Release/CI] Github flow to build `polkadot`/`polkadot-parachain` rc binaries and deb package (#5963)
  [ci] Remove short-benchmarks from Gitlab (#5988)
  Disable flaky tests reported in 5972/5973/5974 (#5976)
  Bump some dependencies (#5886)
  bump zombienet version and set request for k8s (#5968)
  [omni-bencher] Make all runtimes work (#5872)
  Omni-Node renamings (#5915)
  ...
  • Loading branch information
ordian committed Oct 11, 2024
2 parents c403cb7 + b45f89c commit 2b29d09
Show file tree
Hide file tree
Showing 177 changed files with 3,950 additions and 1,744 deletions.
38 changes: 15 additions & 23 deletions .github/actions/set-up-gh/action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 'install gh'
description: 'Install the gh cli in a debian based distro and switches to the PR branch.'
name: "install gh"
description: "Install the gh cli in a debian based distro and switches to the PR branch."
inputs:
pr-number:
description: "Number of the PR"
Expand All @@ -9,28 +9,20 @@ inputs:
required: true
outputs:
branch:
description: 'Branch name for the PR'
description: "Branch name for the PR"
value: ${{ steps.branch.outputs.branch }}
runs:
using: "composite"
steps:
- name: Instal gh cli
shell: bash
# Here it would get the script from previous step
run: |
(type -p wget >/dev/null || (apt update && apt-get install wget -y))
mkdir -p -m 755 /etc/apt/keyrings
wget -qO- https://cli.github.com/packages/githubcli-archive-keyring.gpg | tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null
chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null
apt update
apt install gh -y
git config --global --add safe.directory '*'
- run: gh pr checkout ${{ inputs.pr-number }}
shell: bash
env:
GITHUB_TOKEN: ${{ inputs.GH_TOKEN }}
- name: Export branch name
shell: bash
run: echo "branch=$(git rev-parse --abbrev-ref HEAD)" >> "$GITHUB_OUTPUT"
id: branch
- name: Set up git
shell: bash
# Here it would get the script from previous step
run: git config --global --add safe.directory '*'
- run: gh pr checkout ${{ inputs.pr-number }}
shell: bash
env:
GITHUB_TOKEN: ${{ inputs.GH_TOKEN }}
- name: Export branch name
shell: bash
run: echo "branch=$(git rev-parse --abbrev-ref HEAD)" >> "$GITHUB_OUTPUT"
id: branch
7 changes: 4 additions & 3 deletions .github/scripts/cmd/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
spec.loader.exec_module(generate_prdoc)

parser_prdoc = subparsers.add_parser('prdoc', help='Generates PR documentation')
generate_prdoc.setup_parser(parser_prdoc)
generate_prdoc.setup_parser(parser_prdoc, pr_required=False)

def main():
global args, unknown, runtimesMatrix
Expand All @@ -104,7 +104,7 @@ def main():
print(f'-- listing pallets for benchmark for {runtime["name"]}')
wasm_file = f"target/{profile}/wbuild/{runtime['package']}/{runtime['package'].replace('-', '_')}.wasm"
output = os.popen(
f"frame-omni-bencher v1 benchmark pallet --no-csv-header --no-storage-info --no-min-squares --no-median-slopes --all --list --runtime={wasm_file}").read()
f"frame-omni-bencher v1 benchmark pallet --no-csv-header --no-storage-info --no-min-squares --no-median-slopes --all --list --runtime={wasm_file} {runtime['bench_flags']}").read()
raw_pallets = output.strip().split('\n')

all_pallets = set()
Expand Down Expand Up @@ -182,7 +182,8 @@ def main():
f"--repeat=20 " \
f"--heap-pages=4096 " \
f"{f'--template={template} ' if template else ''}" \
f"--no-storage-info --no-min-squares --no-median-slopes"
f"--no-storage-info --no-min-squares --no-median-slopes " \
f"{config['bench_flags']}"
print(f'-- Running: {cmd} \n')
status = os.system(cmd)
if status != 0 and not args.continue_on_fail:
Expand Down
169 changes: 131 additions & 38 deletions .github/scripts/cmd/test_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,54 @@

# Mock data for runtimes-matrix.json
mock_runtimes_matrix = [
{"name": "dev", "package": "kitchensink-runtime", "path": "substrate/frame", "header": "substrate/HEADER-APACHE2", "template": "substrate/.maintain/frame-weight-template.hbs", "bench_features": "runtime-benchmarks,riscv"},
{"name": "westend", "package": "westend-runtime", "path": "polkadot/runtime/westend", "header": "polkadot/file_header.txt", "template": "polkadot/xcm/pallet-xcm-benchmarks/template.hbs", "bench_features": "runtime-benchmarks"},
{"name": "rococo", "package": "rococo-runtime", "path": "polkadot/runtime/rococo", "header": "polkadot/file_header.txt", "template": "polkadot/xcm/pallet-xcm-benchmarks/template.hbs", "bench_features": "runtime-benchmarks"},
{"name": "asset-hub-westend", "package": "asset-hub-westend-runtime", "path": "cumulus/parachains/runtimes/assets/asset-hub-westend", "header": "cumulus/file_header.txt", "template": "cumulus/templates/xcm-bench-template.hbs", "bench_features": "runtime-benchmarks"},
{
"name": "dev",
"package": "kitchensink-runtime",
"path": "substrate/frame",
"header": "substrate/HEADER-APACHE2",
"template": "substrate/.maintain/frame-weight-template.hbs",
"bench_features": "runtime-benchmarks,riscv",
"bench_flags": "--flag1 --flag2"
},
{
"name": "westend",
"package": "westend-runtime",
"path": "polkadot/runtime/westend",
"header": "polkadot/file_header.txt",
"template": "polkadot/xcm/pallet-xcm-benchmarks/template.hbs",
"bench_features": "runtime-benchmarks",
"bench_flags": "--flag3 --flag4"
},
{
"name": "rococo",
"package": "rococo-runtime",
"path": "polkadot/runtime/rococo",
"header": "polkadot/file_header.txt",
"template": "polkadot/xcm/pallet-xcm-benchmarks/template.hbs",
"bench_features": "runtime-benchmarks",
"bench_flags": ""
},
{
"name": "asset-hub-westend",
"package": "asset-hub-westend-runtime",
"path": "cumulus/parachains/runtimes/assets/asset-hub-westend",
"header": "cumulus/file_header.txt",
"template": "cumulus/templates/xcm-bench-template.hbs",
"bench_features": "runtime-benchmarks",
"bench_flags": "--flag7 --flag8"
}
]

def get_mock_bench_output(runtime, pallets, output_path, header, template = None):
def get_mock_bench_output(runtime, pallets, output_path, header, bench_flags, template = None):
return f"frame-omni-bencher v1 benchmark pallet --extrinsic=* " \
f"--runtime=target/release/wbuild/{runtime}-runtime/{runtime.replace('-', '_')}_runtime.wasm " \
f"--pallet={pallets} --header={header} " \
f"--output={output_path} " \
f"--wasm-execution=compiled " \
f"--steps=50 --repeat=20 --heap-pages=4096 " \
f"{f'--template={template} ' if template else ''}" \
f"--no-storage-info --no-min-squares --no-median-slopes"
f"--no-storage-info --no-min-squares --no-median-slopes " \
f"{bench_flags}"

class TestCmd(unittest.TestCase):

Expand Down Expand Up @@ -89,10 +122,29 @@ def test_bench_command_normal_execution_all_runtimes(self):
call("forklift cargo build -p rococo-runtime --profile release --features=runtime-benchmarks"),
call("forklift cargo build -p asset-hub-westend-runtime --profile release --features=runtime-benchmarks"),

call(get_mock_bench_output('kitchensink', 'pallet_balances', './substrate/frame/balances/src/weights.rs', os.path.abspath('substrate/HEADER-APACHE2'), "substrate/.maintain/frame-weight-template.hbs")),
call(get_mock_bench_output('westend', 'pallet_balances', './polkadot/runtime/westend/src/weights', os.path.abspath('polkadot/file_header.txt'))),
call(get_mock_bench_output(
runtime='kitchensink',
pallets='pallet_balances',
output_path='./substrate/frame/balances/src/weights.rs',
header=os.path.abspath('substrate/HEADER-APACHE2'),
bench_flags='--flag1 --flag2',
template="substrate/.maintain/frame-weight-template.hbs"
)),
call(get_mock_bench_output(
runtime='westend',
pallets='pallet_balances',
output_path='./polkadot/runtime/westend/src/weights',
header=os.path.abspath('polkadot/file_header.txt'),
bench_flags='--flag3 --flag4'
)),
# skips rococo benchmark
call(get_mock_bench_output('asset-hub-westend', 'pallet_balances', './cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights', os.path.abspath('cumulus/file_header.txt'))),
call(get_mock_bench_output(
runtime='asset-hub-westend',
pallets='pallet_balances',
output_path='./cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights',
header=os.path.abspath('cumulus/file_header.txt'),
bench_flags='--flag7 --flag8'
)),
]
self.mock_system.assert_has_calls(expected_calls, any_order=True)

Expand Down Expand Up @@ -121,8 +173,20 @@ def test_bench_command_normal_execution(self):
call("forklift cargo build -p westend-runtime --profile release --features=runtime-benchmarks"),

# Westend runtime calls
call(get_mock_bench_output('westend', 'pallet_balances', './polkadot/runtime/westend/src/weights', header_path)),
call(get_mock_bench_output('westend', 'pallet_staking', './polkadot/runtime/westend/src/weights', header_path)),
call(get_mock_bench_output(
runtime='westend',
pallets='pallet_balances',
output_path='./polkadot/runtime/westend/src/weights',
header=header_path,
bench_flags='--flag3 --flag4'
)),
call(get_mock_bench_output(
runtime='westend',
pallets='pallet_staking',
output_path='./polkadot/runtime/westend/src/weights',
header=header_path,
bench_flags='--flag3 --flag4'
)),
]
self.mock_system.assert_has_calls(expected_calls, any_order=True)

Expand Down Expand Up @@ -153,11 +217,12 @@ def test_bench_command_normal_execution_xcm(self):

# Westend runtime calls
call(get_mock_bench_output(
'westend',
'pallet_xcm_benchmarks::generic',
'./polkadot/runtime/westend/src/weights/xcm',
header_path,
"polkadot/xcm/pallet-xcm-benchmarks/template.hbs"
runtime='westend',
pallets='pallet_xcm_benchmarks::generic',
output_path='./polkadot/runtime/westend/src/weights/xcm',
header=header_path,
bench_flags='--flag3 --flag4',
template="polkadot/xcm/pallet-xcm-benchmarks/template.hbs"
)),
]
self.mock_system.assert_has_calls(expected_calls, any_order=True)
Expand Down Expand Up @@ -188,11 +253,35 @@ def test_bench_command_two_runtimes_two_pallets(self):
call("forklift cargo build -p westend-runtime --profile release --features=runtime-benchmarks"),
call("forklift cargo build -p rococo-runtime --profile release --features=runtime-benchmarks"),
# Westend runtime calls
call(get_mock_bench_output('westend', 'pallet_staking', './polkadot/runtime/westend/src/weights', header_path)),
call(get_mock_bench_output('westend', 'pallet_balances', './polkadot/runtime/westend/src/weights', header_path)),
call(get_mock_bench_output(
runtime='westend',
pallets='pallet_staking',
output_path='./polkadot/runtime/westend/src/weights',
header=header_path,
bench_flags='--flag3 --flag4'
)),
call(get_mock_bench_output(
runtime='westend',
pallets='pallet_balances',
output_path='./polkadot/runtime/westend/src/weights',
header=header_path,
bench_flags='--flag3 --flag4'
)),
# Rococo runtime calls
call(get_mock_bench_output('rococo', 'pallet_staking', './polkadot/runtime/rococo/src/weights', header_path)),
call(get_mock_bench_output('rococo', 'pallet_balances', './polkadot/runtime/rococo/src/weights', header_path)),
call(get_mock_bench_output(
runtime='rococo',
pallets='pallet_staking',
output_path='./polkadot/runtime/rococo/src/weights',
header=header_path,
bench_flags=''
)),
call(get_mock_bench_output(
runtime='rococo',
pallets='pallet_balances',
output_path='./polkadot/runtime/rococo/src/weights',
header=header_path,
bench_flags=''
)),
]
self.mock_system.assert_has_calls(expected_calls, any_order=True)

Expand Down Expand Up @@ -223,11 +312,12 @@ def test_bench_command_one_dev_runtime(self):
call("forklift cargo build -p kitchensink-runtime --profile release --features=runtime-benchmarks,riscv"),
# Westend runtime calls
call(get_mock_bench_output(
'kitchensink',
'pallet_balances',
manifest_dir + "/src/weights.rs",
header_path,
"substrate/.maintain/frame-weight-template.hbs"
runtime='kitchensink',
pallets='pallet_balances',
output_path=manifest_dir + "/src/weights.rs",
header=header_path,
bench_flags='--flag1 --flag2',
template="substrate/.maintain/frame-weight-template.hbs"
)),
]
self.mock_system.assert_has_calls(expected_calls, any_order=True)
Expand Down Expand Up @@ -257,10 +347,11 @@ def test_bench_command_one_cumulus_runtime(self):
call("forklift cargo build -p asset-hub-westend-runtime --profile release --features=runtime-benchmarks"),
# Asset-hub-westend runtime calls
call(get_mock_bench_output(
'asset-hub-westend',
'pallet_assets',
'./cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights',
header_path
runtime='asset-hub-westend',
pallets='pallet_assets',
output_path='./cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights',
header=header_path,
bench_flags='--flag7 --flag8'
)),
]

Expand Down Expand Up @@ -291,17 +382,19 @@ def test_bench_command_one_cumulus_runtime_xcm(self):
call("forklift cargo build -p asset-hub-westend-runtime --profile release --features=runtime-benchmarks"),
# Asset-hub-westend runtime calls
call(get_mock_bench_output(
'asset-hub-westend',
'pallet_xcm_benchmarks::generic',
'./cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm',
header_path,
"cumulus/templates/xcm-bench-template.hbs"
runtime='asset-hub-westend',
pallets='pallet_xcm_benchmarks::generic',
output_path='./cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm',
header=header_path,
bench_flags='--flag7 --flag8',
template="cumulus/templates/xcm-bench-template.hbs"
)),
call(get_mock_bench_output(
'asset-hub-westend',
'pallet_assets',
'./cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights',
header_path
runtime='asset-hub-westend',
pallets='pallet_assets',
output_path='./cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights',
header=header_path,
bench_flags='--flag7 --flag8'
)),
]

Expand Down
28 changes: 17 additions & 11 deletions .github/scripts/generate-prdoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
This will delete any prdoc that already exists for the PR if `--force` is passed.
Usage:
python generate-prdoc.py --pr 1234 --audience "TODO" --bump "TODO"
python generate-prdoc.py --pr 1234 --audience node_dev --bump patch
"""

import argparse
Expand Down Expand Up @@ -110,27 +110,33 @@ def yaml_multiline_string_presenter(dumper, data):
yaml.add_representer(str, yaml_multiline_string_presenter)

# parse_args is also used by cmd/cmd.py
def setup_parser(parser=None):
# if pr_required is False, then --pr is optional, as it can be derived from the PR comment body
def setup_parser(parser=None, pr_required=True):
allowed_audiences = ["runtime_dev", "runtime_user", "node_dev", "node_operator"]
if parser is None:
parser = argparse.ArgumentParser()
parser.add_argument("--pr", type=int, required=True, help="The PR number to generate the PrDoc for." )
parser.add_argument("--audience", type=str, default="TODO", help="The audience of whom the changes may concern.")
parser.add_argument("--bump", type=str, default="TODO", help="A default bump level for all crates.")
parser.add_argument("--force", type=str, help="Whether to overwrite any existing PrDoc.")

parser.add_argument("--pr", type=int, required=pr_required, help="The PR number to generate the PrDoc for.")
parser.add_argument("--audience", type=str, nargs='*', choices=allowed_audiences, default=["todo"], help="The audience of whom the changes may concern. Example: --audience runtime_dev node_dev")
parser.add_argument("--bump", type=str, default="major", choices=["patch", "minor", "major", "silent", "ignore", "no_change"], help="A default bump level for all crates. Example: --bump patch")
parser.add_argument("--force", action="store_true", help="Whether to overwrite any existing PrDoc.")
return parser

def snake_to_title(s):
return ' '.join(word.capitalize() for word in s.split('_'))

def main(args):
force = True if (args.force or "false").lower() == "true" else False
print(f"Args: {args}, force: {force}")
print(f"Args: {args}, force: {args.force}")
setup_yaml()
try:
from_pr_number(args.pr, args.audience, args.bump, force)
# Convert snake_case audience arguments to title case
mapped_audiences = [snake_to_title(a) for a in args.audience]
from_pr_number(args.pr, mapped_audiences, args.bump, args.force)
return 0
except Exception as e:
print(f"Error generating prdoc: {e}")
return 1

if __name__ == "__main__":
args = setup_parser().parse_args()
parser = setup_parser()
args = parser.parse_args()
main(args)
17 changes: 17 additions & 0 deletions .github/scripts/release/build-deb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash
set -e

PRODUCT=$1
VERSION=$2
PROFILE=${PROFILE:-production}

cargo install --version 2.7.0 cargo-deb --locked -q
echo "Using cargo-deb v$(cargo-deb --version)"
echo "Building a Debian package for '$PRODUCT' in '$PROFILE' profile"

# we need to start the custom version with a didgit as requires it cargo-deb
cargo deb --profile $PROFILE --no-strip --no-build -p $PRODUCT --deb-version 1-$VERSION

deb=target/debian/$PRODUCT_*_amd64.deb

cp $deb target/production/
Loading

0 comments on commit 2b29d09

Please sign in to comment.