parent
33c7f264bc
commit
f7cddcc8ab
|
@ -337,8 +337,8 @@ proc pruneBlocks*(
|
|||
proc pruneAttestations*(
|
||||
db: SlashingProtectionDB,
|
||||
validator: ValidatorPubkey,
|
||||
newMinSourceEpoch: Epoch,
|
||||
newMinTargetEpoch: Epoch) =
|
||||
newMinSourceEpoch: int64,
|
||||
newMinTargetEpoch: int64) =
|
||||
## Prune all blocks from a validator before the specified newMinSlot
|
||||
## This is intended for interchange import to ensure
|
||||
## that in case of a gap, we don't allow signing in that gap.
|
||||
|
|
|
@ -117,7 +117,7 @@ type
|
|||
# Pruning
|
||||
# --------------------------------------------
|
||||
db.pruneBlocks(ValidatorPubKey, Slot)
|
||||
db.pruneAttestations(ValidatorPubKey, Epoch, Epoch)
|
||||
db.pruneAttestations(ValidatorPubKey, int64, int64)
|
||||
db.pruneAfterFinalization(Epoch)
|
||||
|
||||
# Interchange
|
||||
|
@ -446,4 +446,8 @@ proc importInterchangeV5Impl*(
|
|||
|
||||
# Now prune everything that predates
|
||||
# this interchange file max slot
|
||||
db.pruneAttestations(parsedKey, Epoch maxValidSourceEpochSeen, Epoch maxValidTargetEpochSeen)
|
||||
if maxValidSourceEpochSeen < 0 or maxValidTargetEpochSeen < 0:
|
||||
doAssert maxValidSourceEpochSeen == -1 and maxValidTargetEpochSeen == -1
|
||||
notice "No attestation found in slashing interchange file"
|
||||
return
|
||||
db.pruneAttestations(parsedKey, maxValidSourceEpochSeen, maxValidTargetEpochSeen)
|
||||
|
|
|
@ -955,16 +955,19 @@ proc pruneBlocks*(db: SlashingProtectionDB_v1, validator: ValidatorPubkey, newMi
|
|||
proc pruneAttestations*(
|
||||
db: SlashingProtectionDB_v1,
|
||||
validator: ValidatorPubkey,
|
||||
newMinSourceEpoch: Epoch,
|
||||
newMinTargetEpoch: Epoch) =
|
||||
newMinSourceEpoch: int64,
|
||||
newMinTargetEpoch: int64) =
|
||||
## Prune all blocks from a validator before the specified newMinSlot
|
||||
## This is intended for interchange import.
|
||||
##
|
||||
## Note: the Database v1 does not support pruning.
|
||||
##
|
||||
## Negative source/target epoch of -1 can be received if no attestation was imported
|
||||
## In that case nothing is done
|
||||
warn "Slashing DB pruning is not supported on the v1 of our database. Request ignored.",
|
||||
validator = shortLog(validator),
|
||||
newMinSourceEpoch = shortLog(newMinSourceEpoch),
|
||||
newMinTargetEpoch = shortLog(newMinTargetEpoch)
|
||||
newMinSourceEpoch = newMinSourceEpoch,
|
||||
newMinTargetEpoch = newMinTargetEpoch
|
||||
|
||||
proc pruneAfterFinalization*(
|
||||
db: SlashingProtectionDB_v1,
|
||||
|
|
|
@ -1020,14 +1020,16 @@ proc pruneBlocks*(db: SlashingProtectionDB_v2, validator: ValidatorPubkey, newMi
|
|||
proc pruneAttestations*(
|
||||
db: SlashingProtectionDB_v2,
|
||||
validator: ValidatorPubkey,
|
||||
newMinSourceEpoch: Epoch,
|
||||
newMinTargetEpoch: Epoch) =
|
||||
newMinSourceEpoch: int64,
|
||||
newMinTargetEpoch: int64) =
|
||||
## Prune all blocks from a validator before the specified newMinSlot
|
||||
## This is intended for interchange import.
|
||||
## Negative source/target epoch of -1 can be received if no attestation was imported
|
||||
## In that case nothing is done (since we used signed int in SQLite)
|
||||
let valID = db.getOrRegisterValidator(validator)
|
||||
|
||||
let status = db.sqlPruneValidatorAttestations.exec(
|
||||
(valID, int64 newMinSourceEpoch, int64 newMinTargetEpoch))
|
||||
(valID, newMinSourceEpoch, newMinTargetEpoch))
|
||||
doAssert status.isOk(),
|
||||
"SQLite error when pruning validator attestations: " & $status.error & "\n" &
|
||||
"for validator: 0x" & validator.toHex() &
|
||||
|
|
Loading…
Reference in New Issue