From 98febe7588f821f23e964a2ea65b77607e6ff75e Mon Sep 17 00:00:00 2001 From: Trubnikov Sergey Date: Wed, 24 Aug 2022 15:10:16 +0000 Subject: [PATCH] fix: Change hashier for `Sponsoring` storage --- --- a/pallets/evm-contract-helpers/src/eth.rs +++ b/pallets/evm-contract-helpers/src/eth.rs @@ -295,24 +295,24 @@ for HelpersContractSponsoring { fn get_sponsor(who: &T::CrossAccountId, call: &(H160, Vec)) -> Option { - let (contract, _) = call; - let mode = >::sponsoring_mode(*contract); + let (contract_address, _) = call; + let mode = >::sponsoring_mode(*contract_address); if mode == SponsoringModeT::Disabled { return None; } - let sponsor = match >::get_sponsor(*contract) { + let sponsor = match >::get_sponsor(*contract_address) { Some(sponsor) => sponsor, None => return None, }; - if mode == SponsoringModeT::Allowlisted && !>::allowed(*contract, *who.as_eth()) { + if mode == SponsoringModeT::Allowlisted && !>::allowed(*contract_address, *who.as_eth()) { return None; } let block_number = >::block_number() as T::BlockNumber; - if let Some(last_tx_block) = >::get(contract, who.as_eth()) { - let limit = >::get(contract); + if let Some(last_tx_block) = >::get(contract_address, who.as_eth()) { + let limit = >::get(contract_address); let timeout = last_tx_block + limit; if block_number < timeout { @@ -320,7 +320,7 @@ } } - >::insert(contract, who.as_eth(), block_number); + >::insert(contract_address, who.as_eth(), block_number); Some(sponsor) } --- a/pallets/evm-contract-helpers/src/lib.rs +++ b/pallets/evm-contract-helpers/src/lib.rs @@ -29,7 +29,6 @@ use pallet_evm_coder_substrate::DispatchResult; use sp_core::H160; use pallet_evm::account::CrossAccountId; - use frame_system::pallet_prelude::BlockNumberFor; use up_data_structs::SponsorshipState; #[pallet::config] @@ -66,9 +65,13 @@ pub(super) type SelfSponsoring = StorageMap; + /// Store for contract sponsorship state. + /// + /// * **Key** - contract address. + /// * **Value** - sponsorship state. #[pallet::storage] pub(super) type Sponsoring = StorageMap< - Hasher = Twox128, + Hasher = Twox64Concat, Key = H160, Value = SponsorshipState, QueryKind = ValueQuery, -- gitstuff