Skip to content

Commit

Permalink
Give the arbitration payer full control over proceedings of their arb…
Browse files Browse the repository at this point in the history
…itration in the L2ForkArbitrator (#191)
  • Loading branch information
josojo authored Jan 16, 2024
1 parent 7a49bfb commit 7ddeab7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
13 changes: 3 additions & 10 deletions contracts/L1GlobalForkRequester.sol
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,9 @@ contract L1GlobalForkRequester {
token
);

// If for some reason we've already got part of a payment, include it.
uint256 initialBalance = failedRequests[token][beneficiary][requestId]
.amount;

uint256 transferredBalance = initialBalance +
IForkonomicToken(token).balanceOf(moneyBox);
uint256 transferredBalance = IForkonomicToken(token).balanceOf(
moneyBox
);

if (moneyBox.code.length == 0) {
new MoneyBox{salt: salt}(token);
Expand All @@ -90,10 +87,6 @@ contract L1GlobalForkRequester {
transferredBalance >= forkingManager.arbitrationFee() &&
!forkingManager.isForkingInitiated()
) {
if (initialBalance > 0) {
delete (failedRequests[token][beneficiary][requestId]);
}

IForkonomicToken(token).approve(
address(forkingManager),
transferredBalance
Expand Down
8 changes: 8 additions & 0 deletions contracts/L2ForkArbitrator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ contract L2ForkArbitrator is IBridgeMessageReceiver {
revert ForkInProgress(); // Forking over something else
}

if (msg.sender != arbitrationRequests[question_id].payer) {
revert WrongSender();
}

RequestStatus status = arbitrationRequests[question_id].status;
if (
status != RequestStatus.QUEUED &&
Expand Down Expand Up @@ -280,6 +284,10 @@ contract L2ForkArbitrator is IBridgeMessageReceiver {
revert ForkInProgress();
}

if (msg.sender != arbitrationRequests[question_id].payer) {
revert WrongSender();
}

RequestStatus status = arbitrationRequests[question_id].status;
if (status != RequestStatus.FORK_REQUEST_FAILED) {
revert StatusNotForkRequestFailed();
Expand Down
7 changes: 7 additions & 0 deletions test/AdjudicationIntegration.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,13 @@ contract AdjudicationIntegrationTest is Test {
"Not in forking state"
);

vm.expectRevert(L2ForkArbitrator.WrongSender.selector);
l2ForkArbitrator.requestActivateFork(removalQuestionId);

vm.expectRevert(L2ForkArbitrator.WrongSender.selector);
l2ForkArbitrator.cancelArbitration(removalQuestionId);

vm.prank(user2);
l2ForkArbitrator.cancelArbitration(removalQuestionId);
assertEq(forkFee, l2ForkArbitrator.refundsDue(user2));

Expand Down

0 comments on commit 7ddeab7

Please sign in to comment.