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 14985eb
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 24 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
4 changes: 0 additions & 4 deletions deployment/constructor_params/lynx/child.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,3 @@ contracts:
- GlobalAllowList:
constructor:
_coordinator: $Coordinator
- InfractionCollector:
proxy:
constructor:
_data: $encode:initialize,$Coordinator,$TACoChildApplication
5 changes: 2 additions & 3 deletions deployment/constructor_params/lynx/infraction.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ artifacts:
constants:
# See deployment/artifacts/lynx.json
COORDINATOR_PROXY: "0xE9e94499bB0f67b9DBD75506ec1735486DE57770"
TACO_CHILD_PROXY: "0x42F30AEc1A36995eEFaf9536Eb62BD751F982D32"

contracts:
- InfractionCollector:
proxy:
constructor:
_data: $encode:initialize,$COORDINATOR_PROXY,$TACO_CHILD_PROXY
constructor:
_coordinator: $COORDINATOR_PROXY
4 changes: 1 addition & 3 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 All @@ -62,7 +61,6 @@ def main():
ritual_token,
coordinator,
global_allow_list,
infraction,
]

deployer.finalize(deployments=deployments)
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 14985eb

Please sign in to comment.