Skip to content

Commit

Permalink
Merge branch 'master' into ib-omni-node-ps-check
Browse files Browse the repository at this point in the history
  • Loading branch information
iulianbarbu authored Nov 15, 2024
2 parents 1f8128a + a77940b commit bbe6e42
Show file tree
Hide file tree
Showing 157 changed files with 7,462 additions and 5,895 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
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,7 @@ linked-hash-map = { version = "0.5.4" }
linked_hash_set = { version = "0.1.4" }
linregress = { version = "0.5.1" }
lite-json = { version = "0.2.0", default-features = false }
litep2p = { version = "0.8.0", features = ["websocket"] }
litep2p = { version = "0.8.1", features = ["websocket"] }
log = { version = "0.4.22", default-features = false }
macro_magic = { version = "0.5.1" }
maplit = { version = "1.0.2" }
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
17 changes: 6 additions & 11 deletions cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,7 @@ use frame_support::{
ord_parameter_types, parameter_types,
traits::{
fungible, fungibles,
tokens::{
imbalance::ResolveAssetTo, nonfungibles_v2::Inspect, Fortitude::Polite,
Preservation::Expendable,
},
tokens::{imbalance::ResolveAssetTo, nonfungibles_v2::Inspect},
AsEnsureOriginWithArg, ConstBool, ConstU128, ConstU32, ConstU64, ConstU8, InstanceFilter,
Nothing, TransformOrigin,
},
Expand All @@ -68,7 +65,7 @@ use parachains_common::{
NORMAL_DISPATCH_RATIO,
};
use sp_api::impl_runtime_apis;
use sp_core::{crypto::KeyTypeId, OpaqueMetadata, H160};
use sp_core::{crypto::KeyTypeId, OpaqueMetadata, H160, U256};
use sp_runtime::{
generic, impl_opaque_keys,
traits::{AccountIdConversion, BlakeTwo256, Block as BlockT, Saturating, Verify},
Expand Down Expand Up @@ -127,7 +124,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: alloc::borrow::Cow::Borrowed("westmint"),
impl_name: alloc::borrow::Cow::Borrowed("westmint"),
authoring_version: 1,
spec_version: 1_016_005,
spec_version: 1_016_006,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 16,
Expand Down Expand Up @@ -2080,10 +2077,8 @@ impl_runtime_apis! {

impl pallet_revive::ReviveApi<Block, AccountId, Balance, Nonce, BlockNumber, EventRecord> for Runtime
{
fn balance(address: H160) -> Balance {
use frame_support::traits::fungible::Inspect;
let account = <Runtime as pallet_revive::Config>::AddressMapper::to_account_id(&address);
Balances::reducible_balance(&account, Expendable, Polite)
fn balance(address: H160) -> U256 {
Revive::evm_balance(&address)
}

fn nonce(address: H160) -> Nonce {
Expand All @@ -2093,7 +2088,7 @@ impl_runtime_apis! {
fn eth_transact(
from: H160,
dest: Option<H160>,
value: Balance,
value: U256,
input: Vec<u8>,
gas_limit: Option<Weight>,
storage_deposit_limit: Option<Balance>,
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
Loading

0 comments on commit bbe6e42

Please sign in to comment.