Skip to content

Commit

Permalink
Various PR comments and CI fixes (Snowfork#1068)
Browse files Browse the repository at this point in the history
* adjust ci

* update polkadot-sdk

* script tweaks

* updates polkadot-sdk

* clippy

* clippy

* update polkadot-sdk

---------

Co-authored-by: claravanstaden <Cats 4 life!>
  • Loading branch information
claravanstaden authored Dec 19, 2023
1 parent 0becdae commit e5ac19e
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 27 deletions.
11 changes: 9 additions & 2 deletions .github/workflows/parachain.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,17 @@ jobs:
working-directory: parachain
run: |
cargo install taplo-cli --locked && taplo format --check --config .config/taplo.toml
- name: zepter
- name: install zepter
run: |
cargo install zepter -f --locked
- name: zepter snowbridge
working-directory: parachain
run: |
cargo install zepter -f --locked && zepter run check
zepter run check
- name: zepter polkadot-sdk
working-directory: polkadot-sdk
run: |
zepter run check
- name: lint-markdown
working-directory: parachain
run: |
Expand Down
2 changes: 1 addition & 1 deletion parachain/pallets/ethereum-beacon-client/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ pub mod minimal {
{
let filepath: PathBuf =
[env!("CARGO_MANIFEST_DIR"), "tests", "fixtures", basename].iter().collect();
serde_json::from_reader(File::open(&filepath).unwrap())
serde_json::from_reader(File::open(filepath).unwrap())
}

pub fn load_execution_header_update_fixture() -> primitives::ExecutionHeaderUpdate {
Expand Down
23 changes: 10 additions & 13 deletions parachain/pallets/ethereum-beacon-client/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub fn compute_domain() {
new_tester().execute_with(|| {
let domain = EthereumBeaconClient::compute_domain(
hex!("07000000").into(),
hex!("00000001").into(),
hex!("00000001"),
hex!("5dec7ae03261fde20d5b024dfabce8bac3276c9a4908e23d50ba8c9b50b0adff").into(),
);

Expand Down Expand Up @@ -116,7 +116,7 @@ pub fn compute_domain_bls() {
new_tester().execute_with(|| {
let domain = EthereumBeaconClient::compute_domain(
hex!("07000000").into(),
hex!("01000000").into(),
hex!("01000000"),
hex!("4b363db94e286120d76eb905340fdd4e54bfe9f06bf33ff6cf5ad27f511bfe95").into(),
);

Expand All @@ -131,7 +131,7 @@ pub fn compute_domain_bls() {
#[test]
pub fn verify_merkle_branch_for_finalized_root() {
new_tester().execute_with(|| {
assert_eq!(
assert!(
verify_merkle_branch(
hex!("0000000000000000000000000000000000000000000000000000000000000000").into(),
&[
Expand All @@ -145,17 +145,16 @@ pub fn verify_merkle_branch_for_finalized_root() {
crate::config::FINALIZED_ROOT_INDEX,
crate::config::FINALIZED_ROOT_DEPTH,
hex!("e46559327592741956f6beaa0f52e49625eb85dce037a0bd2eff333c743b287f").into()
),
true
)
);
});
}

#[test]
pub fn verify_merkle_branch_fails_if_depth_and_branch_dont_match() {
new_tester().execute_with(|| {
assert_eq!(
verify_merkle_branch(
assert!(
!verify_merkle_branch(
hex!("0000000000000000000000000000000000000000000000000000000000000000").into(),
&[
hex!("0000000000000000000000000000000000000000000000000000000000000000").into(),
Expand All @@ -165,8 +164,7 @@ pub fn verify_merkle_branch_fails_if_depth_and_branch_dont_match() {
crate::config::FINALIZED_ROOT_INDEX,
crate::config::FINALIZED_ROOT_DEPTH,
hex!("e46559327592741956f6beaa0f52e49625eb85dce037a0bd2eff333c743b287f").into()
),
false
)
);
});
}
Expand Down Expand Up @@ -232,7 +230,7 @@ pub fn execution_header_pruning() {
}

// We should have stored everything until now
assert_eq!(ExecutionHeaders::<Test>::iter().count() as usize, stored_hashes.len());
assert_eq!({ ExecutionHeaders::<Test>::iter().count() }, stored_hashes.len());

// Let's push extra entries so that some of the previous entries are deleted.
for i in 0..to_be_deleted {
Expand Down Expand Up @@ -539,8 +537,7 @@ fn submit_update_with_skipped_period() {
let checkpoint = load_checkpoint_update_fixture();
let sync_committee_update = load_sync_committee_update_fixture();
let mut update = load_next_finalized_header_update_fixture();
update.signature_slot =
update.signature_slot + (EPOCHS_PER_SYNC_COMMITTEE_PERIOD * SLOTS_PER_EPOCH) as u64;
update.signature_slot += (EPOCHS_PER_SYNC_COMMITTEE_PERIOD * SLOTS_PER_EPOCH) as u64;
update.attested_header.slot = update.signature_slot - 1;

new_tester().execute_with(|| {
Expand Down Expand Up @@ -705,7 +702,7 @@ fn submit_update_with_invalid_sync_committee_update() {
let prev = x.unwrap();
*x = Some(CompactBeaconState { slot: next_update.attested_header.slot, ..prev });
});
next_update.attested_header.slot = next_update.attested_header.slot + 1;
next_update.attested_header.slot += 1;
next_update.signature_slot = next_update.attested_header.slot + 1;
let next_sync_committee = NextSyncCommitteeUpdate::default();
next_update.next_sync_committee_update = Some(next_sync_committee);
Expand Down
6 changes: 3 additions & 3 deletions parachain/pallets/outbound-queue/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ fn process_message_fails_on_max_nonce_reached() {
new_tester().execute_with(|| {
let sibling_id = 1000;
let channel_id: ChannelId = ParaId::from(sibling_id).into();
let origin = AggregateMessageOrigin::Snowbridge(channel_id.into());
let origin = AggregateMessageOrigin::Snowbridge(channel_id);
let message: QueuedMessage = QueuedMessage {
id: H256::zero(),
channel_id,
Expand All @@ -117,7 +117,7 @@ fn process_message_fails_on_max_nonce_reached() {
Nonce::<Test>::set(channel_id, u64::MAX);

assert_noop!(
OutboundQueue::process_message(&encoded.as_slice(), origin, &mut meter, &mut [0u8; 32]),
OutboundQueue::process_message(encoded.as_slice(), origin, &mut meter, &mut [0u8; 32]),
ProcessMessageError::Unsupported
);
})
Expand All @@ -138,7 +138,7 @@ fn process_message_fails_on_overweight_message() {
let encoded = versioned_queued_message.encode();
let mut meter = WeightMeter::with_limit(Weight::from_parts(1, 1));
assert_noop!(
OutboundQueue::process_message(&encoded.as_slice(), origin, &mut meter, &mut [0u8; 32]),
OutboundQueue::process_message(encoded.as_slice(), origin, &mut meter, &mut [0u8; 32]),
ProcessMessageError::Overweight(<Test as Config>::WeightInfo::do_process_message())
);
})
Expand Down
11 changes: 4 additions & 7 deletions parachain/scripts/verify-pallets-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# - readme
# - license

set -eux
set -eu

# show CLI help
function show_help() {
Expand Down Expand Up @@ -49,12 +49,6 @@ done
# may be located either in call dir, or one of it subdirs.
SNOWBRIDGE_FOLDER="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/../.."

# let's leave repository/subtree in its original (clean) state if something fails below
function revert_to_clean_state {
[[ ! -z "${NO_REVERT}" ]] || { echo "Reverting to clean state..."; git checkout .; }
}
trap revert_to_clean_state EXIT

# remove everything we think is not required for our needs
rm -rf $SNOWBRIDGE_FOLDER/.cargo
rm -rf $SNOWBRIDGE_FOLDER/.github
Expand Down Expand Up @@ -83,6 +77,8 @@ rm -rf $SNOWBRIDGE_FOLDER/parachain/templates
rm -rf $SNOWBRIDGE_FOLDER/parachain/.config
rm -rf $SNOWBRIDGE_FOLDER/parachain/pallets/ethereum-beacon-client/fuzz

git rm $SNOWBRIDGE_FOLDER/polkadot-sdk

cd bridges/snowbridge/parachain

# fix polkadot-sdk paths in Cargo.toml files
Expand All @@ -108,6 +104,7 @@ cargo check -p snowbridge-outbound-queue --features try-runtime
cargo check -p snowbridge-system
cargo check -p snowbridge-system --features runtime-benchmarks
cargo check -p snowbridge-system --features try-runtime

cd -

# we're removing lock file after all checks are done. Otherwise we may use different
Expand Down

0 comments on commit e5ac19e

Please sign in to comment.