Skip to content

Commit

Permalink
Fix OCW
Browse files Browse the repository at this point in the history
  • Loading branch information
rakanalh committed Dec 18, 2023
1 parent 71045d7 commit 4c9003f
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 27 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

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

9 changes: 0 additions & 9 deletions cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,6 @@ pub struct RunCmd {
#[clap(flatten)]
pub base: sc_cli::RunCmd,

/// Enable DDC validation (disabled by default). Works only on validator nodes with enabled
/// offchain workers.
#[arg(long, requires = "dac_url")]
pub enable_ddc_validation: bool,

/// DAC DataModel HTTP endpoint to retrieve DDC activity data for validation.
#[arg(long, requires = "enable_ddc_validation", value_parser = url::Url::parse)]
pub dac_url: Option<String>,

/// Force using Cere Dev runtime.
#[arg(long = "force-cere-dev")]
pub force_cere_dev: bool,
Expand Down
11 changes: 3 additions & 8 deletions cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,14 +245,9 @@ pub fn run() -> sc_cli::Result<()> {
None => {
let runner = cli.create_runner(&cli.run.base)?;
runner.run_node_until_exit(|config| async move {
cere_service::build_full(
config,
cli.run.no_hardware_benchmarks,
cli.run.enable_ddc_validation,
cli.run.dac_url,
)
.map(|full| full.task_manager)
.map_err(Error::Service)
cere_service::build_full(config, cli.run.no_hardware_benchmarks)
.map(|full| full.task_manager)
.map_err(Error::Service)
})
},
}
Expand Down
2 changes: 2 additions & 0 deletions node/client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,7 @@ pub trait RuntimeApiCollection:
+ frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index>
+ pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>
+ sp_api::Metadata<Block>
+ sp_offchain::OffchainWorkerApi<Block>
+ sp_session::SessionKeys<Block>
+ sp_authority_discovery::AuthorityDiscoveryApi<Block>
where
Expand All @@ -514,6 +515,7 @@ where
+ frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index>
+ pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>
+ sp_api::Metadata<Block>
+ sp_offchain::OffchainWorkerApi<Block>
+ sp_session::SessionKeys<Block>
+ sp_authority_discovery::AuthorityDiscoveryApi<Block>,
<Self as sp_api::ApiExt<Block>>::StateBackend: sp_api::StateBackend<BlakeTwo256>,
Expand Down
10 changes: 1 addition & 9 deletions node/service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub use cere_dev_runtime;
#[cfg(feature = "cere-native")]
pub use cere_runtime;
use futures::prelude::*;
use sc_client_api::{Backend, BlockBackend};
use sc_client_api::BlockBackend;
use sc_consensus_babe::{self, SlotProportion};
pub use sc_executor::NativeExecutionDispatch;
use sc_network::Event;
Expand Down Expand Up @@ -269,16 +269,12 @@ where
pub fn build_full(
config: Configuration,
disable_hardware_benchmarks: bool,
enable_ddc_validation: bool,
dac_url: Option<String>,
) -> Result<NewFull<Client>, ServiceError> {
#[cfg(feature = "cere-dev-native")]
if config.chain_spec.is_cere_dev() {
return new_full::<cere_dev_runtime::RuntimeApi, CereDevExecutorDispatch>(
config,
disable_hardware_benchmarks,
enable_ddc_validation,
dac_url,
|_, _| (),
)
.map(|full| full.with_client(Client::CereDev))
Expand All @@ -289,8 +285,6 @@ pub fn build_full(
new_full::<cere_runtime::RuntimeApi, CereExecutorDispatch>(
config,
disable_hardware_benchmarks,
enable_ddc_validation,
dac_url,
|_, _| (),
)
.map(|full| full.with_client(Client::Cere))
Expand Down Expand Up @@ -324,8 +318,6 @@ impl<C> NewFull<C> {
pub fn new_full<RuntimeApi, ExecutorDispatch>(
mut config: Configuration,
disable_hardware_benchmarks: bool,
enable_ddc_validation: bool,
dac_url: Option<String>,
with_startup_data: impl FnOnce(
&sc_consensus_babe::BabeBlockImport<
Block,
Expand Down
1 change: 1 addition & 0 deletions runtime/cere-dev/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ sp-consensus-babe = { default-features = false, git = "https://github.com/parity
sp-core = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.31" }
sp-inherents = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.31" }
sp-io = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.31" }
sp-offchain = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.31" }
sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.31" }
sp-session = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.31" }
sp-staking = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.31" }
Expand Down
6 changes: 6 additions & 0 deletions runtime/cere-dev/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1577,6 +1577,12 @@ impl_runtime_apis! {
}
}

impl sp_offchain::OffchainWorkerApi<Block> for Runtime {
fn offchain_worker(header: &<Block as BlockT>::Header) {
Executive::offchain_worker(header)
}
}

impl fg_primitives::GrandpaApi<Block> for Runtime {
fn grandpa_authorities() -> GrandpaAuthorityList {
Grandpa::grandpa_authorities()
Expand Down
1 change: 1 addition & 0 deletions runtime/cere/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ sp-consensus-babe = { default-features = false, git = "https://github.com/parity
sp-core = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.31" }
sp-inherents = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.31" }
sp-io = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.31" }
sp-offchain = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.31" }
sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.31" }
sp-session = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.31" }
sp-staking = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.31" }
Expand Down
6 changes: 6 additions & 0 deletions runtime/cere/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1484,6 +1484,12 @@ impl_runtime_apis! {
}
}

impl sp_offchain::OffchainWorkerApi<Block> for Runtime {
fn offchain_worker(header: &<Block as BlockT>::Header) {
Executive::offchain_worker(header)
}
}

impl fg_primitives::GrandpaApi<Block> for Runtime {
fn grandpa_authorities() -> GrandpaAuthorityList {
Grandpa::grandpa_authorities()
Expand Down
2 changes: 1 addition & 1 deletion zombienet/0001-ddc-validation/ddc-validation.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[relaychain]
default_command = "./target/release/cere"
default_args = ["--enable-ddc-validation --dac-url {{DAC_URL}}"]
default_args = [""]
chain = "local"

[[relaychain.nodes]]
Expand Down

0 comments on commit 4c9003f

Please sign in to comment.