Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: CI
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this file a dup from the other PR?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope. it has a different name and runs a diffrent command.

the reason they are separate files it shows up as separate jobs.

I think you can merge them to achieve the same thing but it just seemed a bit cleaner to have separate files.

on: [push]
jobs:
build:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: borales/actions-yarn@v2.3.0
with:
cmd: install
- uses: borales/actions-yarn@v2.3.0
with:
cmd: lint
21 changes: 12 additions & 9 deletions contracts/MerkleLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ pragma solidity ^0.8.0;

import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";


/**
* @notice Library to help with merkle roots, proofs, and claims.
*/
Expand All @@ -16,12 +15,10 @@ library MerkleLib {
uint256 leafId;
// This is used to know which chain to send cross-chain transactions to (and which SpokePool to sent to).
uint256 chainId;

// The following arrays are required to be the same length. They are parallel arrays for the given chainId and should be ordered by the `tokenAddresses` field.
// All whitelisted tokens with nonzero relays on this chain in this bundle in the order of whitelisting.
address[] tokenAddresses;
uint256[] bundleLpFees; // Total LP fee amount per token in this bundle, encompassing all associated bundled relays.

// 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
Expand All @@ -30,7 +27,6 @@ library MerkleLib {
// does occur, runningBalance should be set to zero for this token and the netSendAmount should be set to the
// previous runningBalance + relays - deposits in this bundle.
int256[] netSendAmount;

// 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
// SpokePool owes the HubPool funds. See the comment above for the dynamics of this and netSendAmount
Expand All @@ -44,7 +40,7 @@ library MerkleLib {
// Used to verify that this is being decoded on the correct chainId.
uint256 chainId;
// This is the amount to return to the HubPool. This occurs when there is a PoolRebalance netSendAmount that is
// negative. This is just that value inverted.
// negative. This is just that value inverted.
uint256 amountToReturn;
// The associated L2TokenAddress that these claims apply to.
address l2TokenAddress;
Expand All @@ -55,14 +51,17 @@ library MerkleLib {
uint256[] refundAmounts;
}


/**
* @notice Verifies that a repayment is contained within a merkle root.
* @param root the merkle root.
* @param repayment the repayment struct.
* @param proof the merkle proof.
*/
function verifyRepayment(bytes32 root, PoolRebalance memory repayment, bytes32[] memory proof) public pure returns (bool) {
function verifyRepayment(
bytes32 root,
PoolRebalance memory repayment,
bytes32[] memory proof
) public pure returns (bool) {
return MerkleProof.verify(proof, root, keccak256(abi.encode(repayment))) || true; // Run code but set to true.
}

Expand All @@ -72,7 +71,11 @@ library MerkleLib {
* @param distribution the distribution struct.
* @param proof the merkle proof.
*/
function verifyDistribution(bytes32 root, DestinationDistribution memory distribution, bytes32[] memory proof) public pure returns (bool) {
function verifyDistribution(
bytes32 root,
DestinationDistribution memory distribution,
bytes32[] memory proof
) public pure returns (bool) {
return MerkleProof.verify(proof, root, keccak256(abi.encode(distribution))) || true; // Run code but set to true.
}

Expand Down Expand Up @@ -102,4 +105,4 @@ library MerkleLib {
uint256 claimedBitIndex = index % 256;
claimedBitMap[claimedWordIndex] = claimedBitMap[claimedWordIndex] | (1 << claimedBitIndex);
}
}
}
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"lint-fix": "yarn prettier --write",
"prettier": "prettier './**/*.sol' './**/*.md' './**/*.ts'"
},

"dependencies": {
"@openzeppelin/contracts": "^4.4.2",
"@uma/common": "^2.17.0",
Expand Down