Skip to content

Commit 8f752db

Browse files
authored
Merge branch 'master' into ao-fix-issue-64
2 parents 8eafd23 + fb19de2 commit 8f752db

File tree

2,322 files changed

+130635
-76618
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,322 files changed

+130635
-76618
lines changed

.cargo/config.toml

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ rustdocflags = [
99
CC_x86_64_unknown_linux_musl = { value = ".cargo/musl-gcc", force = true, relative = true }
1010
CXX_x86_64_unknown_linux_musl = { value = ".cargo/musl-g++", force = true, relative = true }
1111
CARGO_WORKSPACE_ROOT_DIR = { value = "", relative = true }
12+
SQLX_OFFLINE = "true"
1213

1314
[net]
1415
retry = 5

.config/lychee.toml

+5
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,15 @@ exclude = [
5252
# Behind a captcha (code 403):
5353
"https://chainlist.org/chain/*",
5454
"https://iohk.io/en/blog/posts/2023/11/03/partner-chains-are-coming-to-cardano/",
55+
"https://polymesh.network",
5556
"https://www.reddit.com/r/rust/comments/3spfh1/does_collect_allocate_more_than_once_while/",
5657

5758
# 403 rate limited:
5859
"https://etherscan.io/block/11090290",
5960
"https://subscan.io/",
6061
"https://substrate.stackexchange.com/.*",
62+
63+
# Exclude strings which contain templates like {} and {:?}
64+
"%7B%7D",
65+
"%7B:\\?}",
6166
]

.config/taplo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ exclude = [
66
"cumulus/zombienet/**",
77
"polkadot/node/malus/integrationtests/**",
88
"polkadot/zombienet_tests/**",
9+
"substrate/client/transaction-pool/tests/zombienet/**",
910
"substrate/zombienet/**",
1011
"target/**",
1112
]

.forklift/config.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ project_name = "$CI_PROJECT_PATH"
2626
type = "gcs"
2727

2828
[storage.gcs]
29-
bucketName = "parity-ci-forklift"
29+
bucketName = "parity-ci-forklift-regional"
+4-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: 'build and push image'
1+
name: "build and push image"
22
inputs:
33
dockerfile:
44
description: "dockerfile to build"
@@ -8,14 +8,12 @@ inputs:
88
required: true
99
outputs:
1010
branch:
11-
description: 'Branch name for the PR'
11+
description: "Branch name for the PR"
1212
value: ${{ steps.branch.outputs.branch }}
1313

14-
1514
runs:
1615
using: "composite"
1716
steps:
18-
1917
# gcloud
2018
# https://github.com/paritytech/ci_cd/wiki/GitHub:-Push-Docker-image-to-GCP-Registry
2119
- name: "Set up Cloud SDK"
@@ -25,15 +23,14 @@ runs:
2523
run: "gcloud info"
2624
- name: "Auth in gcloud registry"
2725
shell: bash
28-
run: "gcloud auth configure-docker europe-docker.pkg.dev --quiet"
26+
run: "gcloud auth configure-docker europe-docker.pkg.dev --quiet"
2927

3028
- name: build
3129
shell: bash
3230
env:
3331
ZOMBIENET_IMAGE: "docker.io/paritytech/zombienet:v1.3.105"
3432
run: |
35-
export BRANCH_NAME=${{ github.head_ref || github.ref_name }}
36-
export DOCKER_IMAGES_VERSION=${BRANCH_NAME/\//-}
33+
export DOCKER_IMAGES_VERSION=${{ github.event.pull_request.head.sha }}
3734
if [[ ${{ github.event_name }} == "merge_group" ]]; then export DOCKER_IMAGES_VERSION="${GITHUB_SHA::8}"; fi
3835
docker build \
3936
--build-arg VCS_REF="${GITHUB_SHA}" \
@@ -44,4 +41,3 @@ runs:
4441
-f ${{ inputs.dockerfile }} \
4542
.
4643
docker push "${{ inputs.image-name }}:$DOCKER_IMAGES_VERSION"
47-

.github/env

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
IMAGE="docker.io/paritytech/ci-unified:bullseye-1.81.0-2024-11-19-v202411281558"
1+
IMAGE="docker.io/paritytech/ci-unified:bullseye-1.84.1-2025-01-28-v202502131220"

.github/scripts/cmd/cmd.py

+22-178
Original file line numberDiff line numberDiff line change
@@ -44,34 +44,6 @@ def setup_logging():
4444
BENCH
4545
"""
4646

47-
bench_example = '''**Examples**:
48-
Runs all benchmarks
49-
%(prog)s
50-
51-
Runs benchmarks for pallet_balances and pallet_multisig for all runtimes which have these pallets. **--quiet** makes it to output nothing to PR but reactions
52-
%(prog)s --pallet pallet_balances pallet_xcm_benchmarks::generic --quiet
53-
54-
Runs bench for all pallets for westend runtime and fails fast on first failed benchmark
55-
%(prog)s --runtime westend --fail-fast
56-
57-
Does not output anything and cleans up the previous bot's & author command triggering comments in PR
58-
%(prog)s --runtime westend rococo --pallet pallet_balances pallet_multisig --quiet --clean
59-
'''
60-
61-
parser_bench = subparsers.add_parser('bench', help='Runs benchmarks (old CLI)', epilog=bench_example, formatter_class=argparse.RawDescriptionHelpFormatter)
62-
63-
for arg, config in common_args.items():
64-
parser_bench.add_argument(arg, **config)
65-
66-
parser_bench.add_argument('--runtime', help='Runtime(s) space separated', choices=runtimeNames, nargs='*', default=runtimeNames)
67-
parser_bench.add_argument('--pallet', help='Pallet(s) space separated', nargs='*', default=[])
68-
parser_bench.add_argument('--fail-fast', help='Fail fast on first failed benchmark', action='store_true')
69-
70-
71-
"""
72-
BENCH OMNI
73-
"""
74-
7547
bench_example = '''**Examples**:
7648
Runs all benchmarks
7749
%(prog)s
@@ -86,14 +58,14 @@ def setup_logging():
8658
%(prog)s --runtime westend rococo --pallet pallet_balances pallet_multisig --quiet --clean
8759
'''
8860

89-
parser_bench_old = subparsers.add_parser('bench-omni', help='Runs benchmarks (frame omni bencher)', epilog=bench_example, formatter_class=argparse.RawDescriptionHelpFormatter)
61+
parser_bench = subparsers.add_parser('bench', aliases=['bench-omni'], help='Runs benchmarks (frame omni bencher)', epilog=bench_example, formatter_class=argparse.RawDescriptionHelpFormatter)
9062

9163
for arg, config in common_args.items():
92-
parser_bench_old.add_argument(arg, **config)
64+
parser_bench.add_argument(arg, **config)
9365

94-
parser_bench_old.add_argument('--runtime', help='Runtime(s) space separated', choices=runtimeNames, nargs='*', default=runtimeNames)
95-
parser_bench_old.add_argument('--pallet', help='Pallet(s) space separated', nargs='*', default=[])
96-
parser_bench_old.add_argument('--fail-fast', help='Fail fast on first failed benchmark', action='store_true')
66+
parser_bench.add_argument('--runtime', help='Runtime(s) space separated', choices=runtimeNames, nargs='*', default=runtimeNames)
67+
parser_bench.add_argument('--pallet', help='Pallet(s) space separated', nargs='*', default=[])
68+
parser_bench.add_argument('--fail-fast', help='Fail fast on first failed benchmark', action='store_true')
9769

9870

9971
"""
@@ -127,7 +99,7 @@ def main():
12799

128100
print(f'args: {args}')
129101

130-
if args.command == 'bench-omni':
102+
if args.command == 'bench' or args.command == 'bench-omni':
131103
runtime_pallets_map = {}
132104
failed_benchmarks = {}
133105
successful_benchmarks = {}
@@ -140,11 +112,23 @@ def main():
140112
runtimesMatrix = {x['name']: x for x in runtimesMatrix}
141113
print(f'Filtered out runtimes: {runtimesMatrix}')
142114

115+
compile_bencher = os.system(f"cargo install --path substrate/utils/frame/omni-bencher --locked --profile {profile}")
116+
if compile_bencher != 0:
117+
print_and_log('❌ Failed to compile frame-omni-bencher')
118+
sys.exit(1)
119+
143120
# loop over remaining runtimes to collect available pallets
144121
for runtime in runtimesMatrix.values():
145122
build_command = f"forklift cargo build -p {runtime['package']} --profile {profile} --features={runtime['bench_features']}"
146123
print(f'-- building "{runtime["name"]}" with `{build_command}`')
147-
os.system(build_command)
124+
build_status = os.system(build_command)
125+
if build_status != 0:
126+
print_and_log(f'❌ Failed to build {runtime["name"]}')
127+
if args.fail_fast:
128+
sys.exit(1)
129+
else:
130+
continue
131+
148132
print(f'-- listing pallets for benchmark for {runtime["name"]}')
149133
wasm_file = f"target/{profile}/wbuild/{runtime['package']}/{runtime['package'].replace('-', '_')}.wasm"
150134
list_command = f"frame-omni-bencher v1 benchmark pallet " \
@@ -219,12 +203,15 @@ def main():
219203
# TODO: we can remove once all pallets in dev runtime are migrated to polkadot-sdk-frame
220204
try:
221205
uses_polkadot_sdk_frame = "true" in os.popen(f"cargo metadata --locked --format-version 1 --no-deps | jq -r '.packages[] | select(.name == \"{pallet.replace('_', '-')}\") | .dependencies | any(.name == \"polkadot-sdk-frame\")'").read()
206+
print(f'uses_polkadot_sdk_frame: {uses_polkadot_sdk_frame}')
222207
# Empty output from the previous os.popen command
223208
except StopIteration:
209+
print(f'Error: {pallet} not found in dev runtime')
224210
uses_polkadot_sdk_frame = False
225211
template = config['template']
226212
if uses_polkadot_sdk_frame and re.match(r"frame-(:?umbrella-)?weight-template\.hbs", os.path.normpath(template).split(os.path.sep)[-1]):
227213
template = "substrate/.maintain/frame-umbrella-weight-template.hbs"
214+
print(f'template: {template}')
228215
else:
229216
default_path = f"./{config['path']}/src/weights"
230217
xcm_path = f"./{config['path']}/src/weights/xcm"
@@ -270,149 +257,6 @@ def main():
270257
print_and_log('✅ Successful benchmarks of runtimes/pallets:')
271258
for runtime, pallets in successful_benchmarks.items():
272259
print_and_log(f'-- {runtime}: {pallets}')
273-
274-
if args.command == 'bench':
275-
runtime_pallets_map = {}
276-
failed_benchmarks = {}
277-
successful_benchmarks = {}
278-
279-
profile = "production"
280-
281-
print(f'Provided runtimes: {args.runtime}')
282-
# convert to mapped dict
283-
runtimesMatrix = list(filter(lambda x: x['name'] in args.runtime, runtimesMatrix))
284-
runtimesMatrix = {x['name']: x for x in runtimesMatrix}
285-
print(f'Filtered out runtimes: {runtimesMatrix}')
286-
287-
# loop over remaining runtimes to collect available pallets
288-
for runtime in runtimesMatrix.values():
289-
build_command = f"forklift cargo build -p {runtime['old_package']} --profile {profile} --features={runtime['bench_features']} --locked"
290-
print(f'-- building {runtime["name"]} with `{build_command}`')
291-
os.system(build_command)
292-
293-
chain = runtime['name'] if runtime['name'] == 'dev' else f"{runtime['name']}-dev"
294-
295-
machine_test = f"target/{profile}/{runtime['old_bin']} benchmark machine --chain={chain}"
296-
print(f"Running machine test for `{machine_test}`")
297-
os.system(machine_test)
298-
299-
print(f'-- listing pallets for benchmark for {chain}')
300-
list_command = f"target/{profile}/{runtime['old_bin']} " \
301-
f"benchmark pallet " \
302-
f"--no-csv-header " \
303-
f"--no-storage-info " \
304-
f"--no-min-squares " \
305-
f"--no-median-slopes " \
306-
f"--all " \
307-
f"--list " \
308-
f"--chain={chain}"
309-
print(f'-- running: {list_command}')
310-
output = os.popen(list_command).read()
311-
raw_pallets = output.strip().split('\n')
312-
313-
all_pallets = set()
314-
for pallet in raw_pallets:
315-
if pallet:
316-
all_pallets.add(pallet.split(',')[0].strip())
317-
318-
pallets = list(all_pallets)
319-
print(f'Pallets in {runtime["name"]}: {pallets}')
320-
runtime_pallets_map[runtime['name']] = pallets
321-
322-
print(f'\n')
323-
324-
# filter out only the specified pallets from collected runtimes/pallets
325-
if args.pallet:
326-
print(f'Pallets: {args.pallet}')
327-
new_pallets_map = {}
328-
# keep only specified pallets if they exist in the runtime
329-
for runtime in runtime_pallets_map:
330-
if set(args.pallet).issubset(set(runtime_pallets_map[runtime])):
331-
new_pallets_map[runtime] = args.pallet
332-
333-
runtime_pallets_map = new_pallets_map
334-
335-
print(f'Filtered out runtimes & pallets: {runtime_pallets_map}\n')
336-
337-
if not runtime_pallets_map:
338-
if args.pallet and not args.runtime:
339-
print(f"No pallets {args.pallet} found in any runtime")
340-
elif args.runtime and not args.pallet:
341-
print(f"{args.runtime} runtime does not have any pallets")
342-
elif args.runtime and args.pallet:
343-
print(f"No pallets {args.pallet} found in {args.runtime}")
344-
else:
345-
print('No runtimes found')
346-
sys.exit(1)
347-
348-
for runtime in runtime_pallets_map:
349-
for pallet in runtime_pallets_map[runtime]:
350-
config = runtimesMatrix[runtime]
351-
header_path = os.path.abspath(config['header'])
352-
template = None
353-
354-
chain = config['name'] if runtime == 'dev' else f"{config['name']}-dev"
355-
356-
print(f'-- config: {config}')
357-
if runtime == 'dev':
358-
# to support sub-modules (https://github.com/paritytech/command-bot/issues/275)
359-
search_manifest_path = f"cargo metadata --locked --format-version 1 --no-deps | jq -r '.packages[] | select(.name == \"{pallet.replace('_', '-')}\") | .manifest_path'"
360-
print(f'-- running: {search_manifest_path}')
361-
manifest_path = os.popen(search_manifest_path).read()
362-
if not manifest_path:
363-
print(f'-- pallet {pallet} not found in dev runtime')
364-
if args.fail_fast:
365-
print_and_log(f'Error: {pallet} not found in dev runtime')
366-
sys.exit(1)
367-
package_dir = os.path.dirname(manifest_path)
368-
print(f'-- package_dir: {package_dir}')
369-
print(f'-- manifest_path: {manifest_path}')
370-
output_path = os.path.join(package_dir, "src", "weights.rs")
371-
template = config['template']
372-
else:
373-
default_path = f"./{config['path']}/src/weights"
374-
xcm_path = f"./{config['path']}/src/weights/xcm"
375-
output_path = default_path
376-
if pallet.startswith("pallet_xcm_benchmarks"):
377-
template = config['template']
378-
output_path = xcm_path
379-
380-
print(f'-- benchmarking {pallet} in {runtime} into {output_path}')
381-
cmd = f"target/{profile}/{config['old_bin']} benchmark pallet " \
382-
f"--extrinsic=* " \
383-
f"--chain={chain} " \
384-
f"--pallet={pallet} " \
385-
f"--header={header_path} " \
386-
f"--output={output_path} " \
387-
f"--wasm-execution=compiled " \
388-
f"--steps=50 " \
389-
f"--repeat=20 " \
390-
f"--heap-pages=4096 " \
391-
f"{f'--template={template} ' if template else ''}" \
392-
f"--no-storage-info --no-min-squares --no-median-slopes "
393-
print(f'-- Running: {cmd} \n')
394-
status = os.system(cmd)
395-
396-
if status != 0 and args.fail_fast:
397-
print_and_log(f'❌ Failed to benchmark {pallet} in {runtime}')
398-
sys.exit(1)
399-
400-
# Otherwise collect failed benchmarks and print them at the end
401-
# push failed pallets to failed_benchmarks
402-
if status != 0:
403-
failed_benchmarks[f'{runtime}'] = failed_benchmarks.get(f'{runtime}', []) + [pallet]
404-
else:
405-
successful_benchmarks[f'{runtime}'] = successful_benchmarks.get(f'{runtime}', []) + [pallet]
406-
407-
if failed_benchmarks:
408-
print_and_log('❌ Failed benchmarks of runtimes/pallets:')
409-
for runtime, pallets in failed_benchmarks.items():
410-
print_and_log(f'-- {runtime}: {pallets}')
411-
412-
if successful_benchmarks:
413-
print_and_log('✅ Successful benchmarks of runtimes/pallets:')
414-
for runtime, pallets in successful_benchmarks.items():
415-
print_and_log(f'-- {runtime}: {pallets}')
416260

417261
elif args.command == 'fmt':
418262
command = f"cargo +nightly fmt"

0 commit comments

Comments
 (0)