1
// Copyright (C) Moondance Labs Ltd.
2
// This file is part of Tanssi.
3

            
4
// Tanssi is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
8

            
9
// Tanssi is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
// GNU General Public License for more details.
13

            
14
// You should have received a copy of the GNU General Public License
15
// along with Tanssi.  If not, see <http://www.gnu.org/licenses/>.
16

            
17
use {
18
    sc_network::NetworkService,
19
    sc_network_sync::SyncingService,
20
    sc_transaction_pool::{ChainApi, Pool},
21
    sp_core::H256,
22
    sp_runtime::traits::Block as BlockT,
23
    std::{collections::BTreeMap, sync::Arc},
24
};
25
// Frontier
26
use fc_db::Backend as FrontierBackend;
27
pub use {
28
    fc_rpc::EthBlockDataCacheTask,
29
    fc_rpc_core::types::{FeeHistoryCache, FeeHistoryCacheLimit, FilterPool},
30
    fc_storage::StorageOverride,
31
};
32

            
33
/// Extra dependencies for Ethereum compatibility.
34
pub struct EthDeps<C, P, A: ChainApi, CT, B: BlockT> {
35
    /// The client instance to use.
36
    pub client: Arc<C>,
37
    /// Transaction pool instance.
38
    pub pool: Arc<P>,
39
    /// Graph pool instance.
40
    pub graph: Arc<Pool<A>>,
41
    /// Ethereum transaction converter.
42
    pub converter: Option<CT>,
43
    /// The Node authority flag
44
    pub is_authority: bool,
45
    /// Whether to enable dev signer
46
    pub enable_dev_signer: bool,
47
    /// Network service
48
    pub network: Arc<NetworkService<B, B::Hash>>,
49
    /// Chain syncing service
50
    pub sync: Arc<SyncingService<B>>,
51
    /// Frontier Backend.
52
    pub frontier_backend: Arc<FrontierBackend<B, C>>,
53
    /// Ethereum data access overrides.
54
    pub overrides: Arc<dyn StorageOverride<B>>,
55
    /// Cache for Ethereum block data.
56
    pub block_data_cache: Arc<EthBlockDataCacheTask<B>>,
57
    /// EthFilterApi pool.
58
    pub filter_pool: Option<FilterPool>,
59
    /// Maximum number of logs in a query.
60
    pub max_past_logs: u32,
61
    /// Maximum block range in a query.
62
    pub max_block_range: u32,
63
    /// Fee history cache.
64
    pub fee_history_cache: FeeHistoryCache,
65
    /// Maximum fee history cache size.
66
    pub fee_history_cache_limit: FeeHistoryCacheLimit,
67
    /// Maximum allowed gas limit will be ` block.gas_limit * execute_gas_limit_multiplier` when
68
    /// using eth_call/eth_estimateGas.
69
    pub execute_gas_limit_multiplier: u64,
70
    /// Mandated parent hashes for a given block hash.
71
    pub forced_parent_hashes: Option<BTreeMap<H256, H256>>,
72
}
73

            
74
impl<C, P, A: ChainApi, CT: Clone, B: BlockT> Clone for EthDeps<C, P, A, CT, B> {
75
    fn clone(&self) -> Self {
76
        Self {
77
            client: self.client.clone(),
78
            pool: self.pool.clone(),
79
            graph: self.graph.clone(),
80
            converter: self.converter.clone(),
81
            is_authority: self.is_authority,
82
            enable_dev_signer: self.enable_dev_signer,
83
            network: self.network.clone(),
84
            sync: self.sync.clone(),
85
            frontier_backend: self.frontier_backend.clone(),
86
            overrides: self.overrides.clone(),
87
            block_data_cache: self.block_data_cache.clone(),
88
            filter_pool: self.filter_pool.clone(),
89
            max_past_logs: self.max_past_logs,
90
            max_block_range: self.max_block_range,
91
            fee_history_cache: self.fee_history_cache.clone(),
92
            fee_history_cache_limit: self.fee_history_cache_limit,
93
            execute_gas_limit_multiplier: self.execute_gas_limit_multiplier,
94
            forced_parent_hashes: self.forced_parent_hashes.clone(),
95
        }
96
    }
97
}