Skip to content

Commit

Permalink
Merge branch 'master' into outbound-queue-v2
Browse files Browse the repository at this point in the history
  • Loading branch information
yrong committed Nov 15, 2024
2 parents f08e36e + 5bc571b commit cff1cba
Show file tree
Hide file tree
Showing 112 changed files with 5,885 additions and 5,119 deletions.
36 changes: 36 additions & 0 deletions .github/scripts/check-missing-readme-generation.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash
echo "Running script relative to `pwd`"
# Find all README.docify.md files
DOCIFY_FILES=$(find . -name "README.docify.md")

# Initialize a variable to track directories needing README regeneration
NEED_REGENERATION=""

for file in $DOCIFY_FILES; do
echo "Processing $file"

# Get the directory containing the docify file
DIR=$(dirname "$file")

# Go to the directory and run cargo build
cd "$DIR"
cargo check --features generate-readme || { echo "Readme generation for $DIR failed. Ensure the crate compiles successfully and has a `generate-readme` feature which guards markdown compilation in the crate as follows: https://docs.rs/docify/latest/docify/macro.compile_markdown.html#conventions." && exit 1; }

# Check if README.md has any uncommitted changes
git diff --exit-code README.md

if [ $? -ne 0 ]; then
echo "Error: Found uncommitted changes in $DIR/README.md"
NEED_REGENERATION="$NEED_REGENERATION $DIR"
fi

# Return to the original directory
cd - > /dev/null
done

# Check if any directories need README regeneration
if [ -n "$NEED_REGENERATION" ]; then
echo "The following directories need README regeneration:"
echo "$NEED_REGENERATION"
exit 1
fi
28 changes: 27 additions & 1 deletion .github/workflows/checks-quick.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ concurrency:
permissions: {}

jobs:

preflight:
uses: ./.github/workflows/reusable-preflight.yml

Expand Down Expand Up @@ -172,6 +171,32 @@ jobs:
env:
ASSERT_REGEX: "FAIL-CI"
GIT_DEPTH: 1
check-readme:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4

- name: Install prerequisites
run: |
sudo apt-get update
sudo apt-get install -y protobuf-compiler
- name: Set rust version from env file
run: |
RUST_VERSION=$(cat .github/env | sed -E 's/.*ci-unified:([^-]+)-([^-]+).*/\2/')
echo $RUST_VERSION
echo "RUST_VERSION=${RUST_VERSION}" >> $GITHUB_ENV
- name: Install Rust
uses: actions-rust-lang/setup-rust-toolchain@11df97af8e8102fd60b60a77dfbf58d40cd843b8 # v1.10.1
with:
cache: false
toolchain: ${{ env.RUST_VERSION }}
components: cargo, clippy, rust-docs, rust-src, rustfmt, rustc, rust-std

- name: Find README.docify.md files and check generated READMEs
run: .github/scripts/check-missing-readme-generation.sh

confirm-required-checks-quick-jobs-passed:
runs-on: ubuntu-latest
Expand All @@ -187,6 +212,7 @@ jobs:
- check-markdown
- check-umbrella
- check-fail-ci
- check-readme
if: always() && !cancelled()
steps:
- run: |
Expand Down
12 changes: 8 additions & 4 deletions bridges/bin/runtime-common/src/extensions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,7 @@ mod tests {
&(),
0,
External,
0,
),
InvalidTransaction::Custom(1)
);
Expand All @@ -623,7 +624,8 @@ mod tests {
42u64.into(),
&MockCall { data: 1 },
&(),
0
0,
0,
),
InvalidTransaction::Custom(1)
);
Expand All @@ -635,6 +637,7 @@ mod tests {
&(),
0,
External,
0,
),
InvalidTransaction::Custom(2)
);
Expand All @@ -643,21 +646,22 @@ mod tests {
42u64.into(),
&MockCall { data: 2 },
&(),
0
0,
0,
),
InvalidTransaction::Custom(2)
);

assert_eq!(
BridgeRejectObsoleteHeadersAndMessages
.validate_only(42u64.into(), &MockCall { data: 3 }, &(), 0, External)
.validate_only(42u64.into(), &MockCall { data: 3 }, &(), 0, External, 0)
.unwrap()
.0,
ValidTransaction { priority: 3, ..Default::default() },
);
assert_eq!(
BridgeRejectObsoleteHeadersAndMessages
.validate_and_prepare(42u64.into(), &MockCall { data: 3 }, &(), 0)
.validate_and_prepare(42u64.into(), &MockCall { data: 3 }, &(), 0, 0)
.unwrap()
.0
.unwrap(),
Expand Down
6 changes: 6 additions & 0 deletions bridges/modules/relayers/src/extension/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1081,6 +1081,7 @@ mod tests {
&DispatchInfo::default(),
0,
External,
0,
)
.map(|t| t.0)
}
Expand All @@ -1094,6 +1095,7 @@ mod tests {
&DispatchInfo::default(),
0,
External,
0,
)
.map(|t| t.0)
}
Expand All @@ -1107,6 +1109,7 @@ mod tests {
&DispatchInfo::default(),
0,
External,
0,
)
.map(|t| t.0)
}
Expand All @@ -1132,6 +1135,7 @@ mod tests {
&call,
&DispatchInfo::default(),
0,
0,
)
.map(|(pre, _)| pre)
}
Expand All @@ -1149,6 +1153,7 @@ mod tests {
&call,
&DispatchInfo::default(),
0,
0,
)
.map(|(pre, _)| pre)
}
Expand All @@ -1166,6 +1171,7 @@ mod tests {
&call,
&DispatchInfo::default(),
0,
0,
)
.map(|(pre, _)| pre)
}
Expand Down
26 changes: 13 additions & 13 deletions cumulus/primitives/storage-weight-reclaim/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ fn basic_refund() {
assert_ok!(CheckWeight::<Test>::do_prepare(&info, LEN, next_len));

let (pre, _) = StorageWeightReclaim::<Test>(PhantomData)
.validate_and_prepare(Some(ALICE.clone()).into(), CALL, &info, LEN)
.validate_and_prepare(Some(ALICE.clone()).into(), CALL, &info, LEN, 0)
.unwrap();
assert_eq!(pre, Some(0));

Expand Down Expand Up @@ -130,7 +130,7 @@ fn underestimating_refund() {
assert_ok!(CheckWeight::<Test>::do_prepare(&info, LEN, next_len));

let (pre, _) = StorageWeightReclaim::<Test>(PhantomData)
.validate_and_prepare(Some(ALICE.clone()).into(), CALL, &info, LEN)
.validate_and_prepare(Some(ALICE.clone()).into(), CALL, &info, LEN, 0)
.unwrap();
assert_eq!(pre, Some(0));

Expand Down Expand Up @@ -168,7 +168,7 @@ fn sets_to_node_storage_proof_if_higher() {
assert_ok!(CheckWeight::<Test>::do_prepare(&info, LEN, next_len));

let (pre, _) = StorageWeightReclaim::<Test>(PhantomData)
.validate_and_prepare(Some(ALICE.clone()).into(), CALL, &info, LEN)
.validate_and_prepare(Some(ALICE.clone()).into(), CALL, &info, LEN, 0)
.unwrap();
assert_eq!(pre, Some(1000));

Expand Down Expand Up @@ -211,7 +211,7 @@ fn sets_to_node_storage_proof_if_higher() {
assert_ok!(CheckWeight::<Test>::do_prepare(&info, LEN, next_len));

let (pre, _) = StorageWeightReclaim::<Test>(PhantomData)
.validate_and_prepare(Some(ALICE.clone()).into(), CALL, &info, LEN)
.validate_and_prepare(Some(ALICE.clone()).into(), CALL, &info, LEN, 0)
.unwrap();
assert_eq!(pre, Some(175));

Expand Down Expand Up @@ -256,7 +256,7 @@ fn does_nothing_without_extension() {
assert_ok!(CheckWeight::<Test>::do_prepare(&info, LEN, next_len));

let (pre, _) = StorageWeightReclaim::<Test>(PhantomData)
.validate_and_prepare(Some(ALICE.clone()).into(), CALL, &info, LEN)
.validate_and_prepare(Some(ALICE.clone()).into(), CALL, &info, LEN, 0)
.unwrap();
assert_eq!(pre, None);

Expand Down Expand Up @@ -288,7 +288,7 @@ fn negative_refund_is_added_to_weight() {
assert_ok!(CheckWeight::<Test>::do_prepare(&info, LEN, next_len));

let (pre, _) = StorageWeightReclaim::<Test>(PhantomData)
.validate_and_prepare(Some(ALICE.clone()).into(), CALL, &info, LEN)
.validate_and_prepare(Some(ALICE.clone()).into(), CALL, &info, LEN, 0)
.unwrap();
assert_eq!(pre, Some(100));

Expand Down Expand Up @@ -321,7 +321,7 @@ fn test_zero_proof_size() {
assert_ok!(CheckWeight::<Test>::do_prepare(&info, LEN, next_len));

let (pre, _) = StorageWeightReclaim::<Test>(PhantomData)
.validate_and_prepare(Some(ALICE.clone()).into(), CALL, &info, LEN)
.validate_and_prepare(Some(ALICE.clone()).into(), CALL, &info, LEN, 0)
.unwrap();
assert_eq!(pre, Some(0));

Expand Down Expand Up @@ -354,7 +354,7 @@ fn test_larger_pre_dispatch_proof_size() {
assert_ok!(CheckWeight::<Test>::do_prepare(&info, LEN, next_len));

let (pre, _) = StorageWeightReclaim::<Test>(PhantomData)
.validate_and_prepare(Some(ALICE.clone()).into(), CALL, &info, LEN)
.validate_and_prepare(Some(ALICE.clone()).into(), CALL, &info, LEN, 0)
.unwrap();
assert_eq!(pre, Some(300));

Expand Down Expand Up @@ -394,7 +394,7 @@ fn test_incorporates_check_weight_unspent_weight() {
assert_ok!(CheckWeight::<Test>::do_prepare(&info, LEN, next_len));

let (pre, _) = StorageWeightReclaim::<Test>(PhantomData)
.validate_and_prepare(Some(ALICE.clone()).into(), CALL, &info, LEN)
.validate_and_prepare(Some(ALICE.clone()).into(), CALL, &info, LEN, 0)
.unwrap();
assert_eq!(pre, Some(100));

Expand Down Expand Up @@ -434,7 +434,7 @@ fn test_incorporates_check_weight_unspent_weight_on_negative() {
assert_ok!(CheckWeight::<Test>::do_prepare(&info, LEN, next_len));

let (pre, _) = StorageWeightReclaim::<Test>(PhantomData)
.validate_and_prepare(Some(ALICE.clone()).into(), CALL, &info, LEN)
.validate_and_prepare(Some(ALICE.clone()).into(), CALL, &info, LEN, 0)
.unwrap();
assert_eq!(pre, Some(100));

Expand Down Expand Up @@ -478,7 +478,7 @@ fn test_nothing_relcaimed() {
assert_eq!(get_storage_weight().total().proof_size(), 250);

let (pre, _) = StorageWeightReclaim::<Test>(PhantomData)
.validate_and_prepare(Some(ALICE.clone()).into(), CALL, &info, LEN)
.validate_and_prepare(Some(ALICE.clone()).into(), CALL, &info, LEN, 0)
.unwrap();
// Should return `setup_test_externalities` proof recorder value: 100.
assert_eq!(pre, Some(0));
Expand Down Expand Up @@ -525,7 +525,7 @@ fn test_incorporates_check_weight_unspent_weight_reverse_order() {
assert_ok!(CheckWeight::<Test>::do_prepare(&info, LEN, next_len));

let (pre, _) = StorageWeightReclaim::<Test>(PhantomData)
.validate_and_prepare(Some(ALICE.clone()).into(), CALL, &info, LEN)
.validate_and_prepare(Some(ALICE.clone()).into(), CALL, &info, LEN, 0)
.unwrap();
assert_eq!(pre, Some(100));

Expand Down Expand Up @@ -567,7 +567,7 @@ fn test_incorporates_check_weight_unspent_weight_on_negative_reverse_order() {
assert_ok!(CheckWeight::<Test>::do_prepare(&info, LEN, next_len));

let (pre, _) = StorageWeightReclaim::<Test>(PhantomData)
.validate_and_prepare(Some(ALICE.clone()).into(), CALL, &info, LEN)
.validate_and_prepare(Some(ALICE.clone()).into(), CALL, &info, LEN, 0)
.unwrap();
assert_eq!(pre, Some(100));

Expand Down
8 changes: 4 additions & 4 deletions polkadot/runtime/common/src/claims.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,7 @@ mod tests {
});
let di = c.get_dispatch_info();
assert_eq!(di.pays_fee, Pays::No);
let r = p.validate_only(Some(42).into(), &c, &di, 20, External);
let r = p.validate_only(Some(42).into(), &c, &di, 20, External, 0);
assert_eq!(r.unwrap().0, ValidTransaction::default());
});
}
Expand All @@ -1091,13 +1091,13 @@ mod tests {
statement: StatementKind::Regular.to_text().to_vec(),
});
let di = c.get_dispatch_info();
let r = p.validate_only(Some(42).into(), &c, &di, 20, External);
let r = p.validate_only(Some(42).into(), &c, &di, 20, External, 0);
assert!(r.is_err());
let c = RuntimeCall::Claims(ClaimsCall::attest {
statement: StatementKind::Saft.to_text().to_vec(),
});
let di = c.get_dispatch_info();
let r = p.validate_only(Some(69).into(), &c, &di, 20, External);
let r = p.validate_only(Some(69).into(), &c, &di, 20, External, 0);
assert!(r.is_err());
});
}
Expand Down Expand Up @@ -1739,7 +1739,7 @@ mod benchmarking {
#[block]
{
assert!(ext
.test_run(RawOrigin::Signed(account).into(), &call, &info, 0, |_| {
.test_run(RawOrigin::Signed(account).into(), &call, &info, 0, 0, |_| {
Ok(Default::default())
})
.unwrap()
Expand Down
10 changes: 10 additions & 0 deletions prdoc/pr_6411.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
title: "Support more types in TypeWithDefault"

doc:
- audience: Runtime Dev
description: |
This PR supports more integer types to be used with `TypeWithDefault` and makes `TypeWithDefault<u8/u16/u32, ..>: BaseArithmetic` satisfied

crates:
- name: sp-runtime
bump: patch
Loading

0 comments on commit cff1cba

Please sign in to comment.