Skip to content

Commit

Permalink
Decouple TACoChildApplication and infraction collector
Browse files Browse the repository at this point in the history
  • Loading branch information
theref committed Aug 9, 2024
1 parent 904b811 commit 4ca9272
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 16 deletions.
2 changes: 1 addition & 1 deletion contracts/contracts/coordination/InfractionCollector.sol
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ contract InfractionCollector is OwnableUpgradeable {
if (participant.transcript.length == 0) {
// Transcript TX wasn't posted
// Penalize the staking provider
tacoChildApplication.penalize(stakingProviders[i]);
// tacoChildApplication.penalize(stakingProviders[i]);
infractions[ritualId][stakingProviders[i]][
InfractionType.MISSING_TRANSCRIPT
] = true;
Expand Down
18 changes: 6 additions & 12 deletions contracts/contracts/coordination/TACoChildApplication.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ contract TACoChildApplication is ITACoRootToChild, ITACoChildApplication, Initia

ITACoChildToRoot public immutable rootApplication;
address public coordinator;
address public infractionCollector;
address public adjudicator;

uint96 public immutable minimumAuthorization;

Expand Down Expand Up @@ -61,21 +61,18 @@ contract TACoChildApplication is ITACoRootToChild, ITACoChildApplication, Initia
/**
* @notice Initialize function for using with OpenZeppelin proxy
*/
function initialize(address _coordinator, address _infractionCollector) external initializer {
function initialize(address _coordinator, address _adjudicator) external initializer {
require(coordinator == address(0) || adjudicator == address(0), "Contracts already set");
require(
coordinator == address(0) || infractionCollector == address(0),
"Contracts already set"
);
require(
_coordinator != address(0) && _infractionCollector != address(0),
_coordinator != address(0) && _adjudicator != address(0),
"Contracts must be specified"
);
require(
address(Coordinator(_coordinator).application()) == address(this),
"Invalid coordinator"
);
coordinator = _coordinator;
infractionCollector = _infractionCollector;
adjudicator = _adjudicator;
}

function authorizedStake(address _stakingProvider) external view returns (uint96) {
Expand Down Expand Up @@ -203,10 +200,7 @@ contract TACoChildApplication is ITACoRootToChild, ITACoChildApplication, Initia
* @param _stakingProvider Staking provider address
*/
function penalize(address _stakingProvider) external override {
require(
msg.sender == address(infractionCollector),
"Only infractionCollector allowed to penalize"
);
require(msg.sender == address(adjudicator), "Only adjudicator allowed to penalize");
rootApplication.penalize(_stakingProvider);
emit Penalized(_stakingProvider);
}
Expand Down
3 changes: 1 addition & 2 deletions scripts/lynx/deploy_child.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ def main():
ritual_token = deployer.deploy(project.LynxRitualToken)

coordinator = deployer.deploy(project.Coordinator)
infraction = deployer.deploy(project.InfractionCollector)
deployer.transact(taco_child_application.initialize, coordinator.address, infraction.address)
deployer.transact(taco_child_application.initialize, coordinator.address)

global_allow_list = deployer.deploy(project.GlobalAllowList)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_child_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ def test_penalize(accounts, root_application, child_application, coordinator):
) = accounts[0:]

# Penalize can be done only from adjudicator address
with ape.reverts("Only infractionCollector allowed to penalize"):
with ape.reverts("Only adjudicator allowed to penalize"):
child_application.penalize(staking_provider, sender=staking_provider)

tx = child_application.penalize(staking_provider, sender=creator)
Expand Down

0 comments on commit 4ca9272

Please sign in to comment.