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.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 up_data_structs::mapping::{EvmTokenAddressMapping, CrossTokenAddressMapping};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 xcm::v1::{BodyId, Junction::*, MultiLocation, NetworkId, Junctions::*};97use xcm_builder::{98 AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,99 EnsureXcmOrigin, FixedWeightBounds, LocationInverter, NativeAsset, ParentAsSuperuser,100 RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,101 SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,102 ParentIsPreset,103};104use xcm_executor::{Config, XcmExecutor, Assets};105use sp_std::{marker::PhantomData};106107use xcm::latest::{108 // Xcm,109 AssetId::{Concrete},110 Fungibility::Fungible as XcmFungible,111 MultiAsset,112 Error as XcmError,113};114use xcm_executor::traits::{MatchesFungible, WeightTrader};115//use xcm_executor::traits::MatchesFungible;116use sp_runtime::traits::CheckedConversion;117118use unique_runtime_common::{119 impl_common_runtime_apis,120 types::*,121 constants::*,122 dispatch::{CollectionDispatchT, CollectionDispatch},123 sponsoring::UniqueSponsorshipHandler,124 eth_sponsoring::UniqueEthSponsorshipHandler,125 weights::CommonWeights,126};127128pub const RUNTIME_NAME: &str = "opal";129pub const TOKEN_SYMBOL: &str = "OPL";130131type CrossAccountId = pallet_evm::account::BasicCrossAccountId<Runtime>;132133impl RuntimeInstance for Runtime {134 type CrossAccountId = self::CrossAccountId;135 type TransactionConverter = self::TransactionConverter;136137 fn get_transaction_converter() -> TransactionConverter {138 TransactionConverter139 }140}141142/// The type for looking up accounts. We don't expect more than 4 billion of them, but you143/// never know...144pub type AccountIndex = u32;145146/// Balance of an account.147pub type Balance = u128;148149/// Index of a transaction in the chain.150pub type Index = u32;151152/// A hash of some data used by the chain.153pub type Hash = sp_core::H256;154155/// Digest item type.156pub type DigestItem = generic::DigestItem;157158/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know159/// the specifics of the runtime. They can then be made to be agnostic over specific formats160/// of data like extrinsics, allowing for them to continue syncing the network through upgrades161/// to even the core data structures.162pub mod opaque {163 use sp_std::prelude::*;164 use sp_runtime::impl_opaque_keys;165 use super::Aura;166167 pub use unique_runtime_common::types::*;168169 impl_opaque_keys! {170 pub struct SessionKeys {171 pub aura: Aura,172 }173 }174}175176/// This runtime version.177pub const VERSION: RuntimeVersion = RuntimeVersion {178 spec_name: create_runtime_str!(RUNTIME_NAME),179 impl_name: create_runtime_str!(RUNTIME_NAME),180 authoring_version: 1,181 spec_version: 920000,182 impl_version: 0,183 apis: RUNTIME_API_VERSIONS,184 transaction_version: 1,185 state_version: 0,186};187188#[derive(codec::Encode, codec::Decode)]189pub enum XCMPMessage<XAccountId, XBalance> {190 /// Transfer tokens to the given account from the Parachain account.191 TransferToken(XAccountId, XBalance),192}193194/// The version information used to identify this runtime when compiled natively.195#[cfg(feature = "std")]196pub fn native_version() -> NativeVersion {197 NativeVersion {198 runtime_version: VERSION,199 can_author_with: Default::default(),200 }201}202203type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;204205pub struct DealWithFees;206impl OnUnbalanced<NegativeImbalance> for DealWithFees {207 fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance>) {208 if let Some(fees) = fees_then_tips.next() {209 // for fees, 100% to treasury210 let mut split = fees.ration(100, 0);211 if let Some(tips) = fees_then_tips.next() {212 // for tips, if any, 100% to treasury213 tips.ration_merge_into(100, 0, &mut split);214 }215 Treasury::on_unbalanced(split.0);216 // Author::on_unbalanced(split.1);217 }218 }219}220221parameter_types! {222 pub const BlockHashCount: BlockNumber = 2400;223 pub RuntimeBlockLength: BlockLength =224 BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);225 pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);226 pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;227 pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()228 .base_block(BlockExecutionWeight::get())229 .for_class(DispatchClass::all(), |weights| {230 weights.base_extrinsic = ExtrinsicBaseWeight::get();231 })232 .for_class(DispatchClass::Normal, |weights| {233 weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);234 })235 .for_class(DispatchClass::Operational, |weights| {236 weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);237 // Operational transactions have some extra reserved space, so that they238 // are included even if block reached `MAXIMUM_BLOCK_WEIGHT`.239 weights.reserved = Some(240 MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT241 );242 })243 .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)244 .build_or_panic();245 pub const Version: RuntimeVersion = VERSION;246 pub const SS58Prefix: u8 = 42;247}248249parameter_types! {250 pub const ChainId: u64 = 8882;251}252253pub struct FixedFee;254impl FeeCalculator for FixedFee {255 fn min_gas_price() -> U256 {256 MIN_GAS_PRICE.into()257 }258}259260// Assuming slowest ethereum opcode is SSTORE, with gas price of 20000 as our worst case261// (contract, which only writes a lot of data),262// approximating on top of our real store write weight263parameter_types! {264 pub const WritesPerSecond: u64 = WEIGHT_PER_SECOND / <Runtime as frame_system::Config>::DbWeight::get().write;265 pub const GasPerSecond: u64 = WritesPerSecond::get() * 20000;266 pub const WeightPerGas: u64 = WEIGHT_PER_SECOND / GasPerSecond::get();267}268269/// Limiting EVM execution to 50% of block for substrate users and management tasks270/// EVM transaction consumes more weight than substrate's, so we can't rely on them being271/// scheduled fairly272const EVM_DISPATCH_RATIO: Perbill = Perbill::from_percent(50);273parameter_types! {274 pub BlockGasLimit: U256 = U256::from(NORMAL_DISPATCH_RATIO * EVM_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT / WeightPerGas::get());275}276277pub enum FixedGasWeightMapping {}278impl GasWeightMapping for FixedGasWeightMapping {279 fn gas_to_weight(gas: u64) -> Weight {280 gas.saturating_mul(WeightPerGas::get())281 }282 fn weight_to_gas(weight: Weight) -> u64 {283 weight / WeightPerGas::get()284 }285}286287impl pallet_evm::account::Config for Runtime {288 type CrossAccountId = pallet_evm::account::BasicCrossAccountId<Self>;289 type EvmAddressMapping = pallet_evm::HashedAddressMapping<Self::Hashing>;290 type EvmBackwardsAddressMapping = fp_evm_mapping::MapBackwardsAddressTruncated;291}292293impl pallet_evm::Config for Runtime {294 type BlockGasLimit = BlockGasLimit;295 type FeeCalculator = FixedFee;296 type GasWeightMapping = FixedGasWeightMapping;297 type BlockHashMapping = pallet_ethereum::EthereumBlockHashMapping<Self>;298 type CallOrigin = EnsureAddressTruncated<Self>;299 type WithdrawOrigin = EnsureAddressTruncated<Self>;300 type AddressMapping = HashedAddressMapping<Self::Hashing>;301 type PrecompilesType = ();302 type PrecompilesValue = ();303 type Currency = Balances;304 type Event = Event;305 type OnMethodCall = (306 pallet_evm_migration::OnMethodCall<Self>,307 pallet_evm_contract_helpers::HelpersOnMethodCall<Self>,308 CollectionDispatchT<Self>,309 );310 type OnCreate = pallet_evm_contract_helpers::HelpersOnCreate<Self>;311 type ChainId = ChainId;312 type Runner = pallet_evm::runner::stack::Runner<Self>;313 type OnChargeTransaction = pallet_evm::EVMCurrencyAdapter<Balances, DealWithFees>;314 type TransactionValidityHack = pallet_evm_transaction_payment::TransactionValidityHack<Self>;315 type FindAuthor = EthereumFindAuthor<Aura>;316}317318impl pallet_evm_migration::Config for Runtime {319 type WeightInfo = pallet_evm_migration::weights::SubstrateWeight<Self>;320}321322pub struct EthereumFindAuthor<F>(core::marker::PhantomData<F>);323impl<F: FindAuthor<u32>> FindAuthor<H160> for EthereumFindAuthor<F> {324 fn find_author<'a, I>(digests: I) -> Option<H160>325 where326 I: 'a + IntoIterator<Item = (ConsensusEngineId, &'a [u8])>,327 {328 if let Some(author_index) = F::find_author(digests) {329 let authority_id = Aura::authorities()[author_index as usize].clone();330 return Some(H160::from_slice(&authority_id.to_raw_vec()[4..24]));331 }332 None333 }334}335336impl pallet_ethereum::Config for Runtime {337 type Event = Event;338 type StateRoot = pallet_ethereum::IntermediateStateRoot<Self>;339}340341impl pallet_randomness_collective_flip::Config for Runtime {}342343impl frame_system::Config for Runtime {344 /// The data to be stored in an account.345 type AccountData = pallet_balances::AccountData<Balance>;346 /// The identifier used to distinguish between accounts.347 type AccountId = AccountId;348 /// The basic call filter to use in dispatchable.349 type BaseCallFilter = Everything;350 /// Maximum number of block number to block hash mappings to keep (oldest pruned first).351 type BlockHashCount = BlockHashCount;352 /// The maximum length of a block (in bytes).353 type BlockLength = RuntimeBlockLength;354 /// The index type for blocks.355 type BlockNumber = BlockNumber;356 /// The weight of the overhead invoked on the block import process, independent of the extrinsics included in that block.357 type BlockWeights = RuntimeBlockWeights;358 /// The aggregated dispatch type that is available for extrinsics.359 type Call = Call;360 /// The weight of database operations that the runtime can invoke.361 type DbWeight = RocksDbWeight;362 /// The ubiquitous event type.363 type Event = Event;364 /// The type for hashing blocks and tries.365 type Hash = Hash;366 /// The hashing algorithm used.367 type Hashing = BlakeTwo256;368 /// The header type.369 type Header = generic::Header<BlockNumber, BlakeTwo256>;370 /// The index type for storing how many extrinsics an account has signed.371 type Index = Index;372 /// The lookup mechanism to get account ID from whatever is passed in dispatchers.373 type Lookup = AccountIdLookup<AccountId, ()>;374 /// What to do if an account is fully reaped from the system.375 type OnKilledAccount = ();376 /// What to do if a new account is created.377 type OnNewAccount = ();378 type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;379 /// The ubiquitous origin type.380 type Origin = Origin;381 /// This type is being generated by `construct_runtime!`.382 type PalletInfo = PalletInfo;383 /// This is used as an identifier of the chain. 42 is the generic substrate prefix.384 type SS58Prefix = SS58Prefix;385 /// Weight information for the extrinsics of this pallet.386 type SystemWeightInfo = frame_system::weights::SubstrateWeight<Self>;387 /// Version of the runtime.388 type Version = Version;389 type MaxConsumers = ConstU32<16>;390}391392parameter_types! {393 pub const MinimumPeriod: u64 = SLOT_DURATION / 2;394}395396impl pallet_timestamp::Config for Runtime {397 /// A timestamp: milliseconds since the unix epoch.398 type Moment = u64;399 type OnTimestampSet = ();400 type MinimumPeriod = MinimumPeriod;401 type WeightInfo = ();402}403404parameter_types! {405 // pub const ExistentialDeposit: u128 = 500;406 pub const ExistentialDeposit: u128 = 0;407 pub const MaxLocks: u32 = 50;408}409410impl pallet_balances::Config for Runtime {411 type MaxLocks = MaxLocks;412 type MaxReserves = ();413 type ReserveIdentifier = [u8; 8];414 /// The type for recording an account's balance.415 type Balance = Balance;416 /// The ubiquitous event type.417 type Event = Event;418 type DustRemoval = Treasury;419 type ExistentialDeposit = ExistentialDeposit;420 type AccountStore = System;421 type WeightInfo = pallet_balances::weights::SubstrateWeight<Self>;422}423424pub const fn deposit(items: u32, bytes: u32) -> Balance {425 items as Balance * 15 * CENTIUNIQUE + (bytes as Balance) * 6 * CENTIUNIQUE426}427428/*429parameter_types! {430 pub TombstoneDeposit: Balance = deposit(431 1,432 sp_std::mem::size_of::<pallet_contracts::Pallet<Runtime>> as u32,433 );434 pub DepositPerContract: Balance = TombstoneDeposit::get();435 pub const DepositPerStorageByte: Balance = deposit(0, 1);436 pub const DepositPerStorageItem: Balance = deposit(1, 0);437 pub RentFraction: Perbill = Perbill::from_rational(1u32, 30 * DAYS);438 pub const SurchargeReward: Balance = 150 * MILLIUNIQUE;439 pub const SignedClaimHandicap: u32 = 2;440 pub const MaxDepth: u32 = 32;441 pub const MaxValueSize: u32 = 16 * 1024;442 pub const MaxCodeSize: u32 = 1024 * 1024 * 25; // 25 Mb443 // The lazy deletion runs inside on_initialize.444 pub DeletionWeightLimit: Weight = AVERAGE_ON_INITIALIZE_RATIO *445 RuntimeBlockWeights::get().max_block;446 // The weight needed for decoding the queue should be less or equal than a fifth447 // of the overall weight dedicated to the lazy deletion.448 pub DeletionQueueDepth: u32 = ((DeletionWeightLimit::get() / (449 <Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(1) -450 <Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(0)451 )) / 5) as u32;452 pub Schedule: pallet_contracts::Schedule<Runtime> = Default::default();453}454455impl pallet_contracts::Config for Runtime {456 type Time = Timestamp;457 type Randomness = RandomnessCollectiveFlip;458 type Currency = Balances;459 type Event = Event;460 type RentPayment = ();461 type SignedClaimHandicap = SignedClaimHandicap;462 type TombstoneDeposit = TombstoneDeposit;463 type DepositPerContract = DepositPerContract;464 type DepositPerStorageByte = DepositPerStorageByte;465 type DepositPerStorageItem = DepositPerStorageItem;466 type RentFraction = RentFraction;467 type SurchargeReward = SurchargeReward;468 type WeightPrice = pallet_transaction_payment::Pallet<Self>;469 type WeightInfo = pallet_contracts::weights::SubstrateWeight<Self>;470 type ChainExtension = NFTExtension;471 type DeletionQueueDepth = DeletionQueueDepth;472 type DeletionWeightLimit = DeletionWeightLimit;473 type Schedule = Schedule;474 type CallStack = [pallet_contracts::Frame<Self>; 31];475}476*/477478parameter_types! {479 /// This value increases the priority of `Operational` transactions by adding480 /// a "virtual tip" that's equal to the `OperationalFeeMultiplier * final_fee`.481 pub const OperationalFeeMultiplier: u8 = 5;482}483484/// Linear implementor of `WeightToFeePolynomial`485pub struct LinearFee<T>(sp_std::marker::PhantomData<T>);486487impl<T> WeightToFeePolynomial for LinearFee<T>488where489 T: BaseArithmetic + From<u32> + Copy + Unsigned,490{491 type Balance = T;492493 fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {494 smallvec!(WeightToFeeCoefficient {495 // Targeting 0.1 Unique per NFT transfer496 coeff_integer: WEIGHT_TO_FEE_COEFF.into(),497 coeff_frac: Perbill::zero(),498 negative: false,499 degree: 1,500 })501 }502}503504impl pallet_transaction_payment::Config for Runtime {505 type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees>;506 type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;507 type OperationalFeeMultiplier = OperationalFeeMultiplier;508 type WeightToFee = LinearFee<Balance>;509 type FeeMultiplierUpdate = ();510}511512parameter_types! {513 pub const ProposalBond: Permill = Permill::from_percent(5);514 pub const ProposalBondMinimum: Balance = 1 * UNIQUE;515 pub const ProposalBondMaximum: Balance = 1000 * UNIQUE;516 pub const SpendPeriod: BlockNumber = 5 * MINUTES;517 pub const Burn: Permill = Permill::from_percent(0);518 pub const TipCountdown: BlockNumber = 1 * DAYS;519 pub const TipFindersFee: Percent = Percent::from_percent(20);520 pub const TipReportDepositBase: Balance = 1 * UNIQUE;521 pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;522 pub const BountyDepositBase: Balance = 1 * UNIQUE;523 pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;524 pub const TreasuryModuleId: PalletId = PalletId(*b"py/trsry");525 pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;526 pub const MaximumReasonLength: u32 = 16384;527 pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);528 pub const BountyValueMinimum: Balance = 5 * UNIQUE;529 pub const MaxApprovals: u32 = 100;530}531532impl pallet_treasury::Config for Runtime {533 type PalletId = TreasuryModuleId;534 type Currency = Balances;535 type ApproveOrigin = EnsureRoot<AccountId>;536 type RejectOrigin = EnsureRoot<AccountId>;537 type Event = Event;538 type OnSlash = ();539 type ProposalBond = ProposalBond;540 type ProposalBondMinimum = ProposalBondMinimum;541 type ProposalBondMaximum = ProposalBondMaximum;542 type SpendPeriod = SpendPeriod;543 type Burn = Burn;544 type BurnDestination = ();545 type SpendFunds = ();546 type WeightInfo = pallet_treasury::weights::SubstrateWeight<Self>;547 type MaxApprovals = MaxApprovals;548}549550impl pallet_sudo::Config for Runtime {551 type Event = Event;552 type Call = Call;553}554555pub struct RelayChainBlockNumberProvider<T>(sp_std::marker::PhantomData<T>);556557impl<T: cumulus_pallet_parachain_system::Config> BlockNumberProvider558 for RelayChainBlockNumberProvider<T>559{560 type BlockNumber = BlockNumber;561562 fn current_block_number() -> Self::BlockNumber {563 cumulus_pallet_parachain_system::Pallet::<T>::validation_data()564 .map(|d| d.relay_parent_number)565 .unwrap_or_default()566 }567}568569parameter_types! {570 pub const MinVestedTransfer: Balance = 10 * UNIQUE;571 pub const MaxVestingSchedules: u32 = 28;572}573574impl orml_vesting::Config for Runtime {575 type Event = Event;576 type Currency = pallet_balances::Pallet<Runtime>;577 type MinVestedTransfer = MinVestedTransfer;578 type VestedTransferOrigin = EnsureSigned<AccountId>;579 type WeightInfo = ();580 type MaxVestingSchedules = MaxVestingSchedules;581 type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;582}583584parameter_types! {585 pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;586 pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;587}588589impl cumulus_pallet_parachain_system::Config for Runtime {590 type Event = Event;591 type SelfParaId = parachain_info::Pallet<Self>;592 type OnSystemEvent = ();593 // type DownwardMessageHandlers = cumulus_primitives_utility::UnqueuedDmpAsParent<594 // MaxDownwardMessageWeight,595 // XcmExecutor<XcmConfig>,596 // Call,597 // >;598 type OutboundXcmpMessageSource = XcmpQueue;599 type DmpMessageHandler = DmpQueue;600 type ReservedDmpWeight = ReservedDmpWeight;601 type ReservedXcmpWeight = ReservedXcmpWeight;602 type XcmpMessageHandler = XcmpQueue;603}604605impl parachain_info::Config for Runtime {}606607impl cumulus_pallet_aura_ext::Config for Runtime {}608609parameter_types! {610 pub const RelayLocation: MultiLocation = MultiLocation::parent();611 pub const RelayNetwork: NetworkId = NetworkId::Polkadot;612 pub RelayOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into();613 pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();614}615616/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used617/// when determining ownership of accounts for asset transacting and when attempting to use XCM618/// `Transact` in order to determine the dispatch Origin.619pub type LocationToAccountId = (620 // The parent (Relay-chain) origin converts to the default `AccountId`.621 ParentIsPreset<AccountId>,622 // Sibling parachain origins convert to AccountId via the `ParaId::into`.623 SiblingParachainConvertsVia<Sibling, AccountId>,624 // Straight up local `AccountId32` origins just alias directly to `AccountId`.625 AccountId32Aliases<RelayNetwork, AccountId>,626);627628pub struct OnlySelfCurrency;629impl<B: TryFrom<u128>> MatchesFungible<B> for OnlySelfCurrency {630 fn matches_fungible(a: &MultiAsset) -> Option<B> {631 match (&a.id, &a.fun) {632 (Concrete(_), XcmFungible(ref amount)) => CheckedConversion::checked_from(*amount),633 _ => None,634 }635 }636}637638/// Means for transacting assets on this chain.639pub type LocalAssetTransactor = CurrencyAdapter<640 // Use this currency:641 Balances,642 // Use this currency when it is a fungible asset matching the given location or name:643 OnlySelfCurrency,644 // Do a simple punn to convert an AccountId32 MultiLocation into a native chain account ID:645 LocationToAccountId,646 // Our chain's account ID type (we can't get away without mentioning it explicitly):647 AccountId,648 // We don't track any teleports.649 (),650>;651652/// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance,653/// ready for dispatching a transaction with Xcm's `Transact`. There is an `OriginKind` which can654/// biases the kind of local `Origin` it will become.655pub type XcmOriginToTransactDispatchOrigin = (656 // Sovereign account converter; this attempts to derive an `AccountId` from the origin location657 // using `LocationToAccountId` and then turn that into the usual `Signed` origin. Useful for658 // foreign chains who want to have a local sovereign account on this chain which they control.659 SovereignSignedViaLocation<LocationToAccountId, Origin>,660 // Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when661 // recognised.662 RelayChainAsNative<RelayOrigin, Origin>,663 // Native converter for sibling Parachains; will convert to a `SiblingPara` origin when664 // recognised.665 SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>,666 // Superuser converter for the Relay-chain (Parent) location. This will allow it to issue a667 // transaction from the Root origin.668 ParentAsSuperuser<Origin>,669 // Native signed account converter; this just converts an `AccountId32` origin into a normal670 // `Origin::Signed` origin of the same 32-byte value.671 SignedAccountId32AsNative<RelayNetwork, Origin>,672 // Xcm origins can be represented natively under the Xcm pallet's Xcm origin.673 XcmPassthrough<Origin>,674);675676parameter_types! {677 // One XCM operation is 1_000_000 weight - almost certainly a conservative estimate.678 pub UnitWeightCost: Weight = 1_000_000;679 // 1200 UNIQUEs buy 1 second of weight.680 pub const WeightPrice: (MultiLocation, u128) = (MultiLocation::parent(), 1_200 * UNIQUE);681 pub const MaxInstructions: u32 = 100;682 pub const MaxAuthorities: u32 = 100_000;683}684685match_types! {686 pub type ParentOrParentsUnitPlurality: impl Contains<MultiLocation> = {687 MultiLocation { parents: 1, interior: Here } |688 MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Unit, .. }) }689 };690}691692pub type Barrier = (693 TakeWeightCredit,694 AllowTopLevelPaidExecutionFrom<Everything>,695 AllowUnpaidExecutionFrom<ParentOrParentsUnitPlurality>,696 // ^^^ Parent & its unit plurality gets free execution697);698699pub struct UsingOnlySelfCurrencyComponents<700 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,701 AssetId: Get<MultiLocation>,702 AccountId,703 Currency: CurrencyT<AccountId>,704 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,705>(706 Weight,707 Currency::Balance,708 PhantomData<(WeightToFee, AssetId, AccountId, Currency, OnUnbalanced)>,709);710impl<711 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,712 AssetId: Get<MultiLocation>,713 AccountId,714 Currency: CurrencyT<AccountId>,715 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,716 > WeightTrader717 for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>718{719 fn new() -> Self {720 Self(0, Zero::zero(), PhantomData)721 }722723 fn buy_weight(&mut self, weight: Weight, payment: Assets) -> Result<Assets, XcmError> {724 let amount = WeightToFee::calc(&weight);725 let u128_amount: u128 = amount.try_into().map_err(|_| XcmError::Overflow)?;726727 // location to this parachain through relay chain728 let option1: xcm::v1::AssetId = Concrete(MultiLocation {729 parents: 1,730 interior: X1(Parachain(ParachainInfo::parachain_id().into())),731 });732 // direct location733 let option2: xcm::v1::AssetId = Concrete(MultiLocation {734 parents: 0,735 interior: Here,736 });737738 let required = if payment.fungible.contains_key(&option1) {739 (option1, u128_amount).into()740 } else if payment.fungible.contains_key(&option2) {741 (option2, u128_amount).into()742 } else {743 (Concrete(MultiLocation::default()), u128_amount).into()744 };745746 let unused = payment747 .checked_sub(required)748 .map_err(|_| XcmError::TooExpensive)?;749 self.0 = self.0.saturating_add(weight);750 self.1 = self.1.saturating_add(amount);751 Ok(unused)752 }753754 fn refund_weight(&mut self, weight: Weight) -> Option<MultiAsset> {755 let weight = weight.min(self.0);756 let amount = WeightToFee::calc(&weight);757 self.0 -= weight;758 self.1 = self.1.saturating_sub(amount);759 let amount: u128 = amount.saturated_into();760 if amount > 0 {761 Some((AssetId::get(), amount).into())762 } else {763 None764 }765 }766}767impl<768 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,769 AssetId: Get<MultiLocation>,770 AccountId,771 Currency: CurrencyT<AccountId>,772 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,773 > Drop774 for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>775{776 fn drop(&mut self) {777 OnUnbalanced::on_unbalanced(Currency::issue(self.1));778 }779}780781pub struct XcmConfig;782impl Config for XcmConfig {783 type Call = Call;784 type XcmSender = XcmRouter;785 // How to withdraw and deposit an asset.786 type AssetTransactor = LocalAssetTransactor;787 type OriginConverter = XcmOriginToTransactDispatchOrigin;788 type IsReserve = NativeAsset;789 type IsTeleporter = (); // Teleportation is disabled790 type LocationInverter = LocationInverter<Ancestry>;791 type Barrier = Barrier;792 type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;793 type Trader = UsingOnlySelfCurrencyComponents<794 IdentityFee<Balance>,795 RelayLocation,796 AccountId,797 Balances,798 (),799 >;800 type ResponseHandler = (); // Don't handle responses for now.801 type SubscriptionService = PolkadotXcm;802803 type AssetTrap = PolkadotXcm;804 type AssetClaims = PolkadotXcm;805}806807// parameter_types! {808// pub const MaxDownwardMessageWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 10;809// }810811/// No local origins on this chain are allowed to dispatch XCM sends/executions.812pub type LocalOriginToLocation = (SignedToAccountId32<Origin, AccountId, RelayNetwork>,);813814/// The means for routing XCM messages which are not for local execution into the right message815/// queues.816pub type XcmRouter = (817 // Two routers - use UMP to communicate with the relay chain:818 cumulus_primitives_utility::ParentAsUmp<ParachainSystem, ()>,819 // ..and XCMP to communicate with the sibling chains.820 XcmpQueue,821);822823impl pallet_evm_coder_substrate::Config for Runtime {824 type EthereumTransactionSender = pallet_ethereum::Pallet<Self>;825 type GasWeightMapping = FixedGasWeightMapping;826}827828impl pallet_xcm::Config for Runtime {829 type Event = Event;830 type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;831 type XcmRouter = XcmRouter;832 type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;833 type XcmExecuteFilter = Everything;834 type XcmExecutor = XcmExecutor<XcmConfig>;835 type XcmTeleportFilter = Everything;836 type XcmReserveTransferFilter = Everything;837 type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;838 type LocationInverter = LocationInverter<Ancestry>;839 type Origin = Origin;840 type Call = Call;841 const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;842 type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;843}844845impl cumulus_pallet_xcm::Config for Runtime {846 type Event = Event;847 type XcmExecutor = XcmExecutor<XcmConfig>;848}849850impl cumulus_pallet_xcmp_queue::Config for Runtime {851 type WeightInfo = ();852 type Event = Event;853 type XcmExecutor = XcmExecutor<XcmConfig>;854 type ChannelInfo = ParachainSystem;855 type VersionWrapper = ();856 type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;857 type ControllerOrigin = EnsureRoot<AccountId>;858 type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;859}860861impl cumulus_pallet_dmp_queue::Config for Runtime {862 type Event = Event;863 type XcmExecutor = XcmExecutor<XcmConfig>;864 type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;865}866867impl pallet_aura::Config for Runtime {868 type AuthorityId = AuraId;869 type DisabledValidators = ();870 type MaxAuthorities = MaxAuthorities;871}872873parameter_types! {874 pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account();875 pub const CollectionCreationPrice: Balance = 2 * UNIQUE;876}877878impl pallet_common::Config for Runtime {879 type Event = Event;880 type Currency = Balances;881 type CollectionCreationPrice = CollectionCreationPrice;882 type TreasuryAccountId = TreasuryAccountId;883 type CollectionDispatch = CollectionDispatchT<Self>;884885 type EvmTokenAddressMapping = EvmTokenAddressMapping;886 type CrossTokenAddressMapping = CrossTokenAddressMapping<Self::AccountId>;887}888889impl pallet_structure::Config for Runtime {890 type Event = Event;891 type Call = Call;892 type WeightInfo = pallet_structure::weights::SubstrateWeight<Self>;893}894895impl pallet_fungible::Config for Runtime {896 type WeightInfo = pallet_fungible::weights::SubstrateWeight<Self>;897}898impl pallet_refungible::Config for Runtime {899 type WeightInfo = pallet_refungible::weights::SubstrateWeight<Self>;900}901impl pallet_nonfungible::Config for Runtime {902 type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;903}904905impl pallet_unique::Config for Runtime {906 type Event = Event;907 type WeightInfo = pallet_unique::weights::SubstrateWeight<Self>;908 type CommonWeightInfo = CommonWeights<Self>;909}910911parameter_types! {912 pub const InflationBlockInterval: BlockNumber = 100; // every time per how many blocks inflation is applied913}914915/// Used for the pallet inflation916impl pallet_inflation::Config for Runtime {917 type Currency = Balances;918 type TreasuryAccountId = TreasuryAccountId;919 type InflationBlockInterval = InflationBlockInterval;920 type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;921}922923// parameter_types! {924// pub MaximumSchedulerWeight: Weight = Perbill::from_percent(50) *925// RuntimeBlockWeights::get().max_block;926// pub const MaxScheduledPerBlock: u32 = 50;927// }928929type EvmSponsorshipHandler = (930 UniqueEthSponsorshipHandler<Runtime>,931 pallet_evm_contract_helpers::HelpersContractSponsoring<Runtime>,932);933type SponsorshipHandler = (934 UniqueSponsorshipHandler<Runtime>,935 //pallet_contract_helpers::ContractSponsorshipHandler<Runtime>,936 pallet_evm_transaction_payment::BridgeSponsorshipHandler<Runtime>,937);938939// impl pallet_unq_scheduler::Config for Runtime {940// type Event = Event;941// type Origin = Origin;942// type PalletsOrigin = OriginCaller;943// type Call = Call;944// type MaximumWeight = MaximumSchedulerWeight;945// type ScheduleOrigin = EnsureSigned<AccountId>;946// type MaxScheduledPerBlock = MaxScheduledPerBlock;947// type SponsorshipHandler = SponsorshipHandler;948// type WeightInfo = ();949// }950951impl pallet_evm_transaction_payment::Config for Runtime {952 type EvmSponsorshipHandler = EvmSponsorshipHandler;953 type Currency = Balances;954}955956impl pallet_charge_transaction::Config for Runtime {957 type SponsorshipHandler = SponsorshipHandler;958}959960// impl pallet_contract_helpers::Config for Runtime {961// type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;962// }963964parameter_types! {965 // 0x842899ECF380553E8a4de75bF534cdf6fBF64049966 pub const HelpersContractAddress: H160 = H160([967 0x84, 0x28, 0x99, 0xec, 0xf3, 0x80, 0x55, 0x3e, 0x8a, 0x4d, 0xe7, 0x5b, 0xf5, 0x34, 0xcd, 0xf6, 0xfb, 0xf6, 0x40, 0x49,968 ]);969}970971impl pallet_evm_contract_helpers::Config for Runtime {972 type ContractAddress = HelpersContractAddress;973 type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;974}975976construct_runtime!(977 pub enum Runtime where978 Block = Block,979 NodeBlock = opaque::Block,980 UncheckedExtrinsic = UncheckedExtrinsic981 {982 ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Config, Storage, Inherent, Event<T>, ValidateUnsigned} = 20,983 ParachainInfo: parachain_info::{Pallet, Storage, Config} = 21,984985 Aura: pallet_aura::{Pallet, Config<T>} = 22,986 AuraExt: cumulus_pallet_aura_ext::{Pallet, Config} = 23,987988 Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 30,989 RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Storage} = 31,990 Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 32,991 TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 33,992 Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>} = 34,993 Sudo: pallet_sudo::{Pallet, Call, Storage, Config<T>, Event<T>} = 35,994 System: frame_system::{Pallet, Call, Storage, Config, Event<T>} = 36,995 Vesting: orml_vesting::{Pallet, Storage, Call, Event<T>, Config<T>} = 37,996 // Vesting: pallet_vesting::{Pallet, Call, Config<T>, Storage, Event<T>} = 37,997 // Contracts: pallet_contracts::{Pallet, Call, Storage, Event<T>} = 38,998999 // XCM helpers.1000 XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 50,1001 PolkadotXcm: pallet_xcm::{Pallet, Call, Event<T>, Origin} = 51,1002 CumulusXcm: cumulus_pallet_xcm::{Pallet, Call, Event<T>, Origin} = 52,1003 DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event<T>} = 53,10041005 // Unique Pallets1006 Inflation: pallet_inflation::{Pallet, Call, Storage} = 60,1007 Unique: pallet_unique::{Pallet, Call, Storage, Event<T>} = 61,1008 // Scheduler: pallet_unq_scheduler::{Pallet, Call, Storage, Event<T>} = 62,1009 // free = 631010 Charging: pallet_charge_transaction::{Pallet, Call, Storage } = 64,1011 // ContractHelpers: pallet_contract_helpers::{Pallet, Call, Storage} = 65,1012 Common: pallet_common::{Pallet, Storage, Event<T>} = 66,1013 Fungible: pallet_fungible::{Pallet, Storage} = 67,1014 Refungible: pallet_refungible::{Pallet, Storage} = 68,1015 Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,1016 Structure: pallet_structure::{Pallet, Call, Storage, Event<T>} = 70,10171018 // Frontier1019 EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,1020 Ethereum: pallet_ethereum::{Pallet, Config, Call, Storage, Event, Origin} = 101,10211022 EvmCoderSubstrate: pallet_evm_coder_substrate::{Pallet, Storage} = 150,1023 EvmContractHelpers: pallet_evm_contract_helpers::{Pallet, Storage} = 151,1024 EvmTransactionPayment: pallet_evm_transaction_payment::{Pallet} = 152,1025 EvmMigration: pallet_evm_migration::{Pallet, Call, Storage} = 153,1026 }1027);10281029pub struct TransactionConverter;10301031impl fp_rpc::ConvertTransaction<UncheckedExtrinsic> for TransactionConverter {1032 fn convert_transaction(&self, transaction: pallet_ethereum::Transaction) -> UncheckedExtrinsic {1033 UncheckedExtrinsic::new_unsigned(1034 pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),1035 )1036 }1037}10381039impl fp_rpc::ConvertTransaction<opaque::UncheckedExtrinsic> for TransactionConverter {1040 fn convert_transaction(1041 &self,1042 transaction: pallet_ethereum::Transaction,1043 ) -> opaque::UncheckedExtrinsic {1044 let extrinsic = UncheckedExtrinsic::new_unsigned(1045 pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),1046 );1047 let encoded = extrinsic.encode();1048 opaque::UncheckedExtrinsic::decode(&mut &encoded[..])1049 .expect("Encoded extrinsic is always valid")1050 }1051}10521053/// The address format for describing accounts.1054pub type Address = sp_runtime::MultiAddress<AccountId, ()>;1055/// Block header type as expected by this runtime.1056pub type Header = generic::Header<BlockNumber, BlakeTwo256>;1057/// Block type as expected by this runtime.1058pub type Block = generic::Block<Header, UncheckedExtrinsic>;1059/// A Block signed with a Justification1060pub type SignedBlock = generic::SignedBlock<Block>;1061/// BlockId type as expected by this runtime.1062pub type BlockId = generic::BlockId<Block>;1063/// The SignedExtension to the basic transaction logic.1064pub type SignedExtra = (1065 frame_system::CheckSpecVersion<Runtime>,1066 // system::CheckTxVersion<Runtime>,1067 frame_system::CheckGenesis<Runtime>,1068 frame_system::CheckEra<Runtime>,1069 frame_system::CheckNonce<Runtime>,1070 frame_system::CheckWeight<Runtime>,1071 pallet_charge_transaction::ChargeTransactionPayment<Runtime>,1072 //pallet_contract_helpers::ContractHelpersExtension<Runtime>,1073);1074/// Unchecked extrinsic type as expected by this runtime.1075pub type UncheckedExtrinsic =1076 fp_self_contained::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;1077/// Extrinsic type that has already been checked.1078pub type CheckedExtrinsic = fp_self_contained::CheckedExtrinsic<AccountId, Call, SignedExtra, H160>;1079/// Executive: handles dispatch to the various modules.1080pub type Executive = frame_executive::Executive<1081 Runtime,1082 Block,1083 frame_system::ChainContext<Runtime>,1084 Runtime,1085 AllPalletsReversedWithSystemFirst,1086>;10871088impl_opaque_keys! {1089 pub struct SessionKeys {1090 pub aura: Aura,1091 }1092}10931094impl fp_self_contained::SelfContainedCall for Call {1095 type SignedInfo = H160;10961097 fn is_self_contained(&self) -> bool {1098 match self {1099 Call::Ethereum(call) => call.is_self_contained(),1100 _ => false,1101 }1102 }11031104 fn check_self_contained(&self) -> Option<Result<Self::SignedInfo, TransactionValidityError>> {1105 match self {1106 Call::Ethereum(call) => call.check_self_contained(),1107 _ => None,1108 }1109 }11101111 fn validate_self_contained(&self, info: &Self::SignedInfo) -> Option<TransactionValidity> {1112 match self {1113 Call::Ethereum(call) => call.validate_self_contained(info),1114 _ => None,1115 }1116 }11171118 fn pre_dispatch_self_contained(1119 &self,1120 info: &Self::SignedInfo,1121 ) -> Option<Result<(), TransactionValidityError>> {1122 match self {1123 Call::Ethereum(call) => call.pre_dispatch_self_contained(info),1124 _ => None,1125 }1126 }11271128 fn apply_self_contained(1129 self,1130 info: Self::SignedInfo,1131 ) -> Option<sp_runtime::DispatchResultWithInfo<PostDispatchInfoOf<Self>>> {1132 match self {1133 call @ Call::Ethereum(pallet_ethereum::Call::transact { .. }) => Some(call.dispatch(1134 Origin::from(pallet_ethereum::RawOrigin::EthereumTransaction(info)),1135 )),1136 _ => None,1137 }1138 }1139}11401141macro_rules! dispatch_unique_runtime {1142 ($collection:ident.$method:ident($($name:ident),*)) => {{1143 let collection = <Runtime as pallet_common::Config>::CollectionDispatch::dispatch(<pallet_common::CollectionHandle<Runtime>>::try_get($collection)?);1144 let dispatch = collection.as_dyn();11451146 Ok(dispatch.$method($($name),*))1147 }};1148}11491150impl_common_runtime_apis!();11511152struct CheckInherents;11531154impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {1155 fn check_inherents(1156 block: &Block,1157 relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof,1158 ) -> sp_inherents::CheckInherentsResult {1159 let relay_chain_slot = relay_state_proof1160 .read_slot()1161 .expect("Could not read the relay chain slot from the proof");11621163 let inherent_data =1164 cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration(1165 relay_chain_slot,1166 sp_std::time::Duration::from_secs(6),1167 )1168 .create_inherent_data()1169 .expect("Could not create the timestamp inherent data");11701171 inherent_data.check_extrinsics(block)1172 }1173}11741175cumulus_pallet_parachain_system::register_validate_block!(1176 Runtime = Runtime,1177 BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,1178 CheckInherents = CheckInherents,1179);1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617//! 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 up_data_structs::mapping::{EvmTokenAddressMapping, CrossTokenAddressMapping};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 xcm::v1::{BodyId, Junction::*, MultiLocation, NetworkId, Junctions::*};97use xcm_builder::{98 AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,99 EnsureXcmOrigin, FixedWeightBounds, LocationInverter, NativeAsset, ParentAsSuperuser,100 RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,101 SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,102 ParentIsPreset,103};104use xcm_executor::{Config, XcmExecutor, Assets};105use sp_std::{marker::PhantomData};106107use xcm::latest::{108 // Xcm,109 AssetId::{Concrete},110 Fungibility::Fungible as XcmFungible,111 MultiAsset,112 Error as XcmError,113};114use xcm_executor::traits::{MatchesFungible, WeightTrader};115//use xcm_executor::traits::MatchesFungible;116use sp_runtime::traits::CheckedConversion;117118use unique_runtime_common::{119 impl_common_runtime_apis,120 types::*,121 constants::*,122 dispatch::{CollectionDispatchT, CollectionDispatch},123 sponsoring::UniqueSponsorshipHandler,124 eth_sponsoring::UniqueEthSponsorshipHandler,125 weights::CommonWeights,126};127128pub const RUNTIME_NAME: &str = "opal";129pub const TOKEN_SYMBOL: &str = "OPL";130131type CrossAccountId = pallet_evm::account::BasicCrossAccountId<Runtime>;132133impl RuntimeInstance for Runtime {134 type CrossAccountId = self::CrossAccountId;135 type TransactionConverter = self::TransactionConverter;136137 fn get_transaction_converter() -> TransactionConverter {138 TransactionConverter139 }140}141142/// The type for looking up accounts. We don't expect more than 4 billion of them, but you143/// never know...144pub type AccountIndex = u32;145146/// Balance of an account.147pub type Balance = u128;148149/// Index of a transaction in the chain.150pub type Index = u32;151152/// A hash of some data used by the chain.153pub type Hash = sp_core::H256;154155/// Digest item type.156pub type DigestItem = generic::DigestItem;157158/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know159/// the specifics of the runtime. They can then be made to be agnostic over specific formats160/// of data like extrinsics, allowing for them to continue syncing the network through upgrades161/// to even the core data structures.162pub mod opaque {163 use sp_std::prelude::*;164 use sp_runtime::impl_opaque_keys;165 use super::Aura;166167 pub use unique_runtime_common::types::*;168169 impl_opaque_keys! {170 pub struct SessionKeys {171 pub aura: Aura,172 }173 }174}175176/// This runtime version.177pub const VERSION: RuntimeVersion = RuntimeVersion {178 spec_name: create_runtime_str!(RUNTIME_NAME),179 impl_name: create_runtime_str!(RUNTIME_NAME),180 authoring_version: 1,181 spec_version: 920000,182 impl_version: 0,183 apis: RUNTIME_API_VERSIONS,184 transaction_version: 1,185 state_version: 0,186};187188#[derive(codec::Encode, codec::Decode)]189pub enum XCMPMessage<XAccountId, XBalance> {190 /// Transfer tokens to the given account from the Parachain account.191 TransferToken(XAccountId, XBalance),192}193194/// The version information used to identify this runtime when compiled natively.195#[cfg(feature = "std")]196pub fn native_version() -> NativeVersion {197 NativeVersion {198 runtime_version: VERSION,199 can_author_with: Default::default(),200 }201}202203type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;204205pub struct DealWithFees;206impl OnUnbalanced<NegativeImbalance> for DealWithFees {207 fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance>) {208 if let Some(fees) = fees_then_tips.next() {209 // for fees, 100% to treasury210 let mut split = fees.ration(100, 0);211 if let Some(tips) = fees_then_tips.next() {212 // for tips, if any, 100% to treasury213 tips.ration_merge_into(100, 0, &mut split);214 }215 Treasury::on_unbalanced(split.0);216 // Author::on_unbalanced(split.1);217 }218 }219}220221parameter_types! {222 pub const BlockHashCount: BlockNumber = 2400;223 pub RuntimeBlockLength: BlockLength =224 BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);225 pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);226 pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;227 pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()228 .base_block(BlockExecutionWeight::get())229 .for_class(DispatchClass::all(), |weights| {230 weights.base_extrinsic = ExtrinsicBaseWeight::get();231 })232 .for_class(DispatchClass::Normal, |weights| {233 weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);234 })235 .for_class(DispatchClass::Operational, |weights| {236 weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);237 // Operational transactions have some extra reserved space, so that they238 // are included even if block reached `MAXIMUM_BLOCK_WEIGHT`.239 weights.reserved = Some(240 MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT241 );242 })243 .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)244 .build_or_panic();245 pub const Version: RuntimeVersion = VERSION;246 pub const SS58Prefix: u8 = 42;247}248249parameter_types! {250 pub const ChainId: u64 = 8882;251}252253pub struct FixedFee;254impl FeeCalculator for FixedFee {255 fn min_gas_price() -> U256 {256 MIN_GAS_PRICE.into()257 }258}259260// Assuming slowest ethereum opcode is SSTORE, with gas price of 20000 as our worst case261// (contract, which only writes a lot of data),262// approximating on top of our real store write weight263parameter_types! {264 pub const WritesPerSecond: u64 = WEIGHT_PER_SECOND / <Runtime as frame_system::Config>::DbWeight::get().write;265 pub const GasPerSecond: u64 = WritesPerSecond::get() * 20000;266 pub const WeightPerGas: u64 = WEIGHT_PER_SECOND / GasPerSecond::get();267}268269/// Limiting EVM execution to 50% of block for substrate users and management tasks270/// EVM transaction consumes more weight than substrate's, so we can't rely on them being271/// scheduled fairly272const EVM_DISPATCH_RATIO: Perbill = Perbill::from_percent(50);273parameter_types! {274 pub BlockGasLimit: U256 = U256::from(NORMAL_DISPATCH_RATIO * EVM_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT / WeightPerGas::get());275}276277pub enum FixedGasWeightMapping {}278impl GasWeightMapping for FixedGasWeightMapping {279 fn gas_to_weight(gas: u64) -> Weight {280 gas.saturating_mul(WeightPerGas::get())281 }282 fn weight_to_gas(weight: Weight) -> u64 {283 weight / WeightPerGas::get()284 }285}286287impl pallet_evm::account::Config for Runtime {288 type CrossAccountId = pallet_evm::account::BasicCrossAccountId<Self>;289 type EvmAddressMapping = pallet_evm::HashedAddressMapping<Self::Hashing>;290 type EvmBackwardsAddressMapping = fp_evm_mapping::MapBackwardsAddressTruncated;291}292293impl pallet_evm::Config for Runtime {294 type BlockGasLimit = BlockGasLimit;295 type FeeCalculator = FixedFee;296 type GasWeightMapping = FixedGasWeightMapping;297 type BlockHashMapping = pallet_ethereum::EthereumBlockHashMapping<Self>;298 type CallOrigin = EnsureAddressTruncated<Self>;299 type WithdrawOrigin = EnsureAddressTruncated<Self>;300 type AddressMapping = HashedAddressMapping<Self::Hashing>;301 type PrecompilesType = ();302 type PrecompilesValue = ();303 type Currency = Balances;304 type Event = Event;305 type OnMethodCall = (306 pallet_evm_migration::OnMethodCall<Self>,307 pallet_evm_contract_helpers::HelpersOnMethodCall<Self>,308 CollectionDispatchT<Self>,309 );310 type OnCreate = pallet_evm_contract_helpers::HelpersOnCreate<Self>;311 type ChainId = ChainId;312 type Runner = pallet_evm::runner::stack::Runner<Self>;313 type OnChargeTransaction = pallet_evm::EVMCurrencyAdapter<Balances, DealWithFees>;314 type TransactionValidityHack = pallet_evm_transaction_payment::TransactionValidityHack<Self>;315 type FindAuthor = EthereumFindAuthor<Aura>;316}317318impl pallet_evm_migration::Config for Runtime {319 type WeightInfo = pallet_evm_migration::weights::SubstrateWeight<Self>;320}321322pub struct EthereumFindAuthor<F>(core::marker::PhantomData<F>);323impl<F: FindAuthor<u32>> FindAuthor<H160> for EthereumFindAuthor<F> {324 fn find_author<'a, I>(digests: I) -> Option<H160>325 where326 I: 'a + IntoIterator<Item = (ConsensusEngineId, &'a [u8])>,327 {328 if let Some(author_index) = F::find_author(digests) {329 let authority_id = Aura::authorities()[author_index as usize].clone();330 return Some(H160::from_slice(&authority_id.to_raw_vec()[4..24]));331 }332 None333 }334}335336impl pallet_ethereum::Config for Runtime {337 type Event = Event;338 type StateRoot = pallet_ethereum::IntermediateStateRoot<Self>;339}340341impl pallet_randomness_collective_flip::Config for Runtime {}342343impl frame_system::Config for Runtime {344 /// The data to be stored in an account.345 type AccountData = pallet_balances::AccountData<Balance>;346 /// The identifier used to distinguish between accounts.347 type AccountId = AccountId;348 /// The basic call filter to use in dispatchable.349 type BaseCallFilter = Everything;350 /// Maximum number of block number to block hash mappings to keep (oldest pruned first).351 type BlockHashCount = BlockHashCount;352 /// The maximum length of a block (in bytes).353 type BlockLength = RuntimeBlockLength;354 /// The index type for blocks.355 type BlockNumber = BlockNumber;356 /// The weight of the overhead invoked on the block import process, independent of the extrinsics included in that block.357 type BlockWeights = RuntimeBlockWeights;358 /// The aggregated dispatch type that is available for extrinsics.359 type Call = Call;360 /// The weight of database operations that the runtime can invoke.361 type DbWeight = RocksDbWeight;362 /// The ubiquitous event type.363 type Event = Event;364 /// The type for hashing blocks and tries.365 type Hash = Hash;366 /// The hashing algorithm used.367 type Hashing = BlakeTwo256;368 /// The header type.369 type Header = generic::Header<BlockNumber, BlakeTwo256>;370 /// The index type for storing how many extrinsics an account has signed.371 type Index = Index;372 /// The lookup mechanism to get account ID from whatever is passed in dispatchers.373 type Lookup = AccountIdLookup<AccountId, ()>;374 /// What to do if an account is fully reaped from the system.375 type OnKilledAccount = ();376 /// What to do if a new account is created.377 type OnNewAccount = ();378 type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;379 /// The ubiquitous origin type.380 type Origin = Origin;381 /// This type is being generated by `construct_runtime!`.382 type PalletInfo = PalletInfo;383 /// This is used as an identifier of the chain. 42 is the generic substrate prefix.384 type SS58Prefix = SS58Prefix;385 /// Weight information for the extrinsics of this pallet.386 type SystemWeightInfo = frame_system::weights::SubstrateWeight<Self>;387 /// Version of the runtime.388 type Version = Version;389 type MaxConsumers = ConstU32<16>;390}391392parameter_types! {393 pub const MinimumPeriod: u64 = SLOT_DURATION / 2;394}395396impl pallet_timestamp::Config for Runtime {397 /// A timestamp: milliseconds since the unix epoch.398 type Moment = u64;399 type OnTimestampSet = ();400 type MinimumPeriod = MinimumPeriod;401 type WeightInfo = ();402}403404parameter_types! {405 // pub const ExistentialDeposit: u128 = 500;406 pub const ExistentialDeposit: u128 = 0;407 pub const MaxLocks: u32 = 50;408}409410impl pallet_balances::Config for Runtime {411 type MaxLocks = MaxLocks;412 type MaxReserves = ();413 type ReserveIdentifier = [u8; 8];414 /// The type for recording an account's balance.415 type Balance = Balance;416 /// The ubiquitous event type.417 type Event = Event;418 type DustRemoval = Treasury;419 type ExistentialDeposit = ExistentialDeposit;420 type AccountStore = System;421 type WeightInfo = pallet_balances::weights::SubstrateWeight<Self>;422}423424pub const fn deposit(items: u32, bytes: u32) -> Balance {425 items as Balance * 15 * CENTIUNIQUE + (bytes as Balance) * 6 * CENTIUNIQUE426}427428/*429parameter_types! {430 pub TombstoneDeposit: Balance = deposit(431 1,432 sp_std::mem::size_of::<pallet_contracts::Pallet<Runtime>> as u32,433 );434 pub DepositPerContract: Balance = TombstoneDeposit::get();435 pub const DepositPerStorageByte: Balance = deposit(0, 1);436 pub const DepositPerStorageItem: Balance = deposit(1, 0);437 pub RentFraction: Perbill = Perbill::from_rational(1u32, 30 * DAYS);438 pub const SurchargeReward: Balance = 150 * MILLIUNIQUE;439 pub const SignedClaimHandicap: u32 = 2;440 pub const MaxDepth: u32 = 32;441 pub const MaxValueSize: u32 = 16 * 1024;442 pub const MaxCodeSize: u32 = 1024 * 1024 * 25; // 25 Mb443 // The lazy deletion runs inside on_initialize.444 pub DeletionWeightLimit: Weight = AVERAGE_ON_INITIALIZE_RATIO *445 RuntimeBlockWeights::get().max_block;446 // The weight needed for decoding the queue should be less or equal than a fifth447 // of the overall weight dedicated to the lazy deletion.448 pub DeletionQueueDepth: u32 = ((DeletionWeightLimit::get() / (449 <Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(1) -450 <Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(0)451 )) / 5) as u32;452 pub Schedule: pallet_contracts::Schedule<Runtime> = Default::default();453}454455impl pallet_contracts::Config for Runtime {456 type Time = Timestamp;457 type Randomness = RandomnessCollectiveFlip;458 type Currency = Balances;459 type Event = Event;460 type RentPayment = ();461 type SignedClaimHandicap = SignedClaimHandicap;462 type TombstoneDeposit = TombstoneDeposit;463 type DepositPerContract = DepositPerContract;464 type DepositPerStorageByte = DepositPerStorageByte;465 type DepositPerStorageItem = DepositPerStorageItem;466 type RentFraction = RentFraction;467 type SurchargeReward = SurchargeReward;468 type WeightPrice = pallet_transaction_payment::Pallet<Self>;469 type WeightInfo = pallet_contracts::weights::SubstrateWeight<Self>;470 type ChainExtension = NFTExtension;471 type DeletionQueueDepth = DeletionQueueDepth;472 type DeletionWeightLimit = DeletionWeightLimit;473 type Schedule = Schedule;474 type CallStack = [pallet_contracts::Frame<Self>; 31];475}476*/477478parameter_types! {479 /// This value increases the priority of `Operational` transactions by adding480 /// a "virtual tip" that's equal to the `OperationalFeeMultiplier * final_fee`.481 pub const OperationalFeeMultiplier: u8 = 5;482}483484/// Linear implementor of `WeightToFeePolynomial`485pub struct LinearFee<T>(sp_std::marker::PhantomData<T>);486487impl<T> WeightToFeePolynomial for LinearFee<T>488where489 T: BaseArithmetic + From<u32> + Copy + Unsigned,490{491 type Balance = T;492493 fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {494 smallvec!(WeightToFeeCoefficient {495 // Targeting 0.1 Unique per NFT transfer496 coeff_integer: WEIGHT_TO_FEE_COEFF.into(),497 coeff_frac: Perbill::zero(),498 negative: false,499 degree: 1,500 })501 }502}503504impl pallet_transaction_payment::Config for Runtime {505 type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees>;506 type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;507 type OperationalFeeMultiplier = OperationalFeeMultiplier;508 type WeightToFee = LinearFee<Balance>;509 type FeeMultiplierUpdate = ();510}511512parameter_types! {513 pub const ProposalBond: Permill = Permill::from_percent(5);514 pub const ProposalBondMinimum: Balance = 1 * UNIQUE;515 pub const ProposalBondMaximum: Balance = 1000 * UNIQUE;516 pub const SpendPeriod: BlockNumber = 5 * MINUTES;517 pub const Burn: Permill = Permill::from_percent(0);518 pub const TipCountdown: BlockNumber = 1 * DAYS;519 pub const TipFindersFee: Percent = Percent::from_percent(20);520 pub const TipReportDepositBase: Balance = 1 * UNIQUE;521 pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;522 pub const BountyDepositBase: Balance = 1 * UNIQUE;523 pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;524 pub const TreasuryModuleId: PalletId = PalletId(*b"py/trsry");525 pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;526 pub const MaximumReasonLength: u32 = 16384;527 pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);528 pub const BountyValueMinimum: Balance = 5 * UNIQUE;529 pub const MaxApprovals: u32 = 100;530}531532impl pallet_treasury::Config for Runtime {533 type PalletId = TreasuryModuleId;534 type Currency = Balances;535 type ApproveOrigin = EnsureRoot<AccountId>;536 type RejectOrigin = EnsureRoot<AccountId>;537 type Event = Event;538 type OnSlash = ();539 type ProposalBond = ProposalBond;540 type ProposalBondMinimum = ProposalBondMinimum;541 type ProposalBondMaximum = ProposalBondMaximum;542 type SpendPeriod = SpendPeriod;543 type Burn = Burn;544 type BurnDestination = ();545 type SpendFunds = ();546 type WeightInfo = pallet_treasury::weights::SubstrateWeight<Self>;547 type MaxApprovals = MaxApprovals;548}549550impl pallet_sudo::Config for Runtime {551 type Event = Event;552 type Call = Call;553}554555pub struct RelayChainBlockNumberProvider<T>(sp_std::marker::PhantomData<T>);556557impl<T: cumulus_pallet_parachain_system::Config> BlockNumberProvider558 for RelayChainBlockNumberProvider<T>559{560 type BlockNumber = BlockNumber;561562 fn current_block_number() -> Self::BlockNumber {563 cumulus_pallet_parachain_system::Pallet::<T>::validation_data()564 .map(|d| d.relay_parent_number)565 .unwrap_or_default()566 }567}568569parameter_types! {570 pub const MinVestedTransfer: Balance = 10 * UNIQUE;571 pub const MaxVestingSchedules: u32 = 28;572}573574impl orml_vesting::Config for Runtime {575 type Event = Event;576 type Currency = pallet_balances::Pallet<Runtime>;577 type MinVestedTransfer = MinVestedTransfer;578 type VestedTransferOrigin = EnsureSigned<AccountId>;579 type WeightInfo = ();580 type MaxVestingSchedules = MaxVestingSchedules;581 type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;582}583584parameter_types! {585 pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;586 pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;587}588589impl cumulus_pallet_parachain_system::Config for Runtime {590 type Event = Event;591 type SelfParaId = parachain_info::Pallet<Self>;592 type OnSystemEvent = ();593 // type DownwardMessageHandlers = cumulus_primitives_utility::UnqueuedDmpAsParent<594 // MaxDownwardMessageWeight,595 // XcmExecutor<XcmConfig>,596 // Call,597 // >;598 type OutboundXcmpMessageSource = XcmpQueue;599 type DmpMessageHandler = DmpQueue;600 type ReservedDmpWeight = ReservedDmpWeight;601 type ReservedXcmpWeight = ReservedXcmpWeight;602 type XcmpMessageHandler = XcmpQueue;603}604605impl parachain_info::Config for Runtime {}606607impl cumulus_pallet_aura_ext::Config for Runtime {}608609parameter_types! {610 pub const RelayLocation: MultiLocation = MultiLocation::parent();611 pub const RelayNetwork: NetworkId = NetworkId::Polkadot;612 pub RelayOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into();613 pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();614}615616/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used617/// when determining ownership of accounts for asset transacting and when attempting to use XCM618/// `Transact` in order to determine the dispatch Origin.619pub type LocationToAccountId = (620 // The parent (Relay-chain) origin converts to the default `AccountId`.621 ParentIsPreset<AccountId>,622 // Sibling parachain origins convert to AccountId via the `ParaId::into`.623 SiblingParachainConvertsVia<Sibling, AccountId>,624 // Straight up local `AccountId32` origins just alias directly to `AccountId`.625 AccountId32Aliases<RelayNetwork, AccountId>,626);627628pub struct OnlySelfCurrency;629impl<B: TryFrom<u128>> MatchesFungible<B> for OnlySelfCurrency {630 fn matches_fungible(a: &MultiAsset) -> Option<B> {631 match (&a.id, &a.fun) {632 (Concrete(_), XcmFungible(ref amount)) => CheckedConversion::checked_from(*amount),633 _ => None,634 }635 }636}637638/// Means for transacting assets on this chain.639pub type LocalAssetTransactor = CurrencyAdapter<640 // Use this currency:641 Balances,642 // Use this currency when it is a fungible asset matching the given location or name:643 OnlySelfCurrency,644 // Do a simple punn to convert an AccountId32 MultiLocation into a native chain account ID:645 LocationToAccountId,646 // Our chain's account ID type (we can't get away without mentioning it explicitly):647 AccountId,648 // We don't track any teleports.649 (),650>;651652/// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance,653/// ready for dispatching a transaction with Xcm's `Transact`. There is an `OriginKind` which can654/// biases the kind of local `Origin` it will become.655pub type XcmOriginToTransactDispatchOrigin = (656 // Sovereign account converter; this attempts to derive an `AccountId` from the origin location657 // using `LocationToAccountId` and then turn that into the usual `Signed` origin. Useful for658 // foreign chains who want to have a local sovereign account on this chain which they control.659 SovereignSignedViaLocation<LocationToAccountId, Origin>,660 // Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when661 // recognised.662 RelayChainAsNative<RelayOrigin, Origin>,663 // Native converter for sibling Parachains; will convert to a `SiblingPara` origin when664 // recognised.665 SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>,666 // Superuser converter for the Relay-chain (Parent) location. This will allow it to issue a667 // transaction from the Root origin.668 ParentAsSuperuser<Origin>,669 // Native signed account converter; this just converts an `AccountId32` origin into a normal670 // `Origin::Signed` origin of the same 32-byte value.671 SignedAccountId32AsNative<RelayNetwork, Origin>,672 // Xcm origins can be represented natively under the Xcm pallet's Xcm origin.673 XcmPassthrough<Origin>,674);675676parameter_types! {677 // One XCM operation is 1_000_000 weight - almost certainly a conservative estimate.678 pub UnitWeightCost: Weight = 1_000_000;679 // 1200 UNIQUEs buy 1 second of weight.680 pub const WeightPrice: (MultiLocation, u128) = (MultiLocation::parent(), 1_200 * UNIQUE);681 pub const MaxInstructions: u32 = 100;682 pub const MaxAuthorities: u32 = 100_000;683}684685match_types! {686 pub type ParentOrParentsUnitPlurality: impl Contains<MultiLocation> = {687 MultiLocation { parents: 1, interior: Here } |688 MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Unit, .. }) }689 };690}691692pub type Barrier = (693 TakeWeightCredit,694 AllowTopLevelPaidExecutionFrom<Everything>,695 AllowUnpaidExecutionFrom<ParentOrParentsUnitPlurality>,696 // ^^^ Parent & its unit plurality gets free execution697);698699pub struct UsingOnlySelfCurrencyComponents<700 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,701 AssetId: Get<MultiLocation>,702 AccountId,703 Currency: CurrencyT<AccountId>,704 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,705>(706 Weight,707 Currency::Balance,708 PhantomData<(WeightToFee, AssetId, AccountId, Currency, OnUnbalanced)>,709);710impl<711 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,712 AssetId: Get<MultiLocation>,713 AccountId,714 Currency: CurrencyT<AccountId>,715 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,716 > WeightTrader717 for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>718{719 fn new() -> Self {720 Self(0, Zero::zero(), PhantomData)721 }722723 fn buy_weight(&mut self, weight: Weight, payment: Assets) -> Result<Assets, XcmError> {724 let amount = WeightToFee::calc(&weight);725 let u128_amount: u128 = amount.try_into().map_err(|_| XcmError::Overflow)?;726727 // location to this parachain through relay chain728 let option1: xcm::v1::AssetId = Concrete(MultiLocation {729 parents: 1,730 interior: X1(Parachain(ParachainInfo::parachain_id().into())),731 });732 // direct location733 let option2: xcm::v1::AssetId = Concrete(MultiLocation {734 parents: 0,735 interior: Here,736 });737738 let required = if payment.fungible.contains_key(&option1) {739 (option1, u128_amount).into()740 } else if payment.fungible.contains_key(&option2) {741 (option2, u128_amount).into()742 } else {743 (Concrete(MultiLocation::default()), u128_amount).into()744 };745746 let unused = payment747 .checked_sub(required)748 .map_err(|_| XcmError::TooExpensive)?;749 self.0 = self.0.saturating_add(weight);750 self.1 = self.1.saturating_add(amount);751 Ok(unused)752 }753754 fn refund_weight(&mut self, weight: Weight) -> Option<MultiAsset> {755 let weight = weight.min(self.0);756 let amount = WeightToFee::calc(&weight);757 self.0 -= weight;758 self.1 = self.1.saturating_sub(amount);759 let amount: u128 = amount.saturated_into();760 if amount > 0 {761 Some((AssetId::get(), amount).into())762 } else {763 None764 }765 }766}767impl<768 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,769 AssetId: Get<MultiLocation>,770 AccountId,771 Currency: CurrencyT<AccountId>,772 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,773 > Drop774 for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>775{776 fn drop(&mut self) {777 OnUnbalanced::on_unbalanced(Currency::issue(self.1));778 }779}780781pub struct XcmConfig;782impl Config for XcmConfig {783 type Call = Call;784 type XcmSender = XcmRouter;785 // How to withdraw and deposit an asset.786 type AssetTransactor = LocalAssetTransactor;787 type OriginConverter = XcmOriginToTransactDispatchOrigin;788 type IsReserve = NativeAsset;789 type IsTeleporter = (); // Teleportation is disabled790 type LocationInverter = LocationInverter<Ancestry>;791 type Barrier = Barrier;792 type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;793 type Trader = UsingOnlySelfCurrencyComponents<794 IdentityFee<Balance>,795 RelayLocation,796 AccountId,797 Balances,798 (),799 >;800 type ResponseHandler = (); // Don't handle responses for now.801 type SubscriptionService = PolkadotXcm;802803 type AssetTrap = PolkadotXcm;804 type AssetClaims = PolkadotXcm;805}806807// parameter_types! {808// pub const MaxDownwardMessageWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 10;809// }810811/// No local origins on this chain are allowed to dispatch XCM sends/executions.812pub type LocalOriginToLocation = (SignedToAccountId32<Origin, AccountId, RelayNetwork>,);813814/// The means for routing XCM messages which are not for local execution into the right message815/// queues.816pub type XcmRouter = (817 // Two routers - use UMP to communicate with the relay chain:818 cumulus_primitives_utility::ParentAsUmp<ParachainSystem, ()>,819 // ..and XCMP to communicate with the sibling chains.820 XcmpQueue,821);822823impl pallet_evm_coder_substrate::Config for Runtime {824 type GasWeightMapping = FixedGasWeightMapping;825}826827impl pallet_xcm::Config for Runtime {828 type Event = Event;829 type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;830 type XcmRouter = XcmRouter;831 type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;832 type XcmExecuteFilter = Everything;833 type XcmExecutor = XcmExecutor<XcmConfig>;834 type XcmTeleportFilter = Everything;835 type XcmReserveTransferFilter = Everything;836 type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;837 type LocationInverter = LocationInverter<Ancestry>;838 type Origin = Origin;839 type Call = Call;840 const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;841 type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;842}843844impl cumulus_pallet_xcm::Config for Runtime {845 type Event = Event;846 type XcmExecutor = XcmExecutor<XcmConfig>;847}848849impl cumulus_pallet_xcmp_queue::Config for Runtime {850 type WeightInfo = ();851 type Event = Event;852 type XcmExecutor = XcmExecutor<XcmConfig>;853 type ChannelInfo = ParachainSystem;854 type VersionWrapper = ();855 type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;856 type ControllerOrigin = EnsureRoot<AccountId>;857 type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;858}859860impl cumulus_pallet_dmp_queue::Config for Runtime {861 type Event = Event;862 type XcmExecutor = XcmExecutor<XcmConfig>;863 type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;864}865866impl pallet_aura::Config for Runtime {867 type AuthorityId = AuraId;868 type DisabledValidators = ();869 type MaxAuthorities = MaxAuthorities;870}871872parameter_types! {873 pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account();874 pub const CollectionCreationPrice: Balance = 2 * UNIQUE;875}876877impl pallet_common::Config for Runtime {878 type Event = Event;879 type Currency = Balances;880 type CollectionCreationPrice = CollectionCreationPrice;881 type TreasuryAccountId = TreasuryAccountId;882 type CollectionDispatch = CollectionDispatchT<Self>;883884 type EvmTokenAddressMapping = EvmTokenAddressMapping;885 type CrossTokenAddressMapping = CrossTokenAddressMapping<Self::AccountId>;886}887888impl pallet_structure::Config for Runtime {889 type Event = Event;890 type Call = Call;891 type WeightInfo = pallet_structure::weights::SubstrateWeight<Self>;892}893894impl pallet_fungible::Config for Runtime {895 type WeightInfo = pallet_fungible::weights::SubstrateWeight<Self>;896}897impl pallet_refungible::Config for Runtime {898 type WeightInfo = pallet_refungible::weights::SubstrateWeight<Self>;899}900impl pallet_nonfungible::Config for Runtime {901 type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;902}903904impl pallet_unique::Config for Runtime {905 type Event = Event;906 type WeightInfo = pallet_unique::weights::SubstrateWeight<Self>;907 type CommonWeightInfo = CommonWeights<Self>;908}909910parameter_types! {911 pub const InflationBlockInterval: BlockNumber = 100; // every time per how many blocks inflation is applied912}913914/// Used for the pallet inflation915impl pallet_inflation::Config for Runtime {916 type Currency = Balances;917 type TreasuryAccountId = TreasuryAccountId;918 type InflationBlockInterval = InflationBlockInterval;919 type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;920}921922// parameter_types! {923// pub MaximumSchedulerWeight: Weight = Perbill::from_percent(50) *924// RuntimeBlockWeights::get().max_block;925// pub const MaxScheduledPerBlock: u32 = 50;926// }927928type EvmSponsorshipHandler = (929 UniqueEthSponsorshipHandler<Runtime>,930 pallet_evm_contract_helpers::HelpersContractSponsoring<Runtime>,931);932type SponsorshipHandler = (933 UniqueSponsorshipHandler<Runtime>,934 //pallet_contract_helpers::ContractSponsorshipHandler<Runtime>,935 pallet_evm_transaction_payment::BridgeSponsorshipHandler<Runtime>,936);937938// impl pallet_unq_scheduler::Config for Runtime {939// type Event = Event;940// type Origin = Origin;941// type PalletsOrigin = OriginCaller;942// type Call = Call;943// type MaximumWeight = MaximumSchedulerWeight;944// type ScheduleOrigin = EnsureSigned<AccountId>;945// type MaxScheduledPerBlock = MaxScheduledPerBlock;946// type SponsorshipHandler = SponsorshipHandler;947// type WeightInfo = ();948// }949950impl pallet_evm_transaction_payment::Config for Runtime {951 type EvmSponsorshipHandler = EvmSponsorshipHandler;952 type Currency = Balances;953}954955impl pallet_charge_transaction::Config for Runtime {956 type SponsorshipHandler = SponsorshipHandler;957}958959// impl pallet_contract_helpers::Config for Runtime {960// type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;961// }962963parameter_types! {964 // 0x842899ECF380553E8a4de75bF534cdf6fBF64049965 pub const HelpersContractAddress: H160 = H160([966 0x84, 0x28, 0x99, 0xec, 0xf3, 0x80, 0x55, 0x3e, 0x8a, 0x4d, 0xe7, 0x5b, 0xf5, 0x34, 0xcd, 0xf6, 0xfb, 0xf6, 0x40, 0x49,967 ]);968}969970impl pallet_evm_contract_helpers::Config for Runtime {971 type ContractAddress = HelpersContractAddress;972 type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;973}974975construct_runtime!(976 pub enum Runtime where977 Block = Block,978 NodeBlock = opaque::Block,979 UncheckedExtrinsic = UncheckedExtrinsic980 {981 ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Config, Storage, Inherent, Event<T>, ValidateUnsigned} = 20,982 ParachainInfo: parachain_info::{Pallet, Storage, Config} = 21,983984 Aura: pallet_aura::{Pallet, Config<T>} = 22,985 AuraExt: cumulus_pallet_aura_ext::{Pallet, Config} = 23,986987 Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 30,988 RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Storage} = 31,989 Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 32,990 TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 33,991 Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>} = 34,992 Sudo: pallet_sudo::{Pallet, Call, Storage, Config<T>, Event<T>} = 35,993 System: frame_system::{Pallet, Call, Storage, Config, Event<T>} = 36,994 Vesting: orml_vesting::{Pallet, Storage, Call, Event<T>, Config<T>} = 37,995 // Vesting: pallet_vesting::{Pallet, Call, Config<T>, Storage, Event<T>} = 37,996 // Contracts: pallet_contracts::{Pallet, Call, Storage, Event<T>} = 38,997998 // XCM helpers.999 XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 50,1000 PolkadotXcm: pallet_xcm::{Pallet, Call, Event<T>, Origin} = 51,1001 CumulusXcm: cumulus_pallet_xcm::{Pallet, Call, Event<T>, Origin} = 52,1002 DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event<T>} = 53,10031004 // Unique Pallets1005 Inflation: pallet_inflation::{Pallet, Call, Storage} = 60,1006 Unique: pallet_unique::{Pallet, Call, Storage, Event<T>} = 61,1007 // Scheduler: pallet_unq_scheduler::{Pallet, Call, Storage, Event<T>} = 62,1008 // free = 631009 Charging: pallet_charge_transaction::{Pallet, Call, Storage } = 64,1010 // ContractHelpers: pallet_contract_helpers::{Pallet, Call, Storage} = 65,1011 Common: pallet_common::{Pallet, Storage, Event<T>} = 66,1012 Fungible: pallet_fungible::{Pallet, Storage} = 67,1013 Refungible: pallet_refungible::{Pallet, Storage} = 68,1014 Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,1015 Structure: pallet_structure::{Pallet, Call, Storage, Event<T>} = 70,10161017 // Frontier1018 EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,1019 Ethereum: pallet_ethereum::{Pallet, Config, Call, Storage, Event, Origin} = 101,10201021 EvmCoderSubstrate: pallet_evm_coder_substrate::{Pallet, Storage} = 150,1022 EvmContractHelpers: pallet_evm_contract_helpers::{Pallet, Storage} = 151,1023 EvmTransactionPayment: pallet_evm_transaction_payment::{Pallet} = 152,1024 EvmMigration: pallet_evm_migration::{Pallet, Call, Storage} = 153,1025 }1026);10271028pub struct TransactionConverter;10291030impl fp_rpc::ConvertTransaction<UncheckedExtrinsic> for TransactionConverter {1031 fn convert_transaction(&self, transaction: pallet_ethereum::Transaction) -> UncheckedExtrinsic {1032 UncheckedExtrinsic::new_unsigned(1033 pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),1034 )1035 }1036}10371038impl fp_rpc::ConvertTransaction<opaque::UncheckedExtrinsic> for TransactionConverter {1039 fn convert_transaction(1040 &self,1041 transaction: pallet_ethereum::Transaction,1042 ) -> opaque::UncheckedExtrinsic {1043 let extrinsic = UncheckedExtrinsic::new_unsigned(1044 pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),1045 );1046 let encoded = extrinsic.encode();1047 opaque::UncheckedExtrinsic::decode(&mut &encoded[..])1048 .expect("Encoded extrinsic is always valid")1049 }1050}10511052/// The address format for describing accounts.1053pub type Address = sp_runtime::MultiAddress<AccountId, ()>;1054/// Block header type as expected by this runtime.1055pub type Header = generic::Header<BlockNumber, BlakeTwo256>;1056/// Block type as expected by this runtime.1057pub type Block = generic::Block<Header, UncheckedExtrinsic>;1058/// A Block signed with a Justification1059pub type SignedBlock = generic::SignedBlock<Block>;1060/// BlockId type as expected by this runtime.1061pub type BlockId = generic::BlockId<Block>;1062/// The SignedExtension to the basic transaction logic.1063pub type SignedExtra = (1064 frame_system::CheckSpecVersion<Runtime>,1065 // system::CheckTxVersion<Runtime>,1066 frame_system::CheckGenesis<Runtime>,1067 frame_system::CheckEra<Runtime>,1068 frame_system::CheckNonce<Runtime>,1069 frame_system::CheckWeight<Runtime>,1070 pallet_charge_transaction::ChargeTransactionPayment<Runtime>,1071 //pallet_contract_helpers::ContractHelpersExtension<Runtime>,1072 pallet_ethereum::FakeTransactionFinalizer<Runtime>,1073);1074/// Unchecked extrinsic type as expected by this runtime.1075pub type UncheckedExtrinsic =1076 fp_self_contained::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;1077/// Extrinsic type that has already been checked.1078pub type CheckedExtrinsic = fp_self_contained::CheckedExtrinsic<AccountId, Call, SignedExtra, H160>;1079/// Executive: handles dispatch to the various modules.1080pub type Executive = frame_executive::Executive<1081 Runtime,1082 Block,1083 frame_system::ChainContext<Runtime>,1084 Runtime,1085 AllPalletsReversedWithSystemFirst,1086>;10871088impl_opaque_keys! {1089 pub struct SessionKeys {1090 pub aura: Aura,1091 }1092}10931094impl fp_self_contained::SelfContainedCall for Call {1095 type SignedInfo = H160;10961097 fn is_self_contained(&self) -> bool {1098 match self {1099 Call::Ethereum(call) => call.is_self_contained(),1100 _ => false,1101 }1102 }11031104 fn check_self_contained(&self) -> Option<Result<Self::SignedInfo, TransactionValidityError>> {1105 match self {1106 Call::Ethereum(call) => call.check_self_contained(),1107 _ => None,1108 }1109 }11101111 fn validate_self_contained(&self, info: &Self::SignedInfo) -> Option<TransactionValidity> {1112 match self {1113 Call::Ethereum(call) => call.validate_self_contained(info),1114 _ => None,1115 }1116 }11171118 fn pre_dispatch_self_contained(1119 &self,1120 info: &Self::SignedInfo,1121 ) -> Option<Result<(), TransactionValidityError>> {1122 match self {1123 Call::Ethereum(call) => call.pre_dispatch_self_contained(info),1124 _ => None,1125 }1126 }11271128 fn apply_self_contained(1129 self,1130 info: Self::SignedInfo,1131 ) -> Option<sp_runtime::DispatchResultWithInfo<PostDispatchInfoOf<Self>>> {1132 match self {1133 call @ Call::Ethereum(pallet_ethereum::Call::transact { .. }) => Some(call.dispatch(1134 Origin::from(pallet_ethereum::RawOrigin::EthereumTransaction(info)),1135 )),1136 _ => None,1137 }1138 }1139}11401141macro_rules! dispatch_unique_runtime {1142 ($collection:ident.$method:ident($($name:ident),*)) => {{1143 let collection = <Runtime as pallet_common::Config>::CollectionDispatch::dispatch(<pallet_common::CollectionHandle<Runtime>>::try_get($collection)?);1144 let dispatch = collection.as_dyn();11451146 Ok(dispatch.$method($($name),*))1147 }};1148}11491150impl_common_runtime_apis!();11511152struct CheckInherents;11531154impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {1155 fn check_inherents(1156 block: &Block,1157 relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof,1158 ) -> sp_inherents::CheckInherentsResult {1159 let relay_chain_slot = relay_state_proof1160 .read_slot()1161 .expect("Could not read the relay chain slot from the proof");11621163 let inherent_data =1164 cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration(1165 relay_chain_slot,1166 sp_std::time::Duration::from_secs(6),1167 )1168 .create_inherent_data()1169 .expect("Could not create the timestamp inherent data");11701171 inherent_data.check_extrinsics(block)1172 }1173}11741175cumulus_pallet_parachain_system::register_validate_block!(1176 Runtime = Runtime,1177 BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,1178 CheckInherents = CheckInherents,1179);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.rsdiffbeforeafterboth--- a/runtime/quartz/src/lib.rs
+++ b/runtime/quartz/src/lib.rs
@@ -793,7 +793,6 @@
);
impl pallet_evm_coder_substrate::Config for Runtime {
- type EthereumTransactionSender = pallet_ethereum::Pallet<Self>;
type GasWeightMapping = FixedGasWeightMapping;
}
@@ -1048,6 +1047,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/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,