Skip to content

Commit

Permalink
Add first draft of InfractionCollector
Browse files Browse the repository at this point in the history
  • Loading branch information
theref committed Aug 26, 2024
1 parent 346f364 commit 965bba2
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions contracts/contracts/coordination/InfractionCollector.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin-upgradeable/contracts/access/OwnableUpgradeable.sol";
import "./Coordinator.sol";
import "./TACoChildApplication.sol";

contract InfractionCollector is OwnableUpgradeable {
// Reference to the Coordinator contract
Coordinator private coordinator;

// Reference to the TACoChildApplication contract
TACoChildApplication private tacoChildApplication;

// Mapping to keep track of reported infractions
mapping(bytes32 => mapping(address => bool)) private infractions;

function initialize(Coordinator _coordinator, TACoChildApplication _tacoChildApplication) public initializer {
__Ownable_init();

coordinator = _coordinator;
tacoChildApplication = _tacoChildApplication;
}

function reportMissingTranscript(bytes32 ritualId, address[] calldata stakingProviders) external {
// Ritual must have failed
require(coordinator.getRitualState(ritualId) == Coordinator.RitualState.DKG_TIMEOUT, "Ritual must have failed");

for (uint256 i = 0; i < stakingProviders.length; i++) {
// Check if the infraction has already been reported
require(!infractions[ritualId][stakingProviders[i]], "Infraction already reported");
participant = coordinator.getParticipantFromProvider(ritualId, stakingProviders[i]);
if (participant.transcript.length == 0) {
// Penalize the staking provider
tacoChildApplication.penalize(stakingProviders[i]);
infractions[ritualId][stakingProviders[i]] = true;
}
}
}
}

0 comments on commit 965bba2

Please sign in to comment.