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
34 changes: 17 additions & 17 deletions Cargo.lock

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

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1258,13 +1258,13 @@ snowbridge-inbound-queue-primitives = { path = "bridges/snowbridge/primitives/in
snowbridge-merkle-tree = { path = "bridges/snowbridge/primitives/merkle-tree", default-features = false }
snowbridge-outbound-queue-primitives = { path = "bridges/snowbridge/primitives/outbound-queue", default-features = false }
snowbridge-outbound-queue-runtime-api = { path = "bridges/snowbridge/pallets/outbound-queue/runtime-api", default-features = false }
snowbridge-outbound-queue-runtime-api-v2 = { path = "bridges/snowbridge/pallets/outbound-queue-v2/runtime-api", default-features = false }
snowbridge-outbound-queue-v2-runtime-api = { path = "bridges/snowbridge/pallets/outbound-queue-v2/runtime-api", default-features = false }
snowbridge-pallet-ethereum-client = { path = "bridges/snowbridge/pallets/ethereum-client", default-features = false }
snowbridge-pallet-ethereum-client-fixtures = { path = "bridges/snowbridge/pallets/ethereum-client/fixtures", default-features = false }
snowbridge-pallet-inbound-queue = { path = "bridges/snowbridge/pallets/inbound-queue", default-features = false }
snowbridge-pallet-inbound-queue-fixtures = { path = "bridges/snowbridge/pallets/inbound-queue/fixtures", default-features = false }
snowbridge-pallet-inbound-queue-fixtures-v2 = { path = "bridges/snowbridge/pallets/inbound-queue-v2/fixtures", default-features = false }
snowbridge-pallet-inbound-queue-v2 = { path = "bridges/snowbridge/pallets/inbound-queue-v2", default-features = false }
snowbridge-pallet-inbound-queue-v2-fixtures = { path = "bridges/snowbridge/pallets/inbound-queue-v2/fixtures", default-features = false }
snowbridge-pallet-outbound-queue = { path = "bridges/snowbridge/pallets/outbound-queue", default-features = false }
snowbridge-pallet-outbound-queue-v2 = { path = "bridges/snowbridge/pallets/outbound-queue-v2", default-features = false }
snowbridge-pallet-system = { path = "bridges/snowbridge/pallets/system", default-features = false }
Expand All @@ -1273,7 +1273,7 @@ snowbridge-pallet-system-v2 = { path = "bridges/snowbridge/pallets/system-v2", d
snowbridge-runtime-common = { path = "bridges/snowbridge/runtime/runtime-common", default-features = false }
snowbridge-runtime-test-common = { path = "bridges/snowbridge/runtime/test-common", default-features = false }
snowbridge-system-runtime-api = { path = "bridges/snowbridge/pallets/system/runtime-api", default-features = false }
snowbridge-system-runtime-api-v2 = { path = "bridges/snowbridge/pallets/system-v2/runtime-api", default-features = false }
snowbridge-system-v2-runtime-api = { path = "bridges/snowbridge/pallets/system-v2/runtime-api", default-features = false }
snowbridge-test-utils = { path = "bridges/snowbridge/test-utils" }
snowbridge-verification-primitives = { path = "bridges/snowbridge/primitives/verification", default-features = false }
soketto = { version = "0.8.0" }
Expand Down
6 changes: 3 additions & 3 deletions bridges/snowbridge/pallets/inbound-queue-v2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ xcm-executor = { workspace = true }
snowbridge-beacon-primitives = { workspace = true }
snowbridge-core = { workspace = true }
snowbridge-inbound-queue-primitives = { workspace = true }
snowbridge-pallet-inbound-queue-fixtures-v2 = { optional = true, workspace = true }
snowbridge-pallet-inbound-queue-v2-fixtures = { optional = true, workspace = true }

bp-relayers = { workspace = true }

Expand Down Expand Up @@ -70,7 +70,7 @@ std = [
"snowbridge-beacon-primitives/std",
"snowbridge-core/std",
"snowbridge-inbound-queue-primitives/std",
"snowbridge-pallet-inbound-queue-fixtures-v2?/std",
"snowbridge-pallet-inbound-queue-v2-fixtures?/std",
"sp-core/std",
"sp-io/std",
"sp-runtime/std",
Expand All @@ -90,7 +90,7 @@ runtime-benchmarks = [
"snowbridge-core/runtime-benchmarks",
"snowbridge-inbound-queue-primitives/runtime-benchmarks",
"snowbridge-pallet-ethereum-client/runtime-benchmarks",
"snowbridge-pallet-inbound-queue-fixtures-v2/runtime-benchmarks",
"snowbridge-pallet-inbound-queue-v2-fixtures/runtime-benchmarks",
"snowbridge-test-utils/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"xcm-builder/runtime-benchmarks",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "snowbridge-pallet-inbound-queue-fixtures-v2"
name = "snowbridge-pallet-inbound-queue-v2-fixtures"
description = "Snowbridge Inbound Queue Test Fixtures V2"
version = "0.10.0"
authors = ["Snowfork <contact@snowfork.com>"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::Pallet as InboundQueue;
use frame_benchmarking::v2::*;
use frame_support::assert_ok;
use frame_system::RawOrigin;
use snowbridge_pallet_inbound_queue_fixtures_v2::register_token::make_register_token_message;
use snowbridge_pallet_inbound_queue_v2_fixtures::register_token::make_register_token_message;

#[benchmarks]
mod benchmarks {
Expand Down
7 changes: 4 additions & 3 deletions bridges/snowbridge/pallets/inbound-queue-v2/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
//!
//! ## Message Submission
//!
//! * [`Call::submit`]: Submit a message for verification and dispatch the final destination
//! * [`Call::submit`]: Submit a message for verification and dispatch to the final destination
//! parachain.
#![cfg_attr(not(feature = "std"), no_std)]

Expand Down Expand Up @@ -283,9 +283,10 @@ pub mod pallet {
) -> Result<XcmHash, SendError> {
let (ticket, fee) = validate_send::<T::XcmSender>(dest, xcm)?;
let fee_payer = T::AccountToLocation::try_convert(&fee_payer).map_err(|err| {
log::error!(
tracing::error!(
target: LOG_TARGET,
"Failed to convert account to XCM location: {err:?}",
?err,
"Failed to convert account to XCM location",
);
SendError::NotApplicable
})?;
Expand Down
4 changes: 3 additions & 1 deletion bridges/snowbridge/pallets/inbound-queue-v2/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ frame_support::construct_runtime!(
}
);

pub(crate) const ERROR_ADDRESS: [u8; 20] = hex!("0000000000000000000000000000000000000911");

pub type AccountId = sp_runtime::AccountId32;
type Balance = u128;

Expand Down Expand Up @@ -99,7 +101,7 @@ pub struct MockVerifier;

impl Verifier for MockVerifier {
fn verify(log: &Log, _: &Proof) -> Result<(), VerificationError> {
if log.address == hex!("0000000000000000000000000000000000000911").into() {
if log.address == ERROR_ADDRESS.into() {
return Err(VerificationError::InvalidProof)
}
Ok(())
Expand Down
16 changes: 8 additions & 8 deletions bridges/snowbridge/pallets/inbound-queue-v2/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use super::*;

use crate::{mock::*, Error};
use codec::Encode;
use frame_support::{assert_err, assert_noop, assert_ok};
use frame_support::{assert_noop, assert_ok};
use hex_literal::hex;
use snowbridge_inbound_queue_primitives::{EventProof, Proof};
use snowbridge_test_utils::mock_xcm::{set_charge_fees_override, set_sender_override};
Expand Down Expand Up @@ -85,9 +85,9 @@ fn test_submit_verification_fails_with_invalid_proof() {
},
};
// The mock verifier will error once it matches this address.
event.event_log.address = hex!("0000000000000000000000000000000000000911").into();
event.event_log.address = ERROR_ADDRESS.into();

assert_err!(
assert_noop!(
InboundQueue::submit(origin.clone(), Box::new(event.clone())),
Error::<Test>::Verification(VerificationError::InvalidProof)
);
Expand All @@ -110,7 +110,7 @@ fn test_submit_fails_with_malformed_message() {
},
};

assert_err!(
assert_noop!(
InboundQueue::submit(origin.clone(), Box::new(event.clone())),
Error::<Test>::InvalidMessage
);
Expand Down Expand Up @@ -145,7 +145,7 @@ fn test_using_same_nonce_fails() {
"no event emitted."
);

assert_err!(
assert_noop!(
InboundQueue::submit(origin.clone(), Box::new(event.clone())),
Error::<Test>::InvalidNonce
);
Expand Down Expand Up @@ -216,7 +216,7 @@ fn test_xcm_send_failure() {
},
};

assert_err!(
assert_noop!(
crate::test::InboundQueue::submit(origin.clone(), Box::new(event.clone())),
Error::<Test>::SendFailure
);
Expand Down Expand Up @@ -246,7 +246,7 @@ fn test_xcm_send_validate_failure() {
},
};

assert_err!(
assert_noop!(
crate::test::InboundQueue::submit(origin.clone(), Box::new(event.clone())),
Error::<Test>::Unreachable
);
Expand All @@ -271,7 +271,7 @@ fn test_xcm_charge_fees_failure() {
},
};

assert_err!(
assert_noop!(
crate::test::InboundQueue::submit(origin.clone(), Box::new(event.clone())),
Error::<Test>::FeesNotMet
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "snowbridge-outbound-queue-runtime-api-v2"
name = "snowbridge-outbound-queue-v2-runtime-api"
description = "Snowbridge Outbound Queue Runtime API V2"
version = "0.2.0"
authors = ["Snowfork <contact@snowfork.com>"]
Expand Down
15 changes: 7 additions & 8 deletions bridges/snowbridge/pallets/outbound-queue-v2/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
//! [`frame_support::traits::ProcessMessage::process_message`]
//! 5. The message is processed in `Pallet::do_process_message`:
//! a. Convert to `OutboundMessage`, and stored into the `Messages` vector storage
//! b. ABI-encoded the OutboundMessage, with commited hash stored into the `MessageLeaves` storage
//! c. Generate `PendingOrder` with assigned nonce and fee attach, stored into the `PendingOrders`
//! map storage, with nonce as the key
//! b. ABI-encode the `OutboundMessage` and store the committed hash in `MessageLeaves`
//! c. Generate `PendingOrder` with assigned nonce and fee attached, stored into the
//! `PendingOrders` map storage, with nonce as the key
//! d. Increment nonce and update the `Nonce` storage
//! 6. At the end of the block, a merkle root is constructed from all the leaves in `MessageLeaves`,
//! then `MessageLeaves` is dropped so that it is never committed to storage or included in PoV.
Expand All @@ -31,8 +31,9 @@
//! a. Generating a merkle proof for the committed message using the `prove_message` runtime API
//! b. Reading the actual message content from the `Messages` vector in storage
//! 9. On the Ethereum side, the message root is ultimately the thing being verified by the Beefy
//! light client. When the message has been verified and executed, the relayer will call the
//! extrinsic `submit_delivery_proof` work the way as follows:
//! light client.
//! 10. When the message has been verified and executed, the relayer will call the
//! extrinsic `submit_delivery_receipt` work the way as follows:
//! a. Verify the message with proof for a transaction receipt containing the event log,
//! same as the inbound queue verification flow
//! b. Fetch the pending order by nonce of the message, pay reward with fee attached in the order
Expand All @@ -41,12 +42,11 @@
//!
//! # Extrinsics
//!
//! * [`Call::submit_delivery_proof`]: Submit delivery proof
//! * [`Call::submit_delivery_receipt`]: Submit delivery proof
//!
//! # Runtime API
//!
//! * `prove_message`: Generate a merkle proof for a committed message
//! * `dry_run`: Convert xcm to InboundMessage
#![cfg_attr(not(feature = "std"), no_std)]
pub mod api;
pub mod process_message_impl;
Expand Down Expand Up @@ -216,7 +216,6 @@ pub mod pallet {
/// `on_initialize`, so should never go into block PoV.
#[pallet::storage]
#[pallet::unbounded]
#[pallet::getter(fn message_leaves)]
pub(super) type MessageLeaves<T: Config> = StorageValue<_, Vec<H256>, ValueQuery>;

/// The current nonce for the messages
Expand Down
6 changes: 4 additions & 2 deletions bridges/snowbridge/pallets/outbound-queue-v2/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use frame_support::{
};

use codec::Encode;
use hex_literal::hex;
use snowbridge_core::{ChannelId, ParaId};
use snowbridge_outbound_queue_primitives::{
v2::{abi::OutboundMessageWrapper, Command, Initializer, SendMessage},
Expand Down Expand Up @@ -140,8 +141,8 @@ fn process_message_fails_on_overweight_message() {
}

#[test]
fn governance_message_does_not_get_the_chance_to_processed_in_same_block_when_congest_of_low_priority_sibling_messages(
) {
fn governance_message_not_processed_in_same_block_when_queue_congested_with_low_priority_messages()
{
use AggregateMessageOrigin::*;

let sibling_id: u32 = 1000;
Expand Down Expand Up @@ -250,4 +251,5 @@ fn encode_mock_message() {
};
let message_abi_encoded = committed_message.abi_encode();
println!("{}", HexDisplay::from(&message_abi_encoded));
assert_eq!(hex!("000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000003e80000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000186a000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000eda338e4dc46038493b885327842fd3e301cab3900000000000000000000000000000000000000000000000000000000000f4240").to_vec(), message_abi_encoded)
}
4 changes: 2 additions & 2 deletions bridges/snowbridge/pallets/system-frontend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//!
//! System frontend pallet that acts as the user-facing controlplane for Snowbridge.
//!
//! Some operations are delegated to a backend pallet installed a remote parachain.
//! Some operations are delegated to a backend pallet installed on a remote parachain.
//!
//! # Extrinsics
//!
Expand Down Expand Up @@ -120,7 +120,7 @@ pub mod pallet {
#[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config> {
/// A XCM message was sent
/// An XCM was sent
MessageSent {
origin: Location,
destination: Location,
Expand Down
3 changes: 3 additions & 0 deletions bridges/snowbridge/pallets/system-v2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Ethereum System V2

This pallet is part of BridgeHub. Certain extrinsics in this pallet (like `register_token` and `add_tip`) will be called from the System Frontend pallet on AssetHub.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "snowbridge-system-runtime-api-v2"
name = "snowbridge-system-v2-runtime-api"
description = "Snowbridge System Runtime API V2"
version = "0.2.0"
authors = ["Snowfork <contact@snowfork.com>"]
Expand Down
2 changes: 1 addition & 1 deletion bridges/snowbridge/pallets/system-v2/runtime-api/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Ethereum System Runtime API V2

Provides an API for looking up an agent ID on Ethereum.
Provides an API for looking up an agent ID on Ethereum. An agent ID is a unique mapping to an Agent contract on Ethereum which acts as the sovereign account for the Location.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use xcm::VersionedLocation;
sp_api::decl_runtime_apis! {
pub trait ControlV2Api
{
/// Provides the Agent ID on Ethereum for the specified location.
fn agent_id(location: VersionedLocation) -> Option<AgentId>;
}
}
Loading
Loading