mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-08 17:26:04 +00:00
More logging on v20 upgrade
This commit is contained in:
@@ -3,6 +3,7 @@ use operation_pool::{
|
|||||||
PersistedOperationPool, PersistedOperationPoolV15, PersistedOperationPoolV20,
|
PersistedOperationPool, PersistedOperationPoolV15, PersistedOperationPoolV20,
|
||||||
};
|
};
|
||||||
use slog::{debug, info, Logger};
|
use slog::{debug, info, Logger};
|
||||||
|
use ssz::Encode;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use store::{Error, HotColdDB, KeyValueStoreOp, StoreItem};
|
use store::{Error, HotColdDB, KeyValueStoreOp, StoreItem};
|
||||||
use types::Attestation;
|
use types::Attestation;
|
||||||
@@ -11,6 +12,7 @@ pub fn upgrade_to_v20<T: BeaconChainTypes>(
|
|||||||
db: Arc<HotColdDB<T::EthSpec, T::HotStore, T::ColdStore>>,
|
db: Arc<HotColdDB<T::EthSpec, T::HotStore, T::ColdStore>>,
|
||||||
log: Logger,
|
log: Logger,
|
||||||
) -> Result<Vec<KeyValueStoreOp>, Error> {
|
) -> Result<Vec<KeyValueStoreOp>, Error> {
|
||||||
|
info!(log, "Upgrading from v19 to v20");
|
||||||
// Load a V15 op pool and transform it to V20.
|
// Load a V15 op pool and transform it to V20.
|
||||||
let Some(PersistedOperationPoolV15::<T::EthSpec> {
|
let Some(PersistedOperationPoolV15::<T::EthSpec> {
|
||||||
attestations_v15,
|
attestations_v15,
|
||||||
@@ -36,7 +38,7 @@ pub fn upgrade_to_v20<T: BeaconChainTypes>(
|
|||||||
.map(|slashing| slashing.into())
|
.map(|slashing| slashing.into())
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let v20 = PersistedOperationPool::V20(PersistedOperationPoolV20 {
|
let v20 = PersistedOperationPoolV20 {
|
||||||
attestations,
|
attestations,
|
||||||
sync_contributions,
|
sync_contributions,
|
||||||
attester_slashings,
|
attester_slashings,
|
||||||
@@ -44,14 +46,20 @@ pub fn upgrade_to_v20<T: BeaconChainTypes>(
|
|||||||
voluntary_exits,
|
voluntary_exits,
|
||||||
bls_to_execution_changes,
|
bls_to_execution_changes,
|
||||||
capella_bls_change_broadcast_indices,
|
capella_bls_change_broadcast_indices,
|
||||||
});
|
};
|
||||||
Ok(vec![v20.as_kv_store_op(OP_POOL_DB_KEY)])
|
let v20_bytes = v20.as_ssz_bytes();
|
||||||
|
let wrapped = PersistedOperationPool::V20(v20);
|
||||||
|
let wrapped_bytes = wrapped.as_ssz_bytes();
|
||||||
|
assert_eq!(v20_bytes.len(), wrapped_bytes.len());
|
||||||
|
assert_eq!(v20_bytes, wrapped_bytes);
|
||||||
|
Ok(vec![wrapped.as_kv_store_op(OP_POOL_DB_KEY)])
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn downgrade_from_v20<T: BeaconChainTypes>(
|
pub fn downgrade_from_v20<T: BeaconChainTypes>(
|
||||||
db: Arc<HotColdDB<T::EthSpec, T::HotStore, T::ColdStore>>,
|
db: Arc<HotColdDB<T::EthSpec, T::HotStore, T::ColdStore>>,
|
||||||
log: Logger,
|
log: Logger,
|
||||||
) -> Result<Vec<KeyValueStoreOp>, Error> {
|
) -> Result<Vec<KeyValueStoreOp>, Error> {
|
||||||
|
info!(log, "Downgrading from v20 to v19");
|
||||||
// Load a V20 op pool and transform it to V15.
|
// Load a V20 op pool and transform it to V15.
|
||||||
let Some(PersistedOperationPoolV20::<T::EthSpec> {
|
let Some(PersistedOperationPoolV20::<T::EthSpec> {
|
||||||
attestations,
|
attestations,
|
||||||
|
|||||||
@@ -246,7 +246,7 @@ impl<E: EthSpec> StoreItem for PersistedOperationPoolV20<E> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Deserialization for `PersistedOperationPool` defaults to `PersistedOperationPool::V12`.
|
/// Deserialization for `PersistedOperationPool` defaults to `PersistedOperationPool::V20`.
|
||||||
impl<E: EthSpec> StoreItem for PersistedOperationPool<E> {
|
impl<E: EthSpec> StoreItem for PersistedOperationPool<E> {
|
||||||
fn db_column() -> DBColumn {
|
fn db_column() -> DBColumn {
|
||||||
DBColumn::OpPool
|
DBColumn::OpPool
|
||||||
|
|||||||
Reference in New Issue
Block a user