Skip to content

Commit

Permalink
Merge pull request #5686 from oasisprotocol/kostko/fix/km-epoch-desync
Browse files Browse the repository at this point in the history
  • Loading branch information
kostko authored May 8, 2024
2 parents dcaef17 + ee9c570 commit d50dfae
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .changelog/5686.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
keymanager: Allow one epoch in the future during validation

This avoids an issue where a key manager node that is slightly behind
would return an error during an epoch transition.
4 changes: 2 additions & 2 deletions keymanager/src/runtime/secrets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -534,10 +534,10 @@ impl Secrets {
}

/// Validate that the epoch used for derivation of ephemeral private keys is not
/// in the future or too far back in the past.
/// too far in the future or too far back in the past.
fn validate_ephemeral_key_epoch(&self, epoch: EpochTime) -> Result<()> {
let consensus_epoch = self.consensus_epoch()?;
if consensus_epoch < epoch || consensus_epoch > epoch + MAX_EPHEMERAL_KEY_AGE {
if consensus_epoch + 1 < epoch || consensus_epoch > epoch + MAX_EPHEMERAL_KEY_AGE {
return Err(KeyManagerError::InvalidEpoch(consensus_epoch, epoch).into());
}
Ok(())
Expand Down

0 comments on commit d50dfae

Please sign in to comment.