Skip to content

Commit

Permalink
Merge tag 'polkadot-v1.6.0' into serai
Browse files Browse the repository at this point in the history
  • Loading branch information
kayabaNerve committed Jan 17, 2024
2 parents 2ba1a5a + 481165d commit 3cb1726
Show file tree
Hide file tree
Showing 570 changed files with 13,424 additions and 3,417 deletions.
34 changes: 0 additions & 34 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,6 @@ rustdocflags = [
"-Arustdoc::redundant_explicit_links", # stylistic
]

# An auto defined `clippy` feature was introduced,
# but it was found to clash with user defined features,
# so was renamed to `cargo-clippy`.
#
# If you want standard clippy run:
# RUSTFLAGS= cargo clippy
[target.'cfg(feature = "cargo-clippy")']
rustflags = [
"-Aclippy::all",
"-Dclippy::correctness",
"-Aclippy::if-same-then-else",
"-Asuspicious-double-ref-op",
"-Dclippy::complexity",
"-Aclippy::zero-prefixed-literal", # 00_1000_000
"-Aclippy::type_complexity", # raison d'etre
"-Aclippy::nonminimal-bool", # maybe
"-Aclippy::borrowed-box", # Reasonable to fix this one
"-Aclippy::too-many-arguments", # (Turning this on would lead to)
"-Aclippy::unnecessary_cast", # Types may change
"-Aclippy::identity-op", # One case where we do 0 +
"-Aclippy::useless_conversion", # Types may change
"-Aclippy::unit_arg", # styalistic.
"-Aclippy::option-map-unit-fn", # styalistic
"-Aclippy::bind_instead_of_map", # styalistic
"-Aclippy::erasing_op", # E.g. 0 * DOLLARS
"-Aclippy::eq_op", # In tests we test equality.
"-Aclippy::while_immutable_condition", # false positives
"-Aclippy::needless_option_as_deref", # false positives
"-Aclippy::derivable_impls", # false positives
"-Aclippy::stable_sort_primitive", # prefer stable sort
"-Aclippy::extra-unused-type-parameters", # stylistic
"-Aclippy::default_constructed_unit_structs", # stylistic
]

[env]
# Needed for musl builds so user doesn't have to install musl-tools.
CC_x86_64_unknown_linux_musl = { value = ".cargo/musl-gcc", force = true, relative = true }
Expand Down
4 changes: 2 additions & 2 deletions .config/lychee.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ exclude_all_private = true
# Treat these codes as success condition:
accept = [
# Ok
200,
"200",

# Rate limited - GitHub likes to throw this.
429,
"429",
]

exclude_path = ["./target"]
Expand Down
2 changes: 1 addition & 1 deletion .config/taplo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ reorder_arrays = false
# don't re-order order-dependent rustflags
[[rule]]
include = [".cargo/config.toml"]
keys = ["build", "target.'cfg(feature = \"cargo-clippy\")'"]
keys = ["build"]

[rule.formatting]
reorder_arrays = false
47 changes: 12 additions & 35 deletions .github/review-bot.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
rules:
- name: CI files
countAuthor: true
condition:
include:
- ^\.gitlab-ci\.yml
Expand All @@ -8,24 +9,26 @@ rules:
- ^\.gitlab/.*
- ^\.config/nextest.toml
- ^\.cargo/.*
exclude:
exclude:
- ^\.gitlab/pipeline/zombienet.*
minApprovals: 2
type: basic
teams:
- ci
- release-engineering
type: "or"
reviewers:
- minApprovals: 2
teams:
- ci
- minApprovals: 2
teams:
- core-devs

- name: Audit rules
type: basic
condition:
include:
- ^polkadot/runtime\/(kusama|polkadot|common)\/.*
- ^polkadot/runtime/common/.*
- ^polkadot/primitives/src\/.+\.rs$
- ^substrate/primitives/.*
- ^substrate/frame/.*
exclude:
- ^polkadot/runtime\/(kusama|polkadot)\/src\/weights\/.+\.rs$
- ^substrate\/frame\/.+\.md$
minApprovals: 1
allowedToSkipRule:
Expand All @@ -41,13 +44,8 @@ rules:
- .*
# excluding files from 'Runtime files' and 'CI files' rules
exclude:
- ^polkadot/runtime/(kusama|polkadot)/src/[^/]+\.rs$
- ^cumulus/parachains/runtimes/assets/(asset-hub-kusama|asset-hub-polkadot)/src/[^/]+\.rs$
- ^cumulus/parachains/runtimes/bridge-hubs/(bridge-hub-kusama|bridge-hub-polkadot)/src/[^/]+\.rs$
- ^cumulus/parachains/runtimes/collectives/collectives-polkadot/src/[^/]+\.rs$
- ^cumulus/parachains/common/src/[^/]+\.rs$
- ^substrate/frame/(?!.*(nfts/.*|uniques/.*|babe/.*|grandpa/.*|beefy|merkle-mountain-range/.*|contracts/.*|election|nomination-pools/.*|staking/.*|aura/.*))
- ^polkadot/runtime/(kusama|polkadot)/src/[^/]+\.rs$
- ^\.gitlab-ci\.yml
- ^docker/.*
- ^\.github/.*
Expand All @@ -59,24 +57,6 @@ rules:
teams:
- core-devs

# cumulus
- name: Runtime files cumulus
countAuthor: true
condition:
include:
- ^cumulus/parachains/runtimes/assets/(asset-hub-kusama|asset-hub-polkadot)/src/[^/]+\.rs$
- ^cumulus/parachains/runtimes/bridge-hubs/(bridge-hub-kusama|bridge-hub-polkadot)/src/[^/]+\.rs$
- ^cumulus/parachains/runtimes/collectives/collectives-polkadot/src/[^/]+\.rs$
- ^cumulus/parachains/common/src/[^/]+\.rs$
type: and-distinct
reviewers:
- minApprovals: 1
teams:
- locks-review
- minApprovals: 1
teams:
- polkadot-review

# if there are any changes in the bridges subtree (in case of backport changes back to bridges repo)
- name: Bridges subtree files
type: basic
Expand All @@ -88,7 +68,6 @@ rules:
- bridges-core

# substrate

- name: FRAME coders substrate
condition:
include:
Expand All @@ -104,6 +83,7 @@ rules:

# Protection of THIS file
- name: Review Bot
countAuthor: true
condition:
include:
- review-bot\.yml
Expand All @@ -115,9 +95,6 @@ rules:
- minApprovals: 1
teams:
- locks-review
- minApprovals: 1
teams:
- ci

preventReviewRequests:
teams:
Expand Down
17 changes: 17 additions & 0 deletions .github/runtime_specs/rococo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"pallets": {
"1": {
"constants": {
"EpochDuration": {
"value": [ 88, 2, 0, 0, 0, 0, 0, 0 ]}
}
},

"2": {
"constants": {
"MinimumPeriod": {
"value": [ 184, 11, 0, 0, 0, 0, 0, 0 ]}
}
}
}
}
17 changes: 17 additions & 0 deletions .github/runtime_specs/westend.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"pallets": {
"1": {
"constants": {
"EpochDuration": {
"value": [ 88, 2, 0, 0, 0, 0, 0, 0 ]}
}
},

"2": {
"constants": {
"MinimumPeriod": {
"value": [ 184, 11, 0, 0, 0, 0, 0, 0 ]}
}
}
}
}
124 changes: 124 additions & 0 deletions .github/scripts/check-runtime.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
#!/usr/bin/env python3

import json
import sys
import logging
import os


def check_constant(spec_pallet_id, spec_pallet_value, meta_constant):
"""
Check a single constant
:param spec_pallet_id:
:param spec_pallet_value:
:param meta_constant:
:return:
"""
if meta_constant['name'] == list(spec_pallet_value.keys())[0]:
constant = meta_constant['name']
res = list(spec_pallet_value.values())[0]["value"] == meta_constant["value"]

logging.debug(f" Checking pallet:{spec_pallet_id}/constants/{constant}")
logging.debug(f" spec_pallet_value: {spec_pallet_value}")
logging.debug(f" meta_constant: {meta_constant}")
logging.info(f"pallet:{spec_pallet_id}/constants/{constant} -> {res}")
return res
else:
# logging.warning(f" Skipping pallet:{spec_pallet_id}/constants/{meta_constant['name']}")
pass


def check_pallet(metadata, spec_pallet):
"""
Check one pallet
:param metadata:
:param spec_pallet_id:
:param spec_pallet_value:
:return:
"""

spec_pallet_id, spec_pallet_value = spec_pallet
logging.debug(f"Pallet: {spec_pallet_id}")

metadata_pallets = metadata["pallets"]
metadata_pallet = metadata_pallets[spec_pallet_id]

res = map(lambda meta_constant_value: check_constant(
spec_pallet_id, spec_pallet_value["constants"], meta_constant_value),
metadata_pallet["constants"].values())
res = list(filter(lambda item: item is not None, res))
return all(res)


def check_pallets(metadata, specs):
"""
CHeck all pallets
:param metadata:
:param specs:
:return:
"""

res = list(map(lambda spec_pallet: check_pallet(metadata, spec_pallet),
specs['pallets'].items()))
res = list(filter(lambda item: item is not None, res))
return all(res)


def check_metadata(metadata, specs):
"""
Check metadata (json) against a list of expectations
:param metadata: Metadata in JSON format
:param expectation: Expectations
:return: Bool
"""

res = check_pallets(metadata, specs)
return res


def help():
""" Show some simple help """

print(f"You must pass 2 args, you passed {len(sys.argv) - 1}")
print("Sample call:")
print("check-runtime.py <metadata.json> <specs.json>")


def load_json(file):
""" Load json from a file """

f = open(file)
return json.load(f)


def main():
LOGLEVEL = os.environ.get('LOGLEVEL', 'INFO').upper()
logging.basicConfig(level=LOGLEVEL)

if len(sys.argv) != 3:
help()
exit(1)

metadata_file = sys.argv[1]
specs_file = sys.argv[2]
print(f"Checking metadata from: {metadata_file} with specs from: {specs_file}")

metadata = load_json(metadata_file)
specs = load_json(specs_file)

res = check_metadata(metadata, specs)

if res:
logging.info(f"OK")
exit(0)
else:
print("")
logging.info(f"Some errors were found, run again with LOGLEVEL=debug")
exit(1)

if __name__ == "__main__":
main()
Loading

0 comments on commit 3cb1726

Please sign in to comment.