difftreelog
build upgrade frontier
in: master
4 files changed
node/src/rpc.rsdiffbeforeafterboth4//! capabilities that are specific to this project's runtime configuration.4//! capabilities that are specific to this project's runtime configuration.556use std::sync::Arc;6use std::sync::Arc;7use core::marker::PhantomData;788use std::collections::BTreeMap;9use std::collections::BTreeMap;10use fc_rpc::RuntimeApiStorageOverride;11use fc_rpc::OverrideHandle;9use fc_rpc_core::types::{PendingTransactions, FilterPool};12use fc_rpc_core::types::{PendingTransactions, FilterPool};10use nft_runtime::{Hash, AccountId, Index, opaque::Block, BlockNumber, Balance};13use nft_runtime::{Hash, AccountId, Index, opaque::Block, BlockNumber, Balance, NftApi};11use sp_api::ProvideRuntimeApi;14use sp_api::ProvideRuntimeApi;12use sp_blockchain::{Error as BlockChainError, HeaderMetadata, HeaderBackend};15use sp_blockchain::{Error as BlockChainError, HeaderMetadata, HeaderBackend};13use sc_client_api::{16use sc_client_api::{56 pub filter_pool: Option<FilterPool>,59 pub filter_pool: Option<FilterPool>,57 /// Backend.60 /// Backend.58 pub backend: Arc<fc_db::Backend<Block>>,61 pub backend: Arc<fc_db::Backend<Block>>,62 /// Maximum number of logs in a query.63 pub max_past_logs: u32,59}64}6566struct AccountCodes<C, B> {67 client: Arc<C>,68 _marker: PhantomData<B>,69}7071impl<C, Block> AccountCodes<C, Block>72where73 Block: sp_api::BlockT,74 C: ProvideRuntimeApi<Block>,75{76 fn new(client: Arc<C>) -> Self {77 Self {78 client,79 _marker: PhantomData,80 }81 }82}8384impl<C, Block> fc_rpc::AccountCodeProvider<Block> for AccountCodes<C, Block>85where86 Block: sp_api::BlockT,87 C: ProvideRuntimeApi<Block>,88 C::Api: pallet_nft::NftApi<Block>,89{90 fn code(&self, block: &sp_api::BlockId<Block>, account: sp_core::H160) -> Option<Vec<u8>> {91 self.client.runtime_api().eth_contract_code(block, account).ok().flatten()92 }93}609461/// Instantiate all full RPC extensions.95/// Instantiate all full RPC extensions.62pub fn create_full<C, P, BE>(96pub fn create_full<C, P, BE>(74 C::Api: pallet_contracts_rpc::ContractsRuntimeApi<Block, AccountId, Balance, BlockNumber>,108 C::Api: pallet_contracts_rpc::ContractsRuntimeApi<Block, AccountId, Balance, BlockNumber>,75 C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>,109 C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>,76 C::Api: fp_rpc::EthereumRuntimeRPCApi<Block>,110 C::Api: fp_rpc::EthereumRuntimeRPCApi<Block>,111 C::Api: pallet_nft::NftApi<Block>,77 P: TransactionPool<Block=Block> + 'static,112 P: TransactionPool<Block=Block> + 'static,78{113{79 use substrate_frame_rpc_system::{FullSystem, SystemApi};114 use substrate_frame_rpc_system::{FullSystem, SystemApi};95 filter_pool,130 filter_pool,96 backend,131 backend,97 enable_dev_signer,132 enable_dev_signer,133 max_past_logs,98 } = deps;134 } = deps;99135100 io.extend_with(136 io.extend_with(113 if enable_dev_signer {149 if enable_dev_signer {114 signers.push(Box::new(EthDevSigner::new()) as Box<dyn EthSigner>);150 signers.push(Box::new(EthDevSigner::new()) as Box<dyn EthSigner>);115 }151 }116 let mut overrides = BTreeMap::new();152 let mut overrides_map = BTreeMap::new();117 overrides.insert(153 overrides_map.insert(118 EthereumStorageSchema::V1,154 EthereumStorageSchema::V1,119 Box::new(SchemaV1Override::new(client.clone())) as Box<dyn StorageOverride<_> + Send + Sync>155 Box::new(SchemaV1Override::new_with_code_provider(156 client.clone(),157 Arc::new(AccountCodes::<C, Block>::new(client.clone()))158 )) as Box<dyn StorageOverride<_> + Send + Sync>120 );159 );160161 let overrides = Arc::new(OverrideHandle {162 schemas: overrides_map,163 fallback: Box::new(RuntimeApiStorageOverride::new(client.clone())),164 });165121 io.extend_with(166 io.extend_with(122 EthApiServer::to_delegate(EthApi::new(167 EthApiServer::to_delegate(EthApi::new(126 network.clone(),171 network.clone(),127 pending_transactions.clone(),172 pending_transactions.clone(),128 signers,173 signers,129 overrides,174 overrides.clone(),130 backend,175 backend,131 is_authority,176 is_authority,177 max_past_logs,132 ))178 ))133 );179 );134180138 client.clone(),184 client.clone(),139 filter_pool.clone(),185 filter_pool.clone(),140 500 as usize, // max stored filters186 500 as usize, // max stored filters187 overrides.clone(),188 max_past_logs,141 ))189 ))142 );190 );143 }191 }164 HexEncodedIdProvider::default(),212 HexEncodedIdProvider::default(),165 Arc::new(subscription_task_executor)213 Arc::new(subscription_task_executor)166 ),214 ),215 overrides,167 ))216 ))168 );217 );169218node/src/service.rsdiffbeforeafterboth--- a/node/src/service.rs
+++ b/node/src/service.rs
@@ -237,6 +237,8 @@
let pending = pending_transactions.clone();
let filter_pool = filter_pool.clone();
let frontier_backend = frontier_backend.clone();
+ // TODO: Tune
+ let max_past_logs = 10000;
Box::new(move |deny_unsafe, _| {
let deps = crate::rpc::FullDeps {
@@ -249,6 +251,7 @@
pending_transactions: pending.clone(),
filter_pool: filter_pool.clone(),
backend: frontier_backend.clone(),
+ max_past_logs,
};
crate::rpc::create_full(
deps,
pallets/nft/src/lib.rsdiffbeforeafterboth--- a/pallets/nft/src/lib.rs
+++ b/pallets/nft/src/lib.rs
@@ -2889,4 +2889,11 @@
}
}
-// #endregion
\ No newline at end of file
+// #endregion
+
+sp_api::decl_runtime_apis! {
+ pub trait NftApi {
+ /// Used for ethereum integration
+ fn eth_contract_code(account: H160) -> Option<Vec<u8>>;
+ }
+}
runtime/src/lib.rsdiffbeforeafterboth--- a/runtime/src/lib.rs
+++ b/runtime/src/lib.rs
@@ -64,7 +64,7 @@
use sp_arithmetic::{traits::{BaseArithmetic, Unsigned}};
use smallvec::smallvec;
use codec::{Encode, Decode};
-use pallet_evm::{Account as EVMAccount, FeeCalculator};
+use pallet_evm::{Account as EVMAccount, FeeCalculator, OnMethodCall};
use fp_rpc::TransactionStatus;
use sp_core::H256;
@@ -344,14 +344,16 @@
}
impl pallet_evm::Config for Runtime {
+ type BlockGasLimit = BlockGasLimit;
type FeeCalculator = ();
type GasWeightMapping = ();
type CallOrigin = EnsureAddressTruncated;
type WithdrawOrigin = EnsureAddressTruncated;
- type AddressMapping = HashedAddressMapping<BlakeTwo256>;
+ type AddressMapping = HashedAddressMapping<Self::Hashing>;
+ type Precompiles = ();
type Currency = Balances;
type Event = Event;
- type Precompiles = ();
+ type OnMethodCall = pallet_nft::NftErcSupport<Self>;
type ChainId = ChainId;
type Runner = pallet_evm::runner::stack::Runner<Self>;
type OnChargeTransaction = ();
@@ -379,7 +381,6 @@
type Event = Event;
type FindAuthor = EthereumFindAuthor<Aura>;
type StateRoot = pallet_ethereum::IntermediateStateRoot;
- type BlockGasLimit = BlockGasLimit;
}
impl pallet_grandpa::Config for Runtime {
@@ -657,6 +658,13 @@
frame_executive::Executive<Runtime, Block, system::ChainContext<Runtime>, Runtime, AllModules>;
impl_runtime_apis! {
+ impl pallet_nft::NftApi<Block>
+ for Runtime
+ {
+ fn eth_contract_code(account: H160) -> Option<Vec<u8>> {
+ <pallet_nft::NftErcSupport<Runtime>>::get_code(&account)
+ }
+ }
impl pallet_contracts_rpc_runtime_api::ContractsApi<Block, AccountId, Balance, BlockNumber>
for Runtime