git.delta.rocks / unique-network / refs/commits / bfcf3ca7e01c

difftreelog

chore replace u128 with CallContext

Grigoriy Simonov2022-09-13parent: #a94c6b6.patch.diff
in: master

19 files changed

modifiedCargo.lockdiffbeforeafterboth
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -5794,6 +5794,7 @@
  "pallet-common",
  "pallet-evm 6.0.0-dev (git+https://github.com/uniquenetwork/frontier?rev=89a37c5a489f426cc7a42d7b94019974093a052d)",
  "pallet-evm-coder-substrate",
+ "pallet-evm-transaction-payment",
  "parity-scale-codec 3.1.5",
  "scale-info",
  "sp-core",
@@ -6409,7 +6410,7 @@
 [[package]]
 name = "pallet-template-transaction-payment"
 version = "3.0.0"
-source = "git+https://github.com/uniquenetwork/pallet-sponsoring?rev=a8ec4bf8d5ded662d96da6d8fb211b0bbf6617b3#a8ec4bf8d5ded662d96da6d8fb211b0bbf6617b3"
+source = "git+https://github.com/uniquenetwork/pallet-sponsoring?rev=9ee7d6e57e03a2575cbab79431774b56f170018e#9ee7d6e57e03a2575cbab79431774b56f170018e"
 dependencies = [
  "frame-benchmarking",
  "frame-support",
@@ -12577,7 +12578,7 @@
 [[package]]
 name = "up-sponsorship"
 version = "0.1.0"
-source = "git+https://github.com/uniquenetwork/pallet-sponsoring?rev=a8ec4bf8d5ded662d96da6d8fb211b0bbf6617b3#a8ec4bf8d5ded662d96da6d8fb211b0bbf6617b3"
+source = "git+https://github.com/uniquenetwork/pallet-sponsoring?rev=9ee7d6e57e03a2575cbab79431774b56f170018e#9ee7d6e57e03a2575cbab79431774b56f170018e"
 dependencies = [
  "impl-trait-for-tuples",
 ]
modifiedpallets/evm-contract-helpers/Cargo.tomldiffbeforeafterboth
--- a/pallets/evm-contract-helpers/Cargo.toml
+++ b/pallets/evm-contract-helpers/Cargo.toml
@@ -21,12 +21,13 @@
 # Unique
 pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", rev = "89a37c5a489f426cc7a42d7b94019974093a052d" }
 fp-evm-mapping = { default-features = false, git = "https://github.com/uniquenetwork/frontier", rev = "89a37c5a489f426cc7a42d7b94019974093a052d" }
-up-sponsorship = { version = "0.1.0", default-features = false, git = "https://github.com/uniquenetwork/pallet-sponsoring", rev="a8ec4bf8d5ded662d96da6d8fb211b0bbf6617b3" }
+up-sponsorship = { version = "0.1.0", default-features = false, git = "https://github.com/uniquenetwork/pallet-sponsoring", rev="9ee7d6e57e03a2575cbab79431774b56f170018e" }
 
 # Locals
 evm-coder = { default-features = false, path = '../../crates/evm-coder' }
 pallet-common = { default-features = false, path = '../../pallets/common' }
 pallet-evm-coder-substrate = { default-features = false, path = '../../pallets/evm-coder-substrate' }
+pallet-evm-transaction-payment = {  default-features = false, path = '../../pallets/evm-transaction-payment' }
 up-data-structs = { default-features = false, path = '../../primitives/data-structs', features = [
     'serde1',
 ] }
modifiedpallets/evm-contract-helpers/src/eth.rsdiffbeforeafterboth
before · pallets/evm-contract-helpers/src/eth.rs
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617//! Implementation of magic contract1819use core::marker::PhantomData;20use evm_coder::{21	abi::AbiWriter, execution::Result, generate_stubgen, solidity_interface, types::*, ToLog,22};23use pallet_evm_coder_substrate::{SubstrateRecorder, WithRecorder, dispatch_to_evm};24use pallet_evm::{25	ExitRevert, OnCreate, OnMethodCall, PrecompileResult, PrecompileFailure, PrecompileHandle,26	account::CrossAccountId,27};28use sp_core::{H160, U256};29use up_data_structs::SponsorshipState;30use crate::{31	AllowlistEnabled, Config, Owner, Pallet, SponsorBasket, SponsoringFeeLimit,32	SponsoringRateLimit, SponsoringModeT, Sponsoring,33};34use frame_support::traits::Get;35use up_sponsorship::SponsorshipHandler;36use sp_std::vec::Vec;3738/// Pallet events.39#[derive(ToLog)]40pub enum ContractHelpersEvents {41	/// Contract sponsor was set.42	ContractSponsorSet {43		/// Contract address of the affected collection.44		#[indexed]45		contract_address: address,46		/// New sponsor address.47		sponsor: address,48	},4950	/// New sponsor was confirm.51	ContractSponsorshipConfirmed {52		/// Contract address of the affected collection.53		#[indexed]54		contract_address: address,55		/// New sponsor address.56		sponsor: address,57	},5859	/// Collection sponsor was removed.60	ContractSponsorRemoved {61		/// Contract address of the affected collection.62		#[indexed]63		contract_address: address,64	},65}6667/// See [`ContractHelpersCall`]68pub struct ContractHelpers<T: Config>(SubstrateRecorder<T>);69impl<T: Config> WithRecorder<T> for ContractHelpers<T> {70	fn recorder(&self) -> &SubstrateRecorder<T> {71		&self.072	}7374	fn into_recorder(self) -> SubstrateRecorder<T> {75		self.076	}77}7879/// @title Magic contract, which allows users to reconfigure other contracts80#[solidity_interface(name = ContractHelpers, events(ContractHelpersEvents))]81impl<T: Config> ContractHelpers<T>82where83	T::AccountId: AsRef<[u8; 32]>,84{85	/// Get user, which deployed specified contract86	/// @dev May return zero address in case if contract is deployed87	///  using uniquenetwork evm-migration pallet, or using other terms not88	///  intended by pallet-evm89	/// @dev Returns zero address if contract does not exists90	/// @param contractAddress Contract to get owner of91	/// @return address Owner of contract92	fn contract_owner(&self, contract_address: address) -> Result<address> {93		Ok(<Owner<T>>::get(contract_address))94	}9596	/// Set sponsor.97	/// @param contractAddress Contract for which a sponsor is being established.98	/// @param sponsor User address who set as pending sponsor.99	fn set_sponsor(100		&mut self,101		caller: caller,102		contract_address: address,103		sponsor: address,104	) -> Result<void> {105		self.recorder().consume_sload()?;106		self.recorder().consume_sstore()?;107108		Pallet::<T>::set_sponsor(109			&T::CrossAccountId::from_eth(caller),110			contract_address,111			&T::CrossAccountId::from_eth(sponsor),112		)113		.map_err(dispatch_to_evm::<T>)?;114115		Ok(())116	}117118	/// Set contract as self sponsored.119	///120	/// @param contractAddress Contract for which a self sponsoring is being enabled.121	fn self_sponsored_enable(&mut self, caller: caller, contract_address: address) -> Result<void> {122		self.recorder().consume_sload()?;123		self.recorder().consume_sstore()?;124125		let caller = T::CrossAccountId::from_eth(caller);126127		Pallet::<T>::ensure_owner(contract_address, *caller.as_eth())128			.map_err(dispatch_to_evm::<T>)?;129130		Pallet::<T>::force_set_sponsor(131			contract_address,132			&T::CrossAccountId::from_eth(contract_address),133		)134		.map_err(dispatch_to_evm::<T>)?;135136		Ok(())137	}138139	/// Remove sponsor.140	///141	/// @param contractAddress Contract for which a sponsorship is being removed.142	fn remove_sponsor(&mut self, caller: caller, contract_address: address) -> Result<void> {143		self.recorder().consume_sload()?;144		self.recorder().consume_sstore()?;145146		Pallet::<T>::remove_sponsor(&T::CrossAccountId::from_eth(caller), contract_address)147			.map_err(dispatch_to_evm::<T>)?;148149		Ok(())150	}151152	/// Confirm sponsorship.153	///154	/// @dev Caller must be same that set via [`setSponsor`].155	///156	/// @param contractAddress Сontract for which need to confirm sponsorship.157	fn confirm_sponsorship(&mut self, caller: caller, contract_address: address) -> Result<void> {158		self.recorder().consume_sload()?;159		self.recorder().consume_sstore()?;160161		Pallet::<T>::confirm_sponsorship(&T::CrossAccountId::from_eth(caller), contract_address)162			.map_err(dispatch_to_evm::<T>)?;163164		Ok(())165	}166167	/// Get current sponsor.168	///169	/// @param contractAddress The contract for which a sponsor is requested.170	/// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.171	fn get_sponsor(&self, contract_address: address) -> Result<(address, uint256)> {172		let sponsor =173			Pallet::<T>::get_sponsor(contract_address).ok_or("Contract has no sponsor")?;174		let result: (address, uint256) = if sponsor.is_canonical_substrate() {175			let sponsor = pallet_common::eth::convert_cross_account_to_uint256::<T>(&sponsor);176			(Default::default(), sponsor)177		} else {178			let sponsor = *sponsor.as_eth();179			(sponsor, Default::default())180		};181		Ok(result)182	}183184	/// Check tat contract has confirmed sponsor.185	///186	/// @param contractAddress The contract for which the presence of a confirmed sponsor is checked.187	/// @return **true** if contract has confirmed sponsor.188	fn has_sponsor(&self, contract_address: address) -> Result<bool> {189		Ok(Pallet::<T>::get_sponsor(contract_address).is_some())190	}191192	/// Check tat contract has pending sponsor.193	///194	/// @param contractAddress The contract for which the presence of a pending sponsor is checked.195	/// @return **true** if contract has pending sponsor.196	fn has_pending_sponsor(&self, contract_address: address) -> Result<bool> {197		Ok(match Sponsoring::<T>::get(contract_address) {198			SponsorshipState::Disabled | SponsorshipState::Confirmed(_) => false,199			SponsorshipState::Unconfirmed(_) => true,200		})201	}202203	fn sponsoring_enabled(&self, contract_address: address) -> Result<bool> {204		Ok(<Pallet<T>>::sponsoring_mode(contract_address) != SponsoringModeT::Disabled)205	}206207	fn set_sponsoring_mode(208		&mut self,209		caller: caller,210		contract_address: address,211		// TODO: implement support for enums in evm-coder212		mode: uint8,213	) -> Result<void> {214		self.recorder().consume_sload()?;215		self.recorder().consume_sstore()?;216217		<Pallet<T>>::ensure_owner(contract_address, caller).map_err(dispatch_to_evm::<T>)?;218		let mode = SponsoringModeT::from_eth(mode).ok_or("unknown mode")?;219		<Pallet<T>>::set_sponsoring_mode(contract_address, mode);220221		Ok(())222	}223224	/// Get current contract sponsoring rate limit225	/// @param contractAddress Contract to get sponsoring mode of226	/// @return uint32 Amount of blocks between two sponsored transactions227	fn get_sponsoring_rate_limit(&self, contract_address: address) -> Result<uint32> {228		Ok(<SponsoringRateLimit<T>>::get(contract_address)229			.try_into()230			.map_err(|_| "rate limit > u32::MAX")?)231	}232233	/// Set contract sponsoring rate limit234	/// @dev Sponsoring rate limit - is a minimum amount of blocks that should235	///  pass between two sponsored transactions236	/// @param contractAddress Contract to change sponsoring rate limit of237	/// @param rateLimit Target rate limit238	/// @dev Only contract owner can change this setting239	fn set_sponsoring_rate_limit(240		&mut self,241		caller: caller,242		contract_address: address,243		rate_limit: uint32,244	) -> Result<void> {245		self.recorder().consume_sload()?;246		self.recorder().consume_sstore()?;247248		<Pallet<T>>::ensure_owner(contract_address, caller).map_err(dispatch_to_evm::<T>)?;249		<Pallet<T>>::set_sponsoring_rate_limit(contract_address, rate_limit.into());250		Ok(())251	}252253	fn set_sponsoring_fee_limit(254		&mut self,255		caller: caller,256		contract_address: address,257		fee_limit: uint128,258	) -> Result<void> {259		<Pallet<T>>::ensure_owner(contract_address, caller).map_err(dispatch_to_evm::<T>)?;260		<Pallet<T>>::set_sponsoring_fee_limit(contract_address, fee_limit.into());261		Ok(())262	}263264	fn get_sponsoring_fee_limit(&self, contract_address: address) -> Result<uint128> {265		Ok(<SponsoringFeeLimit<T>>::get(contract_address)266			.try_into()267			.map_err(|_| "fee limit > u128::MAX")?)268	}269270	/// Is specified user present in contract allow list271	/// @dev Contract owner always implicitly included272	/// @param contractAddress Contract to check allowlist of273	/// @param user User to check274	/// @return bool Is specified users exists in contract allowlist275	fn allowed(&self, contract_address: address, user: address) -> Result<bool> {276		self.0.consume_sload()?;277		Ok(<Pallet<T>>::allowed(contract_address, user))278	}279280	/// Toggle user presence in contract allowlist281	/// @param contractAddress Contract to change allowlist of282	/// @param user Which user presence should be toggled283	/// @param isAllowed `true` if user should be allowed to be sponsored284	///  or call this contract, `false` otherwise285	/// @dev Only contract owner can change this setting286	fn toggle_allowed(287		&mut self,288		caller: caller,289		contract_address: address,290		user: address,291		is_allowed: bool,292	) -> Result<void> {293		self.recorder().consume_sload()?;294		self.recorder().consume_sstore()?;295296		<Pallet<T>>::ensure_owner(contract_address, caller).map_err(dispatch_to_evm::<T>)?;297		<Pallet<T>>::toggle_allowed(contract_address, user, is_allowed);298299		Ok(())300	}301302	/// Is this contract has allowlist access enabled303	/// @dev Allowlist always can have users, and it is used for two purposes:304	///  in case of allowlist sponsoring mode, users will be sponsored if they exist in allowlist305	///  in case of allowlist access enabled, only users from allowlist may call this contract306	/// @param contractAddress Contract to get allowlist access of307	/// @return bool Is specified contract has allowlist access enabled308	fn allowlist_enabled(&self, contract_address: address) -> Result<bool> {309		Ok(<AllowlistEnabled<T>>::get(contract_address))310	}311312	/// Toggle contract allowlist access313	/// @param contractAddress Contract to change allowlist access of314	/// @param enabled Should allowlist access to be enabled?315	fn toggle_allowlist(316		&mut self,317		caller: caller,318		contract_address: address,319		enabled: bool,320	) -> Result<void> {321		self.recorder().consume_sload()?;322		self.recorder().consume_sstore()?;323324		<Pallet<T>>::ensure_owner(contract_address, caller).map_err(dispatch_to_evm::<T>)?;325		<Pallet<T>>::toggle_allowlist(contract_address, enabled);326		Ok(())327	}328}329330/// Implements [`OnMethodCall`], which delegates call to [`ContractHelpers`]331pub struct HelpersOnMethodCall<T: Config>(PhantomData<*const T>);332impl<T: Config> OnMethodCall<T> for HelpersOnMethodCall<T>333where334	T::AccountId: AsRef<[u8; 32]>,335{336	fn is_reserved(contract: &sp_core::H160) -> bool {337		contract == &T::ContractAddress::get()338	}339340	fn is_used(contract: &sp_core::H160) -> bool {341		contract == &T::ContractAddress::get()342	}343344	fn call(handle: &mut impl PrecompileHandle) -> Option<PrecompileResult> {345		// TODO: Extract to another OnMethodCall handler346		if <AllowlistEnabled<T>>::get(handle.code_address())347			&& !<Pallet<T>>::allowed(handle.code_address(), handle.context().caller)348		{349			return Some(Err(PrecompileFailure::Revert {350				exit_status: ExitRevert::Reverted,351				output: {352					let mut writer = AbiWriter::new_call(evm_coder::fn_selector!(Error(string)));353					writer.string("Target contract is allowlisted");354					writer.finish()355				},356			}));357		}358359		if handle.code_address() != T::ContractAddress::get() {360			return None;361		}362363		let helpers = ContractHelpers::<T>(SubstrateRecorder::<T>::new(handle.remaining_gas()));364		pallet_evm_coder_substrate::call(handle, helpers)365	}366367	fn get_code(contract: &sp_core::H160) -> Option<Vec<u8>> {368		(contract == &T::ContractAddress::get())369			.then(|| include_bytes!("./stubs/ContractHelpers.raw").to_vec())370	}371}372373/// Hooks into contract creation, storing owner of newly deployed contract374pub struct HelpersOnCreate<T: Config>(PhantomData<*const T>);375impl<T: Config> OnCreate<T> for HelpersOnCreate<T> {376	fn on_create(owner: H160, contract: H160) {377		<Owner<T>>::insert(contract, owner);378	}379}380381/// Bridge to pallet-sponsoring382pub struct HelpersContractSponsoring<T: Config>(PhantomData<*const T>);383impl<T: Config> SponsorshipHandler<T::CrossAccountId, (H160, Vec<u8>), u128>384	for HelpersContractSponsoring<T>385{386	fn get_sponsor(387		who: &T::CrossAccountId,388		call: &(H160, Vec<u8>),389		fee_limit: &u128,390	) -> Option<T::CrossAccountId> {391		let (contract_address, _) = call;392		let mode = <Pallet<T>>::sponsoring_mode(*contract_address);393		if mode == SponsoringModeT::Disabled {394			return None;395		}396397		let sponsor = match <Pallet<T>>::get_sponsor(*contract_address) {398			Some(sponsor) => sponsor,399			None => return None,400		};401402		if mode == SponsoringModeT::Allowlisted403			&& !<Pallet<T>>::allowed(*contract_address, *who.as_eth())404		{405			return None;406		}407		let block_number = <frame_system::Pallet<T>>::block_number() as T::BlockNumber;408409		if let Some(last_tx_block) = <SponsorBasket<T>>::get(contract_address, who.as_eth()) {410			let limit = <SponsoringRateLimit<T>>::get(contract_address);411412			let timeout = last_tx_block + limit;413			if block_number < timeout {414				return None;415			}416		}417418		let sponsored_fee_limit = <SponsoringFeeLimit<T>>::get(contract_address);419420		if *fee_limit > sponsored_fee_limit {421			return None;422		}423424		<SponsorBasket<T>>::insert(contract_address, who.as_eth(), block_number);425426		Some(sponsor)427	}428}429430generate_stubgen!(contract_helpers_impl, ContractHelpersCall<()>, true);431generate_stubgen!(contract_helpers_iface, ContractHelpersCall<()>, false);
after · pallets/evm-contract-helpers/src/eth.rs
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617//! Implementation of magic contract1819use core::marker::PhantomData;20use evm_coder::{21	abi::AbiWriter, execution::Result, generate_stubgen, solidity_interface, types::*, ToLog,22};23use pallet_evm::{24	ExitRevert, OnCreate, OnMethodCall, PrecompileResult, PrecompileFailure, PrecompileHandle,25	account::CrossAccountId,26};27use pallet_evm_coder_substrate::{SubstrateRecorder, WithRecorder, dispatch_to_evm};28use pallet_evm_transaction_payment::CallContext;29use sp_core::H160;30use up_data_structs::SponsorshipState;31use crate::{32	AllowlistEnabled, Config, Owner, Pallet, SponsorBasket, SponsoringFeeLimit,33	SponsoringRateLimit, SponsoringModeT, Sponsoring,34};35use frame_support::traits::Get;36use up_sponsorship::SponsorshipHandler;37use sp_std::vec::Vec;3839/// Pallet events.40#[derive(ToLog)]41pub enum ContractHelpersEvents {42	/// Contract sponsor was set.43	ContractSponsorSet {44		/// Contract address of the affected collection.45		#[indexed]46		contract_address: address,47		/// New sponsor address.48		sponsor: address,49	},5051	/// New sponsor was confirm.52	ContractSponsorshipConfirmed {53		/// Contract address of the affected collection.54		#[indexed]55		contract_address: address,56		/// New sponsor address.57		sponsor: address,58	},5960	/// Collection sponsor was removed.61	ContractSponsorRemoved {62		/// Contract address of the affected collection.63		#[indexed]64		contract_address: address,65	},66}6768/// See [`ContractHelpersCall`]69pub struct ContractHelpers<T: Config>(SubstrateRecorder<T>);70impl<T: Config> WithRecorder<T> for ContractHelpers<T> {71	fn recorder(&self) -> &SubstrateRecorder<T> {72		&self.073	}7475	fn into_recorder(self) -> SubstrateRecorder<T> {76		self.077	}78}7980/// @title Magic contract, which allows users to reconfigure other contracts81#[solidity_interface(name = ContractHelpers, events(ContractHelpersEvents))]82impl<T: Config> ContractHelpers<T>83where84	T::AccountId: AsRef<[u8; 32]>,85{86	/// Get user, which deployed specified contract87	/// @dev May return zero address in case if contract is deployed88	///  using uniquenetwork evm-migration pallet, or using other terms not89	///  intended by pallet-evm90	/// @dev Returns zero address if contract does not exists91	/// @param contractAddress Contract to get owner of92	/// @return address Owner of contract93	fn contract_owner(&self, contract_address: address) -> Result<address> {94		Ok(<Owner<T>>::get(contract_address))95	}9697	/// Set sponsor.98	/// @param contractAddress Contract for which a sponsor is being established.99	/// @param sponsor User address who set as pending sponsor.100	fn set_sponsor(101		&mut self,102		caller: caller,103		contract_address: address,104		sponsor: address,105	) -> Result<void> {106		self.recorder().consume_sload()?;107		self.recorder().consume_sstore()?;108109		Pallet::<T>::set_sponsor(110			&T::CrossAccountId::from_eth(caller),111			contract_address,112			&T::CrossAccountId::from_eth(sponsor),113		)114		.map_err(dispatch_to_evm::<T>)?;115116		Ok(())117	}118119	/// Set contract as self sponsored.120	///121	/// @param contractAddress Contract for which a self sponsoring is being enabled.122	fn self_sponsored_enable(&mut self, caller: caller, contract_address: address) -> Result<void> {123		self.recorder().consume_sload()?;124		self.recorder().consume_sstore()?;125126		let caller = T::CrossAccountId::from_eth(caller);127128		Pallet::<T>::ensure_owner(contract_address, *caller.as_eth())129			.map_err(dispatch_to_evm::<T>)?;130131		Pallet::<T>::force_set_sponsor(132			contract_address,133			&T::CrossAccountId::from_eth(contract_address),134		)135		.map_err(dispatch_to_evm::<T>)?;136137		Ok(())138	}139140	/// Remove sponsor.141	///142	/// @param contractAddress Contract for which a sponsorship is being removed.143	fn remove_sponsor(&mut self, caller: caller, contract_address: address) -> Result<void> {144		self.recorder().consume_sload()?;145		self.recorder().consume_sstore()?;146147		Pallet::<T>::remove_sponsor(&T::CrossAccountId::from_eth(caller), contract_address)148			.map_err(dispatch_to_evm::<T>)?;149150		Ok(())151	}152153	/// Confirm sponsorship.154	///155	/// @dev Caller must be same that set via [`setSponsor`].156	///157	/// @param contractAddress Сontract for which need to confirm sponsorship.158	fn confirm_sponsorship(&mut self, caller: caller, contract_address: address) -> Result<void> {159		self.recorder().consume_sload()?;160		self.recorder().consume_sstore()?;161162		Pallet::<T>::confirm_sponsorship(&T::CrossAccountId::from_eth(caller), contract_address)163			.map_err(dispatch_to_evm::<T>)?;164165		Ok(())166	}167168	/// Get current sponsor.169	///170	/// @param contractAddress The contract for which a sponsor is requested.171	/// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.172	fn get_sponsor(&self, contract_address: address) -> Result<(address, uint256)> {173		let sponsor =174			Pallet::<T>::get_sponsor(contract_address).ok_or("Contract has no sponsor")?;175		let result: (address, uint256) = if sponsor.is_canonical_substrate() {176			let sponsor = pallet_common::eth::convert_cross_account_to_uint256::<T>(&sponsor);177			(Default::default(), sponsor)178		} else {179			let sponsor = *sponsor.as_eth();180			(sponsor, Default::default())181		};182		Ok(result)183	}184185	/// Check tat contract has confirmed sponsor.186	///187	/// @param contractAddress The contract for which the presence of a confirmed sponsor is checked.188	/// @return **true** if contract has confirmed sponsor.189	fn has_sponsor(&self, contract_address: address) -> Result<bool> {190		Ok(Pallet::<T>::get_sponsor(contract_address).is_some())191	}192193	/// Check tat contract has pending sponsor.194	///195	/// @param contractAddress The contract for which the presence of a pending sponsor is checked.196	/// @return **true** if contract has pending sponsor.197	fn has_pending_sponsor(&self, contract_address: address) -> Result<bool> {198		Ok(match Sponsoring::<T>::get(contract_address) {199			SponsorshipState::Disabled | SponsorshipState::Confirmed(_) => false,200			SponsorshipState::Unconfirmed(_) => true,201		})202	}203204	fn sponsoring_enabled(&self, contract_address: address) -> Result<bool> {205		Ok(<Pallet<T>>::sponsoring_mode(contract_address) != SponsoringModeT::Disabled)206	}207208	fn set_sponsoring_mode(209		&mut self,210		caller: caller,211		contract_address: address,212		// TODO: implement support for enums in evm-coder213		mode: uint8,214	) -> Result<void> {215		self.recorder().consume_sload()?;216		self.recorder().consume_sstore()?;217218		<Pallet<T>>::ensure_owner(contract_address, caller).map_err(dispatch_to_evm::<T>)?;219		let mode = SponsoringModeT::from_eth(mode).ok_or("unknown mode")?;220		<Pallet<T>>::set_sponsoring_mode(contract_address, mode);221222		Ok(())223	}224225	/// Get current contract sponsoring rate limit226	/// @param contractAddress Contract to get sponsoring mode of227	/// @return uint32 Amount of blocks between two sponsored transactions228	fn get_sponsoring_rate_limit(&self, contract_address: address) -> Result<uint32> {229		Ok(<SponsoringRateLimit<T>>::get(contract_address)230			.try_into()231			.map_err(|_| "rate limit > u32::MAX")?)232	}233234	/// Set contract sponsoring rate limit235	/// @dev Sponsoring rate limit - is a minimum amount of blocks that should236	///  pass between two sponsored transactions237	/// @param contractAddress Contract to change sponsoring rate limit of238	/// @param rateLimit Target rate limit239	/// @dev Only contract owner can change this setting240	fn set_sponsoring_rate_limit(241		&mut self,242		caller: caller,243		contract_address: address,244		rate_limit: uint32,245	) -> Result<void> {246		self.recorder().consume_sload()?;247		self.recorder().consume_sstore()?;248249		<Pallet<T>>::ensure_owner(contract_address, caller).map_err(dispatch_to_evm::<T>)?;250		<Pallet<T>>::set_sponsoring_rate_limit(contract_address, rate_limit.into());251		Ok(())252	}253254	fn set_sponsoring_fee_limit(255		&mut self,256		caller: caller,257		contract_address: address,258		fee_limit: uint256,259	) -> Result<void> {260		<Pallet<T>>::ensure_owner(contract_address, caller).map_err(dispatch_to_evm::<T>)?;261		<Pallet<T>>::set_sponsoring_fee_limit(contract_address, fee_limit.into());262		Ok(())263	}264265	fn get_sponsoring_fee_limit(&self, contract_address: address) -> Result<uint256> {266		Ok(<SponsoringFeeLimit<T>>::get(contract_address))267	}268269	/// Is specified user present in contract allow list270	/// @dev Contract owner always implicitly included271	/// @param contractAddress Contract to check allowlist of272	/// @param user User to check273	/// @return bool Is specified users exists in contract allowlist274	fn allowed(&self, contract_address: address, user: address) -> Result<bool> {275		self.0.consume_sload()?;276		Ok(<Pallet<T>>::allowed(contract_address, user))277	}278279	/// Toggle user presence in contract allowlist280	/// @param contractAddress Contract to change allowlist of281	/// @param user Which user presence should be toggled282	/// @param isAllowed `true` if user should be allowed to be sponsored283	///  or call this contract, `false` otherwise284	/// @dev Only contract owner can change this setting285	fn toggle_allowed(286		&mut self,287		caller: caller,288		contract_address: address,289		user: address,290		is_allowed: bool,291	) -> Result<void> {292		self.recorder().consume_sload()?;293		self.recorder().consume_sstore()?;294295		<Pallet<T>>::ensure_owner(contract_address, caller).map_err(dispatch_to_evm::<T>)?;296		<Pallet<T>>::toggle_allowed(contract_address, user, is_allowed);297298		Ok(())299	}300301	/// Is this contract has allowlist access enabled302	/// @dev Allowlist always can have users, and it is used for two purposes:303	///  in case of allowlist sponsoring mode, users will be sponsored if they exist in allowlist304	///  in case of allowlist access enabled, only users from allowlist may call this contract305	/// @param contractAddress Contract to get allowlist access of306	/// @return bool Is specified contract has allowlist access enabled307	fn allowlist_enabled(&self, contract_address: address) -> Result<bool> {308		Ok(<AllowlistEnabled<T>>::get(contract_address))309	}310311	/// Toggle contract allowlist access312	/// @param contractAddress Contract to change allowlist access of313	/// @param enabled Should allowlist access to be enabled?314	fn toggle_allowlist(315		&mut self,316		caller: caller,317		contract_address: address,318		enabled: bool,319	) -> Result<void> {320		self.recorder().consume_sload()?;321		self.recorder().consume_sstore()?;322323		<Pallet<T>>::ensure_owner(contract_address, caller).map_err(dispatch_to_evm::<T>)?;324		<Pallet<T>>::toggle_allowlist(contract_address, enabled);325		Ok(())326	}327}328329/// Implements [`OnMethodCall`], which delegates call to [`ContractHelpers`]330pub struct HelpersOnMethodCall<T: Config>(PhantomData<*const T>);331impl<T: Config> OnMethodCall<T> for HelpersOnMethodCall<T>332where333	T::AccountId: AsRef<[u8; 32]>,334{335	fn is_reserved(contract: &sp_core::H160) -> bool {336		contract == &T::ContractAddress::get()337	}338339	fn is_used(contract: &sp_core::H160) -> bool {340		contract == &T::ContractAddress::get()341	}342343	fn call(handle: &mut impl PrecompileHandle) -> Option<PrecompileResult> {344		// TODO: Extract to another OnMethodCall handler345		if <AllowlistEnabled<T>>::get(handle.code_address())346			&& !<Pallet<T>>::allowed(handle.code_address(), handle.context().caller)347		{348			return Some(Err(PrecompileFailure::Revert {349				exit_status: ExitRevert::Reverted,350				output: {351					let mut writer = AbiWriter::new_call(evm_coder::fn_selector!(Error(string)));352					writer.string("Target contract is allowlisted");353					writer.finish()354				},355			}));356		}357358		if handle.code_address() != T::ContractAddress::get() {359			return None;360		}361362		let helpers = ContractHelpers::<T>(SubstrateRecorder::<T>::new(handle.remaining_gas()));363		pallet_evm_coder_substrate::call(handle, helpers)364	}365366	fn get_code(contract: &sp_core::H160) -> Option<Vec<u8>> {367		(contract == &T::ContractAddress::get())368			.then(|| include_bytes!("./stubs/ContractHelpers.raw").to_vec())369	}370}371372/// Hooks into contract creation, storing owner of newly deployed contract373pub struct HelpersOnCreate<T: Config>(PhantomData<*const T>);374impl<T: Config> OnCreate<T> for HelpersOnCreate<T> {375	fn on_create(owner: H160, contract: H160) {376		<Owner<T>>::insert(contract, owner);377	}378}379380/// Bridge to pallet-sponsoring381pub struct HelpersContractSponsoring<T: Config>(PhantomData<*const T>);382impl<T: Config> SponsorshipHandler<T::CrossAccountId, (H160, Vec<u8>), CallContext>383	for HelpersContractSponsoring<T>384{385	fn get_sponsor(386		who: &T::CrossAccountId,387		call: &(H160, Vec<u8>),388		call_context: &CallContext,389	) -> Option<T::CrossAccountId> {390		let (contract_address, _) = call;391		let mode = <Pallet<T>>::sponsoring_mode(*contract_address);392		if mode == SponsoringModeT::Disabled {393			return None;394		}395396		let sponsor = match <Pallet<T>>::get_sponsor(*contract_address) {397			Some(sponsor) => sponsor,398			None => return None,399		};400401		if mode == SponsoringModeT::Allowlisted402			&& !<Pallet<T>>::allowed(*contract_address, *who.as_eth())403		{404			return None;405		}406		let block_number = <frame_system::Pallet<T>>::block_number() as T::BlockNumber;407408		if let Some(last_tx_block) = <SponsorBasket<T>>::get(contract_address, who.as_eth()) {409			let limit = <SponsoringRateLimit<T>>::get(contract_address);410411			let timeout = last_tx_block + limit;412			if block_number < timeout {413				return None;414			}415		}416417		let sponsored_fee_limit = <SponsoringFeeLimit<T>>::get(contract_address);418419		if call_context.max_fee > sponsored_fee_limit {420			return None;421		}422423		<SponsorBasket<T>>::insert(contract_address, who.as_eth(), block_number);424425		Some(sponsor)426	}427}428429generate_stubgen!(contract_helpers_impl, ContractHelpersCall<()>, true);430generate_stubgen!(contract_helpers_iface, ContractHelpersCall<()>, false);
modifiedpallets/evm-contract-helpers/src/lib.rsdiffbeforeafterboth
--- a/pallets/evm-contract-helpers/src/lib.rs
+++ b/pallets/evm-contract-helpers/src/lib.rs
@@ -30,7 +30,7 @@
 	use crate::eth::ContractHelpersEvents;
 	use frame_support::pallet_prelude::*;
 	use pallet_evm_coder_substrate::DispatchResult;
-	use sp_core::H160;
+	use sp_core::{H160, U256};
 	use pallet_evm::{account::CrossAccountId, Pallet as PalletEvm};
 	use up_data_structs::SponsorshipState;
 	use evm_coder::ToLog;
@@ -50,7 +50,7 @@
 		type DefaultSponsoringRateLimit: Get<Self::BlockNumber>;
 		/// In case of enabled sponsoring, but no sponsoring fee limit set,
 		/// this value will be used implicitly
-		type DefaultSponsoringFeeLimit: Get<u128>;
+		type DefaultSponsoringFeeLimit: Get<U256>;
 	}
 
 	#[pallet::error]
@@ -124,7 +124,7 @@
 	pub(super) type SponsoringFeeLimit<T: Config> = StorageMap<
 		Hasher = Twox128,
 		Key = H160,
-		Value = u128,
+		Value = U256,
 		QueryKind = ValueQuery,
 		OnEmpty = T::DefaultSponsoringFeeLimit,
 	>;
@@ -366,7 +366,7 @@
 		}
 
 		/// Set maximum for gas limit of transaction
-		pub fn set_sponsoring_fee_limit(contract: H160, fee_limit: u128) {
+		pub fn set_sponsoring_fee_limit(contract: H160, fee_limit: U256) {
 			<SponsoringFeeLimit<T>>::insert(contract, fee_limit);
 		}
 
modifiedpallets/evm-contract-helpers/src/stubs/ContractHelpers.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/evm-contract-helpers/src/stubs/ContractHelpers.soldiffbeforeafterboth
--- a/pallets/evm-contract-helpers/src/stubs/ContractHelpers.sol
+++ b/pallets/evm-contract-helpers/src/stubs/ContractHelpers.sol
@@ -32,7 +32,7 @@
 }
 
 /// @title Magic contract, which allows users to reconfigure other contracts
-/// @dev the ERC-165 identifier for this interface is 0xd77fab70
+/// @dev the ERC-165 identifier for this interface is 0x172cb4fb
 contract ContractHelpers is Dummy, ERC165, ContractHelpersEvents {
 	/// Get user, which deployed specified contract
 	/// @dev May return zero address in case if contract is deployed
@@ -203,9 +203,9 @@
 		dummy = 0;
 	}
 
-	/// @dev EVM selector for this function is: 0x1c362eb4,
-	///  or in textual repr: setSponsoringFeeLimit(address,uint128)
-	function setSponsoringFeeLimit(address contractAddress, uint128 feeLimit)
+	/// @dev EVM selector for this function is: 0x03aed665,
+	///  or in textual repr: setSponsoringFeeLimit(address,uint256)
+	function setSponsoringFeeLimit(address contractAddress, uint256 feeLimit)
 		public
 	{
 		require(false, stub_error);
@@ -219,7 +219,7 @@
 	function getSponsoringFeeLimit(address contractAddress)
 		public
 		view
-		returns (uint128)
+		returns (uint256)
 	{
 		require(false, stub_error);
 		contractAddress;
modifiedpallets/evm-transaction-payment/Cargo.tomldiffbeforeafterboth
--- a/pallets/evm-transaction-payment/Cargo.toml
+++ b/pallets/evm-transaction-payment/Cargo.toml
@@ -17,7 +17,7 @@
 pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", rev = "89a37c5a489f426cc7a42d7b94019974093a052d" }
 fp-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", rev = "89a37c5a489f426cc7a42d7b94019974093a052d" }
 pallet-ethereum = { default-features = false, git = "https://github.com/uniquenetwork/frontier", rev = "89a37c5a489f426cc7a42d7b94019974093a052d" }
-up-sponsorship = { version = "0.1.0", default-features = false, git = "https://github.com/uniquenetwork/pallet-sponsoring", rev = "a8ec4bf8d5ded662d96da6d8fb211b0bbf6617b3" }
+up-sponsorship = { version = "0.1.0", default-features = false, git = "https://github.com/uniquenetwork/pallet-sponsoring", rev = "9ee7d6e57e03a2575cbab79431774b56f170018e" }
 fp-evm-mapping = { default-features = false, git = "https://github.com/uniquenetwork/frontier", rev = "89a37c5a489f426cc7a42d7b94019974093a052d" }
 
 [dependencies.codec]
modifiedpallets/evm-transaction-payment/src/lib.rsdiffbeforeafterboth
--- a/pallets/evm-transaction-payment/src/lib.rs
+++ b/pallets/evm-transaction-payment/src/lib.rs
@@ -22,7 +22,7 @@
 use fp_evm::WithdrawReason;
 use frame_support::traits::IsSubType;
 pub use pallet::*;
-use pallet_evm::{account::CrossAccountId, EnsureAddressOrigin, FeeCalculator};
+use pallet_evm::{account::CrossAccountId, EnsureAddressOrigin};
 use sp_core::{H160, U256};
 use sp_runtime::{TransactionOutcome, DispatchError};
 use up_sponsorship::SponsorshipHandler;
@@ -33,10 +33,20 @@
 
 	use sp_std::vec::Vec;
 
+	/// Contains call data
+	pub struct CallContext {
+		/// Max fee for transaction - gasLimit * gasPrice
+		pub max_fee: U256,
+	}
+
 	#[pallet::config]
 	pub trait Config: frame_system::Config + pallet_evm::account::Config {
 		/// Loosly-coupled handlers for evm call sponsoring
-		type EvmSponsorshipHandler: SponsorshipHandler<Self::CrossAccountId, (H160, Vec<u8>), u128>;
+		type EvmSponsorshipHandler: SponsorshipHandler<
+			Self::CrossAccountId,
+			(H160, Vec<u8>),
+			CallContext,
+		>;
 	}
 
 	#[pallet::pallet]
@@ -55,10 +65,11 @@
 		match reason {
 			WithdrawReason::Call { target, input } => {
 				let origin_sub = T::CrossAccountId::from_eth(origin);
+				let call_context = CallContext { max_fee };
 				T::EvmSponsorshipHandler::get_sponsor(
 					&origin_sub,
 					&(*target, input.clone()),
-					&max_fee.as_u128(),
+					&call_context,
 				)
 			}
 			_ => None,
@@ -68,12 +79,12 @@
 
 /// Implements sponsoring for evm calls performed from pallet-evm (via api.tx.ethereum.transact/api.tx.evm.call)
 pub struct BridgeSponsorshipHandler<T>(PhantomData<T>);
-impl<T, C> SponsorshipHandler<T::AccountId, C, u128> for BridgeSponsorshipHandler<T>
+impl<T, C> SponsorshipHandler<T::AccountId, C, ()> for BridgeSponsorshipHandler<T>
 where
 	T: Config + pallet_evm::Config,
 	C: IsSubType<pallet_evm::Call<T>>,
 {
-	fn get_sponsor(who: &T::AccountId, call: &C, _fee_limit: &u128) -> Option<T::AccountId> {
+	fn get_sponsor(who: &T::AccountId, call: &C, _call_context: &()) -> Option<T::AccountId> {
 		match call.is_sub_type()? {
 			pallet_evm::Call::call {
 				source,
@@ -90,6 +101,7 @@
 				.ok()?;
 				let who = T::CrossAccountId::from_sub(who.clone());
 				let max_fee = max_fee_per_gas.saturating_mul((*gas_limit).into());
+				let call_context = CallContext { max_fee };
 				// Effects from EvmSponsorshipHandler are applied by pallet_evm::runner
 				// TODO: Should we implement simulation mode (test, but do not apply effects) in `up-sponsorship`?
 				let sponsor = frame_support::storage::with_transaction(|| {
@@ -97,7 +109,7 @@
 						T::EvmSponsorshipHandler::get_sponsor(
 							&who,
 							&(*target, input.clone()),
-							&max_fee.try_into().unwrap(),
+							&call_context,
 						),
 					))
 				})
modifiedpallets/scheduler/Cargo.tomldiffbeforeafterboth
--- a/pallets/scheduler/Cargo.toml
+++ b/pallets/scheduler/Cargo.toml
@@ -24,7 +24,7 @@
 sp-core = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.27' }
 frame-benchmarking = { default-features = false, optional = true, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" }
 
-up-sponsorship = { version = "0.1.0", default-features = false, git = "https://github.com/uniquenetwork/pallet-sponsoring", rev="a8ec4bf8d5ded662d96da6d8fb211b0bbf6617b3" }
+up-sponsorship = { version = "0.1.0", default-features = false, git = "https://github.com/uniquenetwork/pallet-sponsoring", rev="9ee7d6e57e03a2575cbab79431774b56f170018e" }
 log = { version = "0.4.14", default-features = false }
 
 [dev-dependencies]
modifiedruntime/common/config/sponsoring.rsdiffbeforeafterboth
--- a/runtime/common/config/sponsoring.rs
+++ b/runtime/common/config/sponsoring.rs
@@ -14,16 +14,17 @@
 // You should have received a copy of the GNU General Public License
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
-use frame_support::parameter_types;
 use crate::{
 	runtime_common::{sponsoring::UniqueSponsorshipHandler},
 	Runtime,
 };
-use up_common::{types::BlockNumber, constants::*};
+use frame_support::parameter_types;
+use sp_core::U256;
+use up_common::{constants::*, types::BlockNumber};
 
 parameter_types! {
 	pub const DefaultSponsoringRateLimit: BlockNumber = 1 * DAYS;
-	pub const DefaultSponsoringFeeLimit: u128 = u128::MAX;
+	pub const DefaultSponsoringFeeLimit: U256 = U256::MAX;
 }
 
 type SponsorshipHandler = (
modifiedruntime/common/ethereum/sponsoring.rsdiffbeforeafterboth
--- a/runtime/common/ethereum/sponsoring.rs
+++ b/runtime/common/ethereum/sponsoring.rs
@@ -16,27 +16,31 @@
 
 //! Implements EVM sponsoring logic via TransactionValidityHack
 
+use core::{convert::TryInto, marker::PhantomData};
 use evm_coder::{Call, abi::AbiReader};
 use pallet_common::{CollectionHandle, eth::map_eth_to_id};
+use pallet_evm::account::CrossAccountId;
+use pallet_evm_transaction_payment::CallContext;
+use pallet_nonfungible::{
+	Config as NonfungibleConfig,
+	erc::{
+		UniqueNFTCall, ERC721UniqueExtensionsCall, ERC721MintableCall, ERC721Call,
+		TokenPropertiesCall,
+	},
+};
+use pallet_fungible::{
+	Config as FungibleConfig,
+	erc::{UniqueFungibleCall, ERC20Call},
+};
+use pallet_refungible::Config as RefungibleConfig;
+use pallet_unique::Config as UniqueConfig;
 use sp_core::H160;
 use sp_std::prelude::*;
+use up_data_structs::{CollectionMode, CreateItemData, CreateNftData, TokenId};
 use up_sponsorship::SponsorshipHandler;
-use core::marker::PhantomData;
-use core::convert::TryInto;
-use pallet_evm::account::CrossAccountId;
-use up_data_structs::{TokenId, CreateItemData, CreateNftData, CollectionMode};
-use pallet_unique::Config as UniqueConfig;
 
 use crate::{Runtime, runtime_common::sponsoring::*};
 
-use pallet_nonfungible::erc::{
-	UniqueNFTCall, ERC721UniqueExtensionsCall, ERC721MintableCall, ERC721Call, TokenPropertiesCall,
-};
-use pallet_fungible::erc::{UniqueFungibleCall, ERC20Call};
-use pallet_fungible::Config as FungibleConfig;
-use pallet_nonfungible::Config as NonfungibleConfig;
-use pallet_refungible::Config as RefungibleConfig;
-
 pub type EvmSponsorshipHandler = (
 	UniqueEthSponsorshipHandler<Runtime>,
 	pallet_evm_contract_helpers::HelpersContractSponsoring<Runtime>,
@@ -44,12 +48,13 @@
 
 pub struct UniqueEthSponsorshipHandler<T: UniqueConfig>(PhantomData<*const T>);
 impl<T: UniqueConfig + FungibleConfig + NonfungibleConfig + RefungibleConfig>
-	SponsorshipHandler<T::CrossAccountId, (H160, Vec<u8>), u128> for UniqueEthSponsorshipHandler<T>
+	SponsorshipHandler<T::CrossAccountId, (H160, Vec<u8>), CallContext>
+	for UniqueEthSponsorshipHandler<T>
 {
 	fn get_sponsor(
 		who: &T::CrossAccountId,
 		call: &(H160, Vec<u8>),
-		_fee_limit: &u128,
+		_fee_limit: &CallContext,
 	) -> Option<T::CrossAccountId> {
 		let collection_id = map_eth_to_id(&call.0)?;
 		let collection = <CollectionHandle<T>>::new(collection_id)?;
modifiedruntime/common/sponsoring.rsdiffbeforeafterboth
--- a/runtime/common/sponsoring.rs
+++ b/runtime/common/sponsoring.rs
@@ -224,12 +224,12 @@
 }
 
 pub struct UniqueSponsorshipHandler<T>(PhantomData<T>);
-impl<T, C> SponsorshipHandler<T::AccountId, C, u128> for UniqueSponsorshipHandler<T>
+impl<T, C> SponsorshipHandler<T::AccountId, C, ()> for UniqueSponsorshipHandler<T>
 where
 	T: Config,
 	C: IsSubType<UniqueCall<T>>,
 {
-	fn get_sponsor(who: &T::AccountId, call: &C, _fee_limit: &u128) -> Option<T::AccountId> {
+	fn get_sponsor(who: &T::AccountId, call: &C, _call_context: &()) -> Option<T::AccountId> {
 		match IsSubType::<UniqueCall<T>>::is_sub_type(call)? {
 			UniqueCall::set_token_properties {
 				collection_id,
modifiedruntime/opal/Cargo.tomldiffbeforeafterboth
--- a/runtime/opal/Cargo.toml
+++ b/runtime/opal/Cargo.toml
@@ -431,7 +431,7 @@
 pallet-proxy-rmrk-equip = { default-features = false, path = "../../pallets/proxy-rmrk-equip", package = "pallet-rmrk-equip" }
 pallet-unique-scheduler = { path = '../../pallets/scheduler', default-features = false }
 # pallet-contract-helpers = { path = '../pallets/contract-helpers', default-features = false, version = '0.1.0' }
-pallet-charge-transaction = { git = "https://github.com/uniquenetwork/pallet-sponsoring", rev="a8ec4bf8d5ded662d96da6d8fb211b0bbf6617b3", package = "pallet-template-transaction-payment", default-features = false, version = "3.0.0" }
+pallet-charge-transaction = { git = "https://github.com/uniquenetwork/pallet-sponsoring", rev="9ee7d6e57e03a2575cbab79431774b56f170018e", package = "pallet-template-transaction-payment", default-features = false, version = "3.0.0" }
 pallet-evm-migration = { path = '../../pallets/evm-migration', default-features = false }
 pallet-evm-contract-helpers = { path = '../../pallets/evm-contract-helpers', default-features = false }
 pallet-evm-transaction-payment = { path = '../../pallets/evm-transaction-payment', default-features = false }
@@ -442,7 +442,7 @@
 fp-rpc = { default-features = false, git = "https://github.com/uniquenetwork/frontier", rev = "89a37c5a489f426cc7a42d7b94019974093a052d" }
 fp-self-contained = { default-features = false, git = "https://github.com/uniquenetwork/frontier", rev = "89a37c5a489f426cc7a42d7b94019974093a052d" }
 evm-coder = { default-features = false, path = '../../crates/evm-coder' }
-up-sponsorship = { default-features = false, git = "https://github.com/uniquenetwork/pallet-sponsoring", rev="a8ec4bf8d5ded662d96da6d8fb211b0bbf6617b3" }
+up-sponsorship = { default-features = false, git = "https://github.com/uniquenetwork/pallet-sponsoring", rev="9ee7d6e57e03a2575cbab79431774b56f170018e" }
 
 ################################################################################
 # Build Dependencies
modifiedruntime/quartz/Cargo.tomldiffbeforeafterboth
--- a/runtime/quartz/Cargo.toml
+++ b/runtime/quartz/Cargo.toml
@@ -432,7 +432,7 @@
 pallet-proxy-rmrk-equip = { default-features = false, path = "../../pallets/proxy-rmrk-equip", package = "pallet-rmrk-equip" }
 pallet-unique-scheduler = { path = '../../pallets/scheduler', default-features = false }
 # pallet-contract-helpers = { path = '../pallets/contract-helpers', default-features = false, version = '0.1.0' }
-pallet-charge-transaction = { git = "https://github.com/uniquenetwork/pallet-sponsoring", rev="a8ec4bf8d5ded662d96da6d8fb211b0bbf6617b3", package = "pallet-template-transaction-payment", default-features = false, version = "3.0.0" }
+pallet-charge-transaction = { git = "https://github.com/uniquenetwork/pallet-sponsoring", rev="9ee7d6e57e03a2575cbab79431774b56f170018e", package = "pallet-template-transaction-payment", default-features = false, version = "3.0.0" }
 pallet-evm-migration = { path = '../../pallets/evm-migration', default-features = false }
 pallet-evm-contract-helpers = { path = '../../pallets/evm-contract-helpers', default-features = false }
 pallet-evm-transaction-payment = { path = '../../pallets/evm-transaction-payment', default-features = false }
@@ -443,7 +443,7 @@
 fp-rpc = { default-features = false, git = "https://github.com/uniquenetwork/frontier", rev = "89a37c5a489f426cc7a42d7b94019974093a052d" }
 fp-self-contained = { default-features = false, git = "https://github.com/uniquenetwork/frontier", rev = "89a37c5a489f426cc7a42d7b94019974093a052d" }
 evm-coder = { default-features = false, path = '../../crates/evm-coder' }
-up-sponsorship = { default-features = false, git = "https://github.com/uniquenetwork/pallet-sponsoring", rev="a8ec4bf8d5ded662d96da6d8fb211b0bbf6617b3" }
+up-sponsorship = { default-features = false, git = "https://github.com/uniquenetwork/pallet-sponsoring", rev="9ee7d6e57e03a2575cbab79431774b56f170018e" }
 
 ################################################################################
 # Build Dependencies
modifiedruntime/tests/Cargo.tomldiffbeforeafterboth
--- a/runtime/tests/Cargo.toml
+++ b/runtime/tests/Cargo.toml
@@ -43,4 +43,4 @@
 scale-info = "*"
 
 evm-coder = { default-features = false, path = '../../crates/evm-coder' }
-up-sponsorship = { default-features = false, git = "https://github.com/uniquenetwork/pallet-sponsoring", rev="a8ec4bf8d5ded662d96da6d8fb211b0bbf6617b3" }
+up-sponsorship = { default-features = false, git = "https://github.com/uniquenetwork/pallet-sponsoring", rev="9ee7d6e57e03a2575cbab79431774b56f170018e" }
modifiedruntime/unique/Cargo.tomldiffbeforeafterboth
--- a/runtime/unique/Cargo.toml
+++ b/runtime/unique/Cargo.toml
@@ -425,7 +425,7 @@
 pallet-proxy-rmrk-equip = { default-features = false, path = "../../pallets/proxy-rmrk-equip", package = "pallet-rmrk-equip" }
 pallet-unique-scheduler = { path = '../../pallets/scheduler', default-features = false }
 # pallet-contract-helpers = { path = '../pallets/contract-helpers', default-features = false, version = '0.1.0' }
-pallet-charge-transaction = { git = "https://github.com/uniquenetwork/pallet-sponsoring", rev="a8ec4bf8d5ded662d96da6d8fb211b0bbf6617b3", package = "pallet-template-transaction-payment", default-features = false, version = "3.0.0" }
+pallet-charge-transaction = { git = "https://github.com/uniquenetwork/pallet-sponsoring", rev="9ee7d6e57e03a2575cbab79431774b56f170018e", package = "pallet-template-transaction-payment", default-features = false, version = "3.0.0" }
 pallet-evm-migration = { path = '../../pallets/evm-migration', default-features = false }
 pallet-evm-contract-helpers = { path = '../../pallets/evm-contract-helpers', default-features = false }
 pallet-evm-transaction-payment = { path = '../../pallets/evm-transaction-payment', default-features = false }
@@ -437,7 +437,7 @@
 fp-self-contained = { default-features = false, git = "https://github.com/uniquenetwork/frontier", rev = "89a37c5a489f426cc7a42d7b94019974093a052d" }
 fp-evm-mapping = { default-features = false, git = "https://github.com/uniquenetwork/frontier", rev = "89a37c5a489f426cc7a42d7b94019974093a052d" }
 evm-coder = { default-features = false, path = '../../crates/evm-coder' }
-up-sponsorship = { default-features = false, git = "https://github.com/uniquenetwork/pallet-sponsoring", rev="a8ec4bf8d5ded662d96da6d8fb211b0bbf6617b3" }
+up-sponsorship = { default-features = false, git = "https://github.com/uniquenetwork/pallet-sponsoring", rev="9ee7d6e57e03a2575cbab79431774b56f170018e" }
 
 ################################################################################
 # Build Dependencies
modifiedtests/src/eth/api/ContractHelpers.soldiffbeforeafterboth
--- a/tests/src/eth/api/ContractHelpers.sol
+++ b/tests/src/eth/api/ContractHelpers.sol
@@ -23,7 +23,7 @@
 }
 
 /// @title Magic contract, which allows users to reconfigure other contracts
-/// @dev the ERC-165 identifier for this interface is 0xd77fab70
+/// @dev the ERC-165 identifier for this interface is 0x172cb4fb
 interface ContractHelpers is Dummy, ERC165, ContractHelpersEvents {
 	/// Get user, which deployed specified contract
 	/// @dev May return zero address in case if contract is deployed
@@ -131,9 +131,9 @@
 	function setSponsoringRateLimit(address contractAddress, uint32 rateLimit)
 		external;
 
-	/// @dev EVM selector for this function is: 0x1c362eb4,
-	///  or in textual repr: setSponsoringFeeLimit(address,uint128)
-	function setSponsoringFeeLimit(address contractAddress, uint128 feeLimit)
+	/// @dev EVM selector for this function is: 0x03aed665,
+	///  or in textual repr: setSponsoringFeeLimit(address,uint256)
+	function setSponsoringFeeLimit(address contractAddress, uint256 feeLimit)
 		external;
 
 	/// @dev EVM selector for this function is: 0xc3fdc9ee,
@@ -141,7 +141,7 @@
 	function getSponsoringFeeLimit(address contractAddress)
 		external
 		view
-		returns (uint128);
+		returns (uint256);
 
 	/// Is specified user present in contract allow list
 	/// @dev Contract owner always implicitly included
modifiedtests/src/eth/contractSponsoring.test.tsdiffbeforeafterboth
--- a/tests/src/eth/contractSponsoring.test.ts
+++ b/tests/src/eth/contractSponsoring.test.ts
@@ -558,7 +558,7 @@
     const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
     const flipper = await deployFlipper(web3, owner);
     const helpers = contractHelpers(web3, owner);
-    expect(await helpers.methods.getSponsoringFeeLimit(flipper.options.address).call()).to.be.equals('340282366920938463463374607431768211455');
+    expect(await helpers.methods.getSponsoringFeeLimit(flipper.options.address).call()).to.be.equals('115792089237316195423570985008687907853269984665640564039457584007913129639935');
   });
 
   itWeb3('Set fee limit', async ({api, web3, privateKeyWrapper}) => {
modifiedtests/src/eth/util/contractHelpersAbi.jsondiffbeforeafterboth
--- a/tests/src/eth/util/contractHelpersAbi.json
+++ b/tests/src/eth/util/contractHelpersAbi.json
@@ -135,7 +135,7 @@
       }
     ],
     "name": "getSponsoringFeeLimit",
-    "outputs": [{ "internalType": "uint128", "name": "", "type": "uint128" }],
+    "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
     "stateMutability": "view",
     "type": "function"
   },
@@ -225,7 +225,7 @@
         "name": "contractAddress",
         "type": "address"
       },
-      { "internalType": "uint128", "name": "feeLimit", "type": "uint128" }
+      { "internalType": "uint256", "name": "feeLimit", "type": "uint256" }
     ],
     "name": "setSponsoringFeeLimit",
     "outputs": [],