Saltar al contenido principal

Evicted Keys Snapshot

Table Metadata​

PropertyConfiguration
Natural Key(s)ledger_key_hash, valid_from
Partition Field(s)valid_to (MONTH partition)
Clustered Field(s)ledger_key_hash
Documentationdbt docs

Column Details​

NameDescriptionData TypeDomain ValuesRequired?Notes
ledger_key_hashHash of the ledgerKey, which is a subset of the ledgerEntry. The subset of ledgerEntry fields depends on ledgerEntryType.STRINGYes
closed_atTimestamp in UTC when this ledger closed and committed.TIMESTAMPYesLedgers are expected to close ~every 5 seconds.
is_evictedStatus flag indicating whether an entry is evicted or not.BOOLEANfalse, trueYesfalse = key has been restored.
ledger_sequenceThe sequence number of this ledger, representing its order in the Stellar blockchain.INTEGERYesCluster Field. Unique per ledger.
valid_fromThe timestamp when this snapshot row was first inserted and became effective.TIMESTAMPYesHelps track changes over time.
valid_toThe timestamp when this row is no longer valid.TIMESTAMPNoIf null, the setting is currently active.

Example Business Questions​

  1. Evicted keys as of today
SELECT ledger_key_hash, is_evicted
FROM `crypto-stellar.snapshots.evicted_keys_snapshot`
WHERE valid_to IS NULL
AND is_evicted = TRUE
LIMIT 100
  1. Point-in-time eviction status
SELECT ledger_key_hash, is_evicted
FROM `crypto-stellar.snapshots.evicted_keys_snapshot`
WHERE ledger_key_hash = 'abc123'
AND AND DATE('2025-03-10') BETWEEN DATE(valid_from) AND COALESCE(DATE(valid_to), '9999-12-31')
LIMIT 100
  1. Monthly Key Restorations
WITH with_lag AS (
SELECT
ledger_key_hash,
valid_from,
is_evicted,
LAG(is_evicted) OVER (
PARTITION BY ledger_key_hash
ORDER BY valid_from
) AS prev_status
FROM `crypto-stellar.snapshots.evicted_keys_snapshot`
)

SELECT
DATE_TRUNC(valid_from, MONTH) AS month,
COUNTIF(prev_status = TRUE AND is_evicted = FALSE) AS restorations_count
FROM with_lag
GROUP BY month
ORDER BY month
LIMIT 100