Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addressing deprecated traits #460

Merged
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [C] Changes is `Cere` Runtime
- [D] Changes is `Cere Dev` Runtime

## [6.6.1]
- [C,D] Remove the Deprecated traits.

## [6.6.0]
- [C,D] Update Substrate from `stable2407` to `stable2409`.

Expand Down
37 changes: 19 additions & 18 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace.package]
version = "6.6.0"
version = "6.6.1"
authors = ["Cerebellum-Network"]
edition = "2021"
homepage = "https://cere.network/"
Expand Down
3 changes: 1 addition & 2 deletions node/cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,7 @@ pub fn run() -> sc_cli::Result<()> {
#[cfg(feature = "cere-dev-native")]
if chain_spec.is_cere_dev() {
return runner.sync_run(|config| {
#[allow(deprecated)]
cmd.run::<sp_runtime::traits::HashingFor<cere_service::cere_dev_runtime::Block>, ()>(config)
cmd.run_with_spec::<sp_runtime::traits::HashingFor<cere_service::cere_dev_runtime::Block>, ()>(Some(config.chain_spec))
});
}

Expand Down
2 changes: 2 additions & 0 deletions node/client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ sp-consensus = { workspace = true, default-features = true }
sp-consensus-babe = { workspace = true, default-features = true }
sp-consensus-grandpa = { workspace = true, default-features = true }
sp-inherents = { workspace = true, default-features = true }
sp-io = { workspace = true, default-features = true }
sp-offchain = { workspace = true, default-features = true }
sp-runtime = { workspace = true, default-features = true }
sp-session = { workspace = true, default-features = true }
Expand All @@ -45,3 +46,4 @@ cere-runtime = { workspace = true, optional = true }
default = ["cere"]
cere = ["cere-runtime"]
cere-dev = ["cere-dev-runtime"]
runtime-benchmarks = []
52 changes: 12 additions & 40 deletions node/client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ use sc_client_api::{
AuxStore, Backend as BackendT, BlockchainEvents, KeysIter, MerkleValue, PairsIter,
UsageProvider,
};
#[allow(deprecated)]
pub use sc_executor::NativeElseWasmExecutor;
use sc_executor::WasmExecutor;
use sp_api::{CallApiAt, ProvideRuntimeApi};
use sp_blockchain::{HeaderBackend, HeaderMetadata};
use sp_consensus::BlockStatus;
Expand All @@ -19,46 +18,19 @@ use sp_runtime::{
use sp_storage::{ChildInfo, StorageData, StorageKey};

pub type FullBackend = sc_service::TFullBackend<Block>;
#[allow(deprecated)]
pub type FullClient<RuntimeApi, ExecutorDispatch> =
sc_service::TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<ExecutorDispatch>>;

#[cfg(not(any(feature = "cere", feature = "cere-dev",)))]
compile_error!("at least one runtime feature must be enabled");

/// The native executor instance for Cere.
#[cfg(feature = "cere")]
pub struct CereExecutorDispatch;

#[cfg(feature = "cere")]
impl sc_executor::NativeExecutionDispatch for CereExecutorDispatch {
type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;
#[cfg(not(feature = "runtime-benchmarks"))]
pub type HostFunctions = sp_io::SubstrateHostFunctions;

fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
cere_runtime::api::dispatch(method, data)
}

fn native_version() -> sc_executor::NativeVersion {
cere_runtime::native_version()
}
}
#[cfg(feature = "runtime-benchmarks")]
pub type HostFunctions =
(sp_io::SubstrateHostFunctions, frame_benchmarking::benchmarking::HostFunctions);

/// The native executor instance for Cere Dev.
#[cfg(feature = "cere-dev")]
pub struct CereDevExecutorDispatch;
pub type ChainExecutor = WasmExecutor<HostFunctions>;
pub type FullClient<RuntimeApi> = sc_service::TFullClient<Block, RuntimeApi, ChainExecutor>;

#[cfg(feature = "cere-dev")]
impl sc_executor::NativeExecutionDispatch for CereDevExecutorDispatch {
type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;

fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
cere_dev_runtime::api::dispatch(method, data)
}

fn native_version() -> sc_executor::NativeVersion {
cere_dev_runtime::native_version()
}
}
#[cfg(not(any(feature = "cere", feature = "cere-dev",)))]
compile_error!("at least one runtime feature must be enabled");

pub trait AbstractClient<Block, Backend>:
BlockchainEvents<Block>
Expand Down Expand Up @@ -102,9 +74,9 @@ where
#[derive(Clone)]
pub enum Client {
#[cfg(feature = "cere")]
Cere(Arc<FullClient<cere_runtime::RuntimeApi, CereExecutorDispatch>>),
Cere(Arc<FullClient<cere_runtime::RuntimeApi>>),
#[cfg(feature = "cere-dev")]
CereDev(Arc<FullClient<cere_dev_runtime::RuntimeApi, CereDevExecutorDispatch>>),
CereDev(Arc<FullClient<cere_dev_runtime::RuntimeApi>>),
}

macro_rules! with_client {
Expand Down
Loading
Loading