mirror of
https://github.com/serai-dex/serai.git
synced 2025-01-22 18:54:40 +00:00
Check a queued key has never been queued before
Re-queueing should only happen with a malicious supermajority and breaks indexing by the key.
This commit is contained in:
parent
e26da1ec34
commit
41a74cb513
1 changed files with 6 additions and 1 deletions
|
@ -72,6 +72,8 @@ impl<S: ScannerFeed> OutputWithInInstruction<S> {
|
||||||
|
|
||||||
create_db!(
|
create_db!(
|
||||||
ScannerGlobal {
|
ScannerGlobal {
|
||||||
|
QueuedKey: <K: Encode>(key: K) -> (),
|
||||||
|
|
||||||
ActiveKeys: <K: Borshy>() -> Vec<SeraiKeyDbEntry<K>>,
|
ActiveKeys: <K: Borshy>() -> Vec<SeraiKeyDbEntry<K>>,
|
||||||
RetireAt: <K: Encode>(key: K) -> u64,
|
RetireAt: <K: Encode>(key: K) -> u64,
|
||||||
|
|
||||||
|
@ -120,7 +122,10 @@ impl<S: ScannerFeed> ScannerGlobalDb<S> {
|
||||||
// Set the block which has a key activate as notable
|
// Set the block which has a key activate as notable
|
||||||
NotableBlock::set(txn, activation_block_number, &());
|
NotableBlock::set(txn, activation_block_number, &());
|
||||||
|
|
||||||
// TODO: Panic if we've ever seen this key before
|
// Check this key has never been queued before
|
||||||
|
// This should only happen if a malicious supermajority collude, and breaks indexing by the key
|
||||||
|
assert!(QueuedKey::get(txn, EncodableG(key)).is_none(), "key being queued was prior queued");
|
||||||
|
QueuedKey::set(txn, EncodableG(key), &());
|
||||||
|
|
||||||
// Fetch the existing keys
|
// Fetch the existing keys
|
||||||
let mut keys: Vec<SeraiKeyDbEntry<EncodableG<KeyFor<S>>>> =
|
let mut keys: Vec<SeraiKeyDbEntry<EncodableG<KeyFor<S>>>> =
|
||||||
|
|
Loading…
Reference in a new issue