diff --git a/client/api/src/backend.rs b/client/api/src/backend.rs index 7e06203ff9..7ad26b95a8 100644 --- a/client/api/src/backend.rs +++ b/client/api/src/backend.rs @@ -52,9 +52,6 @@ pub trait Backend: Send + Sync { fn is_indexed(&self) -> bool { self.log_indexer().is_indexed() } - - /// Get the latest substrate block hash in the sql database. - async fn best_hash(&self) -> Result; } #[derive(Debug, Eq, PartialEq)] diff --git a/client/cli/src/frontier_db_cmd/mapping_db.rs b/client/cli/src/frontier_db_cmd/mapping_db.rs index cee5e206aa..0b1e56410c 100644 --- a/client/cli/src/frontier_db_cmd/mapping_db.rs +++ b/client/cli/src/frontier_db_cmd/mapping_db.rs @@ -40,21 +40,22 @@ pub enum MappingKey { EthBlockOrTransactionHash(H256), } -pub struct MappingDb<'a, B: BlockT, C: HeaderBackend> { +pub struct MappingDb<'a, C, B: BlockT> { cmd: &'a FrontierDbCmd, client: Arc, - backend: Arc>, + backend: Arc>, } -impl<'a, B: BlockT, C> MappingDb<'a, B, C> +impl<'a, C, B: BlockT> MappingDb<'a, C, B> where - C: HeaderBackend + ProvideRuntimeApi, + C: ProvideRuntimeApi, C::Api: EthereumRuntimeRPCApi, + C: HeaderBackend, { pub fn new( cmd: &'a FrontierDbCmd, client: Arc, - backend: Arc>, + backend: Arc>, ) -> Self { Self { cmd, @@ -175,4 +176,4 @@ where } } -impl<'a, B: BlockT, C: HeaderBackend> FrontierDbMessage for MappingDb<'a, B, C> {} +impl<'a, C, B: BlockT> FrontierDbMessage for MappingDb<'a, C, B> {} diff --git a/client/cli/src/frontier_db_cmd/meta_db.rs b/client/cli/src/frontier_db_cmd/meta_db.rs index 75330a60f7..878bd101ac 100644 --- a/client/cli/src/frontier_db_cmd/meta_db.rs +++ b/client/cli/src/frontier_db_cmd/meta_db.rs @@ -25,7 +25,6 @@ use std::{ use ethereum_types::H256; use serde::Deserialize; // Substrate -use sp_blockchain::HeaderBackend; use sp_runtime::traits::Block as BlockT; use super::{utils::FrontierDbMessage, FrontierDbCmd, Operation}; @@ -58,13 +57,13 @@ impl FromStr for MetaKey { } } -pub struct MetaDb<'a, B: BlockT, C: HeaderBackend> { +pub struct MetaDb<'a, B: BlockT> { cmd: &'a FrontierDbCmd, - backend: Arc>, + backend: Arc>, } -impl<'a, B: BlockT, C: HeaderBackend> MetaDb<'a, B, C> { - pub fn new(cmd: &'a FrontierDbCmd, backend: Arc>) -> Self { +impl<'a, B: BlockT> MetaDb<'a, B> { + pub fn new(cmd: &'a FrontierDbCmd, backend: Arc>) -> Self { Self { cmd, backend } } @@ -152,4 +151,4 @@ impl<'a, B: BlockT, C: HeaderBackend> MetaDb<'a, B, C> { } } -impl<'a, B: BlockT, C: HeaderBackend> FrontierDbMessage for MetaDb<'a, B, C> {} +impl<'a, B: BlockT> FrontierDbMessage for MetaDb<'a, B> {} diff --git a/client/cli/src/frontier_db_cmd/mod.rs b/client/cli/src/frontier_db_cmd/mod.rs index 4453625337..a82436b6f3 100644 --- a/client/cli/src/frontier_db_cmd/mod.rs +++ b/client/cli/src/frontier_db_cmd/mod.rs @@ -98,14 +98,15 @@ pub enum DbValue { } impl FrontierDbCmd { - pub fn run( + pub fn run( &self, client: Arc, - backend: Arc>, + backend: Arc>, ) -> sc_cli::Result<()> where - C: HeaderBackend + ProvideRuntimeApi, + C: ProvideRuntimeApi, C::Api: fp_rpc::EthereumRuntimeRPCApi, + C: HeaderBackend, { match self.column { Column::Meta => { diff --git a/client/cli/src/frontier_db_cmd/tests.rs b/client/cli/src/frontier_db_cmd/tests.rs index 1975aa5a38..5983bfa3cc 100644 --- a/client/cli/src/frontier_db_cmd/tests.rs +++ b/client/cli/src/frontier_db_cmd/tests.rs @@ -49,8 +49,8 @@ type OpaqueBlock = pub fn open_frontier_backend>( client: Arc, path: PathBuf, -) -> Result>, String> { - Ok(Arc::new(fc_db::kv::Backend::::new( +) -> Result>, String> { + Ok(Arc::new(fc_db::kv::Backend::::new( client, &fc_db::kv::DatabaseSettings { source: sc_client_db::DatabaseSource::RocksDb { diff --git a/client/db/src/kv/mod.rs b/client/db/src/kv/mod.rs index c1abf01b69..c70ec5f51d 100644 --- a/client/db/src/kv/mod.rs +++ b/client/db/src/kv/mod.rs @@ -34,7 +34,6 @@ use sp_blockchain::HeaderBackend; use sp_core::{H160, H256}; pub use sp_database::Database; use sp_runtime::traits::Block as BlockT; - // Frontier use fc_api::{FilteredLog, TransactionMetadata}; use fp_storage::{EthereumStorageSchema, PALLET_ETHEREUM_SCHEMA_CACHE}; @@ -63,15 +62,14 @@ pub mod static_keys { } #[derive(Clone)] -pub struct Backend> { - client: Arc, +pub struct Backend { meta: Arc>, mapping: Arc>, log_indexer: LogIndexerBackend, } #[async_trait::async_trait] -impl> fc_api::Backend for Backend { +impl fc_api::Backend for Backend { async fn block_hash( &self, ethereum_block_hash: &H256, @@ -90,10 +88,6 @@ impl> fc_api::Backend for Backend< fn log_indexer(&self) -> &dyn fc_api::LogIndexerBackend { &self.log_indexer } - - async fn best_hash(&self) -> Result { - Ok(self.client.info().best_hash) - } } #[derive(Clone, Default)] @@ -121,8 +115,8 @@ pub fn frontier_database_dir(db_config_dir: &Path, db_path: &str) -> PathBuf { db_config_dir.join("frontier").join(db_path) } -impl> Backend { - pub fn open( +impl Backend { + pub fn open>( client: Arc, database: &DatabaseSource, db_config_dir: &Path, @@ -154,11 +148,13 @@ impl> Backend { ) } - pub fn new(client: Arc, config: &DatabaseSettings) -> Result { - let db = utils::open_database::(client.clone(), config)?; + pub fn new>( + client: Arc, + config: &DatabaseSettings, + ) -> Result { + let db = utils::open_database::(client, config)?; Ok(Self { - client, mapping: Arc::new(MappingDb { db: db.clone(), write_lock: Arc::new(Mutex::new(())), diff --git a/client/db/src/kv/upgrade.rs b/client/db/src/kv/upgrade.rs index 34e9c7fe79..be517adbca 100644 --- a/client/db/src/kv/upgrade.rs +++ b/client/db/src/kv/upgrade.rs @@ -348,10 +348,8 @@ mod tests { pub fn open_frontier_backend>( client: Arc, setting: &crate::kv::DatabaseSettings, - ) -> Result>, String> { - Ok(Arc::new(crate::kv::Backend::::new( - client, setting, - )?)) + ) -> Result>, String> { + Ok(Arc::new(crate::kv::Backend::::new(client, setting)?)) } #[cfg_attr(not(feature = "rocksdb"), ignore)] diff --git a/client/db/src/lib.rs b/client/db/src/lib.rs index a03ce2fcae..5fa2044b85 100644 --- a/client/db/src/lib.rs +++ b/client/db/src/lib.rs @@ -16,13 +16,10 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -// #![deny(unused_crate_dependencies)] - -use std::sync::Arc; +#![deny(unused_crate_dependencies)] // Substrate pub use sc_client_db::DatabaseSource; -use sp_blockchain::HeaderBackend; use sp_runtime::traits::Block as BlockT; pub mod kv; @@ -30,8 +27,8 @@ pub mod kv; pub mod sql; #[derive(Clone)] -pub enum Backend> { - KeyValue(Arc>), +pub enum Backend { + KeyValue(kv::Backend), #[cfg(feature = "sql")] - Sql(Arc>), + Sql(sql::Backend), } diff --git a/client/db/src/sql/mod.rs b/client/db/src/sql/mod.rs index f5494ad92e..ead5c0acb6 100644 --- a/client/db/src/sql/mod.rs +++ b/client/db/src/sql/mod.rs @@ -96,8 +96,10 @@ pub enum BackendConfig<'a> { pub struct Backend { /// The Sqlite connection. pool: SqlitePool, + /// The additional overrides for the logs handler. overrides: Arc>, + /// The number of allowed operations for the Sqlite filter call. /// A value of `0` disables the timeout. num_ops_timeout: i32, @@ -237,7 +239,6 @@ where let block_number = 0i32; let is_canon = 1i32; - let mut tx = self.pool().begin().await?; let _ = sqlx::query( "INSERT OR IGNORE INTO blocks( ethereum_block_hash, @@ -252,20 +253,8 @@ where .bind(block_number) .bind(schema) .bind(is_canon) - .execute(&mut *tx) + .execute(self.pool()) .await?; - - sqlx::query("INSERT INTO sync_status(substrate_block_hash) VALUES (?)") - .bind(substrate_block_hash) - .execute(&mut *tx) - .await?; - sqlx::query("UPDATE sync_status SET status = 1 WHERE substrate_block_hash = ?") - .bind(substrate_block_hash) - .execute(&mut *tx) - .await?; - - tx.commit().await?; - log::debug!(target: "frontier-sql", "The genesis block information has been submitted."); } Some(substrate_genesis_hash) } else { @@ -520,6 +509,7 @@ where }); // https://www.sqlite.org/pragma.html#pragma_optimize let _ = sqlx::query("PRAGMA optimize").execute(&pool).await; + log::debug!(target: "frontier-sql", "Batch committed"); } fn get_logs( @@ -696,7 +686,7 @@ where } /// Retrieve the block hash for the last indexed canon block. - pub async fn last_indexed_canon_block(&self) -> Result { + pub async fn get_last_indexed_canon_block(&self) -> Result { let row = sqlx::query( "SELECT b.substrate_block_hash FROM blocks AS b INNER JOIN sync_status AS s @@ -863,21 +853,6 @@ impl> fc_api::Backend for Backend { fn log_indexer(&self) -> &dyn fc_api::LogIndexerBackend { self } - - async fn best_hash(&self) -> Result { - // Retrieves the block hash for the latest indexed block, maybe it's not canon. - sqlx::query( - "SELECT b.substrate_block_hash FROM blocks AS b - INNER JOIN sync_status AS s - ON s.substrate_block_hash = b.substrate_block_hash - WHERE s.status = 1 - ORDER BY b.block_number DESC LIMIT 1", - ) - .fetch_one(self.pool()) - .await - .map(|row| H256::from_slice(&row.get::, _>(0)[..])) - .map_err(|e| format!("Failed to fetch best hash: {}", e)) - } } #[async_trait::async_trait] diff --git a/client/mapping-sync/src/kv/mod.rs b/client/mapping-sync/src/kv/mod.rs index 2a5082dfe9..5aea3c7a5b 100644 --- a/client/mapping-sync/src/kv/mod.rs +++ b/client/mapping-sync/src/kv/mod.rs @@ -40,7 +40,7 @@ use crate::{EthereumBlockNotification, EthereumBlockNotificationSinks, SyncStrat pub fn sync_block( client: &C, overrides: Arc>, - backend: &fc_db::kv::Backend, + backend: &fc_db::kv::Backend, header: &Block::Header, ) -> Result<(), String> where @@ -111,11 +111,11 @@ where pub fn sync_genesis_block( client: &C, - backend: &fc_db::kv::Backend, + backend: &fc_db::kv::Backend, header: &Block::Header, ) -> Result<(), String> where - C: HeaderBackend + ProvideRuntimeApi, + C: ProvideRuntimeApi, C::Api: EthereumRuntimeRPCApi, { let substrate_block_hash = header.hash(); @@ -159,7 +159,7 @@ pub fn sync_one_block( client: &C, substrate_backend: &BE, overrides: Arc>, - frontier_backend: &fc_db::kv::Backend, + frontier_backend: &fc_db::kv::Backend, sync_from: ::Number, strategy: SyncStrategy, sync_oracle: Arc, @@ -248,7 +248,7 @@ pub fn sync_blocks( client: &C, substrate_backend: &BE, overrides: Arc>, - frontier_backend: &fc_db::kv::Backend, + frontier_backend: &fc_db::kv::Backend, limit: usize, sync_from: ::Number, strategy: SyncStrategy, @@ -282,14 +282,13 @@ where Ok(synced_any) } -pub fn fetch_header( +pub fn fetch_header( substrate_backend: &BE, - frontier_backend: &fc_db::kv::Backend, + frontier_backend: &fc_db::kv::Backend, checking_tip: Block::Hash, sync_from: ::Number, ) -> Result, String> where - C: HeaderBackend, BE: HeaderBackend, { if frontier_backend.mapping().is_synced(&checking_tip)? { diff --git a/client/mapping-sync/src/kv/worker.rs b/client/mapping-sync/src/kv/worker.rs index 1c7d4ecc52..aeda795769 100644 --- a/client/mapping-sync/src/kv/worker.rs +++ b/client/mapping-sync/src/kv/worker.rs @@ -39,7 +39,7 @@ use fp_rpc::EthereumRuntimeRPCApi; use crate::SyncStrategy; -pub struct MappingSyncWorker, BE> { +pub struct MappingSyncWorker { import_notifications: ImportNotifications, timeout: Duration, inner_delay: Option, @@ -47,7 +47,7 @@ pub struct MappingSyncWorker, BE> { client: Arc, substrate_backend: Arc, overrides: Arc>, - frontier_backend: Arc>, + frontier_backend: Arc>, have_next: bool, retry_times: usize, @@ -59,16 +59,16 @@ pub struct MappingSyncWorker, BE> { Arc>>, } -impl, BE> Unpin for MappingSyncWorker {} +impl Unpin for MappingSyncWorker {} -impl, BE> MappingSyncWorker { +impl MappingSyncWorker { pub fn new( import_notifications: ImportNotifications, timeout: Duration, client: Arc, substrate_backend: Arc, overrides: Arc>, - frontier_backend: Arc>, + frontier_backend: Arc>, retry_times: usize, sync_from: ::Number, strategy: SyncStrategy, @@ -259,7 +259,7 @@ mod tests { }); let frontier_backend = Arc::new( - fc_db::kv::Backend::::new( + fc_db::kv::Backend::::new( client.clone(), &fc_db::kv::DatabaseSettings { source: sc_client_db::DatabaseSource::RocksDb { @@ -397,7 +397,7 @@ mod tests { }); let frontier_backend = Arc::new( - fc_db::kv::Backend::::new( + fc_db::kv::Backend::::new( client.clone(), &fc_db::kv::DatabaseSettings { source: sc_client_db::DatabaseSource::RocksDb { diff --git a/client/mapping-sync/src/lib.rs b/client/mapping-sync/src/lib.rs index f5b400f4f3..3a03e2ba8a 100644 --- a/client/mapping-sync/src/lib.rs +++ b/client/mapping-sync/src/lib.rs @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -// #![deny(unused_crate_dependencies)] +#![deny(unused_crate_dependencies)] #![allow(clippy::too_many_arguments)] pub mod kv; diff --git a/client/mapping-sync/src/sql/mod.rs b/client/mapping-sync/src/sql/mod.rs index b55d4b43cf..a3af31936d 100644 --- a/client/mapping-sync/src/sql/mod.rs +++ b/client/mapping-sync/src/sql/mod.rs @@ -89,7 +89,7 @@ where match cmd { WorkerCommand::ResumeSync => { // Attempt to resume from last indexed block. If there is no data in the db, sync genesis. - match indexer_backend.last_indexed_canon_block().await.ok() { + match indexer_backend.get_last_indexed_canon_block().await.ok() { Some(last_block_hash) => { log::debug!(target: "frontier-sql", "Resume from last block {last_block_hash:?}"); if let Some(parent_hash) = client @@ -371,7 +371,7 @@ async fn index_canonical_block_and_ancestors( .map_err(|e| { log::error!(target: "frontier-sql", "{e}"); }); - log::debug!(target: "frontier-sql", "Inserted block metadata {hash:?}"); + log::debug!(target: "frontier-sql", "Inserted block metadata {hash:?}"); indexer_backend.index_block_logs(client.clone(), hash).await; if let Ok(Some(header)) = blockchain_backend.header(hash) { diff --git a/client/rpc/src/lib.rs b/client/rpc/src/lib.rs index 7a6c73b032..2a217a41b5 100644 --- a/client/rpc/src/lib.rs +++ b/client/rpc/src/lib.rs @@ -197,27 +197,21 @@ pub mod frontier_backend_client { B: BlockT, C: HeaderBackend + 'static, { - match number.unwrap_or(BlockNumberOrHash::Latest) { + Ok(match number.unwrap_or(BlockNumberOrHash::Latest) { BlockNumberOrHash::Hash { hash, .. } => { if let Ok(Some(hash)) = load_hash::(client, backend, hash).await { - Ok(Some(BlockId::Hash(hash))) + Some(BlockId::Hash(hash)) } else { - Ok(None) + None } } - BlockNumberOrHash::Num(number) => { - Ok(Some(BlockId::Number(number.unique_saturated_into()))) - } - BlockNumberOrHash::Latest => backend - .best_hash() - .await - .map(|hash| Some(BlockId::Hash(hash))) - .map_err(|err| internal_err(format!("fetch to fetch the best hash: {:?}", err))), - BlockNumberOrHash::Earliest => Ok(Some(BlockId::Number(Zero::zero()))), - BlockNumberOrHash::Pending => Ok(None), - BlockNumberOrHash::Safe => Ok(Some(BlockId::Hash(client.info().finalized_hash))), - BlockNumberOrHash::Finalized => Ok(Some(BlockId::Hash(client.info().finalized_hash))), - } + BlockNumberOrHash::Num(number) => Some(BlockId::Number(number.unique_saturated_into())), + BlockNumberOrHash::Latest => Some(BlockId::Hash(client.info().best_hash)), + BlockNumberOrHash::Earliest => Some(BlockId::Number(Zero::zero())), + BlockNumberOrHash::Pending => None, + BlockNumberOrHash::Safe => Some(BlockId::Hash(client.info().finalized_hash)), + BlockNumberOrHash::Finalized => Some(BlockId::Hash(client.info().finalized_hash)), + }) } pub async fn load_hash( @@ -365,8 +359,8 @@ mod tests { fn open_frontier_backend>( client: Arc, path: PathBuf, - ) -> Result>, String> { - Ok(Arc::new(fc_db::kv::Backend::::new( + ) -> Result>, String> { + Ok(Arc::new(fc_db::kv::Backend::::new( client, &fc_db::kv::DatabaseSettings { source: sc_client_db::DatabaseSource::RocksDb { diff --git a/template/node/src/command.rs b/template/node/src/command.rs index 4bc0d2b728..f55f762202 100644 --- a/template/node/src/command.rs +++ b/template/node/src/command.rs @@ -234,7 +234,7 @@ pub fn run() -> sc_cli::Result<()> { let (client, _, _, _, frontier_backend) = service::new_chain_ops(&mut config, &cli.eth)?; let frontier_backend = match frontier_backend { - fc_db::Backend::KeyValue(kv) => kv, + fc_db::Backend::KeyValue(kv) => std::sync::Arc::new(kv), _ => panic!("Only fc_db::Backend::KeyValue supported"), }; cmd.run(client, frontier_backend) diff --git a/template/node/src/eth.rs b/template/node/src/eth.rs index 9bb5d729ce..7400943a91 100644 --- a/template/node/src/eth.rs +++ b/template/node/src/eth.rs @@ -22,7 +22,7 @@ use frontier_template_runtime::opaque::Block; use crate::client::{FullBackend, FullClient}; /// Frontier DB backend type. -pub type FrontierBackend = fc_db::Backend; +pub type FrontierBackend = fc_db::Backend; pub fn db_config_dir(config: &Configuration) -> PathBuf { config.base_path.config_dir(config.chain_spec.id()) @@ -126,7 +126,7 @@ pub async fn spawn_frontier_tasks( task_manager: &TaskManager, client: Arc>, backend: Arc, - frontier_backend: Arc>>, + frontier_backend: FrontierBackend, filter_pool: Option, overrides: Arc>, fee_history_cache: FeeHistoryCache, @@ -144,7 +144,7 @@ pub async fn spawn_frontier_tasks( Executor: NativeExecutionDispatch + 'static, { // Spawn main mapping sync worker background task. - match &*frontier_backend { + match frontier_backend { fc_db::Backend::KeyValue(b) => { task_manager.spawn_essential_handle().spawn( "frontier-mapping-sync-worker", @@ -155,7 +155,7 @@ pub async fn spawn_frontier_tasks( client.clone(), backend, overrides.clone(), - b.clone(), + Arc::new(b), 3, 0, fc_mapping_sync::SyncStrategy::Normal, @@ -172,10 +172,10 @@ pub async fn spawn_frontier_tasks( fc_mapping_sync::sql::SyncWorker::run( client.clone(), backend, - b.clone(), + Arc::new(b), client.import_notification_stream(), fc_mapping_sync::sql::SyncWorkerConfig { - read_notification_timeout: Duration::from_secs(60), + read_notification_timeout: Duration::from_secs(10), check_indexed_blocks_interval: Duration::from_secs(60), }, fc_mapping_sync::SyncStrategy::Parachain, diff --git a/template/node/src/rpc/mod.rs b/template/node/src/rpc/mod.rs index 0835af6b16..b655b1e890 100644 --- a/template/node/src/rpc/mod.rs +++ b/template/node/src/rpc/mod.rs @@ -27,7 +27,7 @@ mod eth; pub use self::eth::{create_eth, overrides_handle, EthDeps}; /// Full client dependencies. -pub struct FullDeps, P, A: ChainApi, CT, CIDP> { +pub struct FullDeps { /// The client instance to use. pub client: Arc, /// Transaction pool instance. diff --git a/template/node/src/service.rs b/template/node/src/service.rs index 2afd892a82..81e2210459 100644 --- a/template/node/src/service.rs +++ b/template/node/src/service.rs @@ -15,7 +15,7 @@ use sc_transaction_pool_api::OffchainTransactionPoolFactory; use sp_api::ConstructRuntimeApi; use sp_consensus_aura::sr25519::AuthorityPair as AuraPair; use sp_core::U256; -// Local +// Runtime use frontier_template_runtime::{opaque::Block, Hash, TransactionConverter}; use crate::{ @@ -59,7 +59,7 @@ pub fn new_partial( Option, BoxBlockImport, GrandpaLinkHalf>, - FrontierBackend>, + FrontierBackend, Arc>, ), >, @@ -118,11 +118,11 @@ where let overrides = crate::rpc::overrides_handle(client.clone()); let frontier_backend = match eth_config.frontier_backend_type { - BackendType::KeyValue => FrontierBackend::KeyValue(Arc::new(fc_db::kv::Backend::open( + BackendType::KeyValue => FrontierBackend::KeyValue(fc_db::kv::Backend::open( Arc::clone(&client), &config.database, &db_config_dir(config), - )?)), + )?), BackendType::Sql => { let db_path = db_config_dir(config).join("sql"); std::fs::create_dir_all(&db_path).expect("failed creating sql db directory"); @@ -142,7 +142,7 @@ where overrides.clone(), )) .unwrap_or_else(|err| panic!("failed creating sql backend: {:?}", err)); - FrontierBackend::Sql(Arc::new(backend)) + FrontierBackend::Sql(backend) } }; @@ -348,7 +348,6 @@ where let role = config.role.clone(); let force_authoring = config.force_authoring; let name = config.network.node_name.clone(); - let frontier_backend = Arc::new(frontier_backend); let enable_grandpa = !config.disable_grandpa && sealing.is_none(); let prometheus_registry = config.prometheus_registry().cloned(); @@ -366,6 +365,7 @@ where // for ethereum-compatibility rpc. config.rpc_id_provider = Some(Box::new(fc_rpc::EthereumSubIdProvider)); + let rpc_builder = { let client = client.clone(); let pool = transaction_pool.clone(); @@ -413,9 +413,9 @@ where enable_dev_signer, network: network.clone(), sync: sync_service.clone(), - frontier_backend: match &*frontier_backend { - fc_db::Backend::KeyValue(b) => b.clone(), - fc_db::Backend::Sql(b) => b.clone(), + frontier_backend: match frontier_backend.clone() { + fc_db::Backend::KeyValue(b) => Arc::new(b), + fc_db::Backend::Sql(b) => Arc::new(b), }, overrides: overrides.clone(), block_data_cache: block_data_cache.clone(), @@ -708,7 +708,7 @@ pub fn new_chain_ops( Arc, BasicQueue, TaskManager, - FrontierBackend, + FrontierBackend, ), ServiceError, > { diff --git a/ts-tests/tests/test-contract-methods.ts b/ts-tests/tests/test-contract-methods.ts index 4a70b84ea6..d8da2273f2 100644 --- a/ts-tests/tests/test-contract-methods.ts +++ b/ts-tests/tests/test-contract-methods.ts @@ -51,7 +51,7 @@ describeWithFrontier("Frontier RPC (Contract Methods)", (context) => { expect(await contract.methods.multiply(3).call()).to.equal("21"); }); - it.skip("should get correct environmental block number", async function () { + it("should get correct environmental block number", async function () { // Solidity `block.number` is expected to return the same height at which the runtime call was made. const contract = new context.web3.eth.Contract(TEST_CONTRACT_ABI, FIRST_CONTRACT_ADDRESS, { from: GENESIS_ACCOUNT, @@ -64,7 +64,7 @@ describeWithFrontier("Frontier RPC (Contract Methods)", (context) => { expect(await contract.methods.currentBlock().call()).to.eq(block.number.toString()); }); - it.skip("should get correct environmental block hash", async function () { + it("should get correct environmental block hash", async function () { this.timeout(20000); // Solidity `blockhash` is expected to return the ethereum block hash at a given height. const contract = new context.web3.eth.Contract(TEST_CONTRACT_ABI, FIRST_CONTRACT_ADDRESS, {