Skip to content

Commit

Permalink
deps: update substrate to polkadot-v0.9.42 (#1054)
Browse files Browse the repository at this point in the history
* deps: update substrate to polkadot-v0.9.42

- update substrate to 16b2e644487f7f767eeefd4debf11a7948bfa4db
- update rust toolchain to 1.68.2

* Enable `insecure_zero_ed` feature of `pallet-balances` to fix tests of `pallet-evm`,
since `ExistentialDeposit: u64 = 0` is configured in the mock impl of `pallet-evm`.

* fix precompile tests

* update some deps

* update evm to 0.39.1

* make clippy happy

* some trivials

* Update client/db/src/kv/upgrade.rs

---------

Co-authored-by: Wei Tang <[email protected]>
  • Loading branch information
koushiro and sorpaas authored Jun 28, 2023
1 parent 3b87145 commit e89f336
Show file tree
Hide file tree
Showing 42 changed files with 1,066 additions and 896 deletions.
1,419 changes: 773 additions & 646 deletions Cargo.lock

Large diffs are not rendered by default.

27 changes: 17 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,31 +39,38 @@ edition = "2021"
repository = "https://github.com/paritytech/frontier/"

[workspace.dependencies]
async-trait = "0.1"
bn = { package = "substrate-bn", version = "0.6", default-features = false }
clap = { version = "4.3", features = ["derive", "deprecated"] }
environmental = { version = "1.1.4", default-features = false }
ethereum = { version = "0.14.0", default-features = false }
ethereum-types = { version = "0.14.1", default-features = false }
evm = { git = "https://github.com/rust-blockchain/evm", branch = "master", default-features = false }
hex-literal = { version = "0.3.4" }
evm = { git = "https://github.com/rust-blockchain/evm", rev = "b7b82c7e1fc57b7449d6dfa6826600de37cc1e65", default-features = false }
futures = "0.3.28"
hex = { version = "0.4.3", default-features = false, features = ["alloc"] }
hex-literal = "0.4.1"
impl-serde = { version = "0.4.0", default-features = false }
jsonrpsee = "0.16.2"
kvdb-rocksdb = "0.17.0"
kvdb-rocksdb = "0.18.0"
libsecp256k1 = { version = "0.7.1", default-features = false }
log = { version = "0.4.17", default-features = false }
parity-db = "0.4.6"
parity-db = "0.4.8"
parking_lot = "0.12.1"
rlp = { version = "0.5", default-features = false }
scale-codec = { package = "parity-scale-codec", version = "3.2.1", default-features = false, features = ["derive"] }
scale-info = { version = "2.3.1", default-features = false, features = ["derive"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
sqlx = "0.7.0-alpha.3"
sqlx = { version = "0.7.0-alpha.3", default-features = false, features = ["macros"] }
thiserror = "1.0"
tokio = "1.28.2"
# Substrate Client
sc-basic-authorship = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate", branch = "master" }
sc-block-builder = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate", branch = "master" }
sc-chain-spec = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "master" }
sc-cli = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sc-client-api = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "master" }
sc-client-db = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate", branch = "master" }
sc-client-db = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sc-consensus = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate", branch = "master" }
sc-consensus-aura = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate", branch = "master" }
sc-consensus-grandpa = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate", branch = "master" }
Expand Down Expand Up @@ -127,11 +134,11 @@ substrate-frame-rpc-system = { version = "4.0.0-dev", git = "https://github.com/
substrate-test-runtime-client = { version = "2.0.0", git = "https://github.com/paritytech/substrate", branch = "master" }
substrate-wasm-builder = { version = "5.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "master" }
# Frontier Client
fc-cli = { version = "1.0.0-dev", path = "client/cli" }
fc-cli = { version = "1.0.0-dev", path = "client/cli", default-features = false }
fc-consensus = { version = "2.0.0-dev", path = "client/consensus" }
fc-db = { version = "2.0.0-dev", path = "client/db" }
fc-mapping-sync = { version = "2.0.0-dev", path = "client/mapping-sync" }
fc-rpc = { version = "2.0.0-dev", path = "client/rpc" }
fc-db = { version = "2.0.0-dev", path = "client/db", default-features = false }
fc-mapping-sync = { version = "2.0.0-dev", path = "client/mapping-sync", default-features = false }
fc-rpc = { version = "2.0.0-dev", path = "client/rpc", default-features = false }
fc-rpc-core = { version = "1.1.0-dev", path = "client/rpc-core" }
fc-storage = { version = "1.0.0-dev", path = "client/storage" }
# Frontier Primitive
Expand Down
11 changes: 9 additions & 2 deletions client/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repository = { workspace = true }
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
clap = { version = "4.1", features = ["derive", "deprecated"] }
clap = { workspace = true }
ethereum-types = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
Expand All @@ -26,7 +26,7 @@ fp-rpc = { workspace = true, features = ["default"] }
fp-storage = { workspace = true, features = ["default"] }

[dev-dependencies]
futures = "0.3.21"
futures = { workspace = true }
scale-codec = { package = "parity-scale-codec", workspace = true }
tempfile = "3.3.0"
# Substrate
Expand All @@ -38,3 +38,10 @@ substrate-test-runtime-client = { workspace = true }
# Frontier
fc-db = { workspace = true, features = ["rocksdb"] }
frontier-template-runtime = { workspace = true, features = ["default"] }

[features]
default = ["rocksdb"]
rocksdb = [
"sc-cli/rocksdb",
"fc-db/rocksdb",
]
4 changes: 2 additions & 2 deletions client/consensus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ repository = { workspace = true }
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
async-trait = "0.1"
thiserror = "1.0"
async-trait = { workspace = true }
thiserror = { workspace = true }
# Substrate
sc-consensus = { workspace = true }
sp-api = { workspace = true }
Expand Down
45 changes: 21 additions & 24 deletions client/db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ repository = { workspace = true }
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
async-trait = "0.1"
async-trait = { workspace = true }
ethereum = { workspace = true, features = ["with-codec"], optional = true }
futures = { version = "0.3.25", optional = true }
futures = { workspace = true, optional = true }
kvdb-rocksdb = { workspace = true, optional = true }
log = "0.4.17"
parity-db = { workspace = true, optional = true }
parking_lot = "0.12.1"
log = { workspace = true }
parity-db = { workspace = true }
parking_lot = { workspace = true }
scale-codec = { package = "parity-scale-codec", workspace = true }
smallvec = { version = "1.10", optional = true }
sqlx = { workspace = true, features = ["runtime-tokio-native-tls", "sqlite"], optional = true }
tokio = { version = "1.19", features = ["macros", "sync"], optional = true }
tokio = { workspace = true, features = ["macros", "sync"], optional = true }
# Substrate
sc-client-api = { workspace = true, optional = true }
sc-client-db = { workspace = true }
Expand All @@ -37,8 +37,22 @@ fp-consensus = { workspace = true, features = ["default"], optional = true }
fp-rpc = { workspace = true, features = ["default"], optional = true }
fp-storage = { workspace = true, features = ["default"] }

[dev-dependencies]
futures = { workspace = true }
maplit = "1.0.2"
tempfile = "3.3.0"
# Substrate
sc-block-builder = { workspace = true }
sp-consensus = { workspace = true }
substrate-test-runtime-client = { workspace = true }

[features]
default = ["parity-db"]
default = ["rocksdb"]
rocksdb = [
"kvdb-rocksdb",
"sc-client-db/rocksdb",
"smallvec",
]
sql = [
"ethereum",
"futures",
Expand All @@ -51,20 +65,3 @@ sql = [
"fp-consensus",
"fp-rpc",
]
parity-db = ["dep:parity-db"]
rocksdb = [
"kvdb-rocksdb",
"sc-client-db/rocksdb",
"smallvec",
]

[dev-dependencies]
futures = { version = "0.3.25" }
maplit = "1.0.2"
tempfile = "3.3.0"
# Substrate
sc-block-builder = { workspace = true }
sp-consensus = { workspace = true }
substrate-test-runtime-client = { workspace = true }
# Frontier
fc-rpc = { workspace = true }
14 changes: 6 additions & 8 deletions client/db/src/kv/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

#[cfg(feature = "parity-db")]
mod parity_db_adapter;
mod upgrade;
mod utils;
Expand Down Expand Up @@ -114,23 +113,22 @@ impl<Block: BlockT> Backend<Block> {
client,
&DatabaseSettings {
source: match database {
DatabaseSource::Auto { .. } => DatabaseSource::Auto {
rocksdb_path: frontier_database_dir(db_config_dir, "db"),
paritydb_path: frontier_database_dir(db_config_dir, "paritydb"),
cache_size: 0,
},
#[cfg(feature = "rocksdb")]
DatabaseSource::RocksDb { .. } => DatabaseSource::RocksDb {
path: frontier_database_dir(db_config_dir, "db"),
cache_size: 0,
},
#[cfg(feature = "parity-db")]
DatabaseSource::ParityDb { .. } => DatabaseSource::ParityDb {
path: frontier_database_dir(db_config_dir, "paritydb"),
},
DatabaseSource::Auto { .. } => DatabaseSource::Auto {
rocksdb_path: frontier_database_dir(db_config_dir, "db"),
paritydb_path: frontier_database_dir(db_config_dir, "paritydb"),
cache_size: 0,
},
_ => {
return Err(
"Supported db sources: `rocksdb` | `paritydb` | `auto`".to_string()
"Supported db sources: `auto` | `rocksdb` | `paritydb`".to_string()
)
}
},
Expand Down
9 changes: 4 additions & 5 deletions client/db/src/kv/upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,9 @@ pub(crate) fn upgrade_db<Block: BlockT, C: HeaderBackend<Block>>(
0 => return Err(UpgradeError::UnsupportedVersion(db_version)),
1 => {
let summary: UpgradeVersion1To2Summary = match source {
#[cfg(feature = "parity-db")]
DatabaseSource::ParityDb { .. } => migrate_1_to_2_parity_db::<Block, C>(client, db_path)?,
DatabaseSource::ParityDb { .. } => {
migrate_1_to_2_parity_db::<Block, C>(client, db_path)?
}
#[cfg(feature = "rocksdb")]
DatabaseSource::RocksDb { .. } => migrate_1_to_2_rocks_db::<Block, C>(client, db_path)?,
_ => panic!("DatabaseSource required for upgrade ParityDb | RocksDb"),
Expand Down Expand Up @@ -245,7 +246,6 @@ pub(crate) fn migrate_1_to_2_rocks_db<Block: BlockT, C: HeaderBackend<Block>>(
Ok(res)
}

#[cfg(feature = "parity-db")]
pub(crate) fn migrate_1_to_2_parity_db<Block: BlockT, C: HeaderBackend<Block>>(
client: Arc<C>,
db_path: &Path,
Expand Down Expand Up @@ -353,7 +353,7 @@ mod tests {
Ok(Arc::new(crate::kv::Backend::<Block>::new(client, setting)?))
}

#[cfg_attr(not(any(feature = "rocksdb", feature = "parity-db")), ignore)]
#[cfg_attr(not(feature = "rocksdb"), ignore)]
#[test]
fn upgrade_1_to_2_works() {
let settings: Vec<DatabaseSettings> = vec![
Expand All @@ -369,7 +369,6 @@ mod tests {
},
},
// Parity db
#[cfg(feature = "parity-db")]
crate::kv::DatabaseSettings {
source: sc_client_db::DatabaseSource::ParityDb {
path: tempdir()
Expand Down
27 changes: 9 additions & 18 deletions client/db/src/kv/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@ pub fn open_database<Block: BlockT, C: HeaderBackend<Block>>(
config: &DatabaseSettings,
) -> Result<Arc<dyn Database<DbHash>>, String> {
let db: Arc<dyn Database<DbHash>> = match &config.source {
#[cfg(feature = "parity-db")]
DatabaseSource::ParityDb { path } => open_parity_db::<Block, C>(client, path, &config.source)?,
#[cfg(feature = "rocksdb")]
DatabaseSource::RocksDb { path, .. } => {
open_kvdb_rocksdb::<Block, C>(client, path, true, &config.source)?
}
DatabaseSource::Auto {
paritydb_path,
rocksdb_path,
Expand All @@ -46,7 +40,14 @@ pub fn open_database<Block: BlockT, C: HeaderBackend<Block>>(
Err(_) => open_parity_db::<Block, C>(client, paritydb_path, &config.source)?,
}
}
_ => return Err("Missing feature flags `parity-db`".to_string()),
#[cfg(feature = "rocksdb")]
DatabaseSource::RocksDb { path, .. } => {
open_kvdb_rocksdb::<Block, C>(client, path, true, &config.source)?
}
DatabaseSource::ParityDb { path } => {
open_parity_db::<Block, C>(client, path, &config.source)?
}
_ => return Err("Supported db sources: `auto` | `rocksdb` | `paritydb`".to_string()),
};
Ok(db)
}
Expand Down Expand Up @@ -82,10 +83,9 @@ fn open_kvdb_rocksdb<Block: BlockT, C: HeaderBackend<Block>>(
_create: bool,
_source: &DatabaseSource,
) -> Result<Arc<dyn Database<DbHash>>, String> {
Err("Missing feature flags `kvdb-rocksdb`".to_string())
Err("Missing feature flags `rocksdb`".to_string())
}

#[cfg(feature = "parity-db")]
fn open_parity_db<Block: BlockT, C: HeaderBackend<Block>>(
client: Arc<C>,
path: &Path,
Expand All @@ -106,12 +106,3 @@ fn open_parity_db<Block: BlockT, C: HeaderBackend<Block>>(
super::upgrade::update_version(path).map_err(|_| "Cannot update db version".to_string())?;
Ok(Arc::new(super::parity_db_adapter::DbAdapter(db)))
}

#[cfg(not(feature = "parity-db"))]
fn open_parity_db<Block: BlockT, C: HeaderBackend<Block>>(
_client: Arc<C>,
_path: &Path,
_source: &DatabaseSource,
) -> Result<Arc<dyn Database<DbHash>>, String> {
Err("Missing feature flags `parity-db`".to_string())
}
31 changes: 12 additions & 19 deletions client/db/src/sql/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,8 @@ where
}
None => {
return Err(Error::Protocol(format!(
"Missing ethereum block for hash mismatch {expect_eth_block_hash:?}"
)))
"Missing ethereum block for hash mismatch {expect_eth_block_hash:?}"
)))
}
}
}
Expand Down Expand Up @@ -341,24 +341,17 @@ where
is_canon,
})
}
Err(FindLogError::NotFound) => {
return Err(Error::Protocol(format!(
"[Metadata] No logs found for hash {:?}",
hash
)))
}
Err(FindLogError::MultipleLogs) => {
return Err(Error::Protocol(format!(
"[Metadata] Multiple logs found for hash {:?}",
hash
)))
}
Err(FindLogError::NotFound) => Err(Error::Protocol(format!(
"[Metadata] No logs found for hash {hash:?}",
))),
Err(FindLogError::MultipleLogs) => Err(Error::Protocol(format!(
"[Metadata] Multiple logs found for hash {hash:?}",
))),
}
} else {
return Err(Error::Protocol(format!(
"[Metadata] Failed retrieving header for hash {:?}",
hash
)));
Err(Error::Protocol(format!(
"[Metadata] Failed retrieving header for hash {hash:?}"
)))
}
}

Expand Down Expand Up @@ -1053,7 +1046,7 @@ mod test {
DefaultTestClientBuilderExt, TestClientBuilder, TestClientBuilderExt,
};
// Frontier
use fc_rpc::{OverrideHandle, SchemaV3Override, StorageOverride};
use fc_storage::{OverrideHandle, SchemaV3Override, StorageOverride};
use fp_storage::{EthereumStorageSchema, PALLET_ETHEREUM_SCHEMA};

type OpaqueBlock =
Expand Down
Loading

0 comments on commit e89f336

Please sign in to comment.