Compare commits

...

5 Commits

Author SHA1 Message Date
Helen Grachtz
e87ac3e54d
Merge 14226dbddc into d43a616b56 2025-03-12 22:29:04 +08:00
0g-peterzhb
d43a616b56
fix shard config init (#354)
Some checks failed
abi-consistent-check / build-and-compare (push) Has been cancelled
code-coverage / unittest-cov (push) Has been cancelled
rust / check (push) Has been cancelled
rust / test (push) Has been cancelled
rust / lints (push) Has been cancelled
functional-test / test (push) Has been cancelled
2025-03-12 22:27:34 +08:00
Helen
14226dbddc
hashset_delay.rs 2025-02-12 12:57:08 +03:00
Helen
608195f536
lib.rs 2025-02-12 12:55:21 +03:00
Helen
d230105b98
lib.rs 2025-02-12 12:51:40 +03:00
7 changed files with 19 additions and 14 deletions

View File

@ -34,7 +34,7 @@ pub struct AppendMerkleTree<E: HashElement, A: Algorithm<E>> {
/// `revert_to` can reset the state correctly when needed.
min_depth: Option<usize>,
/// Used to compute the correct padding hash.
/// 0 for `pora_chunk_merkle` and 10 for not-first `last_chunk_merkle`.
/// 0 for `first_chunk_merkle` and 10 for not-first `last_chunk_merkle`.
leaf_height: usize,
_a: PhantomData<A>,
}

View File

@ -61,7 +61,7 @@ where
self.insert_at(key, self.default_entry_timeout);
}
/// Inserts an entry that will expire at a given instant. If the entry already exists, the
/// Inserts an entry that will expire at a given duration. If the entry already exists, the
/// timeout is updated.
pub fn insert_at(&mut self, key: K, entry_duration: Duration) {
if self.contains(&key) {

View File

@ -5,7 +5,7 @@
//!
//! - `Histogram`: used with `start_timer(..)` and `stop_timer(..)` to record durations (e.g.,
//! block processing time).
//! - `IncCounter`: used to represent an ideally ever-growing, never-shrinking integer (e.g.,
//! - `IntCounter`: used to represent an ideally ever-growing, never-shrinking integer (e.g.,
//! number of block processing requests).
//! - `IntGauge`: used to represent a varying integer (e.g., number of attestations per block).
//!
@ -78,7 +78,7 @@ pub fn try_create_int_counter(name: &str, help: &str) -> Result<IntCounter> {
Ok(counter)
}
/// Attempts to create an `IntGauge`, returning `Err` if the registry does not accept the counter
/// Attempts to create an `IntGauge`, returning `Err` if the registry does not accept the gauge
/// (potentially due to naming conflict).
pub fn try_create_int_gauge(name: &str, help: &str) -> Result<IntGauge> {
let opts = Opts::new(name, help);
@ -87,7 +87,7 @@ pub fn try_create_int_gauge(name: &str, help: &str) -> Result<IntGauge> {
Ok(gauge)
}
/// Attempts to create a `Gauge`, returning `Err` if the registry does not accept the counter
/// Attempts to create a `Gauge`, returning `Err` if the registry does not accept the gauge
/// (potentially due to naming conflict).
pub fn try_create_float_gauge(name: &str, help: &str) -> Result<Gauge> {
let opts = Opts::new(name, help);
@ -96,7 +96,7 @@ pub fn try_create_float_gauge(name: &str, help: &str) -> Result<Gauge> {
Ok(gauge)
}
/// Attempts to create a `Histogram`, returning `Err` if the registry does not accept the counter
/// Attempts to create a `Histogram`, returning `Err` if the registry does not accept the histogram
/// (potentially due to naming conflict).
pub fn try_create_histogram(name: &str, help: &str) -> Result<Histogram> {
let opts = HistogramOpts::new(name, help);
@ -105,7 +105,7 @@ pub fn try_create_histogram(name: &str, help: &str) -> Result<Histogram> {
Ok(histogram)
}
/// Attempts to create a `HistogramVec`, returning `Err` if the registry does not accept the counter
/// Attempts to create a `HistogramVec`, returning `Err` if the registry does not accept the histogram
/// (potentially due to naming conflict).
pub fn try_create_histogram_vec(
name: &str,
@ -144,7 +144,7 @@ pub fn try_create_float_gauge_vec(
Ok(counter_vec)
}
/// Attempts to create a `IntCounterVec`, returning `Err` if the registry does not accept the gauge
/// Attempts to create a `IntCounterVec`, returning `Err` if the registry does not accept the counter
/// (potentially due to naming conflict).
pub fn try_create_int_counter_vec(
name: &str,

View File

@ -276,7 +276,7 @@ impl Pruner {
}
}
async fn get_shard_config(store: &Store) -> Result<Option<ShardConfig>> {
pub async fn get_shard_config(store: &Store) -> Result<Option<ShardConfig>> {
store
.get_config_decoded(&SHARD_CONFIG_KEY, DATA_DB_KEY)
.await

View File

@ -7,7 +7,7 @@ use network::{
self, new_network_channel, Keypair, NetworkConfig, NetworkGlobals, NetworkReceiver,
NetworkSender, RequestId, Service as LibP2PService,
};
use pruner::{Pruner, PrunerConfig, PrunerMessage};
use pruner::{get_shard_config, Pruner, PrunerConfig, PrunerMessage};
use router::RouterService;
use rpc::RPCConfig;
use std::sync::Arc;
@ -203,7 +203,7 @@ impl ClientBuilder {
if let Some(config) = config {
let executor = require!("miner", self, runtime_context).clone().executor;
let network_send = require!("miner", self, network).send.clone();
let store = self.async_store.as_ref().unwrap().clone();
let store = require!("miner", self, async_store).clone();
let send = MineService::spawn(executor, network_send, config, store).await?;
self.miner = Some(MinerComponents { send });
@ -225,7 +225,11 @@ impl ClientBuilder {
Ok(self)
}
pub async fn with_shard(self, config: ShardConfig) -> Result<Self, String> {
pub async fn with_shard(self, mut config: ShardConfig) -> Result<Self, String> {
let store = require!("shard", self, async_store).clone();
if let Some(stored_config) = get_shard_config(store.as_ref()).await.unwrap_or(None) {
config = stored_config;
}
self.async_store
.as_ref()
.unwrap()

View File

@ -23,6 +23,8 @@ async fn start_node(context: RuntimeContext, config: ZgsConfig) -> Result<Client
ClientBuilder::default()
.with_runtime_context(context)
.with_rocksdb_store(&storage_config)?
.with_shard(shard_config)
.await?
.with_log_sync(log_sync_config)
.await?
.with_file_location_cache(config.file_location_cache)
@ -34,8 +36,6 @@ async fn start_node(context: RuntimeContext, config: ZgsConfig) -> Result<Client
.await?
.with_miner(miner_config)
.await?
.with_shard(shard_config)
.await?
.with_pruner(pruner_config)
.await?
.with_rpc(config.rpc)

View File

@ -1157,6 +1157,7 @@ impl LogManager {
.get_tx_by_seq_number(from_tx_seq)?
.ok_or_else(|| anyhow!("from tx missing"))?;
let mut to_tx_offset_list = Vec::with_capacity(to_tx_seq_list.len());
for seq in to_tx_seq_list {
// No need to copy data for completed tx.
if self.check_tx_completed(seq)? {