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 May 15, 2024
1 parent 449ec47 commit 0577c1d
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 {

Check failure on line 18 in contracts/contracts/coordination/InfractionCollector.sol

View workflow job for this annotation

GitHub Actions / linting

Replace Coordinator·_coordinator,·TACoChildApplication·_tacoChildApplication with ⏎········Coordinator·_coordinator,⏎········TACoChildApplication·_tacoChildApplication⏎····
__Ownable_init();

coordinator = _coordinator;
tacoChildApplication = _tacoChildApplication;
}

function reportMissingTranscript(bytes32 ritualId, address[] calldata stakingProviders) external {

Check failure on line 25 in contracts/contracts/coordination/InfractionCollector.sol

View workflow job for this annotation

GitHub Actions / linting

Replace bytes32·ritualId,·address[]·calldata·stakingProviders with ⏎········bytes32·ritualId,⏎········address[]·calldata·stakingProviders⏎····
// Ritual must have failed
require(coordinator.getRitualState(ritualId) == Coordinator.RitualState.DKG_TIMEOUT, "Ritual must have failed");

Check failure on line 27 in contracts/contracts/coordination/InfractionCollector.sol

View workflow job for this annotation

GitHub Actions / linting

Replace coordinator.getRitualState(ritualId)·==·Coordinator.RitualState.DKG_TIMEOUT,·"Ritual·must·have·failed" with ⏎············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;
}
}
}
}

Check failure on line 40 in contracts/contracts/coordination/InfractionCollector.sol

View workflow job for this annotation

GitHub Actions / linting

Insert ⏎

0 comments on commit 0577c1d

Please sign in to comment.