From 36e9ab2b0559e0305462e1768a783fd31c78c521 Mon Sep 17 00:00:00 2001 From: chrismaree Date: Wed, 16 Mar 2022 07:59:38 +0200 Subject: [PATCH 1/6] fix[N04] Add additional documentation Signed-off-by: chrismaree --- contracts/HubPool.sol | 2 ++ contracts/HubPoolInterface.sol | 10 +++++----- contracts/MerkleLib.sol | 6 +++++- contracts/SpokePoolInterface.sol | 4 ++-- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/contracts/HubPool.sol b/contracts/HubPool.sol index c970e0fd2..be83f3c5b 100644 --- a/contracts/HubPool.sol +++ b/contracts/HubPool.sol @@ -124,6 +124,8 @@ contract HubPool is HubPoolInterface, Testable, Lockable, MultiCaller, Ownable { // the full amount of fees entitled to LPs in ~ 7.72 days, just over the standard L2 7 day liveness. uint256 public lpFeeRatePerSecond = 1500000000000; + // Mapping of l1TokenAddress to cumulative unclaimed protocol tokens that the sent to the protocolFeeCaptureAddress + // at any time. This enables the protocol to capture some percentage of LP fees which can be allocated elsewhere. mapping(address => uint256) public unclaimedAccumulatedProtocolFees; // Address that captures protocol fees. Accumulated protocol fees can be claimed by this address. diff --git a/contracts/HubPoolInterface.sol b/contracts/HubPoolInterface.sol index 692ac40d2..273290db1 100644 --- a/contracts/HubPoolInterface.sol +++ b/contracts/HubPoolInterface.sol @@ -16,11 +16,11 @@ interface HubPoolInterface { uint256[] bundleLpFees; // This array is grouped with the two above, and it represents the amount to send or request back from the // SpokePool. If positive, the pool will pay the SpokePool. If negative the SpokePool will pay the HubPool. - // There can be arbitrarily complex rebalancing rules defined offchain. This number is only nonzero - // when the rules indicate that a rebalancing action should occur. When a rebalance does not occur, - // runningBalances for this token should change by the total relays - deposits in this bundle. When a rebalance - // does occur, runningBalances should be set to zero for this token and the netSendAmounts should be set to the - // previous runningBalances + relays - deposits in this bundle. + // There can be arbitrarily complex rebalancing rules defined offchain. This number is only nonzero when the + // rules indicate that a rebalancing action should occur. When a rebalance does occur, runningBalances should be + // set to zero for this token and the netSendAmounts should be set to the previous runningBalances + relays - + // deposits in this bundle. If non-zero then it must be set on the SpokePool's RelayerRefundLeaf amountToReturn + // as -1 * this value to indicate if funds are being sent from or to the SpokePool. int256[] netSendAmounts; // This is only here to be emitted in an event to track a running unpaid balance between the L2 pool and the L1 pool. // A positive number indicates that the HubPool owes the SpokePool funds. A negative number indicates that the diff --git a/contracts/MerkleLib.sol b/contracts/MerkleLib.sol index 85666ca8b..1686c4808 100644 --- a/contracts/MerkleLib.sol +++ b/contracts/MerkleLib.sol @@ -14,6 +14,7 @@ library MerkleLib { * @param root the merkle root. * @param rebalance the rebalance struct. * @param proof the merkle proof. + * @return bool to signal if the pool rebalance proof correctly shows inclusion of the rebalance within the tree. */ function verifyPoolRebalance( bytes32 root, @@ -28,6 +29,7 @@ library MerkleLib { * @param root the merkle root. * @param refund the refund struct. * @param proof the merkle proof. + * @return bool to signal if the relayer refund proof correctly shows inclusion of the refund within the tree. */ function verifyRelayerRefund( bytes32 root, @@ -40,8 +42,9 @@ library MerkleLib { /** * @notice Verifies that a distribution is contained within a merkle root. * @param root the merkle root. - * @param slowRelayFulfillment the relayData fulfullment struct. + * @param slowRelayFulfillment the relayData fulfillment struct. * @param proof the merkle proof. + * @return bool to signal if the slow rely's proof correctly shows inclusion of the slow relay within the tree. */ function verifySlowRelayFulfillment( bytes32 root, @@ -95,6 +98,7 @@ library MerkleLib { * @param claimedBitMap a simple uint256 mapping in storage used as a bitmap. Uint8 type enforces that index * can't be > 255. * @param index the index to mark in the bitmap. + * @param uint256 representing the modified input claimedBitMap with the index set to true. */ function setClaimed1D(uint256 claimedBitMap, uint8 index) internal pure returns (uint256) { return claimedBitMap | (1 << index % 256); diff --git a/contracts/SpokePoolInterface.sol b/contracts/SpokePoolInterface.sol index 5f49b0ca8..f5ab96584 100644 --- a/contracts/SpokePoolInterface.sol +++ b/contracts/SpokePoolInterface.sol @@ -7,8 +7,8 @@ pragma solidity ^0.8.0; interface SpokePoolInterface { // This leaf is meant to be decoded in the SpokePool to pay out successful relayers. struct RelayerRefundLeaf { - // This is the amount to return to the HubPool. This occurs when there is a PoolRebalanceLeaf netSendAmount that is - // negative. This is just that value inverted. + // This is the amount to return to the HubPool. This occurs when there is a PoolRebalanceLeaf netSendAmount that + // is negative. This is just that value inverted. uint256 amountToReturn; // Used to verify that this is being executed on the correct destination chainId. uint256 chainId; From a83a973d8c144414001a1928d8b72ef60bec070a Mon Sep 17 00:00:00 2001 From: chrismaree Date: Wed, 16 Mar 2022 08:40:21 +0200 Subject: [PATCH 2/6] nit Signed-off-by: chrismaree --- contracts/MerkleLib.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/MerkleLib.sol b/contracts/MerkleLib.sol index 1686c4808..124ad5a54 100644 --- a/contracts/MerkleLib.sol +++ b/contracts/MerkleLib.sol @@ -98,7 +98,7 @@ library MerkleLib { * @param claimedBitMap a simple uint256 mapping in storage used as a bitmap. Uint8 type enforces that index * can't be > 255. * @param index the index to mark in the bitmap. - * @param uint256 representing the modified input claimedBitMap with the index set to true. + * @return uint256 representing the modified input claimedBitMap with the index set to true. */ function setClaimed1D(uint256 claimedBitMap, uint8 index) internal pure returns (uint256) { return claimedBitMap | (1 << index % 256); From f9b8f30c229ce9b6090652db716c06223f7eb73b Mon Sep 17 00:00:00 2001 From: Chris Maree Date: Fri, 18 Mar 2022 07:28:03 +0200 Subject: [PATCH 3/6] Update contracts/HubPool.sol Co-authored-by: nicholaspai <9457025+nicholaspai@users.noreply.github.com> --- contracts/HubPool.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/HubPool.sol b/contracts/HubPool.sol index be83f3c5b..f62348c98 100644 --- a/contracts/HubPool.sol +++ b/contracts/HubPool.sol @@ -124,7 +124,7 @@ contract HubPool is HubPoolInterface, Testable, Lockable, MultiCaller, Ownable { // the full amount of fees entitled to LPs in ~ 7.72 days, just over the standard L2 7 day liveness. uint256 public lpFeeRatePerSecond = 1500000000000; - // Mapping of l1TokenAddress to cumulative unclaimed protocol tokens that the sent to the protocolFeeCaptureAddress + // Mapping of l1TokenAddress to cumulative unclaimed protocol tokens that can be sent to the protocolFeeCaptureAddress // at any time. This enables the protocol to capture some percentage of LP fees which can be allocated elsewhere. mapping(address => uint256) public unclaimedAccumulatedProtocolFees; From 4540be3b21b8229b528934725ee49bd153a73027 Mon Sep 17 00:00:00 2001 From: Chris Maree Date: Fri, 18 Mar 2022 07:28:09 +0200 Subject: [PATCH 4/6] Update contracts/HubPool.sol Co-authored-by: nicholaspai <9457025+nicholaspai@users.noreply.github.com> --- contracts/HubPool.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/HubPool.sol b/contracts/HubPool.sol index f62348c98..5715a2785 100644 --- a/contracts/HubPool.sol +++ b/contracts/HubPool.sol @@ -125,7 +125,7 @@ contract HubPool is HubPoolInterface, Testable, Lockable, MultiCaller, Ownable { uint256 public lpFeeRatePerSecond = 1500000000000; // Mapping of l1TokenAddress to cumulative unclaimed protocol tokens that can be sent to the protocolFeeCaptureAddress - // at any time. This enables the protocol to capture some percentage of LP fees which can be allocated elsewhere. + // at any time. This enables the protocol to reallocate some percentage of LP fees elsewhere. mapping(address => uint256) public unclaimedAccumulatedProtocolFees; // Address that captures protocol fees. Accumulated protocol fees can be claimed by this address. From 7d37846d1ea8668b0df0ef79241868c3ba7ce9a4 Mon Sep 17 00:00:00 2001 From: Chris Maree Date: Fri, 18 Mar 2022 07:28:14 +0200 Subject: [PATCH 5/6] Update contracts/MerkleLib.sol Co-authored-by: nicholaspai <9457025+nicholaspai@users.noreply.github.com> --- contracts/MerkleLib.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/MerkleLib.sol b/contracts/MerkleLib.sol index 124ad5a54..caec55408 100644 --- a/contracts/MerkleLib.sol +++ b/contracts/MerkleLib.sol @@ -44,7 +44,7 @@ library MerkleLib { * @param root the merkle root. * @param slowRelayFulfillment the relayData fulfillment struct. * @param proof the merkle proof. - * @return bool to signal if the slow rely's proof correctly shows inclusion of the slow relay within the tree. + * @return bool to signal if the slow relay's proof correctly shows inclusion of the slow relay within the tree. */ function verifySlowRelayFulfillment( bytes32 root, From e2bfe128ff1a9aeed02bfcebe58a5880ad283698 Mon Sep 17 00:00:00 2001 From: Chris Maree Date: Fri, 18 Mar 2022 07:28:18 +0200 Subject: [PATCH 6/6] Update contracts/HubPoolInterface.sol Co-authored-by: nicholaspai <9457025+nicholaspai@users.noreply.github.com> --- contracts/HubPoolInterface.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/HubPoolInterface.sol b/contracts/HubPoolInterface.sol index 273290db1..6bef2e766 100644 --- a/contracts/HubPoolInterface.sol +++ b/contracts/HubPoolInterface.sol @@ -18,7 +18,7 @@ interface HubPoolInterface { // SpokePool. If positive, the pool will pay the SpokePool. If negative the SpokePool will pay the HubPool. // There can be arbitrarily complex rebalancing rules defined offchain. This number is only nonzero when the // rules indicate that a rebalancing action should occur. When a rebalance does occur, runningBalances should be - // set to zero for this token and the netSendAmounts should be set to the previous runningBalances + relays - + // set to zero for this token and the netSendAmounts should be set to the previous runningBalances + relays - // deposits in this bundle. If non-zero then it must be set on the SpokePool's RelayerRefundLeaf amountToReturn // as -1 * this value to indicate if funds are being sent from or to the SpokePool. int256[] netSendAmounts;