mirror of
https://github.com/datahaven-xyz/datahaven
synced 2026-05-23 17:28:23 +00:00
fix: fix RPC for storage hub (#190)
In this PR we actually add the storage hub RPC config to our node in order to allow RPC call for storage hub service.
This commit is contained in:
parent
edbde1cdea
commit
e5e3fbe22c
6 changed files with 93 additions and 48 deletions
|
|
@ -98,9 +98,9 @@ runs:
|
|||
WORK_DIR="$LOCAL_DIR/tmp"
|
||||
mkdir -p "$WORK_DIR" && cd "$WORK_DIR"
|
||||
|
||||
# Download PostgreSQL 17 packages
|
||||
wget -q "https://apt.postgresql.org/pub/repos/apt/pool/main/p/postgresql-17/libpq5_17.6-1.pgdg+1_${ARCH}.deb"
|
||||
wget -q "https://apt.postgresql.org/pub/repos/apt/pool/main/p/postgresql-17/libpq-dev_17.6-1.pgdg+1_${ARCH}.deb"
|
||||
# Download PostgreSQL 18 packages
|
||||
wget -q "https://apt.postgresql.org/pub/repos/apt/pool/main/p/postgresql-18/libpq5_18.0-1.pgdg+3_${ARCH}.deb"
|
||||
wget -q "https://apt.postgresql.org/pub/repos/apt/pool/main/p/postgresql-18/libpq-dev_18.0-1.pgdg+3_${ARCH}.deb"
|
||||
|
||||
# Extract and install
|
||||
for pkg in *.deb; do
|
||||
|
|
|
|||
52
operator/Cargo.lock
generated
52
operator/Cargo.lock
generated
|
|
@ -1468,7 +1468,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "234113d19d0d7d613b40e86fb654acf958910802bcceab913a4f9e7cda03b1a4"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
"regex-automata",
|
||||
"regex-automata 0.4.10",
|
||||
"serde",
|
||||
]
|
||||
|
||||
|
|
@ -2816,7 +2816,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "8d162beedaa69905488a8da94f5ac3edb4dd4788b732fadb7bd120b2625c1976"
|
||||
dependencies = [
|
||||
"data-encoding",
|
||||
"syn 2.0.106",
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -7677,11 +7677,11 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "matchers"
|
||||
version = "0.2.0"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d1525a2a28c7f4fa0fc98bb91ae755d1e2d1505079e05539e35bc876b5d65ae9"
|
||||
checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558"
|
||||
dependencies = [
|
||||
"regex-automata",
|
||||
"regex-automata 0.1.10",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -8273,11 +8273,12 @@ checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be"
|
|||
|
||||
[[package]]
|
||||
name = "nu-ansi-term"
|
||||
version = "0.50.1"
|
||||
version = "0.46.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d4a28e057d01f97e61255210fcff094d74ed0466038633e95017f5beb68e4399"
|
||||
checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84"
|
||||
dependencies = [
|
||||
"windows-sys 0.52.0",
|
||||
"overload",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -8580,6 +8581,12 @@ dependencies = [
|
|||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "overload"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39"
|
||||
|
||||
[[package]]
|
||||
name = "pallet-asset-conversion"
|
||||
version = "21.1.0"
|
||||
|
|
@ -11833,7 +11840,7 @@ dependencies = [
|
|||
"rand 0.9.2",
|
||||
"rand_chacha 0.9.0",
|
||||
"rand_xorshift",
|
||||
"regex-syntax",
|
||||
"regex-syntax 0.8.6",
|
||||
"rusty-fork",
|
||||
"tempfile",
|
||||
"unarray",
|
||||
|
|
@ -12380,8 +12387,17 @@ checksum = "23d7fd106d8c02486a8d64e778353d1cffe08ce79ac2e82f540c86d0facf6912"
|
|||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-automata",
|
||||
"regex-syntax",
|
||||
"regex-automata 0.4.10",
|
||||
"regex-syntax 0.8.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-automata"
|
||||
version = "0.1.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132"
|
||||
dependencies = [
|
||||
"regex-syntax 0.6.29",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -12392,9 +12408,15 @@ checksum = "6b9458fa0bfeeac22b5ca447c63aaf45f28439a709ccd244698632f9aa6394d6"
|
|||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-syntax",
|
||||
"regex-syntax 0.8.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.6.29"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1"
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.8.6"
|
||||
|
|
@ -18333,15 +18355,15 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "tracing-subscriber"
|
||||
version = "0.3.20"
|
||||
version = "0.3.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2054a14f5307d601f88daf0553e1cbf472acc4f2c51afab632431cdcd72124d5"
|
||||
checksum = "e8189decb5ac0fa7bc8b96b7cb9b2701d60d48805aca84a238004d665fcc4008"
|
||||
dependencies = [
|
||||
"matchers",
|
||||
"nu-ansi-term",
|
||||
"once_cell",
|
||||
"parking_lot 0.12.4",
|
||||
"regex-automata",
|
||||
"regex",
|
||||
"sharded-slab",
|
||||
"smallvec",
|
||||
"thread_local",
|
||||
|
|
|
|||
|
|
@ -83,7 +83,10 @@ ssz_rs_derive = { version = "0.9.0", default-features = false }
|
|||
static_assertions = { version = "1.1.0", default-features = false }
|
||||
strum = { version = "0.26.3", default-features = false, features = ["derive"] }
|
||||
strum_macros = "0.24"
|
||||
tracing = { version = "0.1.37", default-features = false }
|
||||
tracing = { version = "0.1.41", default-features = false }
|
||||
tracing-subscriber = { version = "=0.3.19", features = [
|
||||
"env-filter",
|
||||
] } # Dependency pinned because 0.3.20 messes up text formatting in substrate logs
|
||||
url = "2.2.2"
|
||||
|
||||
# Polkadot SDK
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
use crate::client::{FullBackend, FullClient};
|
||||
use datahaven_runtime_common::Block;
|
||||
pub use fc_db::Backend as FrontierBackend;
|
||||
use fc_rpc::EthConfig;
|
||||
use fc_rpc::EthTask;
|
||||
pub use fc_rpc_core::types::{FeeHistoryCache, FeeHistoryCacheLimit, FilterPool};
|
||||
pub use fc_storage::{StorageOverride, StorageOverrideHandler};
|
||||
|
|
@ -23,7 +24,7 @@ use std::{
|
|||
/// Frontier DB backend type.
|
||||
pub struct DefaultEthConfig<C, BE>(std::marker::PhantomData<(C, BE)>);
|
||||
|
||||
impl<C, BE> fc_rpc::EthConfig<Block, C> for DefaultEthConfig<C, BE>
|
||||
impl<C, BE> EthConfig<Block, C> for DefaultEthConfig<C, BE>
|
||||
where
|
||||
C: StorageProvider<Block, BE> + Sync + Send + 'static,
|
||||
BE: Backend<Block> + 'static,
|
||||
|
|
|
|||
|
|
@ -7,9 +7,7 @@
|
|||
|
||||
use crate::consensus::BabeConsensusDataProvider;
|
||||
use crate::eth::DefaultEthConfig;
|
||||
use datahaven_runtime_common::{
|
||||
time::SLOT_DURATION, AccountId, Balance, Block, BlockNumber, Hash, Nonce,
|
||||
};
|
||||
use datahaven_runtime_common::{time::SLOT_DURATION, Block, BlockNumber, Hash};
|
||||
use fc_rpc::TxPool;
|
||||
use fc_rpc::{Eth, EthBlockDataCacheTask, EthFilter, Net, Web3};
|
||||
use fc_rpc_core::types::{FeeHistoryCache, FilterPool};
|
||||
|
|
@ -17,7 +15,7 @@ use fc_rpc_core::{EthApiServer, EthFilterApiServer, NetApiServer, TxPoolApiServe
|
|||
use fc_storage::StorageOverride;
|
||||
use fp_rpc::EthereumRuntimeRPCApi;
|
||||
use jsonrpsee::RpcModule;
|
||||
use sc_client_api::{AuxStore, Backend, StateBackend, StorageProvider};
|
||||
use sc_client_api::{Backend, StateBackend, StorageProvider};
|
||||
use sc_consensus_beefy::communication::notification::{
|
||||
BeefyBestBlockStream, BeefyVersionedFinalityProofStream,
|
||||
};
|
||||
|
|
@ -25,14 +23,19 @@ use sc_consensus_manual_seal::rpc::{EngineCommand, ManualSeal, ManualSealApiServ
|
|||
use sc_network_sync::SyncingService;
|
||||
use sc_transaction_pool::{ChainApi, Pool};
|
||||
use sc_transaction_pool_api::TransactionPool;
|
||||
use sp_api::{CallApiAt, ProvideRuntimeApi};
|
||||
use sp_block_builder::BlockBuilder;
|
||||
use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata};
|
||||
use shc_client::types::FileStorageT;
|
||||
use shc_common::traits::StorageEnableRuntime;
|
||||
use shc_common::traits::StorageEnableRuntimeApi;
|
||||
use shc_common::types::OpaqueBlock;
|
||||
use shc_common::types::ParachainClient;
|
||||
use shc_forest_manager::traits::ForestStorageHandler;
|
||||
use shc_rpc::StorageHubClientApiServer;
|
||||
use shc_rpc::StorageHubClientRpc;
|
||||
use shc_rpc::StorageHubClientRpcConfig;
|
||||
use sp_consensus_babe::{BabeApi, SlotDuration};
|
||||
use sp_consensus_beefy::AuthorityIdBound;
|
||||
use sp_core::H256;
|
||||
use sp_runtime::traits::BlakeTwo256;
|
||||
use sp_runtime::OpaqueExtrinsic;
|
||||
use std::collections::BTreeMap;
|
||||
use std::sync::Arc;
|
||||
|
||||
|
|
@ -47,9 +50,12 @@ pub struct BeefyDeps<AuthorityId: AuthorityIdBound> {
|
|||
}
|
||||
|
||||
/// Full client dependencies.
|
||||
pub struct FullDeps<C, P, B, AuthorityId: AuthorityIdBound, A: ChainApi> {
|
||||
pub struct FullDeps<P, B, AuthorityId: AuthorityIdBound, A: ChainApi, FL, FS, Runtime>
|
||||
where
|
||||
Runtime: StorageEnableRuntime,
|
||||
{
|
||||
/// The client instance to use.
|
||||
pub client: Arc<C>,
|
||||
pub client: Arc<ParachainClient<Runtime::RuntimeApi>>,
|
||||
/// Transaction pool instance.
|
||||
pub pool: Arc<P>,
|
||||
/// BEEFY dependencies.
|
||||
|
|
@ -82,32 +88,33 @@ pub struct FullDeps<C, P, B, AuthorityId: AuthorityIdBound, A: ChainApi> {
|
|||
pub command_sink: Option<futures::channel::mpsc::Sender<EngineCommand<Hash>>>,
|
||||
/// Mandated parent hashes for a given block hash.
|
||||
pub forced_parent_hashes: Option<BTreeMap<H256, H256>>,
|
||||
/// Storage Hub RPC config
|
||||
pub maybe_storage_hub_client_config: Option<StorageHubClientRpcConfig<FL, FS, Runtime>>,
|
||||
}
|
||||
|
||||
/// Instantiate all full RPC extensions.
|
||||
pub fn create_full<C, P, BE, AuthorityId, A>(
|
||||
deps: FullDeps<C, P, BE, AuthorityId, A>,
|
||||
pub fn create_full<P, BE, AuthorityId, A, FL, FSH, Runtime>(
|
||||
deps: FullDeps<P, BE, AuthorityId, A, FL, FSH, Runtime>,
|
||||
) -> Result<RpcModule<()>, Box<dyn std::error::Error + Send + Sync>>
|
||||
where
|
||||
C: ProvideRuntimeApi<Block> + StorageProvider<Block, BE> + AuxStore,
|
||||
C: HeaderBackend<Block> + HeaderMetadata<Block, Error = BlockChainError> + 'static,
|
||||
C: Send + Sync + 'static,
|
||||
C::Api: substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>,
|
||||
C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>,
|
||||
C::Api: BlockBuilder<Block>,
|
||||
C::Api: mmr_rpc::MmrRuntimeApi<Block, <Block as sp_runtime::traits::Block>::Hash, BlockNumber>,
|
||||
C::Api: EthereumRuntimeRPCApi<Block>,
|
||||
C::Api: BabeApi<Block>,
|
||||
C::Api: fp_rpc::ConvertTransactionRuntimeApi<Block>,
|
||||
C: sc_client_api::UsageProvider<Block>,
|
||||
C: CallApiAt<
|
||||
sp_runtime::generic::Block<sp_runtime::generic::Header<u32, BlakeTwo256>, OpaqueExtrinsic>,
|
||||
>,
|
||||
P: TransactionPool<Block = Block> + 'static,
|
||||
BE: Backend<Block> + Send + Sync + 'static,
|
||||
BE::State: StateBackend<BlakeTwo256>,
|
||||
AuthorityId: AuthorityIdBound,
|
||||
A: ChainApi<Block = Block> + 'static,
|
||||
Runtime: StorageEnableRuntime,
|
||||
Runtime::RuntimeApi: StorageEnableRuntimeApi<
|
||||
RuntimeApi: mmr_rpc::MmrRuntimeApi<
|
||||
Block,
|
||||
<Block as sp_runtime::traits::Block>::Hash,
|
||||
BlockNumber,
|
||||
> + EthereumRuntimeRPCApi<Block>
|
||||
+ BabeApi<Block>
|
||||
+ fp_rpc::ConvertTransactionRuntimeApi<Block>,
|
||||
>,
|
||||
ParachainClient<Runtime::RuntimeApi>: StorageProvider<Block, BE>,
|
||||
FL: FileStorageT,
|
||||
FSH: ForestStorageHandler<Runtime> + Send + Sync + 'static,
|
||||
{
|
||||
use mmr_rpc::{Mmr, MmrApiServer};
|
||||
use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer};
|
||||
|
|
@ -133,6 +140,7 @@ where
|
|||
is_authority,
|
||||
command_sink,
|
||||
forced_parent_hashes,
|
||||
maybe_storage_hub_client_config,
|
||||
} = deps;
|
||||
|
||||
module.merge(System::new(Arc::clone(&client), Arc::clone(&pool)).into_rpc())?;
|
||||
|
|
@ -155,6 +163,16 @@ where
|
|||
.into_rpc(),
|
||||
)?;
|
||||
|
||||
if let Some(storage_hub_client_config) = maybe_storage_hub_client_config {
|
||||
module.merge(
|
||||
StorageHubClientRpc::<FL, FSH, Runtime, OpaqueBlock>::new(
|
||||
client.clone(),
|
||||
storage_hub_client_config,
|
||||
)
|
||||
.into_rpc(),
|
||||
)?;
|
||||
}
|
||||
|
||||
enum Never {}
|
||||
impl<T> fp_rpc::ConvertTransaction<T> for Never {
|
||||
fn convert_transaction(&self, _transaction: pallet_ethereum::Transaction) -> T {
|
||||
|
|
@ -182,7 +200,7 @@ where
|
|||
};
|
||||
|
||||
module.merge(
|
||||
Eth::<_, _, _, _, _, _, _, DefaultEthConfig<C, BE>>::new(
|
||||
Eth::<_, _, _, _, _, _, _, DefaultEthConfig<ParachainClient<Runtime::RuntimeApi>, BE>>::new(
|
||||
Arc::clone(&client),
|
||||
Arc::clone(&pool),
|
||||
graph.clone(),
|
||||
|
|
|
|||
|
|
@ -532,7 +532,7 @@ where
|
|||
}
|
||||
|
||||
// Storage Hub builder
|
||||
let (sh_builder, _maybe_storage_hub_client_rpc_config) = init_sh_builder::<R, S, Runtime>(
|
||||
let (sh_builder, maybe_storage_hub_client_rpc_config) = init_sh_builder::<R, S, Runtime>(
|
||||
&provider_options,
|
||||
&task_manager,
|
||||
file_transfer_request_protocol,
|
||||
|
|
@ -627,6 +627,7 @@ where
|
|||
fc_db::Backend::Sql(b) => b.clone(),
|
||||
},
|
||||
forced_parent_hashes: None,
|
||||
maybe_storage_hub_client_config: maybe_storage_hub_client_rpc_config.clone(),
|
||||
};
|
||||
crate::rpc::create_full(deps).map_err(Into::into)
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in a new issue