git.delta.rocks / unique-network / refs/commits / 6e0419083caa

difftreelog

build upgrade frontier

Yaroslav Bolyukin2021-04-30parent: #733eebb.patch.diff
in: master

4 files changed

modifiednode/src/rpc.rsdiffbeforeafterboth
4//! capabilities that are specific to this project's runtime configuration.4//! capabilities that are specific to this project's runtime configuration.
55
6use std::sync::Arc;6use std::sync::Arc;
7use core::marker::PhantomData;
78
8use 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}
65
66struct AccountCodes<C, B> {
67 client: Arc<C>,
68 _marker: PhantomData<B>,
69}
70
71impl<C, Block> AccountCodes<C, Block>
72where
73 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}
83
84impl<C, Block> fc_rpc::AccountCodeProvider<Block> for AccountCodes<C, Block>
85where
86 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}
6094
61/// 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;
99135
100 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 );
160
161 let overrides = Arc::new(OverrideHandle {
162 schemas: overrides_map,
163 fallback: Box::new(RuntimeApiStorageOverride::new(client.clone())),
164 });
165
121 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 );
134180
138 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 filters
187 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 );
169218
modifiednode/src/service.rsdiffbeforeafterboth
237 let pending = pending_transactions.clone();237 let pending = pending_transactions.clone();
238 let filter_pool = filter_pool.clone();238 let filter_pool = filter_pool.clone();
239 let frontier_backend = frontier_backend.clone();239 let frontier_backend = frontier_backend.clone();
240 // TODO: Tune
241 let max_past_logs = 10000;
240242
241 Box::new(move |deny_unsafe, _| {243 Box::new(move |deny_unsafe, _| {
242 let deps = crate::rpc::FullDeps {244 let deps = crate::rpc::FullDeps {
249 pending_transactions: pending.clone(),251 pending_transactions: pending.clone(),
250 filter_pool: filter_pool.clone(),252 filter_pool: filter_pool.clone(),
251 backend: frontier_backend.clone(),253 backend: frontier_backend.clone(),
254 max_past_logs,
252 };255 };
253 crate::rpc::create_full(256 crate::rpc::create_full(
254 deps,257 deps,
modifiedpallets/nft/src/lib.rsdiffbeforeafterboth
28912891
2892// #endregion2892// #endregion
2893
2894sp_api::decl_runtime_apis! {
2895 pub trait NftApi {
2896 /// Used for ethereum integration
2897 fn eth_contract_code(account: H160) -> Option<Vec<u8>>;
2898 }
2899}
2900
modifiedruntime/src/lib.rsdiffbeforeafterboth
64use sp_arithmetic::{traits::{BaseArithmetic, Unsigned}};64use sp_arithmetic::{traits::{BaseArithmetic, Unsigned}};
65use smallvec::smallvec;65use smallvec::smallvec;
66use codec::{Encode, Decode};66use codec::{Encode, Decode};
67use pallet_evm::{Account as EVMAccount, FeeCalculator};67use pallet_evm::{Account as EVMAccount, FeeCalculator, OnMethodCall};
68use fp_rpc::TransactionStatus;68use fp_rpc::TransactionStatus;
69use sp_core::H256;69use sp_core::H256;
7070
344}344}
345345
346impl pallet_evm::Config for Runtime {346impl pallet_evm::Config for Runtime {
347 type BlockGasLimit = BlockGasLimit;
347 type FeeCalculator = ();348 type FeeCalculator = ();
348 type GasWeightMapping = ();349 type GasWeightMapping = ();
349 type CallOrigin = EnsureAddressTruncated;350 type CallOrigin = EnsureAddressTruncated;
350 type WithdrawOrigin = EnsureAddressTruncated;351 type WithdrawOrigin = EnsureAddressTruncated;
351 type AddressMapping = HashedAddressMapping<BlakeTwo256>;352 type AddressMapping = HashedAddressMapping<Self::Hashing>;
353 type Precompiles = ();
352 type Currency = Balances;354 type Currency = Balances;
353 type Event = Event;355 type Event = Event;
354 type Precompiles = ();356 type OnMethodCall = pallet_nft::NftErcSupport<Self>;
355 type ChainId = ChainId;357 type ChainId = ChainId;
356 type Runner = pallet_evm::runner::stack::Runner<Self>;358 type Runner = pallet_evm::runner::stack::Runner<Self>;
357 type OnChargeTransaction = ();359 type OnChargeTransaction = ();
379 type Event = Event;381 type Event = Event;
380 type FindAuthor = EthereumFindAuthor<Aura>;382 type FindAuthor = EthereumFindAuthor<Aura>;
381 type StateRoot = pallet_ethereum::IntermediateStateRoot;383 type StateRoot = pallet_ethereum::IntermediateStateRoot;
382 type BlockGasLimit = BlockGasLimit;
383}384}
384385
385impl pallet_grandpa::Config for Runtime {386impl pallet_grandpa::Config for Runtime {
657 frame_executive::Executive<Runtime, Block, system::ChainContext<Runtime>, Runtime, AllModules>;658 frame_executive::Executive<Runtime, Block, system::ChainContext<Runtime>, Runtime, AllModules>;
658659
659impl_runtime_apis! {660impl_runtime_apis! {
661 impl pallet_nft::NftApi<Block>
662 for Runtime
663 {
664 fn eth_contract_code(account: H160) -> Option<Vec<u8>> {
665 <pallet_nft::NftErcSupport<Runtime>>::get_code(&account)
666 }
667 }
660668
661 impl pallet_contracts_rpc_runtime_api::ContractsApi<Block, AccountId, Balance, BlockNumber>669 impl pallet_contracts_rpc_runtime_api::ContractsApi<Block, AccountId, Balance, BlockNumber>
662 for Runtime670 for Runtime