Skip to content

Commit

Permalink
fix: feedback fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Tomás Migone <[email protected]>
  • Loading branch information
tmigone committed Jun 7, 2024
1 parent 9c6f70f commit 9cb27fe
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 22 deletions.
4 changes: 2 additions & 2 deletions packages/contracts/contracts/arbitrum/ITokenGateway.sol
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ interface ITokenGateway {
// );

function outboundTransfer(
address oken,
address t,
address token,
address to,
uint256 amunt,
uint256 maxas,
uint256 gasPiceBid,
Expand Down
5 changes: 2 additions & 3 deletions packages/horizon/contracts/data-service/DataService.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,13 @@ abstract contract DataService is GraphDirectory, ProvisionManager, DataServiceV1
*/
// solhint-disable-next-line func-name-mixedcase
function __DataService_init() internal onlyInitializing {
__ProvisionManager_init_unchained();
__DataService_init_unchained();
}

/**
* @notice Initializes the contract.
*/
// solhint-disable-next-line func-name-mixedcase
function __DataService_init_unchained() internal onlyInitializing {
__ProvisionManager_init_unchained();
}
function __DataService_init_unchained() internal onlyInitializing {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ abstract contract DataServiceFees is DataService, DataServiceFeesV1Storage, IDat
/**
* @notice See {IDataServiceFees-releaseStake}
*/
function releaseStake(uint256 n) external virtual {
function releaseStake(uint256 n) external virtual override {
_releaseStake(msg.sender, n);
}

Expand Down Expand Up @@ -52,7 +52,7 @@ abstract contract DataServiceFees is DataService, DataServiceFeesV1Storage, IDat
nextClaim: bytes32(0)
});
if (claimsList.count != 0) claims[claimsList.tail].nextClaim = claimId;
claimsList.add(claimId);
claimsList.addTail(claimId);

emit StakeClaimLocked(_serviceProvider, claimId, _tokens, _unlockTimestamp);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ interface IDataService {
/**
* @notice Emitted when a service provider is registered with the data service.
* @param serviceProvider The address of the service provider.
* @param data Custom data, usage defined by the data service.
*/
event ServiceProviderRegistered(address indexed serviceProvider);
event ServiceProviderRegistered(address indexed serviceProvider, bytes data);

/**
* @notice Emitted when a service provider accepts a provision in {Graph Horizon staking contract}.
Expand All @@ -29,14 +30,16 @@ interface IDataService {
/**
* @notice Emitted when a service provider starts providing the service.
* @param serviceProvider The address of the service provider.
* @param data Custom data, usage defined by the data service.
*/
event ServiceStarted(address indexed serviceProvider);
event ServiceStarted(address indexed serviceProvider, bytes data);

/**
* @notice Emitted when a service provider stops providing the service.
* @param serviceProvider The address of the service provider.
* @param data Custom data, usage defined by the data service.
*/
event ServiceStopped(address indexed serviceProvider);
event ServiceStopped(address indexed serviceProvider, bytes data);

/**
* @notice Emitted when a service provider collects payment.
Expand Down
8 changes: 4 additions & 4 deletions packages/horizon/contracts/libraries/LinkedList.sol
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ library LinkedList {
* @param self The list metadata
* @param id The id of the item to add
*/
function add(List storage self, bytes32 id) internal {
function addTail(List storage self, bytes32 id) internal {
require(self.count < MAX_ITEMS, LinkedListMaxElementsExceeded());
self.tail = id;
self.nonce += 1;
Expand All @@ -80,7 +80,7 @@ library LinkedList {
* @param deleteItem A function to delete an item. This should delete the item from
* the contract storage. It takes the id of the item to delete.
*/
function remove(
function removeHead(
List storage self,
function(bytes32) view returns (bytes32) getNextItem,
function(bytes32) deleteItem
Expand All @@ -96,13 +96,13 @@ library LinkedList {

/**
* @notice Traverses the list and processes each item.
* It deletes the processed items from both the list and the storage mapping.
* @param self The list metadata
* @param getNextItem A function to get the next item in the list. It should take
* the id of the current item and return the id of the next item.
* @param processItem A function to process an item. The function should take the id of the item
* and an accumulator, and return:
* - a boolean indicating whether the traversal should stop
* - a boolean indicating whether the item should be deleted
* - an accumulator to pass data between iterations
* @param deleteItem A function to delete an item. This should delete the item from
* the contract storage. It takes the id of the item to delete.
Expand Down Expand Up @@ -132,7 +132,7 @@ library LinkedList {
if (shouldBreak) break;

acc = acc_;
cursor = self.remove(getNextItem, deleteItem);
cursor = self.removeHead(getNextItem, deleteItem);

if (!traverseAll) iterations--;
itemCount++;
Expand Down
2 changes: 1 addition & 1 deletion packages/horizon/contracts/staking/HorizonStaking.sol
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,7 @@ contract HorizonStaking is HorizonStakingBase, IHorizonStakingMain {
_thawRequests[thawRequestId] = ThawRequest({ shares: _shares, thawingUntil: _thawingUntil, next: bytes32(0) });

if (thawRequestList.count != 0) _thawRequests[thawRequestList.tail].next = thawRequestId;
thawRequestList.add(thawRequestId);
thawRequestList.addTail(thawRequestId);

emit ThawRequestCreated(_serviceProvider, _verifier, _owner, _shares, _thawingUntil, thawRequestId);
return thawRequestId;
Expand Down
6 changes: 3 additions & 3 deletions packages/horizon/test/libraries/LinkedList.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ contract LinkedListTest is Test, ListImplementation {
}

vm.expectRevert(LinkedList.LinkedListMaxElementsExceeded.selector);
list.add(_buildItemId(list.nonce));
list.addTail(_buildItemId(list.nonce));
}

function test_Remove_RevertGiven_TheListIsEmpty() external {
vm.expectRevert(LinkedList.LinkedListEmptyList.selector);
list.remove(_getNextItem, _deleteItem);
list.removeHead(_getNextItem, _deleteItem);
}

function test_Remove_GivenTheListIsNotEmpty() external {
Expand Down Expand Up @@ -119,7 +119,7 @@ contract LinkedListTest is Test, ListImplementation {

Item memory beforeHeadItem = items[beforeHead];

list.remove(_getNextItem, _deleteItem);
list.removeHead(_getNextItem, _deleteItem);

uint256 afterNonce = list.nonce;
uint256 afterCount = list.count;
Expand Down
2 changes: 1 addition & 1 deletion packages/horizon/test/libraries/ListImplementation.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ contract ListImplementation {
if (_list.count != 0) {
items[_list.tail].next = _id;
}
_list.add(_id);
_list.addTail(_id);
return _id;
}

Expand Down
6 changes: 3 additions & 3 deletions packages/subgraph-service/contracts/SubgraphService.sol
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ contract SubgraphService is
_setRewardsDestination(indexer, rewardsDestination);
}

emit ServiceProviderRegistered(indexer);
emit ServiceProviderRegistered(indexer, data);
}

/**
Expand Down Expand Up @@ -193,7 +193,7 @@ contract SubgraphService is
(bytes32, uint256, address, bytes)
);
_allocate(indexer, allocationId, subgraphDeploymentId, tokens, allocationProof, maximumDelegationRatio);
emit ServiceStarted(indexer);
emit ServiceStarted(indexer, data);
}

/**
Expand Down Expand Up @@ -221,7 +221,7 @@ contract SubgraphService is
) external override onlyProvisionAuthorized(indexer) onlyRegisteredIndexer(indexer) whenNotPaused {
address allocationId = abi.decode(data, (address));
_closeAllocation(allocationId);
emit ServiceStopped(indexer);
emit ServiceStopped(indexer, data);
}

/**
Expand Down

0 comments on commit 9cb27fe

Please sign in to comment.