Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
334 changes: 170 additions & 164 deletions Cargo.lock

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions client/cli/src/frontier_db_cmd/mapping_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

use std::sync::Arc;

use ethereum_types::H256;
use serde::Deserialize;
use std::sync::Arc;
// Substrate
use sp_runtime::{generic::BlockId, traits::Block as BlockT};
// Frontier
use fp_rpc::EthereumRuntimeRPCApi;

use super::{utils::FrontierDbMessage, Column, FrontierDbCmd, Operation};

use fp_rpc::EthereumRuntimeRPCApi;
use sp_runtime::{generic::BlockId, traits::Block as BlockT};

#[derive(Debug, Deserialize)]
#[serde(untagged)]
pub enum MappingValue<H> {
Expand Down
9 changes: 5 additions & 4 deletions client/cli/src/frontier_db_cmd/meta_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,19 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

use ethereum_types::H256;
use serde::Deserialize;
use std::{
collections::HashMap,
str::{self, FromStr},
sync::Arc,
};

use super::{utils::FrontierDbMessage, FrontierDbCmd, Operation};

use ethereum_types::H256;
use serde::Deserialize;
// Substrate
use sp_runtime::traits::Block as BlockT;

use super::{utils::FrontierDbMessage, FrontierDbCmd, Operation};

#[derive(Debug, Deserialize)]
#[serde(untagged)]
pub enum MetaValue<H> {
Expand Down
14 changes: 8 additions & 6 deletions client/cli/src/frontier_db_cmd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,19 @@ mod meta_db;
mod tests;
pub(crate) mod utils;

use mapping_db::{MappingDb, MappingKey, MappingValue};
use meta_db::{MetaDb, MetaKey, MetaValue};
use std::{path::PathBuf, str::FromStr, sync::Arc};

use clap::ArgEnum;
use sc_cli::{PruningParams, SharedParams};
use ethereum_types::H256;
use serde::Deserialize;
use std::{path::PathBuf, str::FromStr, sync::Arc};

// Substrate
use sc_cli::{PruningParams, SharedParams};
use sp_runtime::traits::Block as BlockT;

use ethereum_types::H256;
use self::{
mapping_db::{MappingDb, MappingKey, MappingValue},
meta_db::{MetaDb, MetaKey, MetaValue},
};

/// Cli tool to interact with the Frontier backend db
#[derive(Debug, Clone, clap::Parser)]
Expand Down
43 changes: 24 additions & 19 deletions client/cli/src/frontier_db_cmd/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,30 @@

#[cfg(test)]
mod tests {
use frontier_template_runtime::RuntimeApi;
use substrate_test_runtime_client::{
BlockBuilderExt, ClientBlockImportExt, ClientExt, DefaultTestClientBuilderExt,
TestClientBuilder,
};

use std::{collections::HashMap, path::PathBuf, sync::Arc};
use std::{collections::HashMap, path::PathBuf, str::FromStr, sync::Arc};

use crate::frontier_db_cmd::{Column, FrontierDbCmd, Operation};
use codec::Encode;
use ethereum_types::H256;
use fp_storage::EthereumStorageSchema;
use futures::executor;
use sc_block_builder::BlockBuilderProvider;
use serde::Serialize;
use tempfile::tempdir;
// Substrate
use sc_block_builder::BlockBuilderProvider;
use sp_consensus::BlockOrigin;
use sp_io::hashing::twox_128;
use sp_runtime::{
generic::{Block, BlockId, Header},
traits::{BlakeTwo256, Block as BlockT},
};
use std::str::FromStr;
use tempfile::tempdir;
use substrate_test_runtime_client::{
BlockBuilderExt, ClientBlockImportExt, ClientExt, DefaultTestClientBuilderExt,
TestClientBuilder,
};
// Frontier
use fp_storage::{EthereumStorageSchema, ETHEREUM_CURRENT_TRANSACTION_STATUS, PALLET_ETHEREUM};
use frontier_template_runtime::RuntimeApi;

use crate::frontier_db_cmd::{Column, FrontierDbCmd, Operation};

type OpaqueBlock =
Block<Header<u64, BlakeTwo256>, substrate_test_runtime_client::runtime::Extrinsic>;
Expand Down Expand Up @@ -93,8 +94,8 @@ mod tests {
detailed_log_output: false,
},
pruning_params: sc_cli::PruningParams {
pruning: None,
keep_blocks: None,
state_pruning: None,
blocks_pruning: None,
},
}
}
Expand Down Expand Up @@ -530,6 +531,7 @@ mod tests {
assert_eq!(backend.meta().ethereum_schema(), Ok(None));
}

#[ignore]
#[test]
fn commitment_create() {
let tmp = tempdir().expect("create a temporary directory");
Expand All @@ -544,7 +546,7 @@ mod tests {
let statuses = vec![t1];

// Build a block and fill the pallet-ethereum status.
let key = storage_prefix_build(b"Ethereum", b"CurrentTransactionStatuses");
let key = storage_prefix_build(PALLET_ETHEREUM, ETHEREUM_CURRENT_TRANSACTION_STATUS);
let mut builder = client.new_block(Default::default()).unwrap();
builder
.push_storage_change(key, Some(statuses.encode()))
Expand Down Expand Up @@ -598,6 +600,7 @@ mod tests {
.is_err());
}

#[ignore]
#[test]
fn commitment_update() {
let tmp = tempdir().expect("create a temporary directory");
Expand All @@ -617,7 +620,7 @@ mod tests {
let statuses_a1 = vec![t1.clone()];
let statuses_a2 = vec![t1, t2];

let key = storage_prefix_build(b"Ethereum", b"CurrentTransactionStatuses");
let key = storage_prefix_build(PALLET_ETHEREUM, ETHEREUM_CURRENT_TRANSACTION_STATUS);

// First we create block and insert data in the offchain db.

Expand Down Expand Up @@ -733,6 +736,7 @@ mod tests {
);
}

#[ignore]
#[test]
fn mapping_read_works() {
let tmp = tempdir().expect("create a temporary directory");
Expand All @@ -747,7 +751,7 @@ mod tests {
let statuses = vec![t1];

// Build a block and fill the pallet-ethereum status.
let key = storage_prefix_build(b"Ethereum", b"CurrentTransactionStatuses");
let key = storage_prefix_build(PALLET_ETHEREUM, ETHEREUM_CURRENT_TRANSACTION_STATUS);
let mut builder = client.new_block(Default::default()).unwrap();
builder
.push_storage_change(key, Some(statuses.encode()))
Expand All @@ -764,13 +768,14 @@ mod tests {

// Create command using some ethereum block hash as key.
let ethereum_block_hash = H256::default();
let _ = cmd(
assert!(cmd(
format!("{:?}", ethereum_block_hash),
Some(test_value_path.clone()),
Operation::Create,
Column::Block,
)
.run(Arc::clone(&client), backend.clone());
.run(Arc::clone(&client), backend.clone())
.is_ok());

// Read block command.
assert!(cmd(
Expand Down
17 changes: 9 additions & 8 deletions client/cli/src/frontier_db_cmd/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,22 @@
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#![allow(clippy::useless_format)]
#![allow(clippy::format_in_format_args)]

use super::{DbValue, Operation};
#![allow(clippy::format_in_format_args)]

use serde::de::DeserializeOwned;
use serde_json::Deserializer;
use std::{
fs,
io::{self, Read},
path::PathBuf,
};

use serde::de::DeserializeOwned;
use serde_json::Deserializer;
// Substrate
use sp_runtime::traits::Block as BlockT;

use super::{DbValue, Operation};

pub fn maybe_deserialize_value<B: BlockT>(
operation: &Operation,
value: Option<&PathBuf>,
Expand All @@ -41,7 +42,7 @@ pub fn maybe_deserialize_value<B: BlockT>(
if let Some(Ok(value)) = stream_deser.next() {
Ok(Some(value))
} else {
Err("Failed to deserialize value data".to_string().into())
Err("Failed to deserialize value data".into())
}
}

Expand Down Expand Up @@ -91,7 +92,7 @@ pub trait FrontierDbMessage {
}

fn one_to_many_error(&self) -> sc_cli::Error {
"One-to-many operation not allowed".to_string().into()
"One-to-many operation not allowed".into()
}

#[cfg(not(test))]
Expand Down Expand Up @@ -121,7 +122,7 @@ pub trait FrontierDbMessage {
let mut buffer = String::new();
io::stdin().read_line(&mut buffer)?;
if buffer.trim() != "confirm" {
return Err(format!("-- Cancel exit --").into());
return Err("-- Cancel exit --".into());
}
Ok(())
}
Expand Down
3 changes: 2 additions & 1 deletion client/consensus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@

use std::{collections::HashMap, marker::PhantomData, sync::Arc};

// Substrate
use sc_client_api::{backend::AuxStore, BlockOf};
use sc_consensus::{BlockCheckParams, BlockImport, BlockImportParams, ImportResult};
use sp_api::ProvideRuntimeApi;
use sp_block_builder::BlockBuilder as BlockBuilderApi;
use sp_blockchain::{well_known_cache_keys::Id as CacheKeyId, HeaderBackend};
use sp_consensus::Error as ConsensusError;
use sp_runtime::traits::{Block as BlockT, Header as HeaderT};

// Frontier
use fp_consensus::{ensure_log, FindLogError};
use fp_rpc::EthereumRuntimeRPCApi;

Expand Down
4 changes: 3 additions & 1 deletion client/db/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ use std::{
};

use codec::{Decode, Encode};
use fp_storage::{EthereumStorageSchema, PALLET_ETHEREUM_SCHEMA_CACHE};
use parking_lot::Mutex;
// Substrate
pub use sc_client_db::DatabaseSource;
use sp_core::H256;
pub use sp_database::Database;
use sp_runtime::traits::Block as BlockT;
// Frontier
use fp_storage::{EthereumStorageSchema, PALLET_ETHEREUM_SCHEMA_CACHE};

const DB_HASH_LEN: usize = 32;
/// Hash type that this backend uses for the database.
Expand Down
3 changes: 2 additions & 1 deletion client/db/src/parity_db_adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

use crate::Database;
use sp_database::{error::DatabaseError, Change, ColumnId, Transaction};

use crate::Database;

fn handle_err<T>(result: parity_db::Result<T>) -> T {
match result {
Ok(r) => r,
Expand Down
6 changes: 4 additions & 2 deletions client/mapping-sync/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,17 @@ mod worker;

pub use worker::{MappingSyncWorker, SyncStrategy};

use fp_consensus::FindLogError;
use fp_rpc::EthereumRuntimeRPCApi;
// Substrate
use sc_client_api::BlockOf;
use sp_api::{ApiExt, ProvideRuntimeApi};
use sp_blockchain::HeaderBackend;
use sp_runtime::{
generic::BlockId,
traits::{Block as BlockT, Header as HeaderT, Zero},
};
// Frontier
use fp_consensus::FindLogError;
use fp_rpc::EthereumRuntimeRPCApi;

pub fn sync_block<Block: BlockT>(
backend: &fc_db::Backend<Block>,
Expand Down
7 changes: 5 additions & 2 deletions client/mapping-sync/src/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,21 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

use fp_rpc::EthereumRuntimeRPCApi;
use std::{pin::Pin, sync::Arc, time::Duration};

use futures::{
prelude::*,
task::{Context, Poll},
};
use futures_timer::Delay;
use log::debug;
// Substrate
use sc_client_api::{BlockOf, ImportNotifications};
use sp_api::ProvideRuntimeApi;
use sp_blockchain::HeaderBackend;
use sp_runtime::traits::{Block as BlockT, Header as HeaderT};
use std::{pin::Pin, sync::Arc, time::Duration};
// Frontier
use fp_rpc::EthereumRuntimeRPCApi;

#[derive(PartialEq, Copy, Clone)]
pub enum SyncStrategy {
Expand Down
2 changes: 1 addition & 1 deletion client/rpc-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ serde_json = "1.0"

# Parity
ethereum-types = "0.13.1"
jsonrpsee = { version = "0.14.0", features = ["server", "macros"] }
jsonrpsee = { version = "0.15.1", features = ["server", "macros"] }
rlp = "0.5"
4 changes: 3 additions & 1 deletion client/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,23 @@ tokio = { version = "1.19", features = ["sync"] }
# Parity
codec = { package = "parity-scale-codec", version = "3.0.0" }
ethereum-types = "0.13.1"
jsonrpsee = { version = "0.14.0", features = ["server", "macros"] }
jsonrpsee = { version = "0.15.1", features = ["server", "macros"] }
libsecp256k1 = "0.7"
rlp = "0.5"

# Substrate
prometheus-endpoint = { package = "substrate-prometheus-endpoint", git = "https://github.com/paritytech/substrate", branch = "master" }
sc-client-api = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "master" }
sc-network = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate", branch = "master" }
sc-network-common = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate", branch = "master" }
sc-rpc = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "master" }
sc-service = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate", branch = "master" }
sc-transaction-pool = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "master" }
sc-transaction-pool-api = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "master" }
sp-api = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "master" }
sp-block-builder = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "master" }
sp-blockchain = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "master" }
sp-consensus = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate", branch = "master" }
sp-core = { version = "6.0.0", git = "https://github.com/paritytech/substrate", branch = "master" }
sp-io = { version = "6.0.0", git = "https://github.com/paritytech/substrate", branch = "master" }
sp-runtime = { version = "6.0.0", git = "https://github.com/paritytech/substrate", branch = "master" }
Expand Down
4 changes: 2 additions & 2 deletions client/rpc/src/eth/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ use std::sync::Arc;

use ethereum_types::{H256, U256};
use jsonrpsee::core::RpcResult as Result;

// Substrate
use sc_client_api::backend::{Backend, StateBackend, StorageProvider};
use sc_network::ExHashT;
use sc_transaction_pool::ChainApi;
use sp_blockchain::HeaderBackend;
use sp_core::hashing::keccak_256;
use sp_runtime::traits::{BlakeTwo256, Block as BlockT};

// Frontier
use fc_rpc_core::types::*;

use crate::{
Expand Down
Loading