Skip to content

Commit cfafbba

Browse files
committed
Add report creation
1 parent cb69f82 commit cfafbba

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

crates/iota-core/src/checkpoints/checkpoint_output.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,20 @@ impl<T: SubmitToConsensus + ReconfigurationInitiator> CheckpointOutput
123123
.set(checkpoint_seq as i64);
124124
}
125125

126+
// We also send misbehavior reports to consensus at this point. Misbehavior
127+
// reports containing proofs of misbehaviour can be send whenever the
128+
// misbehavior is detected, but we choose to send the ones that include only
129+
// unprovable counts at this point, due to periodicity reasons and to ensure a
130+
// (approximate) synchronization with the score updates.
131+
let misbehavior_report = epoch_store.scorer.current_local_metrics_count.to_report();
132+
let transaction = ConsensusTransaction::new_misbehavior_report(
133+
epoch_store.name,
134+
&misbehavior_report,
135+
checkpoint_seq,
136+
);
137+
self.sender
138+
.submit_to_consensus(&vec![transaction], epoch_store)?;
139+
126140
if checkpoint_timestamp >= self.next_reconfiguration_timestamp_ms {
127141
// close_epoch is ok if called multiple times
128142
self.sender.close_epoch(epoch_store);

crates/iota-core/src/checkpoints/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1381,7 +1381,8 @@ impl CheckpointBuilder {
13811381

13821382
batch.write()?;
13831383

1384-
// Send all checkpoint sigs to consensus.
1384+
// Send all checkpoint sigs to consensus. The messages inclusing
1385+
// MisbehaviorReports are also sent in this step.
13851386
for (summary, contents) in &new_checkpoints {
13861387
self.output
13871388
.checkpoint_created(summary, contents, &self.epoch_store, &self.store)

crates/iota-types/src/messages_consensus.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -534,9 +534,9 @@ impl ConsensusTransaction {
534534
}
535535
}
536536

537-
pub fn new_misbehavior_report_v1(
537+
pub fn new_misbehavior_report(
538538
authority: AuthorityName,
539-
report: &MisbehaviorReportV1,
539+
report: &VersionedMisbehaviorReport,
540540
round: CommitRound,
541541
) -> Self {
542542
let serialized_report =
@@ -546,11 +546,7 @@ impl ConsensusTransaction {
546546
let tracking_id = hasher.finish().to_le_bytes();
547547
Self {
548548
tracking_id,
549-
kind: ConsensusTransactionKind::MisbehaviorReport(
550-
authority,
551-
VersionedMisbehaviorReport::V1(report.clone()),
552-
round,
553-
),
549+
kind: ConsensusTransactionKind::MisbehaviorReport(authority, report.clone(), round),
554550
}
555551
}
556552

0 commit comments

Comments
 (0)