difftreelog
build upgrade frontier
in: master
4 files changed
node/src/rpc.rsdiffbeforeafterboth--- a/node/src/rpc.rs
+++ b/node/src/rpc.rs
@@ -4,10 +4,13 @@
//! capabilities that are specific to this project's runtime configuration.
use std::sync::Arc;
+use core::marker::PhantomData;
use std::collections::BTreeMap;
+use fc_rpc::RuntimeApiStorageOverride;
+use fc_rpc::OverrideHandle;
use fc_rpc_core::types::{PendingTransactions, FilterPool};
-use nft_runtime::{Hash, AccountId, Index, opaque::Block, BlockNumber, Balance};
+use nft_runtime::{Hash, AccountId, Index, opaque::Block, BlockNumber, Balance, NftApi};
use sp_api::ProvideRuntimeApi;
use sp_blockchain::{Error as BlockChainError, HeaderMetadata, HeaderBackend};
use sc_client_api::{
@@ -56,8 +59,39 @@
pub filter_pool: Option<FilterPool>,
/// Backend.
pub backend: Arc<fc_db::Backend<Block>>,
+ /// Maximum number of logs in a query.
+ pub max_past_logs: u32,
+}
+
+struct AccountCodes<C, B> {
+ client: Arc<C>,
+ _marker: PhantomData<B>,
+}
+
+impl<C, Block> AccountCodes<C, Block>
+where
+ Block: sp_api::BlockT,
+ C: ProvideRuntimeApi<Block>,
+{
+ fn new(client: Arc<C>) -> Self {
+ Self {
+ client,
+ _marker: PhantomData,
+ }
+ }
}
+impl<C, Block> fc_rpc::AccountCodeProvider<Block> for AccountCodes<C, Block>
+where
+ Block: sp_api::BlockT,
+ C: ProvideRuntimeApi<Block>,
+ C::Api: pallet_nft::NftApi<Block>,
+{
+ fn code(&self, block: &sp_api::BlockId<Block>, account: sp_core::H160) -> Option<Vec<u8>> {
+ self.client.runtime_api().eth_contract_code(block, account).ok().flatten()
+ }
+}
+
/// Instantiate all full RPC extensions.
pub fn create_full<C, P, BE>(
deps: FullDeps<C, P>,
@@ -74,6 +108,7 @@
C::Api: pallet_contracts_rpc::ContractsRuntimeApi<Block, AccountId, Balance, BlockNumber>,
C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>,
C::Api: fp_rpc::EthereumRuntimeRPCApi<Block>,
+ C::Api: pallet_nft::NftApi<Block>,
P: TransactionPool<Block=Block> + 'static,
{
use substrate_frame_rpc_system::{FullSystem, SystemApi};
@@ -95,6 +130,7 @@
filter_pool,
backend,
enable_dev_signer,
+ max_past_logs,
} = deps;
io.extend_with(
@@ -113,11 +149,20 @@
if enable_dev_signer {
signers.push(Box::new(EthDevSigner::new()) as Box<dyn EthSigner>);
}
- let mut overrides = BTreeMap::new();
- overrides.insert(
+ let mut overrides_map = BTreeMap::new();
+ overrides_map.insert(
EthereumStorageSchema::V1,
- Box::new(SchemaV1Override::new(client.clone())) as Box<dyn StorageOverride<_> + Send + Sync>
+ Box::new(SchemaV1Override::new_with_code_provider(
+ client.clone(),
+ Arc::new(AccountCodes::<C, Block>::new(client.clone()))
+ )) as Box<dyn StorageOverride<_> + Send + Sync>
);
+
+ let overrides = Arc::new(OverrideHandle {
+ schemas: overrides_map,
+ fallback: Box::new(RuntimeApiStorageOverride::new(client.clone())),
+ });
+
io.extend_with(
EthApiServer::to_delegate(EthApi::new(
client.clone(),
@@ -126,9 +171,10 @@
network.clone(),
pending_transactions.clone(),
signers,
- overrides,
+ overrides.clone(),
backend,
is_authority,
+ max_past_logs,
))
);
@@ -138,6 +184,8 @@
client.clone(),
filter_pool.clone(),
500 as usize, // max stored filters
+ overrides.clone(),
+ max_past_logs,
))
);
}
@@ -164,6 +212,7 @@
HexEncodedIdProvider::default(),
Arc::new(subscription_task_executor)
),
+ overrides,
))
);
node/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.rsdiffbeforeafterboth289128912892// #endregion2892// #endregion28932894sp_api::decl_runtime_apis! {2895 pub trait NftApi {2896 /// Used for ethereum integration2897 fn eth_contract_code(account: H160) -> Option<Vec<u8>>;2898 }2899}2900runtime/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