Skip to content

Commit

Permalink
wasm-builder: Use riscv32emac-unknown-none-polkavm.json target (parit…
Browse files Browse the repository at this point in the history
…ytech#6419)

# Description

Closes paritytech#6335.

## Integration

N/A

## Review Notes

`RuntimeTarget` is converted to return path to the custom target JSON
file

---------

Signed-off-by: Jarkko Sakkinen <[email protected]>
Co-authored-by: Alexander Theißen <[email protected]>
Co-authored-by: Koute <[email protected]>
  • Loading branch information
3 people authored and sylvaincormier committed Dec 4, 2024
1 parent 2779043 commit c1b1fde
Show file tree
Hide file tree
Showing 1,191 changed files with 10,867 additions and 9,183 deletions.
12 changes: 6 additions & 6 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1090,8 +1090,8 @@ polkadot-test-client = { path = "polkadot/node/test/client" }
polkadot-test-runtime = { path = "polkadot/runtime/test-runtime" }
polkadot-test-service = { path = "polkadot/node/test/service" }
polkavm = { version = "0.9.3", default-features = false }
polkavm-derive = "0.9.1"
polkavm-linker = "0.9.2"
polkavm-derive = "0.17.0"
polkavm-linker = "0.17.1"
portpicker = { version = "0.1.1" }
pretty_assertions = { version = "1.3.0" }
primitive-types = { version = "0.13.1", default-features = false, features = [
Expand Down
12 changes: 6 additions & 6 deletions bridges/bin/runtime-common/src/extensions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ where
has_failed || !SubmitFinalityProofHelper::<T, I>::was_successful(bundled_block_number);

if !has_failed {
return
return;
}

// let's slash registered relayer
Expand Down Expand Up @@ -172,11 +172,11 @@ where
// we are only interested in associated pallet submissions
let Some(update) = maybe_update else { return };
// we are only interested in failed or unneeded transactions
let has_failed = has_failed ||
!SubmitParachainHeadsHelper::<T, ParachainsInstance>::was_successful(&update);
let has_failed = has_failed
|| !SubmitParachainHeadsHelper::<T, ParachainsInstance>::was_successful(&update);

if !has_failed {
return
return;
}

// let's slash registered relayer
Expand Down Expand Up @@ -465,7 +465,7 @@ mod tests {
type ToPostDispatch = u64;
fn validate(_who: &u64, call: &MockCall) -> (u64, TransactionValidity) {
if call.data <= 1 {
return (1, InvalidTransaction::Custom(1).into())
return (1, InvalidTransaction::Custom(1).into());
}

(1, Ok(ValidTransaction { priority: 1, ..Default::default() }))
Expand Down Expand Up @@ -493,7 +493,7 @@ mod tests {
type ToPostDispatch = u64;
fn validate(_who: &u64, call: &MockCall) -> (u64, TransactionValidity) {
if call.data <= 2 {
return (2, InvalidTransaction::Custom(2).into())
return (2, InvalidTransaction::Custom(2).into());
}

(2, Ok(ValidTransaction { priority: 2, ..Default::default() }))
Expand Down
2 changes: 1 addition & 1 deletion bridges/bin/runtime-common/src/messages_benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ fn prepare_inbound_message<LaneId>(

// if we don't need a correct message, then we may just return some random blob
if !params.is_successful_dispatch_expected {
return vec![0u8; expected_size]
return vec![0u8; expected_size];
}

// else let's prepare successful message.
Expand Down
4 changes: 2 additions & 2 deletions bridges/bin/runtime-common/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@ impl MessageDispatch for DummyMessageDispatch {
type LaneId = TestLaneIdType;

fn is_active(lane: Self::LaneId) -> bool {
frame_support::storage::unhashed::take::<bool>(&(b"inactive", lane).encode()[..]) !=
Some(false)
frame_support::storage::unhashed::take::<bool>(&(b"inactive", lane).encode()[..])
!= Some(false)
}

fn dispatch_weight(
Expand Down
2 changes: 1 addition & 1 deletion bridges/modules/beefy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ pub mod pallet {
init_data: InitializationDataOf<T, I>,
) -> Result<(), Error<T, I>> {
if init_data.authority_set.len == 0 {
return Err(Error::<T, I>::InvalidInitialAuthoritySet)
return Err(Error::<T, I>::InvalidInitialAuthoritySet);
}
CurrentAuthoritySetInfo::<T, I>::put(init_data.authority_set);

Expand Down
8 changes: 4 additions & 4 deletions bridges/modules/beefy/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ fn verify_signatures<T: Config<I>, I: 'static>(
if authority.verify(sig, &msg) {
missing_signatures = missing_signatures.saturating_sub(1);
if missing_signatures == 0 {
break
break;
}
} else {
log::debug!(
Expand Down Expand Up @@ -241,9 +241,9 @@ mod tests {
let mut header = ChainBuilder::new(20).append_finalized_header().to_header();
header.customize_signatures(|signatures| {
let first_signature_idx = signatures.iter().position(Option::is_some).unwrap();
let last_signature_idx = signatures.len() -
signatures.iter().rev().position(Option::is_some).unwrap() -
1;
let last_signature_idx = signatures.len()
- signatures.iter().rev().position(Option::is_some).unwrap()
- 1;
signatures[first_signature_idx] = signatures[last_signature_idx].clone();
});
assert_noop!(
Expand Down
15 changes: 8 additions & 7 deletions bridges/modules/grandpa/src/call_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ impl<T: Config<I>, I: 'static> SubmitFinalityProofHelper<T, I> {
best_finalized,
);

return Err(Error::<T, I>::OldHeader)
return Err(Error::<T, I>::OldHeader);
},
};

Expand All @@ -169,7 +169,7 @@ impl<T: Config<I>, I: 'static> SubmitFinalityProofHelper<T, I> {
actual_set_id,
);

return Err(Error::<T, I>::InvalidAuthoritySetId)
return Err(Error::<T, I>::InvalidAuthoritySetId);
}
}

Expand Down Expand Up @@ -201,7 +201,7 @@ pub trait CallSubType<T: Config<I, RuntimeCall = Self>, I: 'static>:
justification,
None,
false,
))
));
} else if let Some(crate::Call::<T, I>::submit_finality_proof_ex {
finality_target,
justification,
Expand All @@ -214,7 +214,7 @@ pub trait CallSubType<T: Config<I, RuntimeCall = Self>, I: 'static>:
justification,
Some(*current_set_id),
*is_free_execution_expected,
))
));
}

None
Expand Down Expand Up @@ -244,13 +244,14 @@ pub trait CallSubType<T: Config<I, RuntimeCall = Self>, I: 'static>:
};

if Pallet::<T, I>::ensure_not_halted().is_err() {
return Err(InvalidTransaction::Call.into())
return Err(InvalidTransaction::Call.into());
}

let result = SubmitFinalityProofHelper::<T, I>::check_obsolete_from_extension(&call_info);
match result {
Ok(improved_by) =>
Ok(Some(VerifiedSubmitFinalityProofInfo { base: call_info, improved_by })),
Ok(improved_by) => {
Ok(Some(VerifiedSubmitFinalityProofInfo { base: call_info, improved_by }))
},
Err(Error::<T, I>::OldHeader) => Err(InvalidTransaction::Stale.into()),
Err(_) => Err(InvalidTransaction::Call.into()),
}
Expand Down
2 changes: 1 addition & 1 deletion bridges/modules/grandpa/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ where
if let Event::<T, I>::UpdatedBestFinalizedHeader { grandpa_info, .. } =
event.event.try_into().ok()?
{
return Some(grandpa_info)
return Some(grandpa_info);
}
None
})
Expand Down
4 changes: 2 additions & 2 deletions bridges/modules/messages/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@ mod benchmarks {
//

fn max_msgs<T: Config<I>, I: 'static>() -> u32 {
T::BridgedChain::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX as u32 -
ReceiveMessagesProofSetup::<T, I>::LATEST_RECEIVED_NONCE as u32
T::BridgedChain::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX as u32
- ReceiveMessagesProofSetup::<T, I>::LATEST_RECEIVED_NONCE as u32
}

// Benchmark `receive_messages_proof` extrinsic with single minimal-weight message and following
Expand Down
22 changes: 11 additions & 11 deletions bridges/modules/messages/src/call_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ impl<T: Config<I>, I: 'static> CallHelper<T, I> {
// `is_obsolete` and every relayer has delivered at least one message,
// so if relayer slots are released, then message slots are also
// released
return post_occupation.free_message_slots >
info.unrewarded_relayers.free_message_slots
return post_occupation.free_message_slots
> info.unrewarded_relayers.free_message_slots;
}

inbound_lane_data.last_delivered_nonce() == *info.base.bundled_range.end()
Expand Down Expand Up @@ -131,7 +131,7 @@ impl<
best_stored_nonce: inbound_lane_data.last_delivered_nonce(),
},
unrewarded_relayers: unrewarded_relayers_occupation::<T, I>(&inbound_lane_data),
})
});
}

None
Expand All @@ -154,22 +154,22 @@ impl<
// confirmation. Because of that, we can't assume that our state has been confirmed
// to the bridged chain. So we are accepting any proof that brings new
// confirmations.
bundled_range: outbound_lane_data.latest_received_nonce + 1..=
relayers_state.last_delivered_nonce,
bundled_range: outbound_lane_data.latest_received_nonce + 1
..=relayers_state.last_delivered_nonce,
best_stored_nonce: outbound_lane_data.latest_received_nonce,
}))
}));
}

None
}

fn call_info(&self) -> Option<MessagesCallInfo<T::LaneId>> {
if let Some(info) = self.receive_messages_proof_info() {
return Some(MessagesCallInfo::ReceiveMessagesProof(info))
return Some(MessagesCallInfo::ReceiveMessagesProof(info));
}

if let Some(info) = self.receive_messages_delivery_proof_info() {
return Some(MessagesCallInfo::ReceiveMessagesDeliveryProof(info))
return Some(MessagesCallInfo::ReceiveMessagesDeliveryProof(info));
}

None
Expand All @@ -195,7 +195,7 @@ impl<
proof_info
);

return sp_runtime::transaction_validity::InvalidTransaction::Call.into()
return sp_runtime::transaction_validity::InvalidTransaction::Call.into();
},
Some(MessagesCallInfo::ReceiveMessagesProof(proof_info))
if proof_info
Expand All @@ -207,7 +207,7 @@ impl<
proof_info
);

return sp_runtime::transaction_validity::InvalidTransaction::Stale.into()
return sp_runtime::transaction_validity::InvalidTransaction::Stale.into();
},
Some(MessagesCallInfo::ReceiveMessagesDeliveryProof(proof_info))
if proof_info.is_obsolete() =>
Expand All @@ -218,7 +218,7 @@ impl<
proof_info,
);

return sp_runtime::transaction_validity::InvalidTransaction::Stale.into()
return sp_runtime::transaction_validity::InvalidTransaction::Stale.into();
},
_ => {},
}
Expand Down
10 changes: 5 additions & 5 deletions bridges/modules/messages/src/inbound_lane.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,10 @@ impl<S: InboundLaneStorage> InboundLane<S> {

if outbound_lane_data.latest_received_nonce > last_delivered_nonce {
// this is something that should never happen if proofs are correct
return None
return None;
}
if outbound_lane_data.latest_received_nonce <= data.last_confirmed_nonce {
return None
return None;
}

let new_confirmed_nonce = outbound_lane_data.latest_received_nonce;
Expand Down Expand Up @@ -191,18 +191,18 @@ impl<S: InboundLaneStorage> InboundLane<S> {
) -> ReceptionResult<Dispatch::DispatchLevelResult> {
let mut data = self.storage.data();
if Some(nonce) != data.last_delivered_nonce().checked_add(1) {
return ReceptionResult::InvalidNonce
return ReceptionResult::InvalidNonce;
}

// if there are more unrewarded relayer entries than we may accept, reject this message
if data.relayers.len() as MessageNonce >= self.storage.max_unrewarded_relayer_entries() {
return ReceptionResult::TooManyUnrewardedRelayers
return ReceptionResult::TooManyUnrewardedRelayers;
}

// if there are more unconfirmed messages than we may accept, reject this message
let unconfirmed_messages_count = nonce.saturating_sub(data.last_confirmed_nonce);
if unconfirmed_messages_count > self.storage.max_unconfirmed_messages() {
return ReceptionResult::TooManyUnconfirmedMessages
return ReceptionResult::TooManyUnconfirmedMessages;
}

// then, dispatch message
Expand Down
16 changes: 8 additions & 8 deletions bridges/modules/messages/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ pub mod pallet {

// reject transactions that are declaring too many messages
ensure!(
MessageNonce::from(messages_count) <=
BridgedChainOf::<T, I>::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX,
MessageNonce::from(messages_count)
<= BridgedChainOf::<T, I>::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX,
Error::<T, I>::TooManyMessagesInTheProof
);

Expand Down Expand Up @@ -319,9 +319,9 @@ pub mod pallet {
valid_messages += 1;
dispatch_result.unspent_weight
},
ReceptionResult::InvalidNonce |
ReceptionResult::TooManyUnrewardedRelayers |
ReceptionResult::TooManyUnconfirmedMessages => message_dispatch_weight,
ReceptionResult::InvalidNonce
| ReceptionResult::TooManyUnrewardedRelayers
| ReceptionResult::TooManyUnconfirmedMessages => message_dispatch_weight,
};
messages_received_status.push(message.key.nonce, receival_result);

Expand Down Expand Up @@ -730,10 +730,10 @@ where

/// Ensure that the pallet is in normal operational mode.
fn ensure_normal_operating_mode<T: Config<I>, I: 'static>() -> Result<(), Error<T, I>> {
if PalletOperatingMode::<T, I>::get() ==
MessagesOperatingMode::Basic(BasicOperatingMode::Normal)
if PalletOperatingMode::<T, I>::get()
== MessagesOperatingMode::Basic(BasicOperatingMode::Normal)
{
return Ok(())
return Ok(());
}

Err(Error::<T, I>::NotOperatingNormally)
Expand Down
Loading

0 comments on commit c1b1fde

Please sign in to comment.