Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
tmpolaczyk committed Nov 20, 2024
1 parent 23124e3 commit 804fafd
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 32 deletions.
3 changes: 1 addition & 2 deletions pallets/external-validator-slashes/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with Tanssi. If not, see <http://www.gnu.org/licenses/>

use snowbridge_core::outbound::SendError;
use snowbridge_core::outbound::SendMessageFeeProvider;
use {
crate as external_validator_slashes,
frame_support::{
parameter_types,
traits::{ConstU16, ConstU64, Get},
},
frame_system as system,
snowbridge_core::outbound::{SendError, SendMessageFeeProvider},
sp_core::H256,
sp_runtime::{
testing::UintAuthorityId,
Expand Down
21 changes: 21 additions & 0 deletions pallets/external-validator-slashes/src/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ use sp_std::marker::PhantomData;
pub trait WeightInfo {
fn cancel_deferred_slash(s: u32, ) -> Weight;
fn force_inject_slash() -> Weight;
fn root_test_send_msg_to_eth() -> Weight;
}

/// Weights for pallet_external_validator_slashes using the Substrate node and recommended hardware.
Expand Down Expand Up @@ -91,6 +92,16 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
.saturating_add(T::DbWeight::get().reads(3_u64))
.saturating_add(T::DbWeight::get().writes(2_u64))
}

fn root_test_send_msg_to_eth() -> Weight {
// Proof Size summary in bytes:
// Measured: `322`
// Estimated: `3601`
// Minimum execution time: 994_654_000 picoseconds.
Weight::from_parts(1_015_195_000, 3601)
.saturating_add(T::DbWeight::get().reads(3_u64))
.saturating_add(T::DbWeight::get().writes(5_u64))
}
}

// For backwards compatibility and tests
Expand Down Expand Up @@ -126,4 +137,14 @@ impl WeightInfo for () {
.saturating_add(RocksDbWeight::get().reads(3_u64))
.saturating_add(RocksDbWeight::get().writes(2_u64))
}

fn root_test_send_msg_to_eth() -> Weight {
// Proof Size summary in bytes:
// Measured: `322`
// Estimated: `3601`
// Minimum execution time: 994_654_000 picoseconds.
Weight::from_parts(1_015_195_000, 3601)
.saturating_add(RocksDbWeight::get().reads(3_u64))
.saturating_add(RocksDbWeight::get().writes(5_u64))
}
}
62 changes: 32 additions & 30 deletions primitives/bridge/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,29 @@

#![cfg_attr(not(feature = "std"), no_std)]

use ethabi::Token;
use frame_support::traits::Contains;
use snowbridge_core::outbound::Fee;
use snowbridge_core::outbound::SendError;
use snowbridge_core::ChannelId;
pub use snowbridge_pallet_outbound_queue::send_message_impl::Ticket;
use sp_runtime::traits::Convert;
use {
core::marker::PhantomData,
ethabi::Token,
frame_support::{
ensure,
pallet_prelude::{Decode, Encode, Get},
traits::Contains,
},
frame_system::unique,
scale_info::TypeInfo,
snowbridge_core::{
outbound::{Fee, SendError},
ChannelId,
},
snowbridge_pallet_outbound_queue::send_message_impl::Ticket,
sp_core::H256,
sp_runtime::{app_crypto::sp_core, RuntimeDebug},
sp_runtime::{app_crypto::sp_core, traits::Convert, RuntimeDebug},
sp_std::vec::Vec,
};
pub use {
custom_do_process_message::{ConstantGasMeter, CustomProcessSnowbridgeMessage},
custom_send_message::CustomSendMessage,
};

// Separate import as rustfmt wrongly change it to `sp_std::vec::self`, which is the module instead
// of the macro.
Expand Down Expand Up @@ -203,21 +207,20 @@ pub trait DeliverMessage {
fn deliver(ticket: Self::Ticket) -> Result<H256, SendError>;
}

pub use custom_do_process_message::ConstantGasMeter;
pub use custom_do_process_message::CustomProcessSnowbridgeMessage;

mod custom_do_process_message {
use super::*;
use frame_support::ensure;
use frame_support::traits::{Defensive, ProcessMessage, ProcessMessageError};
use frame_support::weights::WeightMeter;
use snowbridge_pallet_outbound_queue::MessageLeaves;
use snowbridge_pallet_outbound_queue::Messages;
use snowbridge_pallet_outbound_queue::Nonce;
use snowbridge_pallet_outbound_queue::WeightInfo;
use snowbridge_pallet_outbound_queue::{CommittedMessage, ProcessMessageOriginOf};
use sp_runtime::traits::Hash;
use sp_std::boxed::Box;
use {
super::*,
frame_support::{
ensure,
traits::{Defensive, ProcessMessage, ProcessMessageError},
weights::WeightMeter,
},
snowbridge_pallet_outbound_queue::{
CommittedMessage, MessageLeaves, Messages, Nonce, ProcessMessageOriginOf, WeightInfo,
},
sp_runtime::traits::Hash,
sp_std::boxed::Box,
};

/// Alternative to [snowbridge_pallet_outbound_queue::Pallet::process_message] using a different
/// [Command] enum.
Expand Down Expand Up @@ -350,15 +353,14 @@ mod custom_do_process_message {
}
}

pub use custom_send_message::CustomSendMessage;

mod custom_send_message {
use super::*;
use ethabi::H256;
use frame_support::traits::EnqueueMessage;
use snowbridge_core::outbound::SendError;
use snowbridge_core::PRIMARY_GOVERNANCE_CHANNEL;
use sp_std::marker::PhantomData;
use {
super::*,
ethabi::H256,
frame_support::traits::EnqueueMessage,
snowbridge_core::{outbound::SendError, PRIMARY_GOVERNANCE_CHANNEL},
sp_std::marker::PhantomData,
};

/// Alternative to [snowbridge_pallet_outbound_queue::Pallet::deliver] using a different
/// origin.
Expand Down

0 comments on commit 804fafd

Please sign in to comment.