Skip to content
This repository has been archived by the owner on Jul 12, 2022. It is now read-only.

Commit

Permalink
update weights (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
vedhavyas authored Aug 24, 2020
1 parent 59fbb76 commit d85194e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
18 changes: 9 additions & 9 deletions chainbridge/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ decl_module! {
/// # <weight>
/// - O(1) lookup and insert
/// # </weight>
#[weight = 500_000]
#[weight = 195_000_000]
pub fn set_threshold(origin, threshold: u32) -> DispatchResult {
Self::ensure_admin(origin)?;
Self::set_relayer_threshold(threshold)
Expand All @@ -231,7 +231,7 @@ decl_module! {
/// # <weight>
/// - O(1) write
/// # </weight>
#[weight = 500_000]
#[weight = 195_000_000]
pub fn set_resource(origin, id: ResourceId, method: Vec<u8>) -> DispatchResult {
Self::ensure_admin(origin)?;
Self::register_resource(id, method)
Expand All @@ -245,7 +245,7 @@ decl_module! {
/// # <weight>
/// - O(1) removal
/// # </weight>
#[weight = 500_000]
#[weight = 195_000_000]
pub fn remove_resource(origin, id: ResourceId) -> DispatchResult {
Self::ensure_admin(origin)?;
Self::unregister_resource(id)
Expand All @@ -256,7 +256,7 @@ decl_module! {
/// # <weight>
/// - O(1) lookup and insert
/// # </weight>
#[weight = 500_000]
#[weight = 195_000_000]
pub fn whitelist_chain(origin, id: ChainId) -> DispatchResult {
Self::ensure_admin(origin)?;
Self::whitelist(id)
Expand All @@ -267,7 +267,7 @@ decl_module! {
/// # <weight>
/// - O(1) lookup and insert
/// # </weight>
#[weight = 500_000]
#[weight = 195_000_000]
pub fn add_relayer(origin, v: T::AccountId) -> DispatchResult {
Self::ensure_admin(origin)?;
Self::register_relayer(v)
Expand All @@ -278,7 +278,7 @@ decl_module! {
/// # <weight>
/// - O(1) lookup and removal
/// # </weight>
#[weight = 500_000]
#[weight = 195_000_000]
pub fn remove_relayer(origin, v: T::AccountId) -> DispatchResult {
Self::ensure_admin(origin)?;
Self::unregister_relayer(v)
Expand All @@ -293,7 +293,7 @@ decl_module! {
/// - weight of proposed call, regardless of whether execution is performed
/// # </weight>
#[weight = FunctionOf(
|args: (&DepositNonce, &ChainId, &ResourceId, &Box<<T as Trait>::Proposal>)| args.3.get_dispatch_info().weight + 500_000,
|args: (&DepositNonce, &ChainId, &ResourceId, &Box<<T as Trait>::Proposal>)| args.3.get_dispatch_info().weight + 195_000_000,
|args: (&DepositNonce, &ChainId, &ResourceId, &Box<<T as Trait>::Proposal>)| args.3.get_dispatch_info().class,
Pays::Yes
)]
Expand All @@ -311,7 +311,7 @@ decl_module! {
/// # <weight>
/// - Fixed, since execution of proposal should not be included
/// # </weight>
#[weight = 500_000]
#[weight = 195_000_000]
pub fn reject_proposal(origin, nonce: DepositNonce, src_id: ChainId, r_id: ResourceId, call: Box<<T as Trait>::Proposal>) -> DispatchResult {
let who = ensure_signed(origin)?;
ensure!(Self::is_relayer(&who), Error::<T>::MustBeRelayer);
Expand All @@ -330,7 +330,7 @@ decl_module! {
/// - weight of proposed call, regardless of whether execution is performed
/// # </weight>
#[weight = FunctionOf(
|args: (&DepositNonce, &ChainId, &Box<<T as Trait>::Proposal>)| args.2.get_dispatch_info().weight + 500_000,
|args: (&DepositNonce, &ChainId, &Box<<T as Trait>::Proposal>)| args.2.get_dispatch_info().weight + 195_000_000,
|args: (&DepositNonce, &ChainId, &Box<<T as Trait>::Proposal>)| args.2.get_dispatch_info().class,
Pays::Yes
)]
Expand Down
6 changes: 3 additions & 3 deletions example-erc721/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ decl_module! {
fn deposit_event() = default;

/// Creates a new token with the given token ID and metadata, and gives ownership to owner
#[weight = 1_000_000]
#[weight = 195_000_000]
pub fn mint(origin, owner: T::AccountId, id: TokenId, metadata: Vec<u8>) -> DispatchResult {
ensure_root(origin)?;

Expand All @@ -82,7 +82,7 @@ decl_module! {
}

/// Changes ownership of a token sender owns
#[weight = 1_000_000]
#[weight = 195_000_000]
pub fn transfer(origin, to: T::AccountId, id: TokenId) -> DispatchResult {
let sender = ensure_signed(origin)?;

Expand All @@ -92,7 +92,7 @@ decl_module! {
}

/// Remove token from the system
#[weight = 1_000_000]
#[weight = 195_000_000]
pub fn burn(origin, id: TokenId) -> DispatchResult {
ensure_root(origin)?;

Expand Down
12 changes: 6 additions & 6 deletions example-pallet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ decl_module! {
//

/// Transfers an arbitrary hash to a (whitelisted) destination chain.
#[weight = 1_000_000]
#[weight = 195_000_000]
pub fn transfer_hash(origin, hash: T::Hash, dest_id: bridge::ChainId) -> DispatchResult {
ensure_signed(origin)?;

Expand All @@ -69,7 +69,7 @@ decl_module! {
}

/// Transfers some amount of the native token to some recipient on a (whitelisted) destination chain.
#[weight = 1_000_000]
#[weight = 195_000_000]
pub fn transfer_native(origin, amount: BalanceOf<T>, recipient: Vec<u8>, dest_id: bridge::ChainId) -> DispatchResult {
let source = ensure_signed(origin)?;
ensure!(<bridge::Module<T>>::chain_whitelisted(dest_id), Error::<T>::InvalidTransfer);
Expand All @@ -81,7 +81,7 @@ decl_module! {
}

/// Transfer a non-fungible token (erc721) to a (whitelisted) destination chain.
#[weight = 1_000_000]
#[weight = 195_000_000]
pub fn transfer_erc721(origin, recipient: Vec<u8>, token_id: U256, dest_id: bridge::ChainId) -> DispatchResult {
let source = ensure_signed(origin)?;
ensure!(<bridge::Module<T>>::chain_whitelisted(dest_id), Error::<T>::InvalidTransfer);
Expand All @@ -102,23 +102,23 @@ decl_module! {
//

/// Executes a simple currency transfer using the bridge account as the source
#[weight = 1_000_000]
#[weight = 195_000_000]
pub fn transfer(origin, to: T::AccountId, amount: BalanceOf<T>) -> DispatchResult {
let source = T::BridgeOrigin::ensure_origin(origin)?;
<T as Trait>::Currency::transfer(&source, &to, amount.into(), AllowDeath)?;
Ok(())
}

/// This can be called by the bridge to demonstrate an arbitrary call from a proposal.
#[weight = 1_000_000]
#[weight = 195_000_000]
pub fn remark(origin, hash: T::Hash) -> DispatchResult {
T::BridgeOrigin::ensure_origin(origin)?;
Self::deposit_event(RawEvent::Remark(hash));
Ok(())
}

/// Allows the bridge to issue new erc721 tokens
#[weight = 1_000_000]
#[weight = 195_000_000]
pub fn mint_erc721(origin, recipient: T::AccountId, id: U256, metadata: Vec<u8>) -> DispatchResult {
T::BridgeOrigin::ensure_origin(origin)?;
<erc721::Module<T>>::mint_token(recipient, id, metadata)?;
Expand Down

0 comments on commit d85194e

Please sign in to comment.