From fe4e7633ea1166328b968f1134c96ff4d35cd281 Mon Sep 17 00:00:00 2001 From: Yaroslav Bolyukin Date: Fri, 13 May 2022 11:15:25 +0000 Subject: [PATCH] refactor: switch to new eth log logic --- --- a/Cargo.lock +++ b/Cargo.lock @@ -2555,7 +2555,7 @@ [[package]] name = "fc-consensus" version = "2.0.0-dev" -source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.21#4c0dea347d0388a7b261cbc36568170e288f3e7a" +source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.21-logs#79cd4c4cf29106c431facd6779783fc887b21475" dependencies = [ "async-trait", "fc-db", @@ -2574,7 +2574,7 @@ [[package]] name = "fc-db" version = "2.0.0-dev" -source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.21#4c0dea347d0388a7b261cbc36568170e288f3e7a" +source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.21-logs#79cd4c4cf29106c431facd6779783fc887b21475" dependencies = [ "fp-storage", "kvdb-rocksdb", @@ -2588,7 +2588,7 @@ [[package]] name = "fc-mapping-sync" version = "2.0.0-dev" -source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.21#4c0dea347d0388a7b261cbc36568170e288f3e7a" +source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.21-logs#79cd4c4cf29106c431facd6779783fc887b21475" dependencies = [ "fc-db", "fp-consensus", @@ -2605,7 +2605,7 @@ [[package]] name = "fc-rpc" version = "2.0.0-dev" -source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.21#4c0dea347d0388a7b261cbc36568170e288f3e7a" +source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.21-logs#79cd4c4cf29106c431facd6779783fc887b21475" dependencies = [ "ethereum", "ethereum-types", @@ -2644,7 +2644,7 @@ [[package]] name = "fc-rpc-core" version = "1.1.0-dev" -source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.21#4c0dea347d0388a7b261cbc36568170e288f3e7a" +source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.21-logs#79cd4c4cf29106c431facd6779783fc887b21475" dependencies = [ "ethereum", "ethereum-types", @@ -2777,7 +2777,7 @@ [[package]] name = "fp-consensus" version = "2.0.0-dev" -source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.21#4c0dea347d0388a7b261cbc36568170e288f3e7a" +source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.21-logs#79cd4c4cf29106c431facd6779783fc887b21475" dependencies = [ "ethereum", "parity-scale-codec", @@ -2789,7 +2789,7 @@ [[package]] name = "fp-evm" version = "3.0.0-dev" -source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.21#4c0dea347d0388a7b261cbc36568170e288f3e7a" +source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.21-logs#79cd4c4cf29106c431facd6779783fc887b21475" dependencies = [ "evm", "impl-trait-for-tuples", @@ -2802,7 +2802,7 @@ [[package]] name = "fp-evm-mapping" version = "0.1.0" -source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.21#4c0dea347d0388a7b261cbc36568170e288f3e7a" +source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.21-logs#79cd4c4cf29106c431facd6779783fc887b21475" dependencies = [ "frame-support", "sp-core", @@ -2811,7 +2811,7 @@ [[package]] name = "fp-rpc" version = "3.0.0-dev" -source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.21#4c0dea347d0388a7b261cbc36568170e288f3e7a" +source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.21-logs#79cd4c4cf29106c431facd6779783fc887b21475" dependencies = [ "ethereum", "ethereum-types", @@ -2828,7 +2828,7 @@ [[package]] name = "fp-self-contained" version = "1.0.0-dev" -source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.21#4c0dea347d0388a7b261cbc36568170e288f3e7a" +source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.21-logs#79cd4c4cf29106c431facd6779783fc887b21475" dependencies = [ "ethereum", "frame-support", @@ -2844,7 +2844,7 @@ [[package]] name = "fp-storage" version = "2.0.0" -source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.21#4c0dea347d0388a7b261cbc36568170e288f3e7a" +source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.21-logs#79cd4c4cf29106c431facd6779783fc887b21475" dependencies = [ "parity-scale-codec", ] @@ -5741,7 +5741,7 @@ [[package]] name = "pallet-base-fee" version = "1.0.0" -source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.21#4c0dea347d0388a7b261cbc36568170e288f3e7a" +source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.21-logs#79cd4c4cf29106c431facd6779783fc887b21475" dependencies = [ "fp-evm", "frame-support", @@ -5999,7 +5999,7 @@ [[package]] name = "pallet-ethereum" version = "4.0.0-dev" -source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.21#4c0dea347d0388a7b261cbc36568170e288f3e7a" +source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.21-logs#79cd4c4cf29106c431facd6779783fc887b21475" dependencies = [ "ethereum", "ethereum-types", @@ -6029,7 +6029,7 @@ [[package]] name = "pallet-evm" version = "6.0.0-dev" -source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.21#4c0dea347d0388a7b261cbc36568170e288f3e7a" +source = "git+https://github.com/uniquenetwork/frontier?branch=unique-polkadot-v0.9.21-logs#79cd4c4cf29106c431facd6779783fc887b21475" dependencies = [ "evm", "fp-evm", --- a/client/rpc/Cargo.toml +++ b/client/rpc/Cargo.toml @@ -18,4 +18,4 @@ sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" } sp-rpc = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" } sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" } -pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" } +pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" } --- a/node/cli/Cargo.toml +++ b/node/cli/Cargo.toml @@ -306,13 +306,13 @@ jsonrpc-pubsub = "18.0.0" tokio = { version = "1.17.0", features = ["time"] } -fc-rpc-core = { git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" } -fc-consensus = { git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" } -fc-mapping-sync = { git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" } -fc-rpc = { git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" } -fc-db = { git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" } -fp-rpc = { git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" } -pallet-ethereum = { git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" } +fc-rpc-core = { git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" } +fc-consensus = { git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" } +fc-mapping-sync = { git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" } +fc-rpc = { git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" } +fc-db = { git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" } +fp-rpc = { git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" } +pallet-ethereum = { git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" } unique-rpc = { default-features = false, path = "../rpc" } --- a/node/rpc/Cargo.toml +++ b/node/rpc/Cargo.toml @@ -41,13 +41,13 @@ substrate-frame-rpc-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" } tokio = { version = "0.2.25", features = ["macros", "sync"] } -pallet-ethereum = { git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" } -fc-rpc = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" } -fp-rpc = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" } -fp-storage = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" } -fc-rpc-core = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" } -fc-db = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" } -fc-mapping-sync = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" } +pallet-ethereum = { git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" } +fc-rpc = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" } +fp-rpc = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" } +fp-storage = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" } +fc-rpc-core = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" } +fc-db = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" } +fc-mapping-sync = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" } pallet-common = { default-features = false, path = "../../pallets/common" } unique-runtime-common = { default-features = false, path = "../../runtime/common" } --- a/pallets/common/Cargo.toml +++ b/pallets/common/Cargo.toml @@ -16,11 +16,11 @@ sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" } sp-std = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" } sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" } -fp-evm-mapping = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" } +fp-evm-mapping = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" } up-data-structs = { default-features = false, path = '../../primitives/data-structs' } pallet-evm-coder-substrate = { default-features = false, path = '../../pallets/evm-coder-substrate' } evm-coder = { default-features = false, path = '../../crates/evm-coder' } -pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" } +pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" } serde = { version = "1.0.130", default-features = false } scale-info = { version = "2.0.1", default-features = false, features = [ "derive", --- a/pallets/common/src/dispatch.rs +++ b/pallets/common/src/dispatch.rs @@ -52,8 +52,6 @@ }) => *weight += dispatch_weight::(), _ => {} } - - dispatched.into_inner().submit_logs(); result } --- a/pallets/common/src/lib.rs +++ b/pallets/common/src/lib.rs @@ -66,7 +66,7 @@ >::get(id).map(|collection| Self { id, collection, - recorder: SubstrateRecorder::new(eth::collection_id_to_address(id), gas_limit), + recorder: SubstrateRecorder::new(gas_limit), }) } pub fn new(id: CollectionId) -> Option { @@ -74,12 +74,6 @@ } pub fn try_get(id: CollectionId) -> Result { Ok(Self::new(id).ok_or(>::CollectionNotFound)?) - } - pub fn log_mirrored(&self, log: impl evm_coder::ToLog) { - self.recorder.log_mirrored(log) - } - pub fn log_direct(&self, log: impl evm_coder::ToLog) { - self.recorder.log_direct(log) } pub fn consume_store_reads(&self, reads: u64) -> evm_coder::execution::Result<()> { self.recorder @@ -96,12 +90,8 @@ .write .saturating_mul(writes), )) - } - pub fn submit_logs(self) { - self.recorder.submit_logs() } pub fn save(self) -> DispatchResult { - self.recorder.submit_logs(); >::insert(self.id, self.collection); Ok(()) } --- a/pallets/evm-coder-substrate/Cargo.toml +++ b/pallets/evm-coder-substrate/Cargo.toml @@ -12,8 +12,8 @@ sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" } ethereum = { version = "0.12.0", default-features = false } evm-coder = { default-features = false, path = "../../crates/evm-coder" } -pallet-ethereum = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" } -pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" } +pallet-ethereum = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" } +pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" } frame-support = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" } frame-system = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" } frame-benchmarking = { default-features = false, optional = true, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" } --- a/pallets/evm-coder-substrate/src/lib.rs +++ b/pallets/evm-coder-substrate/src/lib.rs @@ -24,7 +24,6 @@ use core::marker::PhantomData; use sp_std::cell::RefCell; -use sp_std::vec::Vec; use codec::Decode; use frame_support::pallet_prelude::DispatchError; @@ -33,15 +32,13 @@ use up_data_structs::budget; use pallet_evm::{ ExitError, ExitRevert, ExitSucceed, GasWeightMapping, PrecompileFailure, PrecompileOutput, - PrecompileResult, runner::stack::MaybeMirroredLog, + PrecompileResult, }; use sp_core::H160; -use pallet_ethereum::EthereumTransactionSender; // #[cfg(feature = "runtime-benchmarks")] // pub mod benchmarking; use evm_coder::{ - ToLog, abi::{AbiReader, AbiWrite, AbiWriter}, execution::{self, Result}, types::{Msg, value}, @@ -70,7 +67,6 @@ #[pallet::config] pub trait Config: frame_system::Config { - type EthereumTransactionSender: pallet_ethereum::EthereumTransactionSender; type GasWeightMapping: pallet_evm::GasWeightMapping; } @@ -107,43 +103,20 @@ #[derive(Default)] pub struct SubstrateRecorder { - contract: H160, - logs: RefCell>, initial_gas: u64, gas_limit: RefCell, _phantom: PhantomData<*const T>, } impl SubstrateRecorder { - pub fn new(contract: H160, gas_limit: u64) -> Self { + pub fn new(gas_limit: u64) -> Self { Self { - contract, - logs: RefCell::new(Vec::new()), initial_gas: gas_limit, gas_limit: RefCell::new(gas_limit), _phantom: PhantomData, } } - pub fn is_empty(&self) -> bool { - self.logs.borrow().is_empty() - } - // Logs emitted with log_direct appear as substrate evm.Log event - pub fn log_direct(&self, log: impl ToLog) { - self.logs - .borrow_mut() - .push(MaybeMirroredLog::direct(log.to_log(self.contract))) - } - /// If log already has substrate equivalent - then we don't need to emit evm.Log - pub fn log_mirrored(&self, log: impl ToLog) { - self.logs - .borrow_mut() - .push(MaybeMirroredLog::mirrored(log.to_log(self.contract))) - } - pub fn retrieve_logs(self) -> Vec { - self.logs.into_inner() - } - pub fn gas_left(&self) -> u64 { *self.gas_limit.borrow() } @@ -207,8 +180,8 @@ Ok(Some(v)) => Ok(PrecompileOutput { exit_status: ExitSucceed::Returned, cost: self.initial_gas - self.gas_left(), - // TODO: preserve mirroring status - logs: self.retrieve_logs().into_iter().map(|l| l.log).collect(), + // We don't use this interface + logs: sp_std::vec![], output: v.finish(), }), Ok(None) => return None, @@ -225,14 +198,6 @@ Err(Error::Fatal(f)) => Err(f.into()), Err(Error::Error(e)) => Err(e.into()), }) - } - - pub fn submit_logs(self) { - let logs = self.retrieve_logs(); - if logs.is_empty() { - return; - } - T::EthereumTransactionSender::submit_logs_transaction(Default::default(), logs) } } --- a/pallets/evm-contract-helpers/Cargo.toml +++ b/pallets/evm-contract-helpers/Cargo.toml @@ -15,8 +15,8 @@ sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" } evm-coder = { default-features = false, path = '../../crates/evm-coder' } pallet-evm-coder-substrate = { default-features = false, path = '../../pallets/evm-coder-substrate' } -pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" } -fp-evm-mapping = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" } +pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" } +fp-evm-mapping = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" } up-sponsorship = { version = "0.1.0", default-features = false, git = "https://github.com/uniquenetwork/pallet-sponsoring", branch = "polkadot-v0.9.21" } log = "0.4.14" --- a/pallets/evm-contract-helpers/src/eth.rs +++ b/pallets/evm-contract-helpers/src/eth.rs @@ -162,7 +162,7 @@ return None; } - let helpers = ContractHelpers::(SubstrateRecorder::::new(*target, gas_left)); + let helpers = ContractHelpers::(SubstrateRecorder::::new(gas_left)); pallet_evm_coder_substrate::call(*source, helpers, value, input) } --- a/pallets/evm-migration/Cargo.toml +++ b/pallets/evm-migration/Cargo.toml @@ -15,8 +15,8 @@ sp-std = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" } sp-io = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" } sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" } -pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" } -fp-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" } +pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" } +fp-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" } [dependencies.codec] default-features = false --- a/pallets/evm-migration/src/lib.rs +++ b/pallets/evm-migration/src/lib.rs @@ -28,6 +28,7 @@ use sp_core::{H160, H256}; use sp_std::vec::Vec; use super::weights::WeightInfo; + use pallet_evm::Pallet as PalletEvm; #[pallet::config] pub trait Config: frame_system::Config + pallet_evm::Config { @@ -56,8 +57,7 @@ pub fn begin(origin: OriginFor, address: H160) -> DispatchResult { ensure_root(origin)?; ensure!( - >::is_account_empty(&address) - && !>::get(&address), + >::is_account_empty(&address) && !>::get(&address), >::AccountNotEmpty, ); --- a/pallets/evm-transaction-payment/Cargo.toml +++ b/pallets/evm-transaction-payment/Cargo.toml @@ -14,11 +14,11 @@ sp-std = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" } sp-io = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" } sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" } -pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" } -fp-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" } -pallet-ethereum = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" } +pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" } +fp-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" } +pallet-ethereum = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" } up-sponsorship = { version = "0.1.0", default-features = false, git = "https://github.com/uniquenetwork/pallet-sponsoring", branch = "polkadot-v0.9.21" } -fp-evm-mapping = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" } +fp-evm-mapping = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" } [dependencies.codec] default-features = false --- a/pallets/fungible/Cargo.toml +++ b/pallets/fungible/Cargo.toml @@ -23,7 +23,7 @@ pallet-evm-coder-substrate = { default-features = false, path = '../evm-coder-substrate' } ethereum = { version = "0.12.0", default-features = false } frame-benchmarking = { default-features = false, optional = true, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" } -pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" } +pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" } scale-info = { version = "2.0.1", default-features = false, features = [ "derive", ] } --- a/pallets/fungible/src/lib.rs +++ b/pallets/fungible/src/lib.rs @@ -17,6 +17,7 @@ #![cfg_attr(not(feature = "std"), no_std)] use core::ops::Deref; +use evm_coder::ToLog; use frame_support::{ensure}; use pallet_evm::account::CrossAccountId; use up_data_structs::{ @@ -25,8 +26,9 @@ }; use pallet_common::{ Error as CommonError, Event as CommonEvent, Pallet as PalletCommon, CollectionHandle, - dispatch::CollectionDispatch, + dispatch::CollectionDispatch, eth::collection_id_to_address, }; +use pallet_evm::Pallet as PalletEvm; use pallet_structure::Pallet as PalletStructure; use pallet_evm_coder_substrate::WithRecorder; use sp_core::H160; @@ -67,7 +69,7 @@ #[pallet::config] pub trait Config: - frame_system::Config + pallet_common::Config + pallet_structure::Config + frame_system::Config + pallet_common::Config + pallet_structure::Config + pallet_evm::Config { type WeightInfo: WeightInfo; } @@ -179,11 +181,14 @@ } >::insert(collection.id, total_supply); - collection.log_mirrored(ERC20Events::Transfer { - from: *owner.as_eth(), - to: H160::default(), - value: amount.into(), - }); + >::deposit_log( + ERC20Events::Transfer { + from: *owner.as_eth(), + to: H160::default(), + value: amount.into(), + } + .to_log(collection_id_to_address(collection.id)), + ); >::deposit_event(CommonEvent::ItemDestroyed( collection.id, TokenId::default(), @@ -249,11 +254,14 @@ >::insert((collection.id, to), balance_to); } - collection.log_mirrored(ERC20Events::Transfer { - from: *from.as_eth(), - to: *to.as_eth(), - value: amount.into(), - }); + >::deposit_log( + ERC20Events::Transfer { + from: *from.as_eth(), + to: *to.as_eth(), + value: amount.into(), + } + .to_log(collection_id_to_address(collection.id)), + ); >::deposit_event(CommonEvent::Transfer( collection.id, TokenId::default(), @@ -318,11 +326,14 @@ for (user, amount) in balances { >::insert((collection.id, &user), amount); - collection.log_mirrored(ERC20Events::Transfer { - from: H160::default(), - to: *user.as_eth(), - value: amount.into(), - }); + >::deposit_log( + ERC20Events::Transfer { + from: H160::default(), + to: *user.as_eth(), + value: amount.into(), + } + .to_log(collection_id_to_address(collection.id)), + ); >::deposit_event(CommonEvent::ItemCreated( collection.id, TokenId::default(), @@ -346,11 +357,14 @@ >::insert((collection.id, owner, spender), amount); } - collection.log_mirrored(ERC20Events::Approval { - owner: *owner.as_eth(), - spender: *spender.as_eth(), - value: amount.into(), - }); + >::deposit_log( + ERC20Events::Approval { + owner: *owner.as_eth(), + spender: *spender.as_eth(), + value: amount.into(), + } + .to_log(collection_id_to_address(collection.id)), + ); >::deposit_event(CommonEvent::Approved( collection.id, TokenId(0), --- a/pallets/fungible/src/stubs/UniqueFungible.sol +++ b/pallets/fungible/src/stubs/UniqueFungible.sol @@ -8,13 +8,8 @@ uint8 dummy; string stub_error = "this contract is implemented in native"; } - contract ERC165 is Dummy { - function supportsInterface(bytes4 interfaceID) - external - view - returns (bool) - { + function supportsInterface(bytes4 interfaceID) external view returns (bool) { require(false, stub_error); interfaceID; return true; @@ -24,11 +19,36 @@ // Inline contract ERC20Events { event Transfer(address indexed from, address indexed to, uint256 value); - event Approval( - address indexed owner, - address indexed spender, - uint256 value - ); + event Approval(address indexed owner, address indexed spender, uint256 value); +} + +// Selector: 56fd500b +contract CollectionProperties is Dummy, ERC165 { + // Selector: setProperty(string,string) 62d9491f + function setProperty(string memory key, string memory value) public { + require(false, stub_error); + key; + value; + dummy = 0; + } + // Selector: deleteProperty(string) 34241914 + function deleteProperty(string memory key) public { + require(false, stub_error); + key; + dummy = 0; + } +} + +// Selector: 79cc6790 +contract ERC20UniqueExtensions is Dummy, ERC165 { + // Selector: burnFrom(address,uint256) 79cc6790 + function burnFrom(address from, uint256 amount) public returns (bool) { + require(false, stub_error); + from; + amount; + dummy = 0; + return false; + } } // Selector: 942e8b22 @@ -39,28 +59,24 @@ dummy; return ""; } - // Selector: symbol() 95d89b41 function symbol() public view returns (string memory) { require(false, stub_error); dummy; return ""; } - // Selector: totalSupply() 18160ddd function totalSupply() public view returns (uint256) { require(false, stub_error); dummy; return 0; } - // Selector: decimals() 313ce567 function decimals() public view returns (uint8) { require(false, stub_error); dummy; return 0; } - // Selector: balanceOf(address) 70a08231 function balanceOf(address owner) public view returns (uint256) { require(false, stub_error); @@ -68,7 +84,6 @@ dummy; return 0; } - // Selector: transfer(address,uint256) a9059cbb function transfer(address to, uint256 amount) public returns (bool) { require(false, stub_error); @@ -77,13 +92,8 @@ dummy = 0; return false; } - // Selector: transferFrom(address,address,uint256) 23b872dd - function transferFrom( - address from, - address to, - uint256 amount - ) public returns (bool) { + function transferFrom(address from, address to, uint256 amount) public returns (bool) { require(false, stub_error); from; to; @@ -91,7 +101,6 @@ dummy = 0; return false; } - // Selector: approve(address,uint256) 095ea7b3 function approve(address spender, uint256 amount) public returns (bool) { require(false, stub_error); @@ -100,13 +109,8 @@ dummy = 0; return false; } - // Selector: allowance(address,address) dd62ed3e - function allowance(address owner, address spender) - public - view - returns (uint256) - { + function allowance(address owner, address spender) public view returns (uint256) { require(false, stub_error); owner; spender; @@ -115,4 +119,6 @@ } } -contract UniqueFungible is Dummy, ERC165, ERC20 {} +contract UniqueFungible is Dummy, ERC165, ERC20, ERC20UniqueExtensions, CollectionProperties { +} + --- a/pallets/nonfungible/Cargo.toml +++ b/pallets/nonfungible/Cargo.toml @@ -16,7 +16,7 @@ sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" } sp-std = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" } sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" } -pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" } +pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" } pallet-common = { default-features = false, path = '../common' } pallet-structure = { default-features = false, path = '../structure' } up-data-structs = { default-features = false, path = '../../primitives/data-structs' } --- a/pallets/nonfungible/src/lib.rs +++ b/pallets/nonfungible/src/lib.rs @@ -17,16 +17,17 @@ #![cfg_attr(not(feature = "std"), no_std)] use erc::ERC721Events; +use evm_coder::ToLog; use frame_support::{BoundedVec, ensure, fail}; use up_data_structs::{ AccessMode, CollectionId, CustomDataLimit, TokenId, CreateCollectionData, CreateNftExData, mapping::TokenAddressMapping, NestingRule, budget::Budget, Property, PropertyPermission, PropertyKey, PropertyKeyPermission, Properties, TrySet, }; -use pallet_evm::account::CrossAccountId; +use pallet_evm::{account::CrossAccountId, Pallet as PalletEvm}; use pallet_common::{ Error as CommonError, Pallet as PalletCommon, Event as CommonEvent, CollectionHandle, - dispatch::CollectionDispatch, + dispatch::CollectionDispatch, eth::collection_id_to_address, }; use pallet_structure::Pallet as PalletStructure; use pallet_evm_coder_substrate::{SubstrateRecorder, WithRecorder}; @@ -72,7 +73,7 @@ #[pallet::config] pub trait Config: - frame_system::Config + pallet_common::Config + pallet_structure::Config + frame_system::Config + pallet_common::Config + pallet_structure::Config + pallet_evm::Config { type WeightInfo: WeightInfo; } @@ -245,11 +246,14 @@ )); } - collection.log_mirrored(ERC721Events::Transfer { - from: *token_data.owner.as_eth(), - to: H160::default(), - token_id: token.into(), - }); + >::deposit_log( + ERC721Events::Transfer { + from: *token_data.owner.as_eth(), + to: H160::default(), + token_id: token.into(), + } + .to_log(collection_id_to_address(collection.id)), + ); >::deposit_event(CommonEvent::ItemDestroyed( collection.id, token, @@ -357,7 +361,7 @@ } if token_owner { - check_result.or(check_token_owner()) + check_result.and_then(|()| check_token_owner()) } else { check_result } @@ -483,11 +487,14 @@ } Self::set_allowance_unchecked(collection, from, token, None, true); - collection.log_mirrored(ERC721Events::Transfer { - from: *from.as_eth(), - to: *to.as_eth(), - token_id: token.into(), - }); + >::deposit_log( + ERC721Events::Transfer { + from: *from.as_eth(), + to: *to.as_eth(), + token_id: token.into(), + } + .to_log(collection_id_to_address(collection.id)), + ); >::deposit_event(CommonEvent::Transfer( collection.id, token, @@ -583,11 +590,14 @@ data.properties.into_inner(), )?; - collection.log_mirrored(ERC721Events::Transfer { - from: H160::default(), - to: *data.owner.as_eth(), - token_id: token.into(), - }); + >::deposit_log( + ERC721Events::Transfer { + from: H160::default(), + to: *data.owner.as_eth(), + token_id: token.into(), + } + .to_log(collection_id_to_address(collection.id)), + ); >::deposit_event(CommonEvent::ItemCreated( collection.id, TokenId(token), @@ -610,11 +620,14 @@ >::insert((collection.id, token), spender); // In ERC721 there is only one possible approved user of token, so we set // approved user to spender - collection.log_mirrored(ERC721Events::Approval { - owner: *sender.as_eth(), - approved: *spender.as_eth(), - token_id: token.into(), - }); + >::deposit_log( + ERC721Events::Approval { + owner: *sender.as_eth(), + approved: *spender.as_eth(), + token_id: token.into(), + } + .to_log(collection_id_to_address(collection.id)), + ); // In Unique chain, any token can have any amount of approved users, so we need to // set allowance of old owner to 0, and allowance of new owner to 1 if old_spender.as_ref() != Some(spender) { @@ -640,11 +653,14 @@ if !assume_implicit_eth { // In ERC721 there is only one possible approved user of token, so we set // approved user to zero address - collection.log_mirrored(ERC721Events::Approval { - owner: *sender.as_eth(), - approved: H160::default(), - token_id: token.into(), - }); + >::deposit_log( + ERC721Events::Approval { + owner: *sender.as_eth(), + approved: H160::default(), + token_id: token.into(), + } + .to_log(collection_id_to_address(collection.id)), + ); } // In Unique chain, any token can have any amount of approved users, so we need to // set allowance of old owner to 0 --- a/pallets/refungible/Cargo.toml +++ b/pallets/refungible/Cargo.toml @@ -16,7 +16,7 @@ sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" } sp-std = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" } sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" } -pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" } +pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" } pallet-common = { default-features = false, path = '../common' } pallet-structure = { default-features = false, path = '../structure' } up-data-structs = { default-features = false, path = '../../primitives/data-structs' } --- a/pallets/unique/Cargo.toml +++ b/pallets/unique/Cargo.toml @@ -83,5 +83,5 @@ scale-info = { version = "2.0.1", default-features = false, features = [ "derive", ] } -pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" } +pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" } pallet-common = { default-features = false, path = "../common" } --- a/primitives/data-structs/Cargo.toml +++ b/primitives/data-structs/Cargo.toml @@ -23,9 +23,9 @@ sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" } sp-std = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" } sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" } -derivative = "2.2.0" +derivative = { version = "2.2.0", features = ["use_core"] } struct-versioning = { path = "../../crates/struct-versioning" } -pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" } +pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" } [features] default = ["std"] --- a/primitives/rpc/Cargo.toml +++ b/primitives/rpc/Cargo.toml @@ -14,7 +14,7 @@ sp-std = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" } sp-api = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" } sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.21" } -pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" } +pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" } [features] default = ["std"] --- a/runtime/common/Cargo.toml +++ b/runtime/common/Cargo.toml @@ -101,9 +101,9 @@ [dependencies.fp-rpc] default-features = false git = "https://github.com/uniquenetwork/frontier" -branch = "unique-polkadot-v0.9.21" +branch = "unique-polkadot-v0.9.21-logs" [dependencies] -pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" } +pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" } evm-coder = { default-features = false, path = '../../crates/evm-coder' } up-sponsorship = { default-features = false, git = "https://github.com/uniquenetwork/pallet-sponsoring", branch = 'polkadot-v0.9.21' } --- a/runtime/opal/Cargo.toml +++ b/runtime/opal/Cargo.toml @@ -397,7 +397,7 @@ derivative = "2.2.0" pallet-unique = { path = '../../pallets/unique', default-features = false } up-rpc = { path = "../../primitives/rpc", default-features = false } -fp-evm-mapping = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" } +fp-evm-mapping = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" } pallet-inflation = { path = '../../pallets/inflation', default-features = false } up-data-structs = { path = '../../primitives/data-structs', default-features = false } pallet-common = { default-features = false, path = "../../pallets/common" } @@ -412,11 +412,11 @@ pallet-evm-contract-helpers = { path = '../../pallets/evm-contract-helpers', default-features = false } pallet-evm-transaction-payment = { path = '../../pallets/evm-transaction-payment', default-features = false } pallet-evm-coder-substrate = { default-features = false, path = "../../pallets/evm-coder-substrate" } -pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" } -pallet-ethereum = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" } -pallet-base-fee = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" } -fp-rpc = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" } -fp-self-contained = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" } +pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" } +pallet-ethereum = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" } +pallet-base-fee = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" } +fp-rpc = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" } +fp-self-contained = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" } ################################################################################ # Build Dependencies --- a/runtime/opal/src/lib.rs +++ b/runtime/opal/src/lib.rs @@ -821,7 +821,6 @@ ); impl pallet_evm_coder_substrate::Config for Runtime { - type EthereumTransactionSender = pallet_ethereum::Pallet; type GasWeightMapping = FixedGasWeightMapping; } @@ -1070,6 +1069,7 @@ frame_system::CheckWeight, pallet_charge_transaction::ChargeTransactionPayment, //pallet_contract_helpers::ContractHelpersExtension, + pallet_ethereum::FakeTransactionFinalizer, ); /// Unchecked extrinsic type as expected by this runtime. pub type UncheckedExtrinsic = --- a/runtime/quartz/Cargo.toml +++ b/runtime/quartz/Cargo.toml @@ -397,7 +397,7 @@ derivative = "2.2.0" pallet-unique = { path = '../../pallets/unique', default-features = false } up-rpc = { path = "../../primitives/rpc", default-features = false } -fp-evm-mapping = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" } +fp-evm-mapping = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" } pallet-inflation = { path = '../../pallets/inflation', default-features = false } up-data-structs = { path = '../../primitives/data-structs', default-features = false } pallet-common = { default-features = false, path = "../../pallets/common" } @@ -412,11 +412,11 @@ pallet-evm-contract-helpers = { path = '../../pallets/evm-contract-helpers', default-features = false } pallet-evm-transaction-payment = { path = '../../pallets/evm-transaction-payment', default-features = false } pallet-evm-coder-substrate = { default-features = false, path = "../../pallets/evm-coder-substrate" } -pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" } -pallet-ethereum = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" } -pallet-base-fee = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" } -fp-rpc = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" } -fp-self-contained = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" } +pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" } +pallet-ethereum = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" } +pallet-base-fee = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" } +fp-rpc = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" } +fp-self-contained = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" } ################################################################################ # Build Dependencies --- a/runtime/quartz/src/lib.rs +++ b/runtime/quartz/src/lib.rs @@ -793,7 +793,6 @@ ); impl pallet_evm_coder_substrate::Config for Runtime { - type EthereumTransactionSender = pallet_ethereum::Pallet; type GasWeightMapping = FixedGasWeightMapping; } @@ -1048,6 +1047,7 @@ frame_system::CheckWeight, pallet_charge_transaction::ChargeTransactionPayment, //pallet_contract_helpers::ContractHelpersExtension, + pallet_ethereum::FakeTransactionFinalizer, ); /// Unchecked extrinsic type as expected by this runtime. pub type UncheckedExtrinsic = --- a/runtime/tests/Cargo.toml +++ b/runtime/tests/Cargo.toml @@ -12,7 +12,7 @@ sp-io = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.21' } sp-runtime = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.21' } -fp-evm-mapping = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" } +fp-evm-mapping = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" } frame-support = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.21' } frame-system = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.21' } @@ -21,8 +21,8 @@ pallet-transaction-payment = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.21' } pallet-timestamp = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.21' } -pallet-evm = { default-features = false, git = 'https://github.com/uniquenetwork/frontier', branch = 'unique-polkadot-v0.9.21' } -pallet-ethereum = { default-features = false, git = 'https://github.com/uniquenetwork/frontier', branch = 'unique-polkadot-v0.9.21' } +pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" } +pallet-ethereum = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" } pallet-common = { path = '../../pallets/common' } pallet-structure = { path = '../../pallets/structure' } --- a/runtime/tests/src/lib.rs +++ b/runtime/tests/src/lib.rs @@ -16,10 +16,10 @@ #![allow(clippy::from_over_into)] -use sp_core::{H160, H256}; +use sp_core::{H256, U256}; use frame_support::{ parameter_types, - traits::{Everything, ConstU32}, + traits::{Everything, ConstU32, ConstU64}, weights::IdentityFee, }; use sp_runtime::{ @@ -28,7 +28,9 @@ }; use pallet_transaction_payment::{CurrencyAdapter}; use frame_system as system; -use pallet_evm::{AddressMapping, runner::stack::MaybeMirroredLog, account::CrossAccountId}; +use pallet_evm::{ + AddressMapping, account::CrossAccountId, EnsureAddressNever, SubstrateBlockHashMapping, +}; use fp_evm_mapping::EvmBackwardsAddressMapping; use parity_scale_codec::{Encode, Decode, MaxEncodedLen}; use scale_info::TypeInfo; @@ -181,13 +183,31 @@ } } -pub struct TestEtheremTransactionSender; -impl pallet_ethereum::EthereumTransactionSender for TestEtheremTransactionSender { - fn submit_logs_transaction(_source: H160, _logs: Vec) {} +parameter_types! { + pub BlockGasLimit: U256 = 0u32.into(); } +impl pallet_evm::Config for Test { + type Event = (); + type FeeCalculator = (); + type GasWeightMapping = (); + type CallOrigin = EnsureAddressNever; + type WithdrawOrigin = EnsureAddressNever; + type AddressMapping = TestEvmAddressMapping; + type Currency = Balances; + type PrecompilesType = (); + type PrecompilesValue = (); + type Runner = pallet_evm::runner::stack::Runner; + type ChainId = ConstU64<0>; + type BlockGasLimit = BlockGasLimit; + type OnMethodCall = (); + type OnCreate = (); + type OnChargeTransaction = (); + type FindAuthor = (); + type BlockHashMapping = SubstrateBlockHashMapping; + type TransactionValidityHack = (); +} impl pallet_evm_coder_substrate::Config for Test { - type EthereumTransactionSender = TestEtheremTransactionSender; type GasWeightMapping = (); } --- a/runtime/unique/Cargo.toml +++ b/runtime/unique/Cargo.toml @@ -411,12 +411,12 @@ pallet-evm-contract-helpers = { path = '../../pallets/evm-contract-helpers', default-features = false } pallet-evm-transaction-payment = { path = '../../pallets/evm-transaction-payment', default-features = false } pallet-evm-coder-substrate = { default-features = false, path = "../../pallets/evm-coder-substrate" } -pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" } -pallet-ethereum = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" } -pallet-base-fee = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" } -fp-rpc = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" } -fp-self-contained = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" } -fp-evm-mapping = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21" } +pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" } +pallet-ethereum = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" } +pallet-base-fee = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" } +fp-rpc = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" } +fp-self-contained = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" } +fp-evm-mapping = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.21-logs" } ################################################################################ # Build Dependencies --- a/runtime/unique/src/lib.rs +++ b/runtime/unique/src/lib.rs @@ -792,7 +792,6 @@ ); impl pallet_evm_coder_substrate::Config for Runtime { - type EthereumTransactionSender = pallet_ethereum::Pallet; type GasWeightMapping = FixedGasWeightMapping; } @@ -1046,6 +1045,7 @@ frame_system::CheckWeight, pallet_charge_transaction::ChargeTransactionPayment, //pallet_contract_helpers::ContractHelpersExtension, + pallet_ethereum::FakeTransactionFinalizer, ); /// Unchecked extrinsic type as expected by this runtime. pub type UncheckedExtrinsic = --- a/tests/src/substrate/substrate-api.ts +++ b/tests/src/substrate/substrate-api.ts @@ -34,6 +34,10 @@ extrinsic: {}, payload: {}, }, + FakeTransactionFinalizer: { + extrinsic: {}, + payload: {}, + }, }, rpc: { unique: defs.unique.rpc, -- gitstuff