difftreelog
refactor switch to new eth log logic
in: master
33 files changed
Cargo.lockdiffbeforeafterboth--- 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",
client/rpc/Cargo.tomldiffbeforeafterboth--- 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" }
node/cli/Cargo.tomldiffbeforeafterboth--- 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" }
node/rpc/Cargo.tomldiffbeforeafterboth--- 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" }
pallets/common/Cargo.tomldiffbeforeafterboth--- 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",
pallets/common/src/dispatch.rsdiffbeforeafterboth--- a/pallets/common/src/dispatch.rs
+++ b/pallets/common/src/dispatch.rs
@@ -52,8 +52,6 @@
}) => *weight += dispatch_weight::<T>(),
_ => {}
}
-
- dispatched.into_inner().submit_logs();
result
}
pallets/common/src/lib.rsdiffbeforeafterboth--- a/pallets/common/src/lib.rs
+++ b/pallets/common/src/lib.rs
@@ -66,7 +66,7 @@
<CollectionById<T>>::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<Self> {
@@ -74,12 +74,6 @@
}
pub fn try_get(id: CollectionId) -> Result<Self, DispatchError> {
Ok(Self::new(id).ok_or(<Error<T>>::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();
<CollectionById<T>>::insert(self.id, self.collection);
Ok(())
}
pallets/evm-coder-substrate/Cargo.tomldiffbeforeafterboth--- 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" }
pallets/evm-coder-substrate/src/lib.rsdiffbeforeafterboth--- 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<T: Config> {
- contract: H160,
- logs: RefCell<Vec<MaybeMirroredLog>>,
initial_gas: u64,
gas_limit: RefCell<u64>,
_phantom: PhantomData<*const T>,
}
impl<T: Config> SubstrateRecorder<T> {
- 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<MaybeMirroredLog> {
- 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)
}
}
pallets/evm-contract-helpers/Cargo.tomldiffbeforeafterboth--- 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"
pallets/evm-contract-helpers/src/eth.rsdiffbeforeafterboth--- 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::<T>(SubstrateRecorder::<T>::new(*target, gas_left));
+ let helpers = ContractHelpers::<T>(SubstrateRecorder::<T>::new(gas_left));
pallet_evm_coder_substrate::call(*source, helpers, value, input)
}
pallets/evm-migration/Cargo.tomldiffbeforeafterboth--- 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
pallets/evm-migration/src/lib.rsdiffbeforeafterboth--- 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<T>, address: H160) -> DispatchResult {
ensure_root(origin)?;
ensure!(
- <pallet_evm::Pallet<T>>::is_account_empty(&address)
- && !<MigrationPending<T>>::get(&address),
+ <PalletEvm<T>>::is_account_empty(&address) && !<MigrationPending<T>>::get(&address),
<Error<T>>::AccountNotEmpty,
);
pallets/evm-transaction-payment/Cargo.tomldiffbeforeafterboth--- 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
pallets/fungible/Cargo.tomldiffbeforeafterboth--- 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",
] }
pallets/fungible/src/lib.rsdiffbeforeafterboth--- 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 @@
}
<TotalSupply<T>>::insert(collection.id, total_supply);
- collection.log_mirrored(ERC20Events::Transfer {
- from: *owner.as_eth(),
- to: H160::default(),
- value: amount.into(),
- });
+ <PalletEvm<T>>::deposit_log(
+ ERC20Events::Transfer {
+ from: *owner.as_eth(),
+ to: H160::default(),
+ value: amount.into(),
+ }
+ .to_log(collection_id_to_address(collection.id)),
+ );
<PalletCommon<T>>::deposit_event(CommonEvent::ItemDestroyed(
collection.id,
TokenId::default(),
@@ -249,11 +254,14 @@
<Balance<T>>::insert((collection.id, to), balance_to);
}
- collection.log_mirrored(ERC20Events::Transfer {
- from: *from.as_eth(),
- to: *to.as_eth(),
- value: amount.into(),
- });
+ <PalletEvm<T>>::deposit_log(
+ ERC20Events::Transfer {
+ from: *from.as_eth(),
+ to: *to.as_eth(),
+ value: amount.into(),
+ }
+ .to_log(collection_id_to_address(collection.id)),
+ );
<PalletCommon<T>>::deposit_event(CommonEvent::Transfer(
collection.id,
TokenId::default(),
@@ -318,11 +326,14 @@
for (user, amount) in balances {
<Balance<T>>::insert((collection.id, &user), amount);
- collection.log_mirrored(ERC20Events::Transfer {
- from: H160::default(),
- to: *user.as_eth(),
- value: amount.into(),
- });
+ <PalletEvm<T>>::deposit_log(
+ ERC20Events::Transfer {
+ from: H160::default(),
+ to: *user.as_eth(),
+ value: amount.into(),
+ }
+ .to_log(collection_id_to_address(collection.id)),
+ );
<PalletCommon<T>>::deposit_event(CommonEvent::ItemCreated(
collection.id,
TokenId::default(),
@@ -346,11 +357,14 @@
<Allowance<T>>::insert((collection.id, owner, spender), amount);
}
- collection.log_mirrored(ERC20Events::Approval {
- owner: *owner.as_eth(),
- spender: *spender.as_eth(),
- value: amount.into(),
- });
+ <PalletEvm<T>>::deposit_log(
+ ERC20Events::Approval {
+ owner: *owner.as_eth(),
+ spender: *spender.as_eth(),
+ value: amount.into(),
+ }
+ .to_log(collection_id_to_address(collection.id)),
+ );
<PalletCommon<T>>::deposit_event(CommonEvent::Approved(
collection.id,
TokenId(0),
pallets/fungible/src/stubs/UniqueFungible.soldiffbeforeafterboth--- 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 {
+}
+
pallets/nonfungible/Cargo.tomldiffbeforeafterboth--- 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' }
pallets/nonfungible/src/lib.rsdiffbeforeafterboth--- 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(),
- });
+ <PalletEvm<T>>::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)),
+ );
<PalletCommon<T>>::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(),
- });
+ <PalletEvm<T>>::deposit_log(
+ ERC721Events::Transfer {
+ from: *from.as_eth(),
+ to: *to.as_eth(),
+ token_id: token.into(),
+ }
+ .to_log(collection_id_to_address(collection.id)),
+ );
<PalletCommon<T>>::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(),
- });
+ <PalletEvm<T>>::deposit_log(
+ ERC721Events::Transfer {
+ from: H160::default(),
+ to: *data.owner.as_eth(),
+ token_id: token.into(),
+ }
+ .to_log(collection_id_to_address(collection.id)),
+ );
<PalletCommon<T>>::deposit_event(CommonEvent::ItemCreated(
collection.id,
TokenId(token),
@@ -610,11 +620,14 @@
<Allowance<T>>::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(),
- });
+ <PalletEvm<T>>::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(),
- });
+ <PalletEvm<T>>::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
pallets/refungible/Cargo.tomldiffbeforeafterboth--- 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' }
pallets/unique/Cargo.tomldiffbeforeafterboth--- 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" }
primitives/data-structs/Cargo.tomldiffbeforeafterboth--- 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"]
primitives/rpc/Cargo.tomldiffbeforeafterboth--- 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"]
runtime/common/Cargo.tomldiffbeforeafterboth--- 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' }
runtime/opal/Cargo.tomldiffbeforeafterboth--- 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
runtime/opal/src/lib.rsdiffbeforeafterboth--- 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<Self>;
type GasWeightMapping = FixedGasWeightMapping;
}
@@ -1070,6 +1069,7 @@
frame_system::CheckWeight<Runtime>,
pallet_charge_transaction::ChargeTransactionPayment<Runtime>,
//pallet_contract_helpers::ContractHelpersExtension<Runtime>,
+ pallet_ethereum::FakeTransactionFinalizer<Runtime>,
);
/// Unchecked extrinsic type as expected by this runtime.
pub type UncheckedExtrinsic =
runtime/quartz/Cargo.tomldiffbeforeafterboth--- 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
runtime/quartz/src/lib.rsdiffbeforeafterboth1// 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//! The Substrate Node Template runtime. This can be compiled with `#[no_std]`, ready for Wasm.1819#![cfg_attr(not(feature = "std"), no_std)]20// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256.21#![recursion_limit = "1024"]22#![allow(clippy::from_over_into, clippy::identity_op)]23#![allow(clippy::fn_to_numeric_cast_with_truncation)]24// Make the WASM binary available.25#[cfg(feature = "std")]26include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));2728use sp_api::impl_runtime_apis;29use sp_core::{crypto::KeyTypeId, OpaqueMetadata, H256, U256, H160};30use sp_runtime::DispatchError;31// #[cfg(any(feature = "std", test))]32// pub use sp_runtime::BuildStorage;3334use sp_runtime::{35 Permill, Perbill, Percent, create_runtime_str, generic, impl_opaque_keys,36 traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, AccountIdConversion, Zero},37 transaction_validity::{TransactionSource, TransactionValidity},38 ApplyExtrinsicResult, RuntimeAppPublic,39};4041use sp_std::prelude::*;4243#[cfg(feature = "std")]44use sp_version::NativeVersion;45use sp_version::RuntimeVersion;46pub use pallet_transaction_payment::{47 Multiplier, TargetedFeeAdjustment, FeeDetails, RuntimeDispatchInfo,48};49// A few exports that help ease life for downstream crates.50pub use pallet_balances::Call as BalancesCall;51pub use pallet_evm::{52 EnsureAddressTruncated, HashedAddressMapping, Runner, account::CrossAccountId as _,53};54pub use frame_support::{55 construct_runtime, match_types,56 dispatch::DispatchResult,57 PalletId, parameter_types, StorageValue, ConsensusEngineId,58 traits::{59 tokens::currency::Currency as CurrencyT, OnUnbalanced as OnUnbalancedT, Everything,60 Currency, ExistenceRequirement, Get, IsInVec, KeyOwnerProofSystem, LockIdentifier,61 OnUnbalanced, Randomness, FindAuthor, ConstU32, Imbalance,62 },63 weights::{64 constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},65 DispatchClass, DispatchInfo, GetDispatchInfo, IdentityFee, Pays, PostDispatchInfo, Weight,66 WeightToFeePolynomial, WeightToFeeCoefficient, WeightToFeeCoefficients, ConstantMultiplier,67 },68};69use unique_runtime_common::dispatch::{CollectionDispatchT, CollectionDispatch};70use up_data_structs::*;71// use pallet_contracts::weights::WeightInfo;72// #[cfg(any(feature = "std", test))]73use frame_system::{74 self as frame_system, EnsureRoot, EnsureSigned,75 limits::{BlockWeights, BlockLength},76};77use sp_arithmetic::{78 traits::{BaseArithmetic, Unsigned},79};80use smallvec::smallvec;81use codec::{Encode, Decode};82use pallet_evm::{Account as EVMAccount, FeeCalculator, GasWeightMapping};83use fp_rpc::TransactionStatus;84use sp_runtime::{85 traits::{BlockNumberProvider, Dispatchable, PostDispatchInfoOf, Saturating},86 transaction_validity::TransactionValidityError,87 SaturatedConversion,88};8990// pub use pallet_timestamp::Call as TimestampCall;91pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;9293// Polkadot imports94use pallet_xcm::XcmPassthrough;95use polkadot_parachain::primitives::Sibling;96use up_data_structs::mapping::{CrossTokenAddressMapping, EvmTokenAddressMapping};97use xcm::v1::{BodyId, Junction::*, MultiLocation, NetworkId, Junctions::*};98use xcm_builder::{99 AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,100 EnsureXcmOrigin, FixedWeightBounds, LocationInverter, NativeAsset, ParentAsSuperuser,101 RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,102 SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,103 ParentIsPreset,104};105use xcm_executor::{Config, XcmExecutor, Assets};106use sp_std::{marker::PhantomData};107108use xcm::latest::{109 // Xcm,110 AssetId::{Concrete},111 Fungibility::Fungible as XcmFungible,112 MultiAsset,113 Error as XcmError,114};115use xcm_executor::traits::{MatchesFungible, WeightTrader};116//use xcm_executor::traits::MatchesFungible;117use sp_runtime::traits::CheckedConversion;118119use unique_runtime_common::{impl_common_runtime_apis, types::*, constants::*};120121pub const RUNTIME_NAME: &str = "quartz";122pub const TOKEN_SYMBOL: &str = "QTZ";123124type CrossAccountId = pallet_evm::account::BasicCrossAccountId<Runtime>;125126impl RuntimeInstance for Runtime {127 type CrossAccountId = self::CrossAccountId;128129 type TransactionConverter = self::TransactionConverter;130131 fn get_transaction_converter() -> TransactionConverter {132 TransactionConverter133 }134}135136/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know137/// the specifics of the runtime. They can then be made to be agnostic over specific formats138/// of data like extrinsics, allowing for them to continue syncing the network through upgrades139/// to even the core data structures.140pub mod opaque {141 use sp_std::prelude::*;142 use sp_runtime::impl_opaque_keys;143 use super::Aura;144145 pub use unique_runtime_common::types::*;146147 impl_opaque_keys! {148 pub struct SessionKeys {149 pub aura: Aura,150 }151 }152}153154/// This runtime version.155pub const VERSION: RuntimeVersion = RuntimeVersion {156 spec_name: create_runtime_str!(RUNTIME_NAME),157 impl_name: create_runtime_str!(RUNTIME_NAME),158 authoring_version: 1,159 spec_version: 920000,160 impl_version: 0,161 apis: RUNTIME_API_VERSIONS,162 transaction_version: 1,163 state_version: 0,164};165166#[derive(codec::Encode, codec::Decode)]167pub enum XCMPMessage<XAccountId, XBalance> {168 /// Transfer tokens to the given account from the Parachain account.169 TransferToken(XAccountId, XBalance),170}171172/// The version information used to identify this runtime when compiled natively.173#[cfg(feature = "std")]174pub fn native_version() -> NativeVersion {175 NativeVersion {176 runtime_version: VERSION,177 can_author_with: Default::default(),178 }179}180181type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;182183pub struct DealWithFees;184impl OnUnbalanced<NegativeImbalance> for DealWithFees {185 fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance>) {186 if let Some(fees) = fees_then_tips.next() {187 // for fees, 100% to treasury188 let mut split = fees.ration(100, 0);189 if let Some(tips) = fees_then_tips.next() {190 // for tips, if any, 100% to treasury191 tips.ration_merge_into(100, 0, &mut split);192 }193 Treasury::on_unbalanced(split.0);194 // Author::on_unbalanced(split.1);195 }196 }197}198199parameter_types! {200 pub const BlockHashCount: BlockNumber = 2400;201 pub RuntimeBlockLength: BlockLength =202 BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);203 pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);204 pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;205 pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()206 .base_block(BlockExecutionWeight::get())207 .for_class(DispatchClass::all(), |weights| {208 weights.base_extrinsic = ExtrinsicBaseWeight::get();209 })210 .for_class(DispatchClass::Normal, |weights| {211 weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);212 })213 .for_class(DispatchClass::Operational, |weights| {214 weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);215 // Operational transactions have some extra reserved space, so that they216 // are included even if block reached `MAXIMUM_BLOCK_WEIGHT`.217 weights.reserved = Some(218 MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT219 );220 })221 .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)222 .build_or_panic();223 pub const Version: RuntimeVersion = VERSION;224 pub const SS58Prefix: u8 = 255;225}226227parameter_types! {228 pub const ChainId: u64 = 8881;229}230231pub struct FixedFee;232impl FeeCalculator for FixedFee {233 fn min_gas_price() -> U256 {234 MIN_GAS_PRICE.into()235 }236}237238// Assuming slowest ethereum opcode is SSTORE, with gas price of 20000 as our worst case239// (contract, which only writes a lot of data),240// approximating on top of our real store write weight241parameter_types! {242 pub const WritesPerSecond: u64 = WEIGHT_PER_SECOND / <Runtime as frame_system::Config>::DbWeight::get().write;243 pub const GasPerSecond: u64 = WritesPerSecond::get() * 20000;244 pub const WeightPerGas: u64 = WEIGHT_PER_SECOND / GasPerSecond::get();245}246247/// Limiting EVM execution to 50% of block for substrate users and management tasks248/// EVM transaction consumes more weight than substrate's, so we can't rely on them being249/// scheduled fairly250const EVM_DISPATCH_RATIO: Perbill = Perbill::from_percent(50);251parameter_types! {252 pub BlockGasLimit: U256 = U256::from(NORMAL_DISPATCH_RATIO * EVM_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT / WeightPerGas::get());253}254255pub enum FixedGasWeightMapping {}256impl GasWeightMapping for FixedGasWeightMapping {257 fn gas_to_weight(gas: u64) -> Weight {258 gas.saturating_mul(WeightPerGas::get())259 }260 fn weight_to_gas(weight: Weight) -> u64 {261 weight / WeightPerGas::get()262 }263}264265impl pallet_evm::Config for Runtime {266 type BlockGasLimit = BlockGasLimit;267 type FeeCalculator = FixedFee;268 type GasWeightMapping = FixedGasWeightMapping;269 type BlockHashMapping = pallet_ethereum::EthereumBlockHashMapping<Self>;270 type CallOrigin = EnsureAddressTruncated<Self>;271 type WithdrawOrigin = EnsureAddressTruncated<Self>;272 type AddressMapping = HashedAddressMapping<Self::Hashing>;273 type PrecompilesType = ();274 type PrecompilesValue = ();275 type Currency = Balances;276 type Event = Event;277 type OnMethodCall = (278 pallet_evm_migration::OnMethodCall<Self>,279 pallet_evm_contract_helpers::HelpersOnMethodCall<Self>,280 CollectionDispatchT<Self>,281 );282 type OnCreate = pallet_evm_contract_helpers::HelpersOnCreate<Self>;283 type ChainId = ChainId;284 type Runner = pallet_evm::runner::stack::Runner<Self>;285 type OnChargeTransaction = pallet_evm::EVMCurrencyAdapter<Balances, DealWithFees>;286 type TransactionValidityHack = pallet_evm_transaction_payment::TransactionValidityHack<Self>;287 type FindAuthor = EthereumFindAuthor<Aura>;288}289290impl pallet_evm_migration::Config for Runtime {291 type WeightInfo = pallet_evm_migration::weights::SubstrateWeight<Self>;292}293294pub struct EthereumFindAuthor<F>(core::marker::PhantomData<F>);295impl<F: FindAuthor<u32>> FindAuthor<H160> for EthereumFindAuthor<F> {296 fn find_author<'a, I>(digests: I) -> Option<H160>297 where298 I: 'a + IntoIterator<Item = (ConsensusEngineId, &'a [u8])>,299 {300 if let Some(author_index) = F::find_author(digests) {301 let authority_id = Aura::authorities()[author_index as usize].clone();302 return Some(H160::from_slice(&authority_id.to_raw_vec()[4..24]));303 }304 None305 }306}307308impl pallet_ethereum::Config for Runtime {309 type Event = Event;310 type StateRoot = pallet_ethereum::IntermediateStateRoot<Self>;311}312313impl pallet_randomness_collective_flip::Config for Runtime {}314315impl frame_system::Config for Runtime {316 /// The data to be stored in an account.317 type AccountData = pallet_balances::AccountData<Balance>;318 /// The identifier used to distinguish between accounts.319 type AccountId = AccountId;320 /// The basic call filter to use in dispatchable.321 type BaseCallFilter = Everything;322 /// Maximum number of block number to block hash mappings to keep (oldest pruned first).323 type BlockHashCount = BlockHashCount;324 /// The maximum length of a block (in bytes).325 type BlockLength = RuntimeBlockLength;326 /// The index type for blocks.327 type BlockNumber = BlockNumber;328 /// The weight of the overhead invoked on the block import process, independent of the extrinsics included in that block.329 type BlockWeights = RuntimeBlockWeights;330 /// The aggregated dispatch type that is available for extrinsics.331 type Call = Call;332 /// The weight of database operations that the runtime can invoke.333 type DbWeight = RocksDbWeight;334 /// The ubiquitous event type.335 type Event = Event;336 /// The type for hashing blocks and tries.337 type Hash = Hash;338 /// The hashing algorithm used.339 type Hashing = BlakeTwo256;340 /// The header type.341 type Header = generic::Header<BlockNumber, BlakeTwo256>;342 /// The index type for storing how many extrinsics an account has signed.343 type Index = Index;344 /// The lookup mechanism to get account ID from whatever is passed in dispatchers.345 type Lookup = AccountIdLookup<AccountId, ()>;346 /// What to do if an account is fully reaped from the system.347 type OnKilledAccount = ();348 /// What to do if a new account is created.349 type OnNewAccount = ();350 type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;351 /// The ubiquitous origin type.352 type Origin = Origin;353 /// This type is being generated by `construct_runtime!`.354 type PalletInfo = PalletInfo;355 /// This is used as an identifier of the chain. 42 is the generic substrate prefix.356 type SS58Prefix = SS58Prefix;357 /// Weight information for the extrinsics of this pallet.358 type SystemWeightInfo = frame_system::weights::SubstrateWeight<Self>;359 /// Version of the runtime.360 type Version = Version;361 type MaxConsumers = ConstU32<16>;362}363364parameter_types! {365 pub const MinimumPeriod: u64 = SLOT_DURATION / 2;366}367368impl pallet_timestamp::Config for Runtime {369 /// A timestamp: milliseconds since the unix epoch.370 type Moment = u64;371 type OnTimestampSet = ();372 type MinimumPeriod = MinimumPeriod;373 type WeightInfo = ();374}375376parameter_types! {377 // pub const ExistentialDeposit: u128 = 500;378 pub const ExistentialDeposit: u128 = 0;379 pub const MaxLocks: u32 = 50;380}381382impl pallet_balances::Config for Runtime {383 type MaxLocks = MaxLocks;384 type MaxReserves = ();385 type ReserveIdentifier = [u8; 8];386 /// The type for recording an account's balance.387 type Balance = Balance;388 /// The ubiquitous event type.389 type Event = Event;390 type DustRemoval = Treasury;391 type ExistentialDeposit = ExistentialDeposit;392 type AccountStore = System;393 type WeightInfo = pallet_balances::weights::SubstrateWeight<Self>;394}395396pub const fn deposit(items: u32, bytes: u32) -> Balance {397 items as Balance * 15 * CENTIUNIQUE + (bytes as Balance) * 6 * CENTIUNIQUE398}399400/*401parameter_types! {402 pub TombstoneDeposit: Balance = deposit(403 1,404 sp_std::mem::size_of::<pallet_contracts::Pallet<Runtime>> as u32,405 );406 pub DepositPerContract: Balance = TombstoneDeposit::get();407 pub const DepositPerStorageByte: Balance = deposit(0, 1);408 pub const DepositPerStorageItem: Balance = deposit(1, 0);409 pub RentFraction: Perbill = Perbill::from_rational(1u32, 30 * DAYS);410 pub const SurchargeReward: Balance = 150 * MILLIUNIQUE;411 pub const SignedClaimHandicap: u32 = 2;412 pub const MaxDepth: u32 = 32;413 pub const MaxValueSize: u32 = 16 * 1024;414 pub const MaxCodeSize: u32 = 1024 * 1024 * 25; // 25 Mb415 // The lazy deletion runs inside on_initialize.416 pub DeletionWeightLimit: Weight = AVERAGE_ON_INITIALIZE_RATIO *417 RuntimeBlockWeights::get().max_block;418 // The weight needed for decoding the queue should be less or equal than a fifth419 // of the overall weight dedicated to the lazy deletion.420 pub DeletionQueueDepth: u32 = ((DeletionWeightLimit::get() / (421 <Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(1) -422 <Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(0)423 )) / 5) as u32;424 pub Schedule: pallet_contracts::Schedule<Runtime> = Default::default();425}426427impl pallet_contracts::Config for Runtime {428 type Time = Timestamp;429 type Randomness = RandomnessCollectiveFlip;430 type Currency = Balances;431 type Event = Event;432 type RentPayment = ();433 type SignedClaimHandicap = SignedClaimHandicap;434 type TombstoneDeposit = TombstoneDeposit;435 type DepositPerContract = DepositPerContract;436 type DepositPerStorageByte = DepositPerStorageByte;437 type DepositPerStorageItem = DepositPerStorageItem;438 type RentFraction = RentFraction;439 type SurchargeReward = SurchargeReward;440 type WeightPrice = pallet_transaction_payment::Pallet<Self>;441 type WeightInfo = pallet_contracts::weights::SubstrateWeight<Self>;442 type ChainExtension = NFTExtension;443 type DeletionQueueDepth = DeletionQueueDepth;444 type DeletionWeightLimit = DeletionWeightLimit;445 type Schedule = Schedule;446 type CallStack = [pallet_contracts::Frame<Self>; 31];447}448*/449450parameter_types! {451 /// This value increases the priority of `Operational` transactions by adding452 /// a "virtual tip" that's equal to the `OperationalFeeMultiplier * final_fee`.453 pub const OperationalFeeMultiplier: u8 = 5;454}455456/// Linear implementor of `WeightToFeePolynomial`457pub struct LinearFee<T>(sp_std::marker::PhantomData<T>);458459impl<T> WeightToFeePolynomial for LinearFee<T>460where461 T: BaseArithmetic + From<u32> + Copy + Unsigned,462{463 type Balance = T;464465 fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {466 smallvec!(WeightToFeeCoefficient {467 // Targeting 0.1 Unique per NFT transfer468 coeff_integer: WEIGHT_TO_FEE_COEFF.into(),469 coeff_frac: Perbill::zero(),470 negative: false,471 degree: 1,472 })473 }474}475476impl pallet_transaction_payment::Config for Runtime {477 type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees>;478 type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;479 type OperationalFeeMultiplier = OperationalFeeMultiplier;480 type WeightToFee = LinearFee<Balance>;481 type FeeMultiplierUpdate = ();482}483484parameter_types! {485 pub const ProposalBond: Permill = Permill::from_percent(5);486 pub const ProposalBondMinimum: Balance = 1 * UNIQUE;487 pub const ProposalBondMaximum: Balance = 1000 * UNIQUE;488 pub const SpendPeriod: BlockNumber = 5 * MINUTES;489 pub const Burn: Permill = Permill::from_percent(0);490 pub const TipCountdown: BlockNumber = 1 * DAYS;491 pub const TipFindersFee: Percent = Percent::from_percent(20);492 pub const TipReportDepositBase: Balance = 1 * UNIQUE;493 pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;494 pub const BountyDepositBase: Balance = 1 * UNIQUE;495 pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;496 pub const TreasuryModuleId: PalletId = PalletId(*b"py/trsry");497 pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;498 pub const MaximumReasonLength: u32 = 16384;499 pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);500 pub const BountyValueMinimum: Balance = 5 * UNIQUE;501 pub const MaxApprovals: u32 = 100;502}503504impl pallet_treasury::Config for Runtime {505 type PalletId = TreasuryModuleId;506 type Currency = Balances;507 type ApproveOrigin = EnsureRoot<AccountId>;508 type RejectOrigin = EnsureRoot<AccountId>;509 type Event = Event;510 type OnSlash = ();511 type ProposalBond = ProposalBond;512 type ProposalBondMinimum = ProposalBondMinimum;513 type ProposalBondMaximum = ProposalBondMaximum;514 type SpendPeriod = SpendPeriod;515 type Burn = Burn;516 type BurnDestination = ();517 type SpendFunds = ();518 type WeightInfo = pallet_treasury::weights::SubstrateWeight<Self>;519 type MaxApprovals = MaxApprovals;520}521522impl pallet_sudo::Config for Runtime {523 type Event = Event;524 type Call = Call;525}526527pub struct RelayChainBlockNumberProvider<T>(sp_std::marker::PhantomData<T>);528529impl<T: cumulus_pallet_parachain_system::Config> BlockNumberProvider530 for RelayChainBlockNumberProvider<T>531{532 type BlockNumber = BlockNumber;533534 fn current_block_number() -> Self::BlockNumber {535 cumulus_pallet_parachain_system::Pallet::<T>::validation_data()536 .map(|d| d.relay_parent_number)537 .unwrap_or_default()538 }539}540541parameter_types! {542 pub const MinVestedTransfer: Balance = 10 * UNIQUE;543 pub const MaxVestingSchedules: u32 = 28;544}545546impl orml_vesting::Config for Runtime {547 type Event = Event;548 type Currency = pallet_balances::Pallet<Runtime>;549 type MinVestedTransfer = MinVestedTransfer;550 type VestedTransferOrigin = EnsureSigned<AccountId>;551 type WeightInfo = ();552 type MaxVestingSchedules = MaxVestingSchedules;553 type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;554}555556parameter_types! {557 pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;558 pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;559}560561impl cumulus_pallet_parachain_system::Config for Runtime {562 type Event = Event;563 type SelfParaId = parachain_info::Pallet<Self>;564 type OnSystemEvent = ();565 // type DownwardMessageHandlers = cumulus_primitives_utility::UnqueuedDmpAsParent<566 // MaxDownwardMessageWeight,567 // XcmExecutor<XcmConfig>,568 // Call,569 // >;570 type OutboundXcmpMessageSource = XcmpQueue;571 type DmpMessageHandler = DmpQueue;572 type ReservedDmpWeight = ReservedDmpWeight;573 type ReservedXcmpWeight = ReservedXcmpWeight;574 type XcmpMessageHandler = XcmpQueue;575}576577impl parachain_info::Config for Runtime {}578579impl cumulus_pallet_aura_ext::Config for Runtime {}580581parameter_types! {582 pub const RelayLocation: MultiLocation = MultiLocation::parent();583 pub const RelayNetwork: NetworkId = NetworkId::Polkadot;584 pub RelayOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into();585 pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();586}587588/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used589/// when determining ownership of accounts for asset transacting and when attempting to use XCM590/// `Transact` in order to determine the dispatch Origin.591pub type LocationToAccountId = (592 // The parent (Relay-chain) origin converts to the default `AccountId`.593 ParentIsPreset<AccountId>,594 // Sibling parachain origins convert to AccountId via the `ParaId::into`.595 SiblingParachainConvertsVia<Sibling, AccountId>,596 // Straight up local `AccountId32` origins just alias directly to `AccountId`.597 AccountId32Aliases<RelayNetwork, AccountId>,598);599600pub struct OnlySelfCurrency;601impl<B: TryFrom<u128>> MatchesFungible<B> for OnlySelfCurrency {602 fn matches_fungible(a: &MultiAsset) -> Option<B> {603 match (&a.id, &a.fun) {604 (Concrete(_), XcmFungible(ref amount)) => CheckedConversion::checked_from(*amount),605 _ => None,606 }607 }608}609610/// Means for transacting assets on this chain.611pub type LocalAssetTransactor = CurrencyAdapter<612 // Use this currency:613 Balances,614 // Use this currency when it is a fungible asset matching the given location or name:615 OnlySelfCurrency,616 // Do a simple punn to convert an AccountId32 MultiLocation into a native chain account ID:617 LocationToAccountId,618 // Our chain's account ID type (we can't get away without mentioning it explicitly):619 AccountId,620 // We don't track any teleports.621 (),622>;623624/// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance,625/// ready for dispatching a transaction with Xcm's `Transact`. There is an `OriginKind` which can626/// biases the kind of local `Origin` it will become.627pub type XcmOriginToTransactDispatchOrigin = (628 // Sovereign account converter; this attempts to derive an `AccountId` from the origin location629 // using `LocationToAccountId` and then turn that into the usual `Signed` origin. Useful for630 // foreign chains who want to have a local sovereign account on this chain which they control.631 SovereignSignedViaLocation<LocationToAccountId, Origin>,632 // Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when633 // recognised.634 RelayChainAsNative<RelayOrigin, Origin>,635 // Native converter for sibling Parachains; will convert to a `SiblingPara` origin when636 // recognised.637 SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>,638 // Superuser converter for the Relay-chain (Parent) location. This will allow it to issue a639 // transaction from the Root origin.640 ParentAsSuperuser<Origin>,641 // Native signed account converter; this just converts an `AccountId32` origin into a normal642 // `Origin::Signed` origin of the same 32-byte value.643 SignedAccountId32AsNative<RelayNetwork, Origin>,644 // Xcm origins can be represented natively under the Xcm pallet's Xcm origin.645 XcmPassthrough<Origin>,646);647648parameter_types! {649 // One XCM operation is 1_000_000 weight - almost certainly a conservative estimate.650 pub UnitWeightCost: Weight = 1_000_000;651 // 1200 UNIQUEs buy 1 second of weight.652 pub const WeightPrice: (MultiLocation, u128) = (MultiLocation::parent(), 1_200 * UNIQUE);653 pub const MaxInstructions: u32 = 100;654 pub const MaxAuthorities: u32 = 100_000;655}656657match_types! {658 pub type ParentOrParentsUnitPlurality: impl Contains<MultiLocation> = {659 MultiLocation { parents: 1, interior: Here } |660 MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Unit, .. }) }661 };662}663664pub type Barrier = (665 TakeWeightCredit,666 AllowTopLevelPaidExecutionFrom<Everything>,667 AllowUnpaidExecutionFrom<ParentOrParentsUnitPlurality>,668 // ^^^ Parent & its unit plurality gets free execution669);670671pub struct UsingOnlySelfCurrencyComponents<672 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,673 AssetId: Get<MultiLocation>,674 AccountId,675 Currency: CurrencyT<AccountId>,676 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,677>(678 Weight,679 Currency::Balance,680 PhantomData<(WeightToFee, AssetId, AccountId, Currency, OnUnbalanced)>,681);682impl<683 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,684 AssetId: Get<MultiLocation>,685 AccountId,686 Currency: CurrencyT<AccountId>,687 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,688 > WeightTrader689 for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>690{691 fn new() -> Self {692 Self(0, Zero::zero(), PhantomData)693 }694695 fn buy_weight(&mut self, weight: Weight, payment: Assets) -> Result<Assets, XcmError> {696 let amount = WeightToFee::calc(&weight);697 let u128_amount: u128 = amount.try_into().map_err(|_| XcmError::Overflow)?;698699 // location to this parachain through relay chain700 let option1: xcm::v1::AssetId = Concrete(MultiLocation {701 parents: 1,702 interior: X1(Parachain(ParachainInfo::parachain_id().into())),703 });704 // direct location705 let option2: xcm::v1::AssetId = Concrete(MultiLocation {706 parents: 0,707 interior: Here,708 });709710 let required = if payment.fungible.contains_key(&option1) {711 (option1, u128_amount).into()712 } else if payment.fungible.contains_key(&option2) {713 (option2, u128_amount).into()714 } else {715 (Concrete(MultiLocation::default()), u128_amount).into()716 };717718 let unused = payment719 .checked_sub(required)720 .map_err(|_| XcmError::TooExpensive)?;721 self.0 = self.0.saturating_add(weight);722 self.1 = self.1.saturating_add(amount);723 Ok(unused)724 }725726 fn refund_weight(&mut self, weight: Weight) -> Option<MultiAsset> {727 let weight = weight.min(self.0);728 let amount = WeightToFee::calc(&weight);729 self.0 -= weight;730 self.1 = self.1.saturating_sub(amount);731 let amount: u128 = amount.saturated_into();732 if amount > 0 {733 Some((AssetId::get(), amount).into())734 } else {735 None736 }737 }738}739impl<740 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,741 AssetId: Get<MultiLocation>,742 AccountId,743 Currency: CurrencyT<AccountId>,744 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,745 > Drop746 for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>747{748 fn drop(&mut self) {749 OnUnbalanced::on_unbalanced(Currency::issue(self.1));750 }751}752753pub struct XcmConfig;754impl Config for XcmConfig {755 type Call = Call;756 type XcmSender = XcmRouter;757 // How to withdraw and deposit an asset.758 type AssetTransactor = LocalAssetTransactor;759 type OriginConverter = XcmOriginToTransactDispatchOrigin;760 type IsReserve = NativeAsset;761 type IsTeleporter = (); // Teleportation is disabled762 type LocationInverter = LocationInverter<Ancestry>;763 type Barrier = Barrier;764 type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;765 type Trader = UsingOnlySelfCurrencyComponents<766 IdentityFee<Balance>,767 RelayLocation,768 AccountId,769 Balances,770 (),771 >;772 type ResponseHandler = (); // Don't handle responses for now.773 type SubscriptionService = PolkadotXcm;774775 type AssetTrap = PolkadotXcm;776 type AssetClaims = PolkadotXcm;777}778779// parameter_types! {780// pub const MaxDownwardMessageWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 10;781// }782783/// No local origins on this chain are allowed to dispatch XCM sends/executions.784pub type LocalOriginToLocation = (SignedToAccountId32<Origin, AccountId, RelayNetwork>,);785786/// The means for routing XCM messages which are not for local execution into the right message787/// queues.788pub type XcmRouter = (789 // Two routers - use UMP to communicate with the relay chain:790 cumulus_primitives_utility::ParentAsUmp<ParachainSystem, ()>,791 // ..and XCMP to communicate with the sibling chains.792 XcmpQueue,793);794795impl pallet_evm_coder_substrate::Config for Runtime {796 type EthereumTransactionSender = pallet_ethereum::Pallet<Self>;797 type GasWeightMapping = FixedGasWeightMapping;798}799800impl pallet_xcm::Config for Runtime {801 type Event = Event;802 type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;803 type XcmRouter = XcmRouter;804 type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;805 type XcmExecuteFilter = Everything;806 type XcmExecutor = XcmExecutor<XcmConfig>;807 type XcmTeleportFilter = Everything;808 type XcmReserveTransferFilter = Everything;809 type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;810 type LocationInverter = LocationInverter<Ancestry>;811 type Origin = Origin;812 type Call = Call;813 const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;814 type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;815}816817impl cumulus_pallet_xcm::Config for Runtime {818 type Event = Event;819 type XcmExecutor = XcmExecutor<XcmConfig>;820}821822impl cumulus_pallet_xcmp_queue::Config for Runtime {823 type WeightInfo = ();824 type Event = Event;825 type XcmExecutor = XcmExecutor<XcmConfig>;826 type ChannelInfo = ParachainSystem;827 type VersionWrapper = ();828 type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;829 type ControllerOrigin = EnsureRoot<AccountId>;830 type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;831}832833impl cumulus_pallet_dmp_queue::Config for Runtime {834 type Event = Event;835 type XcmExecutor = XcmExecutor<XcmConfig>;836 type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;837}838839impl pallet_aura::Config for Runtime {840 type AuthorityId = AuraId;841 type DisabledValidators = ();842 type MaxAuthorities = MaxAuthorities;843}844845parameter_types! {846 pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account();847 pub const CollectionCreationPrice: Balance = 2 * UNIQUE;848}849850impl pallet_common::Config for Runtime {851 type Event = Event;852853 type Currency = Balances;854 type CollectionCreationPrice = CollectionCreationPrice;855 type TreasuryAccountId = TreasuryAccountId;856 type CollectionDispatch = CollectionDispatchT<Self>;857858 type EvmTokenAddressMapping = EvmTokenAddressMapping;859 type CrossTokenAddressMapping = CrossTokenAddressMapping<Self::AccountId>;860}861862impl pallet_structure::Config for Runtime {863 type Event = Event;864 type Call = Call;865 type WeightInfo = pallet_structure::weights::SubstrateWeight<Self>;866}867868impl pallet_evm::account::Config for Runtime {869 type CrossAccountId = pallet_evm::account::BasicCrossAccountId<Self>;870 type EvmAddressMapping = HashedAddressMapping<Self::Hashing>;871 type EvmBackwardsAddressMapping = fp_evm_mapping::MapBackwardsAddressTruncated;872}873874impl pallet_fungible::Config for Runtime {875 type WeightInfo = pallet_fungible::weights::SubstrateWeight<Self>;876}877impl pallet_refungible::Config for Runtime {878 type WeightInfo = pallet_refungible::weights::SubstrateWeight<Self>;879}880impl pallet_nonfungible::Config for Runtime {881 type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;882}883884impl pallet_unique::Config for Runtime {885 type Event = Event;886 type WeightInfo = pallet_unique::weights::SubstrateWeight<Self>;887}888889parameter_types! {890 pub const InflationBlockInterval: BlockNumber = 100; // every time per how many blocks inflation is applied891}892893/// Used for the pallet inflation894impl pallet_inflation::Config for Runtime {895 type Currency = Balances;896 type TreasuryAccountId = TreasuryAccountId;897 type InflationBlockInterval = InflationBlockInterval;898 type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;899}900901// parameter_types! {902// pub MaximumSchedulerWeight: Weight = Perbill::from_percent(50) *903// RuntimeBlockWeights::get().max_block;904// pub const MaxScheduledPerBlock: u32 = 50;905// }906907type EvmSponsorshipHandler = (908 pallet_unique::UniqueEthSponsorshipHandler<Runtime>,909 pallet_evm_contract_helpers::HelpersContractSponsoring<Runtime>,910);911type SponsorshipHandler = (912 pallet_unique::UniqueSponsorshipHandler<Runtime>,913 //pallet_contract_helpers::ContractSponsorshipHandler<Runtime>,914 pallet_evm_transaction_payment::BridgeSponsorshipHandler<Runtime>,915);916917// impl pallet_unq_scheduler::Config for Runtime {918// type Event = Event;919// type Origin = Origin;920// type PalletsOrigin = OriginCaller;921// type Call = Call;922// type MaximumWeight = MaximumSchedulerWeight;923// type ScheduleOrigin = EnsureSigned<AccountId>;924// type MaxScheduledPerBlock = MaxScheduledPerBlock;925// type SponsorshipHandler = SponsorshipHandler;926// type WeightInfo = ();927// }928929impl pallet_evm_transaction_payment::Config for Runtime {930 type EvmSponsorshipHandler = EvmSponsorshipHandler;931 type Currency = Balances;932}933934impl pallet_charge_transaction::Config for Runtime {935 type SponsorshipHandler = SponsorshipHandler;936}937938// impl pallet_contract_helpers::Config for Runtime {939// type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;940// }941942parameter_types! {943 // 0x842899ECF380553E8a4de75bF534cdf6fBF64049944 pub const HelpersContractAddress: H160 = H160([945 0x84, 0x28, 0x99, 0xec, 0xf3, 0x80, 0x55, 0x3e, 0x8a, 0x4d, 0xe7, 0x5b, 0xf5, 0x34, 0xcd, 0xf6, 0xfb, 0xf6, 0x40, 0x49,946 ]);947}948949impl pallet_evm_contract_helpers::Config for Runtime {950 type ContractAddress = HelpersContractAddress;951 type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;952}953954construct_runtime!(955 pub enum Runtime where956 Block = Block,957 NodeBlock = opaque::Block,958 UncheckedExtrinsic = UncheckedExtrinsic959 {960 ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Config, Storage, Inherent, Event<T>, ValidateUnsigned} = 20,961 ParachainInfo: parachain_info::{Pallet, Storage, Config} = 21,962963 Aura: pallet_aura::{Pallet, Config<T>} = 22,964 AuraExt: cumulus_pallet_aura_ext::{Pallet, Config} = 23,965966 Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 30,967 RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Storage} = 31,968 Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 32,969 TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 33,970 Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>} = 34,971 Sudo: pallet_sudo::{Pallet, Call, Storage, Config<T>, Event<T>} = 35,972 System: frame_system::{Pallet, Call, Storage, Config, Event<T>} = 36,973 Vesting: orml_vesting::{Pallet, Storage, Call, Event<T>, Config<T>} = 37,974 // Vesting: pallet_vesting::{Pallet, Call, Config<T>, Storage, Event<T>} = 37,975 // Contracts: pallet_contracts::{Pallet, Call, Storage, Event<T>} = 38,976977 // XCM helpers.978 XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 50,979 PolkadotXcm: pallet_xcm::{Pallet, Call, Event<T>, Origin} = 51,980 CumulusXcm: cumulus_pallet_xcm::{Pallet, Call, Event<T>, Origin} = 52,981 DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event<T>} = 53,982983 // Unique Pallets984 Inflation: pallet_inflation::{Pallet, Call, Storage} = 60,985 Unique: pallet_unique::{Pallet, Call, Storage, Event<T>} = 61,986 // Scheduler: pallet_unq_scheduler::{Pallet, Call, Storage, Event<T>} = 62,987 // free = 63988 Charging: pallet_charge_transaction::{Pallet, Call, Storage } = 64,989 // ContractHelpers: pallet_contract_helpers::{Pallet, Call, Storage} = 65,990 Common: pallet_common::{Pallet, Storage, Event<T>} = 66,991 Fungible: pallet_fungible::{Pallet, Storage} = 67,992 Refungible: pallet_refungible::{Pallet, Storage} = 68,993 Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,994 Structure: pallet_structure::{Pallet, Call, Storage, Event<T>} = 70,995996 // Frontier997 EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,998 Ethereum: pallet_ethereum::{Pallet, Config, Call, Storage, Event, Origin} = 101,9991000 EvmCoderSubstrate: pallet_evm_coder_substrate::{Pallet, Storage} = 150,1001 EvmContractHelpers: pallet_evm_contract_helpers::{Pallet, Storage} = 151,1002 EvmTransactionPayment: pallet_evm_transaction_payment::{Pallet} = 152,1003 EvmMigration: pallet_evm_migration::{Pallet, Call, Storage} = 153,1004 }1005);10061007pub struct TransactionConverter;10081009impl fp_rpc::ConvertTransaction<UncheckedExtrinsic> for TransactionConverter {1010 fn convert_transaction(&self, transaction: pallet_ethereum::Transaction) -> UncheckedExtrinsic {1011 UncheckedExtrinsic::new_unsigned(1012 pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),1013 )1014 }1015}10161017impl fp_rpc::ConvertTransaction<opaque::UncheckedExtrinsic> for TransactionConverter {1018 fn convert_transaction(1019 &self,1020 transaction: pallet_ethereum::Transaction,1021 ) -> opaque::UncheckedExtrinsic {1022 let extrinsic = UncheckedExtrinsic::new_unsigned(1023 pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),1024 );1025 let encoded = extrinsic.encode();1026 opaque::UncheckedExtrinsic::decode(&mut &encoded[..])1027 .expect("Encoded extrinsic is always valid")1028 }1029}10301031/// The address format for describing accounts.1032pub type Address = sp_runtime::MultiAddress<AccountId, ()>;1033/// Block header type as expected by this runtime.1034pub type Header = generic::Header<BlockNumber, BlakeTwo256>;1035/// Block type as expected by this runtime.1036pub type Block = generic::Block<Header, UncheckedExtrinsic>;1037/// A Block signed with a Justification1038pub type SignedBlock = generic::SignedBlock<Block>;1039/// BlockId type as expected by this runtime.1040pub type BlockId = generic::BlockId<Block>;1041/// The SignedExtension to the basic transaction logic.1042pub type SignedExtra = (1043 frame_system::CheckSpecVersion<Runtime>,1044 // system::CheckTxVersion<Runtime>,1045 frame_system::CheckGenesis<Runtime>,1046 frame_system::CheckEra<Runtime>,1047 frame_system::CheckNonce<Runtime>,1048 frame_system::CheckWeight<Runtime>,1049 pallet_charge_transaction::ChargeTransactionPayment<Runtime>,1050 //pallet_contract_helpers::ContractHelpersExtension<Runtime>,1051);1052/// Unchecked extrinsic type as expected by this runtime.1053pub type UncheckedExtrinsic =1054 fp_self_contained::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;1055/// Extrinsic type that has already been checked.1056pub type CheckedExtrinsic = fp_self_contained::CheckedExtrinsic<AccountId, Call, SignedExtra, H160>;1057/// Executive: handles dispatch to the various modules.1058pub type Executive = frame_executive::Executive<1059 Runtime,1060 Block,1061 frame_system::ChainContext<Runtime>,1062 Runtime,1063 AllPalletsReversedWithSystemFirst,1064>;10651066impl_opaque_keys! {1067 pub struct SessionKeys {1068 pub aura: Aura,1069 }1070}10711072impl fp_self_contained::SelfContainedCall for Call {1073 type SignedInfo = H160;10741075 fn is_self_contained(&self) -> bool {1076 match self {1077 Call::Ethereum(call) => call.is_self_contained(),1078 _ => false,1079 }1080 }10811082 fn check_self_contained(&self) -> Option<Result<Self::SignedInfo, TransactionValidityError>> {1083 match self {1084 Call::Ethereum(call) => call.check_self_contained(),1085 _ => None,1086 }1087 }10881089 fn validate_self_contained(&self, info: &Self::SignedInfo) -> Option<TransactionValidity> {1090 match self {1091 Call::Ethereum(call) => call.validate_self_contained(info),1092 _ => None,1093 }1094 }10951096 fn pre_dispatch_self_contained(1097 &self,1098 info: &Self::SignedInfo,1099 ) -> Option<Result<(), TransactionValidityError>> {1100 match self {1101 Call::Ethereum(call) => call.pre_dispatch_self_contained(info),1102 _ => None,1103 }1104 }11051106 fn apply_self_contained(1107 self,1108 info: Self::SignedInfo,1109 ) -> Option<sp_runtime::DispatchResultWithInfo<PostDispatchInfoOf<Self>>> {1110 match self {1111 call @ Call::Ethereum(pallet_ethereum::Call::transact { .. }) => Some(call.dispatch(1112 Origin::from(pallet_ethereum::RawOrigin::EthereumTransaction(info)),1113 )),1114 _ => None,1115 }1116 }1117}11181119macro_rules! dispatch_unique_runtime {1120 ($collection:ident.$method:ident($($name:ident),*)) => {{1121 let collection = <Runtime as pallet_common::Config>::CollectionDispatch::dispatch(<pallet_common::CollectionHandle<Runtime>>::try_get($collection)?);1122 let dispatch = collection.as_dyn();11231124 Ok(dispatch.$method($($name),*))1125 }};1126}11271128impl_common_runtime_apis!();11291130struct CheckInherents;11311132impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {1133 fn check_inherents(1134 block: &Block,1135 relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof,1136 ) -> sp_inherents::CheckInherentsResult {1137 let relay_chain_slot = relay_state_proof1138 .read_slot()1139 .expect("Could not read the relay chain slot from the proof");11401141 let inherent_data =1142 cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration(1143 relay_chain_slot,1144 sp_std::time::Duration::from_secs(6),1145 )1146 .create_inherent_data()1147 .expect("Could not create the timestamp inherent data");11481149 inherent_data.check_extrinsics(block)1150 }1151}11521153cumulus_pallet_parachain_system::register_validate_block!(1154 Runtime = Runtime,1155 BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,1156 CheckInherents = CheckInherents,1157);runtime/tests/Cargo.tomldiffbeforeafterboth--- 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' }
runtime/tests/src/lib.rsdiffbeforeafterboth--- 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<MaybeMirroredLog>) {}
+parameter_types! {
+ pub BlockGasLimit: U256 = 0u32.into();
}
+impl pallet_evm::Config for Test {
+ type Event = ();
+ type FeeCalculator = ();
+ type GasWeightMapping = ();
+ type CallOrigin = EnsureAddressNever<Self::CrossAccountId>;
+ type WithdrawOrigin = EnsureAddressNever<Self::CrossAccountId>;
+ type AddressMapping = TestEvmAddressMapping;
+ type Currency = Balances;
+ type PrecompilesType = ();
+ type PrecompilesValue = ();
+ type Runner = pallet_evm::runner::stack::Runner<Self>;
+ type ChainId = ConstU64<0>;
+ type BlockGasLimit = BlockGasLimit;
+ type OnMethodCall = ();
+ type OnCreate = ();
+ type OnChargeTransaction = ();
+ type FindAuthor = ();
+ type BlockHashMapping = SubstrateBlockHashMapping<Self>;
+ type TransactionValidityHack = ();
+}
impl pallet_evm_coder_substrate::Config for Test {
- type EthereumTransactionSender = TestEtheremTransactionSender;
type GasWeightMapping = ();
}
runtime/unique/Cargo.tomldiffbeforeafterboth--- 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
runtime/unique/src/lib.rsdiffbeforeafterboth--- 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<Self>;
type GasWeightMapping = FixedGasWeightMapping;
}
@@ -1046,6 +1045,7 @@
frame_system::CheckWeight<Runtime>,
pallet_charge_transaction::ChargeTransactionPayment<Runtime>,
//pallet_contract_helpers::ContractHelpersExtension<Runtime>,
+ pallet_ethereum::FakeTransactionFinalizer<Runtime>,
);
/// Unchecked extrinsic type as expected by this runtime.
pub type UncheckedExtrinsic =
tests/src/substrate/substrate-api.tsdiffbeforeafterboth--- 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,