From d85194e5bfc07d2db59f08e022d12a81c810ac1b Mon Sep 17 00:00:00 2001 From: Vedhavyas Singareddi Date: Mon, 24 Aug 2020 18:16:56 +0530 Subject: [PATCH] update weights (#63) --- chainbridge/src/lib.rs | 18 +++++++++--------- example-erc721/src/lib.rs | 6 +++--- example-pallet/src/lib.rs | 12 ++++++------ 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/chainbridge/src/lib.rs b/chainbridge/src/lib.rs index 27e8189..10d13a2 100644 --- a/chainbridge/src/lib.rs +++ b/chainbridge/src/lib.rs @@ -220,7 +220,7 @@ decl_module! { /// # /// - O(1) lookup and insert /// # - #[weight = 500_000] + #[weight = 195_000_000] pub fn set_threshold(origin, threshold: u32) -> DispatchResult { Self::ensure_admin(origin)?; Self::set_relayer_threshold(threshold) @@ -231,7 +231,7 @@ decl_module! { /// # /// - O(1) write /// # - #[weight = 500_000] + #[weight = 195_000_000] pub fn set_resource(origin, id: ResourceId, method: Vec) -> DispatchResult { Self::ensure_admin(origin)?; Self::register_resource(id, method) @@ -245,7 +245,7 @@ decl_module! { /// # /// - O(1) removal /// # - #[weight = 500_000] + #[weight = 195_000_000] pub fn remove_resource(origin, id: ResourceId) -> DispatchResult { Self::ensure_admin(origin)?; Self::unregister_resource(id) @@ -256,7 +256,7 @@ decl_module! { /// # /// - O(1) lookup and insert /// # - #[weight = 500_000] + #[weight = 195_000_000] pub fn whitelist_chain(origin, id: ChainId) -> DispatchResult { Self::ensure_admin(origin)?; Self::whitelist(id) @@ -267,7 +267,7 @@ decl_module! { /// # /// - O(1) lookup and insert /// # - #[weight = 500_000] + #[weight = 195_000_000] pub fn add_relayer(origin, v: T::AccountId) -> DispatchResult { Self::ensure_admin(origin)?; Self::register_relayer(v) @@ -278,7 +278,7 @@ decl_module! { /// # /// - O(1) lookup and removal /// # - #[weight = 500_000] + #[weight = 195_000_000] pub fn remove_relayer(origin, v: T::AccountId) -> DispatchResult { Self::ensure_admin(origin)?; Self::unregister_relayer(v) @@ -293,7 +293,7 @@ decl_module! { /// - weight of proposed call, regardless of whether execution is performed /// # #[weight = FunctionOf( - |args: (&DepositNonce, &ChainId, &ResourceId, &Box<::Proposal>)| args.3.get_dispatch_info().weight + 500_000, + |args: (&DepositNonce, &ChainId, &ResourceId, &Box<::Proposal>)| args.3.get_dispatch_info().weight + 195_000_000, |args: (&DepositNonce, &ChainId, &ResourceId, &Box<::Proposal>)| args.3.get_dispatch_info().class, Pays::Yes )] @@ -311,7 +311,7 @@ decl_module! { /// # /// - Fixed, since execution of proposal should not be included /// # - #[weight = 500_000] + #[weight = 195_000_000] pub fn reject_proposal(origin, nonce: DepositNonce, src_id: ChainId, r_id: ResourceId, call: Box<::Proposal>) -> DispatchResult { let who = ensure_signed(origin)?; ensure!(Self::is_relayer(&who), Error::::MustBeRelayer); @@ -330,7 +330,7 @@ decl_module! { /// - weight of proposed call, regardless of whether execution is performed /// # #[weight = FunctionOf( - |args: (&DepositNonce, &ChainId, &Box<::Proposal>)| args.2.get_dispatch_info().weight + 500_000, + |args: (&DepositNonce, &ChainId, &Box<::Proposal>)| args.2.get_dispatch_info().weight + 195_000_000, |args: (&DepositNonce, &ChainId, &Box<::Proposal>)| args.2.get_dispatch_info().class, Pays::Yes )] diff --git a/example-erc721/src/lib.rs b/example-erc721/src/lib.rs index c3db7e4..3bda19b 100644 --- a/example-erc721/src/lib.rs +++ b/example-erc721/src/lib.rs @@ -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) -> DispatchResult { ensure_root(origin)?; @@ -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)?; @@ -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)?; diff --git a/example-pallet/src/lib.rs b/example-pallet/src/lib.rs index f08c420..286509b 100644 --- a/example-pallet/src/lib.rs +++ b/example-pallet/src/lib.rs @@ -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)?; @@ -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, recipient: Vec, dest_id: bridge::ChainId) -> DispatchResult { let source = ensure_signed(origin)?; ensure!(>::chain_whitelisted(dest_id), Error::::InvalidTransfer); @@ -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, token_id: U256, dest_id: bridge::ChainId) -> DispatchResult { let source = ensure_signed(origin)?; ensure!(>::chain_whitelisted(dest_id), Error::::InvalidTransfer); @@ -102,7 +102,7 @@ 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) -> DispatchResult { let source = T::BridgeOrigin::ensure_origin(origin)?; ::Currency::transfer(&source, &to, amount.into(), AllowDeath)?; @@ -110,7 +110,7 @@ decl_module! { } /// 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)); @@ -118,7 +118,7 @@ decl_module! { } /// 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) -> DispatchResult { T::BridgeOrigin::ensure_origin(origin)?; >::mint_token(recipient, id, metadata)?;