Improve single-node testnet support and Arc NetworkConfig/ChainSpec (#6396)

* Arc ChainSpec and NetworkConfig

* Fix release tests

* Fix lint

* Merge remote-tracking branch 'origin/unstable' into single-node-testnet
This commit is contained in:
Michael Sproul
2024-09-24 10:16:18 +10:00
committed by GitHub
parent d84df5799c
commit 1447eeb40b
66 changed files with 340 additions and 250 deletions

View File

@@ -82,7 +82,7 @@ pub struct HotColdDB<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> {
/// LRU cache of replayed states.
historic_state_cache: Mutex<LruCache<Slot, BeaconState<E>>>,
/// Chain spec.
pub(crate) spec: ChainSpec,
pub(crate) spec: Arc<ChainSpec>,
/// Logger.
pub log: Logger,
/// Mere vessel for E.
@@ -194,7 +194,7 @@ pub enum HotColdDBError {
impl<E: EthSpec> HotColdDB<E, MemoryStore<E>, MemoryStore<E>> {
pub fn open_ephemeral(
config: StoreConfig,
spec: ChainSpec,
spec: Arc<ChainSpec>,
log: Logger,
) -> Result<HotColdDB<E, MemoryStore<E>, MemoryStore<E>>, Error> {
Self::verify_config(&config)?;
@@ -231,7 +231,7 @@ impl<E: EthSpec> HotColdDB<E, LevelDB<E>, LevelDB<E>> {
blobs_db_path: &Path,
migrate_schema: impl FnOnce(Arc<Self>, SchemaVersion, SchemaVersion) -> Result<(), Error>,
config: StoreConfig,
spec: ChainSpec,
spec: Arc<ChainSpec>,
log: Logger,
) -> Result<Arc<Self>, Error> {
Self::verify_slots_per_restore_point(config.slots_per_restore_point)?;
@@ -1868,7 +1868,7 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
}
/// Get a reference to the `ChainSpec` used by the database.
pub fn get_chain_spec(&self) -> &ChainSpec {
pub fn get_chain_spec(&self) -> &Arc<ChainSpec> {
&self.spec
}