Skip to content

Commit

Permalink
Move EthereumStorageSchema to primitives (#560)
Browse files Browse the repository at this point in the history
* Move `EthereumStorageSchema` to primitives

* Delete unused deps
  • Loading branch information
boundless-forest authored Feb 2, 2022
1 parent d5d4f94 commit ee8c5b4
Show file tree
Hide file tree
Showing 12 changed files with 35 additions and 31 deletions.
7 changes: 4 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion client/db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ repository = "https://github.com/paritytech/frontier/"
sp-core = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate" }
sp-database = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate" }
sp-runtime = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate" }
pallet-ethereum = { version = "4.0.0-dev", path = "../../frame/ethereum" }
fp-storage = { version = "2.0.0-dev", path = "../../primitives/storage"}
kvdb = "0.10.0"
kvdb-rocksdb = "0.14.0"
Expand Down
3 changes: 1 addition & 2 deletions client/db/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ mod utils;
pub use sp_database::Database;

use codec::{Decode, Encode};
use fp_storage::PALLET_ETHEREUM_SCHEMA_CACHE;
use pallet_ethereum::EthereumStorageSchema;
use fp_storage::{EthereumStorageSchema, PALLET_ETHEREUM_SCHEMA_CACHE};
use parking_lot::Mutex;
use sp_core::H256;
use sp_runtime::traits::Block as BlockT;
Expand Down
2 changes: 0 additions & 2 deletions client/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ sc-service = { version = "0.10.0-dev", git = "https://github.com/paritytech/subs
sc-client-api = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate" }
sc-rpc = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate" }
sc-network = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate" }
pallet-evm = { version = "6.0.0-dev", path = "../../frame/evm" }
fp-evm = { version = "3.0.0-dev", path = "../../primitives/evm" }
pallet-ethereum = { version = "4.0.0-dev", path = "../../frame/ethereum" }
ethereum = { version = "0.11.1", features = ["with-codec"] }
codec = { package = "parity-scale-codec", version = "2.0.0" }
rlp = "0.5"
Expand Down
2 changes: 1 addition & 1 deletion client/rpc/src/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ use tokio::sync::{mpsc, oneshot};
use crate::overrides::OverrideHandle;
use codec::{self, Decode, Encode};
pub use fc_rpc_core::{EthApiServer, EthFilterApiServer, NetApiServer, Web3ApiServer};
use pallet_ethereum::EthereumStorageSchema;
use fp_storage::EthereumStorageSchema;

pub struct EthApi<B: BlockT, C, P, CT, BE, H: ExHashT, A: ChainApi> {
pool: Arc<P>,
Expand Down
5 changes: 2 additions & 3 deletions client/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,9 @@ pub use overrides::{
};

use ethereum_types::{H160, H256};
use evm::ExitError;
use evm::{ExitError, ExitReason};
pub use fc_rpc_core::types::TransactionMessage;
use jsonrpc_core::{Error, ErrorCode, Value};
use pallet_evm::ExitReason;
use rustc_hex::ToHex;
use sha3::{Digest, Keccak256};

Expand All @@ -55,7 +54,7 @@ pub mod frontier_backend_client {
use jsonrpc_core::Result as RpcResult;

use ethereum_types::H256;
use pallet_ethereum::EthereumStorageSchema;
use fp_storage::EthereumStorageSchema;

pub fn native_block_id<B: BlockT, C>(
client: &C,
Expand Down
2 changes: 1 addition & 1 deletion client/rpc/src/overrides/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use std::collections::BTreeMap;
use ethereum::BlockV2 as EthereumBlock;
use ethereum_types::{H160, H256, U256};
use fp_rpc::{EthereumRuntimeRPCApi, TransactionStatus};
use fp_storage::EthereumStorageSchema;
use sp_api::{ApiExt, BlockId, ProvideRuntimeApi};
use sp_io::hashing::{blake2_128, twox_128};
use sp_runtime::{traits::Block as BlockT, Permill};
Expand All @@ -28,7 +29,6 @@ mod schema_v2_override;
mod schema_v3_override;

pub use fc_rpc_core::{EthApiServer, NetApiServer};
use pallet_ethereum::EthereumStorageSchema;
pub use schema_v1_override::SchemaV1Override;
pub use schema_v2_override::SchemaV2Override;
pub use schema_v3_override::SchemaV3Override;
Expand Down
17 changes: 1 addition & 16 deletions frame/ethereum/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use ethereum_types::{Bloom, BloomInput, H160, H256, H64, U256};
use evm::ExitReason;
use fp_consensus::{PostLog, PreLog, FRONTIER_ENGINE_ID};
use fp_evm::CallOrCreateInfo;
use fp_storage::PALLET_ETHEREUM_SCHEMA;
use fp_storage::{EthereumStorageSchema, PALLET_ETHEREUM_SCHEMA};
use frame_support::{
dispatch::DispatchResultWithPostInfo,
traits::{EnsureOrigin, Get},
Expand Down Expand Up @@ -859,21 +859,6 @@ pub enum ReturnValue {
Hash(H160),
}

/// The schema version for Pallet Ethereum's storage
#[derive(Clone, Copy, Debug, Encode, Decode, PartialEq, Eq, PartialOrd, Ord)]
pub enum EthereumStorageSchema {
Undefined,
V1,
V2,
V3,
}

impl Default for EthereumStorageSchema {
fn default() -> Self {
Self::Undefined
}
}

pub struct IntermediateStateRoot;
impl Get<H256> for IntermediateStateRoot {
fn get() -> H256 {
Expand Down
7 changes: 6 additions & 1 deletion primitives/storage/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ edition = "2018"
description = "Storage primitives for Ethereum RPC (web3) compatibility layer for Substrate."
license = "Apache-2.0"

[dependencies]
codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false }

[features]
default = ["std"]
std = []
std = [
"codec/std"
]
17 changes: 17 additions & 0 deletions primitives/storage/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,24 @@

#![cfg_attr(not(feature = "std"), no_std)]

use codec::{Decode, Encode};

/// Current version of pallet Ethereum's storage schema is stored under this key.
pub const PALLET_ETHEREUM_SCHEMA: &'static [u8] = b":ethereum_schema";
/// Cached version of pallet Ethereum's storage schema is stored under this key in the AuxStore.
pub const PALLET_ETHEREUM_SCHEMA_CACHE: &'static [u8] = b":ethereum_schema_cache";

/// The schema version for Pallet Ethereum's storage
#[derive(Clone, Copy, Debug, Encode, Decode, PartialEq, Eq, PartialOrd, Ord)]
pub enum EthereumStorageSchema {
Undefined,
V1,
V2,
V3,
}

impl Default for EthereumStorageSchema {
fn default() -> Self {
Self::Undefined
}
}
1 change: 1 addition & 0 deletions template/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ frame-benchmarking-cli = { git = "https://github.com/paritytech/substrate" }

fc-consensus = { path = "../../client/consensus" }
fp-consensus = { path = "../../primitives/consensus" }
fp-storage = { path = "../../primitives/storage" }
frontier-template-runtime = { path = "../runtime", default-features = false, features = ["std"] }
fc-rpc = { path = "../../client/rpc" }
fp-rpc = { path = "../../primitives/rpc" }
Expand Down
2 changes: 1 addition & 1 deletion template/node/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ use fc_rpc::{
SchemaV2Override, SchemaV3Override, StorageOverride,
};
use fc_rpc_core::types::{FeeHistoryCache, FilterPool};
use fp_storage::EthereumStorageSchema;
use frontier_template_runtime::{opaque::Block, AccountId, Balance, Hash, Index};
use jsonrpc_pubsub::manager::SubscriptionManager;
use pallet_ethereum::EthereumStorageSchema;
use sc_client_api::{
backend::{AuxStore, Backend, StateBackend, StorageProvider},
client::BlockchainEvents,
Expand Down

0 comments on commit ee8c5b4

Please sign in to comment.