Skip to content

Commit

Permalink
allow to deactivate manyModificationsAtOnce
Browse files Browse the repository at this point in the history
  • Loading branch information
josojo committed Jan 10, 2024
1 parent 520f53b commit b1d3d70
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 13 deletions.
23 changes: 18 additions & 5 deletions contracts/AdjudicationFramework/MinimalAdjudicationFramework.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ contract MinimalAdjudicationFramework {
EnumerableSet.AddressSet internal _arbitrators;
/// @dev Error thrown when non-allowlisted actor tries to call a function
error OnlyAllowlistedActor();
/// @dev Error thrown when multiple modifications are requested at once
error NoMultipleModificationsAtOnce();

// Iterable list contains list of allowlisted arbitrators
uint256 public constant ARB_DISPUTE_TIMEOUT = 86400;
Expand All @@ -37,6 +39,8 @@ contract MinimalAdjudicationFramework {
uint256 public templateIdAddArbitrator;
uint256 public templateIdReplaceArbitrator;

bool public allowMultipleModificationsAtOnce;

// Contract used for requesting a fork in the L1 chain in remove propositions
address public forkArbitrator;

Expand Down Expand Up @@ -64,11 +68,14 @@ contract MinimalAdjudicationFramework {
/// @param _realityETH The reality.eth instance we adjudicate for
/// @param _forkArbitrator The arbitrator contract that escalates to an L1 fork, used for our governance
/// @param _initialArbitrators Arbitrator contracts we initially support
/// @param _allowMultipleModificationsAtOnce Whether to allow multiple modifications at once
constructor(
address _realityETH,
address _forkArbitrator,
address[] memory _initialArbitrators
address[] memory _initialArbitrators,
bool _allowMultipleModificationsAtOnce
) {
allowMultipleModificationsAtOnce = _allowMultipleModificationsAtOnce;
realityETH = IRealityETH(_realityETH);
forkArbitrator = _forkArbitrator;
// Create reality.eth templates for our add questions
Expand Down Expand Up @@ -119,16 +126,19 @@ contract MinimalAdjudicationFramework {
if (arbitratorsToRemove.length == 0 && arbitratorsToAdd.length == 0) {
revert("No arbitrators to modify");

Check warning on line 127 in contracts/AdjudicationFramework/MinimalAdjudicationFramework.sol

View workflow job for this annotation

GitHub Actions / Code linting (16.x, ubuntu-latest)

Use Custom Errors instead of revert statements
} else if (
arbitratorsToRemove.length == 0 && arbitratorsToAdd.length >= 1
arbitratorsToRemove.length == 0 && arbitratorsToAdd.length == 1
) {
question = _arrayToString(arbitratorsToAdd);
templateId = templateIdAddArbitrator;
} else if (
arbitratorsToRemove.length >= 1 && arbitratorsToAdd.length == 0
arbitratorsToRemove.length == 1 && arbitratorsToAdd.length == 0
) {
question = _arrayToString(arbitratorsToRemove);
templateId = templateIdRemoveArbitrator;
} else {
if(!allowMultipleModificationsAtOnce) {
revert NoMultipleModificationsAtOnce();
}
question = string.concat(
_arrayToString(arbitratorsToRemove),
_arrayToString(arbitratorsToAdd)
Expand Down Expand Up @@ -160,14 +170,17 @@ contract MinimalAdjudicationFramework {
function _arrayToString(
address[] memory _array
) internal pure returns (string memory) {
string memory result = "[";
if (_array.length == 0) {
return "";
}
string memory result = "";
for (uint256 i = 0; i < _array.length; i++) {
result = string.concat(result, Strings.toHexString(_array[i]));
if (i < _array.length - 1) {
result = string.concat(result, ", ");
}
}
result = string.concat(result, "]");
result = string.concat(result, "");
return result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,15 @@ contract AdjudicationFrameworkRequests is
address _realityETH,
uint256 _disputeFee,
address _forkArbitrator,
address[] memory _initialArbitrators
address[] memory _initialArbitrators,
bool _allowMultipleModificationsAtOnce

)
MinimalAdjudicationFramework(
_realityETH,
_forkArbitrator,
_initialArbitrators
_initialArbitrators,
_allowMultipleModificationsAtOnce
)
{
dispute_fee = _disputeFee;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,14 @@ contract AdjudicationFrameworkFeeds is MinimalAdjudicationFramework {
constructor(
address _realityETH,
address _forkArbitrator,
address[] memory _initialArbitrators
address[] memory _initialArbitrators,
bool _allowMultipleModificationsAtOnce
)
MinimalAdjudicationFramework(
_realityETH,
_forkArbitrator,
_initialArbitrators
_initialArbitrators,
_allowMultipleModificationsAtOnce
)
{}

Expand Down
3 changes: 2 additions & 1 deletion test/AdjudicationFramework/AdjudicationFrameworkFeeds.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ contract FeedsTest is Test {
feeds = new AdjudicationFrameworkFeeds(
address(l2RealityEth),
l2Arbitrator,
initialArbitrators
initialArbitrators,
true
);
}

Expand Down
6 changes: 4 additions & 2 deletions test/AdjudicationFramework/AdjudicationFrameworkMinimal.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ contract AdjudicationIntegrationTest is Test {
address(l2RealityEth),
123,
address(l2ForkArbitrator),
initialArbitrators
initialArbitrators,
true
);

l2Arbitrator1 = new Arbitrator();
Expand Down Expand Up @@ -259,7 +260,8 @@ contract AdjudicationIntegrationTest is Test {
address(l2RealityEth),
123,
address(l2ForkArbitrator),
initialArbs
initialArbs,
true
);

// NB The length and indexes of this may change if we add unrelated log entries to the AdjudicationFramework constructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ contract AdjudicationIntegrationTest is Test {
address(l2RealityEth),
123,
address(l2ForkArbitrator),
initialArbitrators
initialArbitrators,
true
);

l2Arbitrator1 = new Arbitrator();
Expand Down

0 comments on commit b1d3d70

Please sign in to comment.