Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions bridges/snowbridge/pallets/outbound-queue-v2/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,17 @@ pub mod pallet {
return Err(Yield);
}

let nonce = Nonce::<T>::get();
let nonce = <Nonce<T>>::try_mutate(|nonce| -> Result<u64, ProcessMessageError> {
*nonce = nonce.checked_add(1).ok_or_else(|| {
Self::deposit_event(Event::MessageRejected {
id: None,
payload: message.to_vec(),
error: Unsupported,
});
Unsupported
})?;
Ok(*nonce)
})?;

// Decode bytes into Message
let Message { origin, id, fee, commands } =
Expand Down Expand Up @@ -409,15 +419,6 @@ pub mod pallet {
};
<PendingOrders<T>>::insert(nonce, order);

Nonce::<T>::set(nonce.checked_add(1).ok_or_else(|| {
Self::deposit_event(Event::MessageRejected {
id: Some(id),
payload: message.to_vec(),
error: Unsupported,
});
Unsupported
})?);

Self::deposit_event(Event::MessageAccepted { id, nonce });

Ok(true)
Expand Down
9 changes: 2 additions & 7 deletions bridges/snowbridge/pallets/outbound-queue-v2/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,10 @@ fn process_message_fails_on_max_nonce_reached() {

match last_event {
mock::RuntimeEvent::OutboundQueue(Event::MessageRejected {
id: Some(id),
id: None,
payload: _,
error: ProcessMessageError::Unsupported,
}) => {
assert_eq!(
id,
hex!("0000000000000000000000000000000000000000000000000000000000000001").into()
);
},
}) => {},
_ => {
panic!("Expected Event::MessageRejected(Unsupported) but got {:?}", last_event);
},
Expand Down
2 changes: 1 addition & 1 deletion bridges/snowbridge/pallets/system-frontend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub enum BridgeHubRuntime {
/// Call indices for dispatchables within `snowbridge-pallet-system-v2`
#[derive(Encode, Decode, Debug, PartialEq, Clone, TypeInfo)]
pub enum EthereumSystemCall {
#[codec(index = 0)]
#[codec(index = 2)]
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

RegisterToken {
sender: Box<VersionedLocation>,
asset_id: Box<VersionedLocation>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ fn send_weth_from_asset_hub_to_ethereum() {
let reward_account = AssetHubWestendReceiver::get();
let receipt = DeliveryReceipt {
gateway: EthereumGatewayAddress::get(),
nonce: 0,
nonce: 1,
reward_address: reward_account.into(),
topic: H256::zero(),
success: true,
Expand Down Expand Up @@ -264,7 +264,7 @@ fn transfer_relay_token_from_ah() {
let reward_account = AssetHubWestendReceiver::get();
let receipt = DeliveryReceipt {
gateway: EthereumGatewayAddress::get(),
nonce: 0,
nonce: 1,
reward_address: reward_account.into(),
topic: H256::zero(),
success: true,
Expand Down Expand Up @@ -351,7 +351,7 @@ fn send_weth_and_dot_from_asset_hub_to_ethereum() {
let reward_account = AssetHubWestendReceiver::get();
let receipt = DeliveryReceipt {
gateway: EthereumGatewayAddress::get(),
nonce: 0,
nonce: 1,
reward_address: reward_account.into(),
topic: H256::zero(),
success: true,
Expand Down Expand Up @@ -447,7 +447,7 @@ fn transact_with_agent_from_asset_hub() {
let reward_account = AssetHubWestendReceiver::get();
let receipt = DeliveryReceipt {
gateway: EthereumGatewayAddress::get(),
nonce: 0,
nonce: 1,
reward_address: reward_account.into(),
topic: H256::zero(),
success: true,
Expand Down Expand Up @@ -531,7 +531,7 @@ fn transact_with_agent_from_asset_hub_without_any_asset_transfer() {
let reward_account = AssetHubWestendReceiver::get();
let receipt = DeliveryReceipt {
gateway: EthereumGatewayAddress::get(),
nonce: 0,
nonce: 1,
reward_address: reward_account.into(),
success: true,
topic: Default::default(),
Expand Down Expand Up @@ -648,7 +648,7 @@ fn register_token_from_penpal() {
let reward_account = AssetHubWestendReceiver::get();
let receipt = DeliveryReceipt {
gateway: EthereumGatewayAddress::get(),
nonce: 0,
nonce: 1,
reward_address: reward_account.into(),
topic: H256::zero(),
success: true,
Expand Down
Loading