Skip to content
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

[EPIC] Infractions #318

Draft
wants to merge 35 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
ecb747c
Add first draft of InfractionCollector
theref May 15, 2024
9e7e0e9
Replace reference to `adjudicator` in `TACoChildApplication` with `in…
theref May 15, 2024
db0d7ce
Set Coordinator and TACoChild contracts to be public
theref May 24, 2024
bca6b8a
Add FAILING tests for infraction collector
theref May 27, 2024
94b69ef
Get first InfractionCollector test passing
theref May 28, 2024
0120022
Add genuine tests for InfractionCollector
theref May 30, 2024
c48f05a
Add deployment script for InfractionCollector on lynx
theref Jun 5, 2024
8508fd6
Use interface for TACo Child Application in Infraction Collector
theref Jun 5, 2024
f870094
Fix deployment typo
theref Jun 5, 2024
aab8582
Update README explaining how to test a deployment locally
theref Jun 20, 2024
b44579d
Add infraction deployment to child script
theref Jun 24, 2024
66bf256
Adding comment about transcript length
theref Jun 24, 2024
9774912
Add infraction type enum for granular punishment
theref Aug 8, 2024
e88941b
Decouple TACoChildApplication and infraction collector
theref Aug 9, 2024
ac4181f
Move coordinator and taco application to contstructor
theref Jul 31, 2024
a43a0e2
Fix bug with removing initialize
theref Aug 9, 2024
b99d3ea
Clean up README deployments
theref Aug 9, 2024
8cb11f5
Make infractionCollector constructor more robust
theref Aug 9, 2024
988dc44
Add InfractionReported event
theref Aug 9, 2024
2867808
Fix tests and contract constructor
theref Aug 9, 2024
bb59916
Fix logic of tests to make code more efficient
theref Aug 9, 2024
5de9946
Fix yaml tab/spaces
theref Aug 9, 2024
d6047d7
Add new test where only half of nodes submit transcripts
theref Aug 9, 2024
ebd1e43
Add PR suggestion on named mapping
theref Aug 13, 2024
1b756ee
Deploy InfractionCollector to Lynx
theref Aug 13, 2024
5fff77b
Deploy InfractionCollector to tapir
theref Aug 13, 2024
c822ab5
Add initialize function back into InfractionCollector
theref Aug 16, 2024
aa07f06
Remove duplicated IEncryptionAuthorizer
theref Aug 16, 2024
837a388
Apply PR suggestions
theref Aug 20, 2024
0246332
Update Infraction tests to align with Coordinator after rebase
theref Aug 20, 2024
b97dd03
Fix solhint errors
theref Aug 20, 2024
2211cd3
Merge pull request #267 from theref/infraction
cygnusv Aug 20, 2024
0fb1c3c
Add deployment script and params for InfractionCollector on mainnet
theref Aug 22, 2024
2c7de44
Deploy InfractionCollector to mainnet
theref Aug 26, 2024
dc5edfe
Merge pull request #314 from theref/deploy-infraction-35
KPrasch Sep 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions contracts/contracts/coordination/InfractionCollector.sol
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;
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
);
}
}
}
1 change: 0 additions & 1 deletion contracts/contracts/testnet/OpenAccessAuthorizer.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// SPDX-License-Identifier: AGPL-3.0-or-later

pragma solidity ^0.8.0;

import "../coordination/IEncryptionAuthorizer.sol";
Expand Down
239 changes: 239 additions & 0 deletions deployment/artifacts/lynx.json
Original file line number Diff line number Diff line change
Expand Up @@ -5476,6 +5476,245 @@
"block_number": 9101909,
"deployer": "0x3B42d26E19FF860bC4dEbB920DD8caA53F93c600"
},
"InfractionCollector": {
"address": "0xad8dADaB38eC94B8fe3c482f7550044201506369",
"abi": [
{
"type": "constructor",
"stateMutability": "nonpayable",
"inputs": [
{
"name": "_coordinator",
"type": "address",
"components": null,
"internal_type": "contract Coordinator"
},
{
"name": "_tacoChildApplication",
"type": "address",
"components": null,
"internal_type": "contract ITACoChildApplication"
}
]
},
{
"type": "error",
"name": "InvalidInitialization",
"inputs": []
},
{
"type": "error",
"name": "NotInitializing",
"inputs": []
},
{
"type": "error",
"name": "OwnableInvalidOwner",
"inputs": [
{
"name": "owner",
"type": "address",
"components": null,
"internal_type": "address"
}
]
},
{
"type": "error",
"name": "OwnableUnauthorizedAccount",
"inputs": [
{
"name": "account",
"type": "address",
"components": null,
"internal_type": "address"
}
]
},
{
"type": "event",
"name": "InfractionReported",
"inputs": [
{
"name": "ritualId",
"type": "uint32",
"components": null,
"internal_type": "uint32",
"indexed": true
},
{
"name": "stakingProvider",
"type": "address",
"components": null,
"internal_type": "address",
"indexed": true
},
{
"name": "infractionType",
"type": "uint8",
"components": null,
"internal_type": "enum InfractionCollector.InfractionType",
"indexed": false
}
],
"anonymous": false
},
{
"type": "event",
"name": "Initialized",
"inputs": [
{
"name": "version",
"type": "uint64",
"components": null,
"internal_type": "uint64",
"indexed": false
}
],
"anonymous": false
},
{
"type": "event",
"name": "OwnershipTransferred",
"inputs": [
{
"name": "previousOwner",
"type": "address",
"components": null,
"internal_type": "address",
"indexed": true
},
{
"name": "newOwner",
"type": "address",
"components": null,
"internal_type": "address",
"indexed": true
}
],
"anonymous": false
},
{
"type": "function",
"name": "coordinator",
"stateMutability": "view",
"inputs": [],
"outputs": [
{
"name": "",
"type": "address",
"components": null,
"internal_type": "contract Coordinator"
}
]
},
{
"type": "function",
"name": "infractions",
"stateMutability": "view",
"inputs": [
{
"name": "ritualId",
"type": "uint32",
"components": null,
"internal_type": "uint32"
},
{
"name": "stakingProvider",
"type": "address",
"components": null,
"internal_type": "address"
},
{
"name": "",
"type": "uint8",
"components": null,
"internal_type": "enum InfractionCollector.InfractionType"
}
],
"outputs": [
{
"name": "",
"type": "bool",
"components": null,
"internal_type": "bool"
}
]
},
{
"type": "function",
"name": "owner",
"stateMutability": "view",
"inputs": [],
"outputs": [
{
"name": "",
"type": "address",
"components": null,
"internal_type": "address"
}
]
},
{
"type": "function",
"name": "renounceOwnership",
"stateMutability": "nonpayable",
"inputs": [],
"outputs": []
},
{
"type": "function",
"name": "reportMissingTranscript",
"stateMutability": "nonpayable",
"inputs": [
{
"name": "ritualId",
"type": "uint32",
"components": null,
"internal_type": "uint32"
},
{
"name": "stakingProviders",
"type": "address[]",
"components": null,
"internal_type": "address[]"
}
],
"outputs": []
},
{
"type": "function",
"name": "tacoChildApplication",
"stateMutability": "view",
"inputs": [],
"outputs": [
{
"name": "",
"type": "address",
"components": null,
"internal_type": "contract ITACoChildApplication"
}
]
},
{
"type": "function",
"name": "transferOwnership",
"stateMutability": "nonpayable",
"inputs": [
{
"name": "newOwner",
"type": "address",
"components": null,
"internal_type": "address"
}
],
"outputs": []
}
],
"tx_hash": "0x36762db270b4706dfe829502e5b6469f783acb4bc74e9d21908ecdc88f150629",
"block_number": 10661923,
"deployer": "0x3B42d26E19FF860bC4dEbB920DD8caA53F93c600"
},
"LynxRitualToken": {
"address": "0x064Be2a9740e565729BC0d47bC616c5bb8Cc87B9",
"abi": [
Expand Down
Loading
Loading