Skip to content

Commit cecefad

Browse files
committed
Merge remote-tracking branch 'origin/main' into ak-various-sized-data-store-test
2 parents 66e62b9 + d89da8d commit cecefad

File tree

14 files changed

+460
-473
lines changed

14 files changed

+460
-473
lines changed

Cargo.lock

Lines changed: 27 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ sc-cli = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1
4444
sc-client-api = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1fb02d4012948cba024fca2f27d94732e52" }
4545
sc-consensus = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1fb02d4012948cba024fca2f27d94732e52" }
4646
sc-consensus-babe = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1fb02d4012948cba024fca2f27d94732e52" }
47+
sc-consensus-babe-rpc = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1fb02d4012948cba024fca2f27d94732e52" }
4748
sc-consensus-grandpa = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1fb02d4012948cba024fca2f27d94732e52" }
4849
sc-consensus-grandpa-rpc = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1fb02d4012948cba024fca2f27d94732e52" }
4950
sc-executor = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1fb02d4012948cba024fca2f27d94732e52" }
@@ -58,13 +59,15 @@ sc-transaction-pool-api = { git = "https://github.com/paritytech/polkadot-sdk.gi
5859
sp-api = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1fb02d4012948cba024fca2f27d94732e52", default-features = false }
5960
sp-block-builder = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1fb02d4012948cba024fca2f27d94732e52", default-features = false }
6061
sp-blockchain = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1fb02d4012948cba024fca2f27d94732e52", default-features = false }
62+
sp-consensus = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1fb02d4012948cba024fca2f27d94732e52", default-features = false }
6163
sp-consensus-babe = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1fb02d4012948cba024fca2f27d94732e52", default-features = false }
6264
sp-consensus-grandpa = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1fb02d4012948cba024fca2f27d94732e52", default-features = false }
6365
sp-core = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1fb02d4012948cba024fca2f27d94732e52", default-features = false }
6466
sp-genesis-builder = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1fb02d4012948cba024fca2f27d94732e52", default-features = false }
6567
sp-inherents = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1fb02d4012948cba024fca2f27d94732e52", default-features = false }
6668
sp-io = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1fb02d4012948cba024fca2f27d94732e52", default-features = false }
6769
sp-keyring = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1fb02d4012948cba024fca2f27d94732e52", default-features = false }
70+
sp-keystore = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1fb02d4012948cba024fca2f27d94732e52", default-features = false }
6871
sp-offchain = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1fb02d4012948cba024fca2f27d94732e52", default-features = false }
6972
sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1fb02d4012948cba024fca2f27d94732e52", default-features = false }
7073
sp-session = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "a64eb1fb02d4012948cba024fca2f27d94732e52", default-features = false }
@@ -136,4 +139,4 @@ panic = "unwind"
136139
[profile.production]
137140
inherits = "release"
138141
lto = true
139-
codegen-units = 1
142+
codegen-units = 1

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,28 @@ The Bulletin chain consists of a customized node implementation and a single run
44

55
## Node implementation
66

7-
The Bulletin chain node implements IPFS support on top of a regualar Substrate node. Only work with `litep2p` network backend is supported (enabled by default), and in order to use IPFS functionality `--ipfs-server` flag must be passed to the node binary.
7+
The Bulletin chain node implements IPFS support on top of a regular Substrate node. Only work with `litep2p` network backend is supported (enabled by default), and in order to use IPFS functionality `--ipfs-server` flag must be passed to the node binary.
88

99
IPFS support comes in two parts:
1010

1111
1. Bitswap protocol implementation. Wire protocol for transferring chunks stored in transaction storage to IPFS clients. This is implemented in `litep2p` networking library and `litep2p` network backend in `sc-network` crate.
12-
2. IPFS Kademlia DHT support. We publish content provider records for our node for CIDs (content identifiers) of transactions stored in transaction storage. Content provider records are only kept for transactions included in the chain during last two weeks, what should agree with block pruning period of the Bulletin nodes. DHT support is provided by `litep2p` networking library and `sc-network` crate. The implementation in the Bulletin node ensures we register as content providers for transactions during last two weeks.
12+
2. IPFS Kademlia DHT support. We publish content provider records for our node for CIDs (content identifiers) of transactions stored in transaction storage. Content provider records are only kept for transactions included in the chain during last two weeks, what should agree with block pruning period of the Bulletin nodes. DHT support is provided by `litep2p` networking library and `sc-network` crate. The implementation in the Bulletin node ensures we register as content providers for transactions during the last two weeks.
1313

14-
Bulletin node also has idle connection timeout set to 1 hour instead of default 10 seconds to allow manually adding the node to the swarm of an IPFS client and ensuring we don't disconnect the IPFS client. This is done to allow IPFS clients to query data over Bitswap protocol before IPFS Kademlia DHT support is implemented (DHT support is planned to be ready by the end of August 2025).
14+
Bulletin node also has an idle connection timeout set to 1 hour instead of the default 10 seconds to allow manually adding the node to the swarm of an IPFS client and ensuring we don't disconnect the IPFS client. This is done to allow IPFS clients to query data over Bitswap protocol before IPFS Kademlia DHT support is implemented (DHT support is planned to be ready by the end of August 2025).
1515

16-
TODO: clarify if we need to store transactiond for two weeks or other period.
16+
TODO: clarify if we need to store transactions for two weeks or another period.
1717

1818
## Runtime functionality
1919

2020
The Bulletin chain runtime is a standard BaBE + GRANDPA chain with a custom validator set pallet which is (currently) controlled by root call (TODO: clarify whether this should be sudo, governance, etc).
21-
It functions to store transactions for a given period of time (currently set at 2 weeks) and provide proofs of storage.
21+
It functions to store transactions for a given period of time (currently set at 2 weeks) and provide proof of storage.
2222

2323
### Core functionality
2424

2525
The main purpose of the Bulletin chain is to provide storage for the People Chain over the bridge.
2626

2727
#### Storage
28-
The core functionality of the bulletin chain is in the transaction-storage pallet, which indexes transcations and manages storage proofs for arbitrary data.
28+
The core functionality of the bulletin chain is in the transaction-storage pallet, which indexes transactions and manages storage proofs for arbitrary data.
2929

3030
Data is added via the `transactionStorage.store` extrinsic, provided the storage of the data is authorized by root call. Authorization is granted either for a specific account via authorize_account or for data with a specific preimage via authorize_preimage. Once data is stored, it can be retrieved from IPFS with the Blake2B hash of the data.
3131

node/Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ sc-cli = { workspace = true }
2525
sc-client-api = { workspace = true }
2626
sc-consensus = { workspace = true }
2727
sc-consensus-babe = { workspace = true }
28+
sc-consensus-babe-rpc = { workspace = true }
2829
sc-consensus-grandpa = { workspace = true }
2930
sc-consensus-grandpa-rpc = { workspace = true }
3031
sc-executor = { workspace = true }
@@ -35,11 +36,13 @@ sc-service = { workspace = true }
3536
sc-telemetry = { workspace = true }
3637
sc-transaction-pool = { workspace = true }
3738
sc-transaction-pool-api = { workspace = true }
39+
sp-consensus = { workspace = true }
3840
sp-consensus-babe = { workspace = true }
3941
sp-core = { workspace = true }
4042
sp-inherents = { workspace = true }
4143
sp-io = { workspace = true }
4244
sp-keyring = { workspace = true }
45+
sp-keystore = { workspace = true }
4346
sp-runtime = { workspace = true }
4447
sp-timestamp = { workspace = true }
4548
sp-transaction-storage-proof = { workspace = true }
@@ -54,7 +57,6 @@ sp-genesis-builder = { workspace = true }
5457
substrate-frame-rpc-system = { workspace = true }
5558

5659
# These dependencies are used for runtime benchmarking
57-
frame-benchmarking = { workspace = true }
5860
frame-benchmarking-cli = { workspace = true }
5961

6062
# Local Dependencies
@@ -74,7 +76,6 @@ substrate-build-script-utils = { workspace = true }
7476
runtime-benchmarks = [
7577
"bulletin-polkadot-runtime/runtime-benchmarks",
7678
"frame-benchmarking-cli/runtime-benchmarks",
77-
"frame-benchmarking/runtime-benchmarks",
7879
"frame-system/runtime-benchmarks",
7980
"polkadot-bulletin-chain-runtime/runtime-benchmarks",
8081
"sc-service/runtime-benchmarks",

node/src/rpc.rs

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use std::sync::Arc;
99

1010
use jsonrpsee::RpcModule;
1111
use polkadot_bulletin_chain_runtime::{opaque::Block, AccountId, BlockNumber, Hash, Nonce};
12+
use sc_consensus_babe::{BabeApi, BabeWorkerHandle};
1213
use sc_consensus_grandpa::{
1314
FinalityProofProvider, GrandpaJustificationStream, SharedAuthoritySet, SharedVoterState,
1415
};
@@ -18,17 +19,31 @@ use sc_transaction_pool_api::TransactionPool;
1819
use sp_api::ProvideRuntimeApi;
1920
use sp_block_builder::BlockBuilder;
2021
use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata};
22+
use sp_consensus::SelectChain;
23+
use sp_keystore::KeystorePtr;
2124

2225
/// Full client dependencies.
23-
pub struct FullDeps<C, P, B> {
26+
pub struct FullDeps<C, P, SC, B> {
2427
/// The client instance to use.
2528
pub client: Arc<C>,
2629
/// Transaction pool instance.
2730
pub pool: Arc<P>,
31+
/// The chain selection strategy.
32+
pub select_chain: SC,
33+
/// BABE RPC dependencies.
34+
pub babe: BabeDeps,
2835
/// GRANDPA RPC dependencies.
2936
pub grandpa: GrandpaDeps<B>,
3037
}
3138

39+
/// BABE RPC dependencies.
40+
pub struct BabeDeps {
41+
/// A handle to the BABE worker for issuing requests.
42+
pub babe_worker_handle: BabeWorkerHandle<Block>,
43+
/// The keystore that manages the keys of the node.
44+
pub keystore: KeystorePtr,
45+
}
46+
3247
/// GRANDPA RPC dependncies.
3348
pub struct GrandpaDeps<B> {
3449
/// Subscription task executor.
@@ -44,24 +59,30 @@ pub struct GrandpaDeps<B> {
4459
}
4560

4661
/// Instantiate all full RPC extensions.
47-
pub fn create_full<C, P, B>(
48-
deps: FullDeps<C, P, B>,
62+
pub fn create_full<C, P, SC, B>(
63+
deps: FullDeps<C, P, SC, B>,
4964
) -> Result<RpcModule<()>, Box<dyn std::error::Error + Send + Sync>>
5065
where
5166
C: ProvideRuntimeApi<Block>,
5267
C: HeaderBackend<Block> + HeaderMetadata<Block, Error = BlockChainError> + 'static,
5368
C: Send + Sync + 'static,
5469
C::Api: substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>,
5570
C::Api: BlockBuilder<Block>,
71+
C::Api: BabeApi<Block>,
5672
P: TransactionPool + 'static,
73+
SC: SelectChain<Block> + 'static,
5774
B: sc_client_api::Backend<Block> + Send + Sync + 'static,
5875
{
76+
use sc_consensus_babe_rpc::{Babe, BabeApiServer};
5977
use substrate_frame_rpc_system::{System, SystemApiServer};
6078

6179
let mut module = RpcModule::new(());
62-
let FullDeps { client, pool, grandpa } = deps;
80+
let FullDeps { client, pool, select_chain, babe, grandpa } = deps;
81+
let BabeDeps { babe_worker_handle, keystore } = babe;
6382

64-
module.merge(System::new(client, pool).into_rpc())?;
83+
module.merge(System::new(client.clone(), pool).into_rpc())?;
84+
module
85+
.merge(Babe::new(client, babe_worker_handle.clone(), keystore, select_chain).into_rpc())?;
6586
module.merge(
6687
Grandpa::new(
6788
grandpa.subscription_executor,

node/src/service.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ pub fn new_partial(
4545
>,
4646
sc_consensus_grandpa::LinkHalf<Block, FullClient, FullSelectChain>,
4747
sc_consensus_babe::BabeLink<Block>,
48+
sc_consensus_babe::BabeWorkerHandle<Block>,
4849
Option<Telemetry>,
4950
),
5051
>,
@@ -128,9 +129,6 @@ pub fn new_partial(
128129
telemetry: telemetry.as_ref().map(|x| x.handle()),
129130
})?;
130131

131-
// TODO Wire up to RPC
132-
std::mem::forget(babe_worker_handle);
133-
134132
Ok(sc_service::PartialComponents {
135133
client,
136134
backend,
@@ -139,7 +137,7 @@ pub fn new_partial(
139137
keystore_container,
140138
select_chain,
141139
transaction_pool,
142-
other: (block_import, grandpa_link, babe_link, telemetry),
140+
other: (block_import, grandpa_link, babe_link, babe_worker_handle, telemetry),
143141
})
144142
}
145143

@@ -157,7 +155,7 @@ pub fn new_full<
157155
keystore_container,
158156
select_chain,
159157
transaction_pool,
160-
other: (block_import, grandpa_link, babe_link, mut telemetry),
158+
other: (block_import, grandpa_link, babe_link, babe_worker_handle, mut telemetry),
161159
} = new_partial(&config)?;
162160

163161
let mut net_config = sc_network::config::FullNetworkConfiguration::<_, _, N>::new(
@@ -226,6 +224,8 @@ pub fn new_full<
226224
let rpc_extensions_builder = {
227225
let client = client.clone();
228226
let pool = transaction_pool.clone();
227+
let keystore = keystore_container.keystore();
228+
let select_chain = select_chain.clone();
229229

230230
let justification_stream = grandpa_link.justification_stream();
231231
let shared_authority_set = grandpa_link.shared_authority_set().clone();
@@ -240,6 +240,11 @@ pub fn new_full<
240240
let deps = crate::rpc::FullDeps {
241241
client: client.clone(),
242242
pool: pool.clone(),
243+
select_chain: select_chain.clone(),
244+
babe: crate::rpc::BabeDeps {
245+
babe_worker_handle: babe_worker_handle.clone(),
246+
keystore: keystore.clone(),
247+
},
243248
grandpa: crate::rpc::GrandpaDeps {
244249
subscription_executor,
245250
shared_authority_set: shared_authority_set.clone(),

pallets/transaction-storage/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,8 +367,8 @@ pub mod pallet {
367367
Ok(().into())
368368
}
369369

370-
/// Check storage proof for block number `block_number() - StoragePeriod`. If such block
371-
/// does not exist the proof is expected to be `None`.
370+
/// Check storage proof for block number `block_number() - StoragePeriod`. If such a block
371+
/// does not exist, the proof is expected to be `None`.
372372
///
373373
/// ## Complexity
374374
///

0 commit comments

Comments
 (0)