More logging on v20 upgrade

This commit is contained in:
Michael Sproul
2024-06-28 16:40:02 +10:00
parent 1758f63b2f
commit cc5789b9d3
2 changed files with 12 additions and 4 deletions

View File

@@ -3,6 +3,7 @@ use operation_pool::{
PersistedOperationPool, PersistedOperationPoolV15, PersistedOperationPoolV20,
};
use slog::{debug, info, Logger};
use ssz::Encode;
use std::sync::Arc;
use store::{Error, HotColdDB, KeyValueStoreOp, StoreItem};
use types::Attestation;
@@ -11,6 +12,7 @@ pub fn upgrade_to_v20<T: BeaconChainTypes>(
db: Arc<HotColdDB<T::EthSpec, T::HotStore, T::ColdStore>>,
log: Logger,
) -> Result<Vec<KeyValueStoreOp>, Error> {
info!(log, "Upgrading from v19 to v20");
// Load a V15 op pool and transform it to V20.
let Some(PersistedOperationPoolV15::<T::EthSpec> {
attestations_v15,
@@ -36,7 +38,7 @@ pub fn upgrade_to_v20<T: BeaconChainTypes>(
.map(|slashing| slashing.into())
.collect();
let v20 = PersistedOperationPool::V20(PersistedOperationPoolV20 {
let v20 = PersistedOperationPoolV20 {
attestations,
sync_contributions,
attester_slashings,
@@ -44,14 +46,20 @@ pub fn upgrade_to_v20<T: BeaconChainTypes>(
voluntary_exits,
bls_to_execution_changes,
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>(
db: Arc<HotColdDB<T::EthSpec, T::HotStore, T::ColdStore>>,
log: Logger,
) -> Result<Vec<KeyValueStoreOp>, Error> {
info!(log, "Downgrading from v20 to v19");
// Load a V20 op pool and transform it to V15.
let Some(PersistedOperationPoolV20::<T::EthSpec> {
attestations,

View File

@@ -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> {
fn db_column() -> DBColumn {
DBColumn::OpPool