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

difftreelog

feat fake event injection

Yaroslav Bolyukin2022-11-23parent: #1d4e56c.patch.diff
in: master

8 files changed

modifiedCargo.lockdiffbeforeafterboth
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -6038,6 +6038,7 @@
 name = "pallet-evm-migration"
 version = "0.1.1"
 dependencies = [
+ "ethereum",
  "fp-evm",
  "frame-benchmarking",
  "frame-support",
modifiedpallets/evm-migration/Cargo.tomldiffbeforeafterboth
--- a/pallets/evm-migration/Cargo.toml
+++ b/pallets/evm-migration/Cargo.toml
@@ -8,6 +8,7 @@
 scale-info = { version = "2.0.1", default-features = false, features = [
     "derive",
 ] }
+ethereum = { version = "0.12.0", default-features = false }
 frame-support = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.30" }
 frame-system = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.30" }
 frame-benchmarking = { default-features = false, optional = true, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.30" }
modifiedpallets/evm-migration/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/evm-migration/src/benchmarking.rs
+++ b/pallets/evm-migration/src/benchmarking.rs
@@ -20,9 +20,11 @@
 use frame_benchmarking::benchmarks;
 use frame_system::RawOrigin;
 use sp_core::{H160, H256};
-use sp_std::vec::Vec;
+use sp_std::{vec::Vec, vec};
 
 benchmarks! {
+	where_clause { where <T as Config>::RuntimeEvent: codec::Encode }
+
 	begin {
 	}: _(RawOrigin::Root, H160::default())
 
@@ -45,4 +47,19 @@
 		let data: Vec<u8> = (0..b as u8).collect();
 		<Pallet<T>>::begin(RawOrigin::Root.into(), address)?;
 	}: _(RawOrigin::Root, address, data)
+
+	insert_eth_logs {
+		let b in 0..200;
+		let logs = (0..b).map(|_| ethereum::Log {
+			address: H160([b as u8; 20]),
+			data: vec![b as u8; 128],
+			topics: vec![H256([b as u8; 32]); 6],
+		}).collect::<Vec<_>>();
+	}: _(RawOrigin::Root, logs)
+
+	insert_events {
+		let b in 0..200;
+		use codec::Encode;
+		let logs = (0..b).map(|_| <T as Config>::RuntimeEvent::from(crate::Event::<T>::TestEvent).encode()).collect::<Vec<_>>();
+	}: _(RawOrigin::Root, logs)
 }
modifiedpallets/evm-migration/src/lib.rsdiffbeforeafterboth
before · pallets/evm-migration/src/lib.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#![doc = include_str!("../README.md")]18#![cfg_attr(not(feature = "std"), no_std)]19#![deny(missing_docs)]2021pub use pallet::*;22#[cfg(feature = "runtime-benchmarks")]23pub mod benchmarking;24pub mod weights;2526#[frame_support::pallet]27pub mod pallet {28	use frame_support::pallet_prelude::*;29	use frame_system::pallet_prelude::*;30	use sp_core::{H160, H256};31	use sp_std::vec::Vec;32	use super::weights::WeightInfo;33	use pallet_evm::{PrecompileHandle, Pallet as PalletEvm};3435	#[pallet::config]36	pub trait Config: frame_system::Config + pallet_evm::Config {37		/// Weights38		type WeightInfo: WeightInfo;39	}4041	type SelfWeightOf<T> = <T as Config>::WeightInfo;4243	#[pallet::pallet]44	#[pallet::generate_store(pub(super) trait Store)]45	pub struct Pallet<T>(_);4647	#[pallet::error]48	pub enum Error<T> {49		/// Can only migrate to empty address.50		AccountNotEmpty,51		/// Migration of this account is not yet started, or already finished.52		AccountIsNotMigrating,53	}5455	#[pallet::storage]56	pub(super) type MigrationPending<T: Config> =57		StorageMap<Hasher = Twox64Concat, Key = H160, Value = bool, QueryKind = ValueQuery>;5859	#[pallet::call]60	impl<T: Config> Pallet<T> {61		/// Start contract migration, inserts contract stub at target address,62		/// and marks account as pending, allowing to insert storage63		#[pallet::weight(<SelfWeightOf<T>>::begin())]64		pub fn begin(origin: OriginFor<T>, address: H160) -> DispatchResult {65			ensure_root(origin)?;66			ensure!(67				<PalletEvm<T>>::is_account_empty(&address) && !<MigrationPending<T>>::get(&address),68				<Error<T>>::AccountNotEmpty,69			);7071			<MigrationPending<T>>::insert(address, true);72			Ok(())73		}7475		/// Insert items into contract storage, this method can be called76		/// multiple times77		#[pallet::weight(<SelfWeightOf<T>>::set_data(data.len() as u32))]78		pub fn set_data(79			origin: OriginFor<T>,80			address: H160,81			data: Vec<(H256, H256)>,82		) -> DispatchResult {83			ensure_root(origin)?;84			ensure!(85				<MigrationPending<T>>::get(&address),86				<Error<T>>::AccountIsNotMigrating,87			);8889			for (k, v) in data {90				<pallet_evm::AccountStorages<T>>::insert(&address, k, v);91			}92			Ok(())93		}9495		/// Finish contract migration, allows it to be called.96		/// It is not possible to alter contract storage via [`Self::set_data`]97		/// after this call.98		#[pallet::weight(<SelfWeightOf<T>>::finish(code.len() as u32))]99		pub fn finish(origin: OriginFor<T>, address: H160, code: Vec<u8>) -> DispatchResult {100			ensure_root(origin)?;101			ensure!(102				<MigrationPending<T>>::get(&address),103				<Error<T>>::AccountIsNotMigrating,104			);105106			<pallet_evm::AccountCodes<T>>::insert(&address, code);107			<MigrationPending<T>>::remove(address);108			Ok(())109		}110	}111112	/// Implements [`pallet_evm::OnMethodCall`], which reserves accounts with pending migration113	pub struct OnMethodCall<T>(PhantomData<T>);114	impl<T: Config> pallet_evm::OnMethodCall<T> for OnMethodCall<T> {115		fn is_reserved(contract: &H160) -> bool {116			<MigrationPending<T>>::get(&contract)117		}118119		fn is_used(_contract: &H160) -> bool {120			false121		}122123		fn call(_handle: &mut impl PrecompileHandle) -> Option<pallet_evm::PrecompileResult> {124			None125		}126127		fn get_code(_contract: &H160) -> Option<Vec<u8>> {128			None129		}130	}131}
after · pallets/evm-migration/src/lib.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#![doc = include_str!("../README.md")]18#![cfg_attr(not(feature = "std"), no_std)]19#![deny(missing_docs)]2021pub use pallet::*;22#[cfg(feature = "runtime-benchmarks")]23pub mod benchmarking;24pub mod weights;2526#[frame_support::pallet]27pub mod pallet {28	use frame_support::{29		pallet_prelude::{*, DispatchResult},30		traits::IsType,31	};32	use frame_system::pallet_prelude::{*, OriginFor};33	use sp_core::{H160, H256};34	use sp_std::vec::Vec;35	use super::weights::WeightInfo;36	use pallet_evm::{PrecompileHandle, Pallet as PalletEvm};3738	#[pallet::config]39	pub trait Config: frame_system::Config + pallet_evm::Config {40		/// Weights41		type WeightInfo: WeightInfo;42		/// The overarching event type.43		type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;44	}4546	type SelfWeightOf<T> = <T as Config>::WeightInfo;4748	#[pallet::pallet]49	#[pallet::generate_store(pub(super) trait Store)]50	pub struct Pallet<T>(_);5152	#[pallet::event]53	pub enum Event<T: Config> {54		/// This event is used in benchmarking and can be used for tests55		TestEvent,56	}5758	#[pallet::error]59	pub enum Error<T> {60		/// Can only migrate to empty address.61		AccountNotEmpty,62		/// Migration of this account is not yet started, or already finished.63		AccountIsNotMigrating,64		/// Failed to decode event bytes65		BadEvent,66	}6768	#[pallet::storage]69	pub(super) type MigrationPending<T: Config> =70		StorageMap<Hasher = Twox64Concat, Key = H160, Value = bool, QueryKind = ValueQuery>;7172	#[pallet::call]73	impl<T: Config> Pallet<T> {74		/// Start contract migration, inserts contract stub at target address,75		/// and marks account as pending, allowing to insert storage76		#[pallet::weight(<SelfWeightOf<T>>::begin())]77		pub fn begin(origin: OriginFor<T>, address: H160) -> DispatchResult {78			ensure_root(origin)?;79			ensure!(80				<PalletEvm<T>>::is_account_empty(&address) && !<MigrationPending<T>>::get(&address),81				<Error<T>>::AccountNotEmpty,82			);8384			<MigrationPending<T>>::insert(address, true);85			Ok(())86		}8788		/// Insert items into contract storage, this method can be called89		/// multiple times90		#[pallet::weight(<SelfWeightOf<T>>::set_data(data.len() as u32))]91		pub fn set_data(92			origin: OriginFor<T>,93			address: H160,94			data: Vec<(H256, H256)>,95		) -> DispatchResult {96			ensure_root(origin)?;97			ensure!(98				<MigrationPending<T>>::get(&address),99				<Error<T>>::AccountIsNotMigrating,100			);101102			for (k, v) in data {103				<pallet_evm::AccountStorages<T>>::insert(&address, k, v);104			}105			Ok(())106		}107108		/// Finish contract migration, allows it to be called.109		/// It is not possible to alter contract storage via [`Self::set_data`]110		/// after this call.111		#[pallet::weight(<SelfWeightOf<T>>::finish(code.len() as u32))]112		pub fn finish(origin: OriginFor<T>, address: H160, code: Vec<u8>) -> DispatchResult {113			ensure_root(origin)?;114			ensure!(115				<MigrationPending<T>>::get(&address),116				<Error<T>>::AccountIsNotMigrating,117			);118119			<pallet_evm::AccountCodes<T>>::insert(&address, code);120			<MigrationPending<T>>::remove(address);121			Ok(())122		}123124		/// Create ethereum events attached to the fake transaction125		#[pallet::weight(<SelfWeightOf<T>>::insert_eth_logs(logs.len() as u32))]126		pub fn insert_eth_logs(origin: OriginFor<T>, logs: Vec<ethereum::Log>) -> DispatchResult {127			ensure_root(origin)?;128			for log in logs {129				<pallet_evm::Pallet<T>>::deposit_log(log);130			}131			// Transactions is created by FakeTransactionFinalizer132			Ok(())133		}134135		/// Create substrate events136		#[pallet::weight(<SelfWeightOf<T>>::insert_events(events.len() as u32))]137		pub fn insert_events(origin: OriginFor<T>, events: Vec<Vec<u8>>) -> DispatchResult {138			ensure_root(origin)?;139			for event in events {140				<frame_system::Pallet<T>>::deposit_event(141					<T as frame_system::Config>::RuntimeEvent::decode(&mut event.as_slice())142						.map_err(|_| <Error<T>>::BadEvent)?,143				);144			}145			Ok(())146		}147	}148149	/// Implements [`pallet_evm::OnMethodCall`], which reserves accounts with pending migration150	pub struct OnMethodCall<T>(PhantomData<T>);151	impl<T: Config> pallet_evm::OnMethodCall<T> for OnMethodCall<T> {152		fn is_reserved(contract: &H160) -> bool {153			<MigrationPending<T>>::get(&contract)154		}155156		fn is_used(_contract: &H160) -> bool {157			false158		}159160		fn call(_handle: &mut impl PrecompileHandle) -> Option<pallet_evm::PrecompileResult> {161			None162		}163164		fn get_code(_contract: &H160) -> Option<Vec<u8>> {165			None166		}167	}168}
modifiedpallets/evm-migration/src/weights.rsdiffbeforeafterboth
--- a/pallets/evm-migration/src/weights.rs
+++ b/pallets/evm-migration/src/weights.rs
@@ -3,7 +3,7 @@
 //! Autogenerated weights for pallet_evm_migration
 //!
 //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
-//! DATE: 2022-08-15, STEPS: `50`, REPEAT: 80, LOW RANGE: `[]`, HIGH RANGE: `[]`
+//! DATE: 2022-11-23, STEPS: `50`, REPEAT: 80, LOW RANGE: `[]`, HIGH RANGE: `[]`
 //! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024
 
 // Executed Command:
@@ -37,6 +37,8 @@
 	fn begin() -> Weight;
 	fn set_data(b: u32, ) -> Weight;
 	fn finish(b: u32, ) -> Weight;
+	fn insert_eth_logs(b: u32, ) -> Weight;
+	fn insert_events(b: u32, ) -> Weight;
 }
 
 /// Weights for pallet_evm_migration using the Substrate node and recommended hardware.
@@ -46,26 +48,38 @@
 	// Storage: System Account (r:1 w:0)
 	// Storage: EVM AccountCodes (r:1 w:0)
 	fn begin() -> Weight {
-		Weight::from_ref_time(8_035_000)
+		Weight::from_ref_time(16_080_000 as u64)
 			.saturating_add(T::DbWeight::get().reads(3 as u64))
 			.saturating_add(T::DbWeight::get().writes(1 as u64))
 	}
 	// Storage: EvmMigration MigrationPending (r:1 w:0)
 	// Storage: EVM AccountStorages (r:0 w:1)
 	fn set_data(b: u32, ) -> Weight {
-		Weight::from_ref_time(3_076_000)
-			// Standard Error: 0
-			.saturating_add(Weight::from_ref_time(828_000).saturating_mul(b as u64))
+		Weight::from_ref_time(7_945_000 as u64)
+			// Standard Error: 1_272
+			.saturating_add(Weight::from_ref_time(1_056_832 as u64).saturating_mul(b as u64))
 			.saturating_add(T::DbWeight::get().reads(1 as u64))
 			.saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(b as u64)))
 	}
 	// Storage: EvmMigration MigrationPending (r:1 w:1)
 	// Storage: EVM AccountCodes (r:0 w:1)
-	fn finish(_b: u32, ) -> Weight {
-		Weight::from_ref_time(6_591_000)
+	fn finish(b: u32, ) -> Weight {
+		Weight::from_ref_time(8_336_000 as u64)
+			// Standard Error: 89
+			.saturating_add(Weight::from_ref_time(6_411 as u64).saturating_mul(b as u64))
 			.saturating_add(T::DbWeight::get().reads(1 as u64))
 			.saturating_add(T::DbWeight::get().writes(2 as u64))
 	}
+	fn insert_eth_logs(b: u32, ) -> Weight {
+		Weight::from_ref_time(3_447_000 as u64)
+			// Standard Error: 843
+			.saturating_add(Weight::from_ref_time(901_039 as u64).saturating_mul(b as u64))
+	}
+	fn insert_events(b: u32, ) -> Weight {
+		Weight::from_ref_time(3_457_000 as u64)
+			// Standard Error: 1_460
+			.saturating_add(Weight::from_ref_time(1_491_611 as u64).saturating_mul(b as u64))
+	}
 }
 
 // For backwards compatibility and tests
@@ -74,24 +88,36 @@
 	// Storage: System Account (r:1 w:0)
 	// Storage: EVM AccountCodes (r:1 w:0)
 	fn begin() -> Weight {
-		Weight::from_ref_time(8_035_000)
+		Weight::from_ref_time(16_080_000 as u64)
 			.saturating_add(RocksDbWeight::get().reads(3 as u64))
 			.saturating_add(RocksDbWeight::get().writes(1 as u64))
 	}
 	// Storage: EvmMigration MigrationPending (r:1 w:0)
 	// Storage: EVM AccountStorages (r:0 w:1)
 	fn set_data(b: u32, ) -> Weight {
-		Weight::from_ref_time(3_076_000)
-			// Standard Error: 0
-			.saturating_add(Weight::from_ref_time(828_000).saturating_mul(b as u64))
+		Weight::from_ref_time(7_945_000 as u64)
+			// Standard Error: 1_272
+			.saturating_add(Weight::from_ref_time(1_056_832 as u64).saturating_mul(b as u64))
 			.saturating_add(RocksDbWeight::get().reads(1 as u64))
 			.saturating_add(RocksDbWeight::get().writes((1 as u64).saturating_mul(b as u64)))
 	}
 	// Storage: EvmMigration MigrationPending (r:1 w:1)
 	// Storage: EVM AccountCodes (r:0 w:1)
-	fn finish(_b: u32, ) -> Weight {
-		Weight::from_ref_time(6_591_000)
+	fn finish(b: u32, ) -> Weight {
+		Weight::from_ref_time(8_336_000 as u64)
+			// Standard Error: 89
+			.saturating_add(Weight::from_ref_time(6_411 as u64).saturating_mul(b as u64))
 			.saturating_add(RocksDbWeight::get().reads(1 as u64))
 			.saturating_add(RocksDbWeight::get().writes(2 as u64))
 	}
+	fn insert_eth_logs(b: u32, ) -> Weight {
+		Weight::from_ref_time(3_447_000 as u64)
+			// Standard Error: 843
+			.saturating_add(Weight::from_ref_time(901_039 as u64).saturating_mul(b as u64))
+	}
+	fn insert_events(b: u32, ) -> Weight {
+		Weight::from_ref_time(3_457_000 as u64)
+			// Standard Error: 1_460
+			.saturating_add(Weight::from_ref_time(1_491_611 as u64).saturating_mul(b as u64))
+	}
 }
modifiedruntime/common/config/ethereum.rsdiffbeforeafterboth
--- a/runtime/common/config/ethereum.rs
+++ b/runtime/common/config/ethereum.rs
@@ -91,6 +91,7 @@
 }
 
 impl pallet_evm_migration::Config for Runtime {
+	type RuntimeEvent = RuntimeEvent;
 	type WeightInfo = pallet_evm_migration::weights::SubstrateWeight<Self>;
 }
 
modifiedruntime/common/construct_runtime/mod.rsdiffbeforeafterboth
--- a/runtime/common/construct_runtime/mod.rs
+++ b/runtime/common/construct_runtime/mod.rs
@@ -92,7 +92,7 @@
                 EvmCoderSubstrate: pallet_evm_coder_substrate::{Pallet, Storage} = 150,
                 EvmContractHelpers: pallet_evm_contract_helpers::{Pallet, Storage, Event<T>} = 151,
                 EvmTransactionPayment: pallet_evm_transaction_payment::{Pallet} = 152,
-                EvmMigration: pallet_evm_migration::{Pallet, Call, Storage} = 153,
+                EvmMigration: pallet_evm_migration::{Pallet, Call, Storage, Event<T>} = 153,
 
                 Maintenance: pallet_maintenance::{Pallet, Call, Storage, Event<T>} = 154,
 
modifiedtests/src/eth/migration.seqtest.tsdiffbeforeafterboth
--- a/tests/src/eth/migration.seqtest.ts
+++ b/tests/src/eth/migration.seqtest.ts
@@ -16,16 +16,36 @@
 
 import {expect, itEth, usingEthPlaygrounds} from './util';
 import {IKeyringPair} from '@polkadot/types/types';
+import {Struct} from '@polkadot/types';
+
+import {IEvent} from '../util/playgrounds/types';
+import {ApiPromise} from '@polkadot/api';
+
+const encodeEvent = (api: ApiPromise, pallet: string, palletEvents: string, event: string, fields: any) => {
+  const palletIndex = api.runtimeMetadata.asV14.pallets.find(p => p.name.toString() == pallet)!.index.toNumber();
+  const eventMeta = api.events[palletEvents][event].meta;
+  const eventIndex = eventMeta.index.toNumber();
+  const data = [
+    palletIndex, eventIndex,
+  ];
+  const metaEvent = api.registry.findMetaEvent(new Uint8Array(data));
+  data.push(...new Struct(api.registry, {data: metaEvent}, {data: fields}).toU8a());
 
+  const typeName = api.registry.lookup.names.find(n => n.endsWith('RuntimeEvent'))!;
+  return api.registry.createType(typeName, new Uint8Array(data)).toHex();
+};
+
 describe('EVM Migrations', () => {
   let superuser: IKeyringPair;
+  let charlie: IKeyringPair;
 
   before(async function() {
     await usingEthPlaygrounds(async (_helper, privateKey) => {
       superuser = await privateKey('//Alice');
+      charlie = await privateKey('//Charlie');
     });
   });
-  
+
   // todo:playgrounds requires sudo, look into later
   itEth('Deploy contract saved state', async ({helper}) => {
     /*
@@ -105,4 +125,83 @@
       expect(await contract.methods.get(i).call()).to.be.equal(i.toString());
     }
   });
+  itEth('Fake collection creation on substrate side', async ({helper}) => {
+    const txInsertEvents = helper.constructApiCall('api.tx.evmMigration.insertEvents', [[
+      encodeEvent(helper.api!, 'Common', 'common', 'CollectionCreated', [
+        // Collection Id
+        9999,
+        // Collection mode: NFT
+        1,
+        // Owner
+        charlie.address,
+      ]),
+    ]]);
+    await helper.executeExtrinsic(superuser, 'api.tx.sudo.sudo', [txInsertEvents]);
+    const event = helper.chainLog[helper.chainLog.length - 1].events as IEvent[];
+    const eventStrings = event.map(e => `${e.section}.${e.method}`);
+
+    expect(eventStrings).to.contain('common.CollectionCreated');
+  });
+  itEth('Fake token creation on substrate side', async ({helper}) => {
+    const txInsertEvents = helper.constructApiCall('api.tx.evmMigration.insertEvents', [[
+      encodeEvent(helper.api!, 'Common', 'common', 'ItemCreated', [
+        // Collection Id
+        9999,
+        // TokenId
+        9999,
+        // Owner
+        {Substrate: charlie.address},
+        // Amount
+        1,
+      ]),
+    ]]);
+    await helper.executeExtrinsic(superuser, 'api.tx.sudo.sudo', [txInsertEvents]);
+    const event = helper.chainLog[helper.chainLog.length - 1].events as IEvent[];
+    const eventStrings = event.map(e => `${e.section}.${e.method}`);
+
+    expect(eventStrings).to.contain('common.ItemCreated');
+  });
+  itEth('Fake token creation on ethereum side', async ({helper}) => {
+    const collection = await helper.nft.mintCollection(superuser);
+    const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);
+    const caller = await helper.eth.createAccountWithBalance(superuser);
+    const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', caller);
+
+    const events: any = [];
+    contract.events.allEvents((_: any, event: any) => {
+      events.push(event);
+    });
+
+    {
+      const txInsertEthLogs = helper.constructApiCall('api.tx.evmMigration.insertEthLogs', [[
+        {
+        // Contract, which has emitted this log
+          address: collectionAddress,
+
+          topics: [
+            // First topic - event signature
+            helper.getWeb3().eth.abi.encodeEventSignature('Transfer(address,address,uint256)'),
+            // Rest of topics - indexed event fields in definition order
+            helper.getWeb3().eth.abi.encodeParameter('address', '0x' + '00'.repeat(20)),
+            helper.getWeb3().eth.abi.encodeParameter('address', caller),
+            helper.getWeb3().eth.abi.encodeParameter('uint256', 9999),
+          ],
+
+          // Every field coming from event, which is not marked as indexed, should be encoded here
+          // NFT transfer has no such fields, but here is an example for some other possible event:
+          // data: helper.getWeb3().eth.abi.encodeParameters(['uint256', 'address'], [22, collectionAddress])
+          data: [],
+        },
+      ]]);
+      await helper.executeExtrinsic(superuser, 'api.tx.sudo.sudo', [txInsertEthLogs]);
+    }
+
+    if (events.length == 0) await helper.wait.newBlocks(1);
+    const event = events[0];
+
+    expect(event.address).to.be.equal(collectionAddress);
+    expect(event.returnValues.from).to.be.equal('0x' + '00'.repeat(20));
+    expect(event.returnValues.to).to.be.equal(caller);
+    expect(event.returnValues.tokenId).to.be.equal('9999');
+  });
 });