Skip to content
Draft
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ build-bridging-mainnet:
cargo build --features frequency,frequency-bridging

build-bridging-westend:
cargo build --features frequency-westend,frequency-bridging --release
cargo build --features frequency-westend,frequency-bridging

build-bridging-local:
cargo build --features frequency-local,frequency-bridging --release
Expand Down
31 changes: 16 additions & 15 deletions common/primitives/src/offchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,24 @@ extern crate alloc;
use alloc::vec::Vec;
use core::fmt::Debug;

#[cfg(feature = "std")]
sp_externalities::decl_extension! {
/// Offchain worker custom extension
pub struct OcwCustomExt (
// rpc address provided to offchain worker
Vec<u8>
);
}
// #[cfg(feature = "std")]
// sp_externalities::decl_extension! {
// /// Offchain worker custom extension
// pub struct OcwCustomExt (
// // rpc address provided to offchain worker
// Vec<u8>
// );
// }

/// runtime new customized
#[runtime_interface]
pub trait Custom: ExternalitiesExt {
/// another function
fn get_val(&mut self) -> Option<Vec<u8>> {
self.extension::<OcwCustomExt>().map(|ext| ext.0.clone())
}
}
// #[runtime_interface]
// pub trait Custom: ExternalitiesExt {
// /// another function
// fn get_val(&mut self) -> Option<Vec<u8>> {
// self.extension::<OcwCustomExt>().map(|ext| ext.0.clone())
// }
// }

/// Lock expiration timeout in milli-seconds for msa pallet per msa account
pub const MSA_ACCOUNT_LOCK_TIMEOUT_EXPIRATION_MS: u64 = 50;
/// Lock name prefix for msa account
Expand Down
6 changes: 4 additions & 2 deletions node/service/src/common.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#![allow(missing_docs)]
use crate::service::ParachainClient;
use common_primitives::{node::Block, offchain::OcwCustomExt};
use common_primitives::node::Block;
// use common_primitives::offchain::OcwCustomExt;
use sc_client_api::Backend;
use sc_offchain::NetworkProvider;
use sc_service::{config::RpcEndpoint, TFullBackend, TaskManager};
Expand Down Expand Up @@ -58,7 +59,8 @@ pub fn start_offchain_workers(
transaction_pool,
network_provider,
enable_http_requests: true,
custom_extensions: move |_hash| vec![Box::new(OcwCustomExt(rpc_address.clone())) as Box<_>],
custom_extensions: move |_hash| vec![],
// custom_extensions: move |_hash| vec![Box::new(OcwCustomExt(rpc_address.clone())) as Box<_>],
})
.expect("Could not create Offchain Worker");

Expand Down
6 changes: 3 additions & 3 deletions node/service/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ type MaybeFullSelectChain = Option<LongestChain<FullBackend, Block>>;
#[cfg(not(feature = "runtime-benchmarks"))]
type HostFunctions = (
cumulus_client_service::ParachainHostFunctions,
common_primitives::offchain::custom::HostFunctions,
// common_primitives::offchain::custom::HostFunctions,
);

#[cfg(feature = "runtime-benchmarks")]
type HostFunctions = (
cumulus_client_service::ParachainHostFunctions,
frame_benchmarking::benchmarking::HostFunctions,
common_primitives::offchain::custom::HostFunctions,
// common_primitives::offchain::custom::HostFunctions,
);

use crate::common::start_offchain_workers;
Expand Down Expand Up @@ -203,7 +203,7 @@ pub async fn start_parachain_node(
override_pool_config: Option<TransactionPoolOptions>,
) -> sc_service::error::Result<(TaskManager, Arc<ParachainClient>)> {
use crate::common::listen_addrs_to_normalized_strings;
use common_primitives::offchain::OcwCustomExt;
// use common_primitives::offchain::OcwCustomExt;
use sc_client_db::Backend;

let parachain_config = prepare_node_config(parachain_config);
Expand Down
7 changes: 4 additions & 3 deletions pallets/msa/src/offchain_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -452,12 +452,13 @@ pub struct FinalizedBlockResponse {
/// fetches finalized block hash from rpc
fn fetch_finalized_block_hash<T: Config>() -> Result<T::Hash, sp_runtime::offchain::http::Error> {
// we are not able to use the custom extension in benchmarks due to feature conflict
let rpc_address = if cfg!(feature = "runtime-benchmarks") {
let rpc_address: Vec<u8> = if cfg!(feature = "runtime-benchmarks") {
RPC_FINALIZED_BLOCK_REQUEST_URL.into()
} else {
RPC_FINALIZED_BLOCK_REQUEST_URL.into()
// rpc address provided to offchain worker via custom extension
common_primitives::offchain::custom::get_val()
.unwrap_or(RPC_FINALIZED_BLOCK_REQUEST_URL.into())
// common_primitives::offchain::custom::get_val()
// .unwrap_or(RPC_FINALIZED_BLOCK_REQUEST_URL.into())
};
let url = core::str::from_utf8(&rpc_address)
.map_err(|_| sp_runtime::offchain::http::Error::Unknown)?;
Expand Down
Loading