Skip to content

Commit 15e0035

Browse files
committed
feat: improve fdc reveal offence check
1 parent 855a258 commit 15e0035

File tree

2 files changed

+26
-9
lines changed

2 files changed

+26
-9
lines changed

observer/observer.py

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -238,14 +238,14 @@ def validate_ftso(round: VotingRound, entity: Entity, config: Configuration):
238238
_submit2, epoch.id, range(epoch.next.start_s, epoch.next.reveal_deadline())
239239
)
240240

241-
sig_deadline = max(
242-
epoch.next.start_s + 55, (finalization and finalization.timestamp) or 0
241+
sig_grace = max(
242+
epoch.next.start_s + 55 + 1, (finalization and finalization.timestamp + 1) or 0
243243
)
244244
_submit_sig = ftso.submit_signatures.by_identity.get(entity.identity_address, [])
245245
submit_sig = extract(
246246
_submit_sig,
247247
epoch.id,
248-
range(epoch.next.reveal_deadline(), sig_deadline),
248+
range(epoch.next.reveal_deadline(), sig_grace),
249249
)
250250

251251
# TODO:(matej) check for transactions that happened too late (or too early)
@@ -336,14 +336,19 @@ def validate_fdc(round: VotingRound, entity: Entity, config: Configuration):
336336
_submit2, epoch.id, range(epoch.next.start_s, epoch.next.reveal_deadline())
337337
)
338338

339-
sig_deadline = max(
340-
epoch.next.start_s + 55, (finalization and finalization.timestamp) or 0
339+
sig_grace = max(
340+
epoch.next.start_s + 55 + 1, (finalization and finalization.timestamp + 1) or 0
341341
)
342342
_submit_sig = fdc.submit_signatures.by_identity.get(entity.identity_address, [])
343343
submit_sig = extract(
344344
_submit_sig,
345345
epoch.id,
346-
range(epoch.next.reveal_deadline(), sig_deadline),
346+
range(epoch.next.reveal_deadline(), sig_grace),
347+
)
348+
submit_sig_deadline = extract(
349+
_submit_sig,
350+
epoch.id,
351+
range(epoch.next.reveal_deadline(), epoch.next.end_s),
347352
)
348353

349354
# TODO:(matej) check for transactions that happened too late (or too early)
@@ -353,6 +358,7 @@ def validate_fdc(round: VotingRound, entity: Entity, config: Configuration):
353358
s1 = submit_1 is not None
354359
s2 = submit_2 is not None
355360
ss = submit_sig is not None
361+
ssd = submit_sig_deadline is not None
356362

357363
if not s1:
358364
# NOTE:(matej) this is expected behaviour in fdc
@@ -365,7 +371,7 @@ def validate_fdc(round: VotingRound, entity: Entity, config: Configuration):
365371
# TODO:(matej) analize request array and report unproven errors
366372
...
367373

368-
if s2 and not ss:
374+
if s2 and not ssd:
369375
# TODO:(matej) check if submit2 bitvote dominated consensus bitvote
370376
issues.append(
371377
mb.build(
@@ -374,6 +380,17 @@ def validate_fdc(round: VotingRound, entity: Entity, config: Configuration):
374380
)
375381
)
376382

383+
if s2 and ssd and not ss:
384+
issues.append(
385+
mb.build(
386+
MessageLevel.CRITICAL,
387+
(
388+
"no submit signatures transaction during grace period, "
389+
"causing loss of rewards"
390+
),
391+
)
392+
)
393+
377394
if not s2 and not ss:
378395
issues.append(
379396
mb.build(MessageLevel.ERROR, "no submit signatures transaction"),

observer/reward_epoch_manager.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,8 +357,8 @@ def finalize(self, block: BlockData) -> list[VotingRound]:
357357
fdc_finalized = round.fdc.finalization is not None
358358
both_finalized = fdc_finalized and ftso_finalized
359359

360-
# 55 is submit sigs deadline, 10 is relay grace, 10 is additional buffer
361-
round_completed = k.next.start_s + 55 + 10 + 10 < block["timestamp"]
360+
# need to wait until end of next epoch for fdc reveal offence condition
361+
round_completed = k.next.end_s < block["timestamp"]
362362

363363
if both_finalized or round_completed:
364364
self.finalized = max(self.finalized, k.id)

0 commit comments

Comments
 (0)