Skip to content

Add key server staleness check#592

Open
jonas-lj wants to merge 1 commit into
mainfrom
jonas/keyserver-staleness
Open

Add key server staleness check#592
jonas-lj wants to merge 1 commit into
mainfrom
jonas/keyserver-staleness

Conversation

@jonas-lj

Copy link
Copy Markdown
Collaborator

Aborts decryption if the key server's clock lags the chain's by more than a fixed 30s (mirroring the existing fullnode staleness check in the other direction). Exposes the condition via a counter and a key_server_stale gauge so operators can alert on it.

@jonas-lj jonas-lj force-pushed the jonas/keyserver-staleness branch 2 times, most recently from 4ad09f4 to 69ab88c Compare June 17, 2026 08:05
Abort decryption if the key server's clock lags the chain by more than a fixed 30s, and expose it via metrics so operators can alert.
@jonas-lj jonas-lj force-pushed the jonas/keyserver-staleness branch from 69ab88c to e4fbc53 Compare June 17, 2026 11:33
@jonas-lj jonas-lj marked this pull request as ready for review June 22, 2026 12:32
@jonas-lj jonas-lj requested review from benr-ml and joyqvq as code owners June 22, 2026 12:32
public fun check_staleness(now: u64, allowed_staleness_in_ms: u64, clock: &clock::Clock) {
// If the clock timestamp is more recent, the check passes
/// The maximum amount the key server's time (`now`) may lag behind the on-chain time.
const ALLOWED_KEY_SERVER_STALENESS_IN_MS: u64 = 30_000;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's change that to 1 min

/// - Abort with `EStaleFullnode` if the on-chain time is more than `allowed_staleness_in_ms` behind `keyserver_time`.
/// - Abort with `EStaleKeyServer` if `keyserver_time` is more than `ALLOWED_KEY_SERVER_STALENESS_IN_MS` behind the on-chain time.
public fun check_staleness(
keyserver_time: u64,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we change the arg name?

}
Staleness::KeyServer => {
m.requests_failed_due_to_key_server_staleness.inc();
m.key_server_stale.set(1);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need key_server_stale? an alert on requests_failed_due_to_key_server_staleness would suffice, no?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants