-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
InfractionCollector Contract #267
Merged
Merged
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
ecb747c
Add first draft of InfractionCollector
theref 9e7e0e9
Replace reference to `adjudicator` in `TACoChildApplication` with `in…
theref db0d7ce
Set Coordinator and TACoChild contracts to be public
theref bca6b8a
Add FAILING tests for infraction collector
theref 94b69ef
Get first InfractionCollector test passing
theref 0120022
Add genuine tests for InfractionCollector
theref c48f05a
Add deployment script for InfractionCollector on lynx
theref 8508fd6
Use interface for TACo Child Application in Infraction Collector
theref f870094
Fix deployment typo
theref aab8582
Update README explaining how to test a deployment locally
theref b44579d
Add infraction deployment to child script
theref 66bf256
Adding comment about transcript length
theref 9774912
Add infraction type enum for granular punishment
theref e88941b
Decouple TACoChildApplication and infraction collector
theref ac4181f
Move coordinator and taco application to contstructor
theref a43a0e2
Fix bug with removing initialize
theref b99d3ea
Clean up README deployments
theref 8cb11f5
Make infractionCollector constructor more robust
theref 988dc44
Add InfractionReported event
theref 2867808
Fix tests and contract constructor
theref bb59916
Fix logic of tests to make code more efficient
theref 5de9946
Fix yaml tab/spaces
theref d6047d7
Add new test where only half of nodes submit transcripts
theref ebd1e43
Add PR suggestion on named mapping
theref 1b756ee
Deploy InfractionCollector to Lynx
theref 5fff77b
Deploy InfractionCollector to tapir
theref c822ab5
Add initialize function back into InfractionCollector
theref aa07f06
Remove duplicated IEncryptionAuthorizer
theref 837a388
Apply PR suggestions
theref 0246332
Update Infraction tests to align with Coordinator after rebase
theref b97dd03
Fix solhint errors
theref File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
pragma solidity ^0.8.0; | ||
|
||
import "@openzeppelin-upgradeable/contracts/access/OwnableUpgradeable.sol"; | ||
import "./Coordinator.sol"; | ||
import "../../threshold/ITACoChildApplication.sol"; | ||
|
||
contract InfractionCollector is OwnableUpgradeable { | ||
event InfractionReported( | ||
uint32 indexed ritualId, | ||
address indexed stakingProvider, | ||
InfractionType infractionType | ||
); | ||
// infraction types | ||
enum InfractionType { | ||
MISSING_TRANSCRIPT | ||
} | ||
Coordinator public immutable coordinator; | ||
// Reference to the TACoChildApplication contract | ||
ITACoChildApplication public immutable tacoChildApplication; | ||
// Mapping to keep track of reported infractions | ||
mapping(uint32 ritualId => mapping(address stakingProvider => mapping(InfractionType => uint256))) | ||
public infractionsForRitual; | ||
|
||
constructor(Coordinator _coordinator) { | ||
require(address(_coordinator) != address(0), "Contracts must be specified"); | ||
coordinator = _coordinator; | ||
theref marked this conversation as resolved.
Show resolved
Hide resolved
|
||
tacoChildApplication = coordinator.application(); | ||
_disableInitializers(); | ||
} | ||
|
||
function initialize() external initializer { | ||
__Ownable_init(msg.sender); | ||
} | ||
|
||
function reportMissingTranscript( | ||
uint32 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( | ||
infractionsForRitual[ritualId][stakingProviders[i]][ | ||
InfractionType.MISSING_TRANSCRIPT | ||
] == 0, | ||
"Infraction already reported" | ||
); | ||
Coordinator.Participant memory participant = coordinator.getParticipantFromProvider( | ||
ritualId, | ||
stakingProviders[i] | ||
); | ||
require(participant.transcript.length == 0, "Transcript is not missing"); | ||
infractionsForRitual[ritualId][stakingProviders[i]][ | ||
InfractionType.MISSING_TRANSCRIPT | ||
] = 1; | ||
emit InfractionReported( | ||
ritualId, | ||
stakingProviders[i], | ||
InfractionType.MISSING_TRANSCRIPT | ||
); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's move this enum before the two variables definition above. We try to keep a common ordering of contract code, starting with events, enums, structs, constants, immutable variables, normal variables, modifiers, and then the constructor. Not set in stone, but in this case, I do think the
enum
goes after the event.