Skip to content

Commit 9d3c1d3

Browse files
feat: prevent dos attack
1 parent c4efbe7 commit 9d3c1d3

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

contracts/src/bridge/merkle/MerkleProof.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ contract MerkleProof {
4848
*/
4949
function calculateRoot(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) {
5050
uint256 proofLength = proof.length;
51-
require(proofLength <= 32, "Invalid Proof");
51+
require(proofLength <= 64, "Invalid Proof");
5252
bytes32 h = leaf;
5353
for (uint256 i = 0; i < proofLength; i++) {
5454
bytes32 proofElement = proof[i];

contracts/src/bridge/merkle/MerkleTreeHistory.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ contract MerkleTreeHistory {
2121
// ***************************** //
2222

2323
// merkle tree representation
24-
// supports 2^32-1 messages.
25-
bytes32[32] public branch;
24+
// supports 2^64 messages.
25+
bytes32[64] public branch;
2626
uint256 public count;
2727

2828
// block number => merkle root history
@@ -45,7 +45,7 @@ contract MerkleTreeHistory {
4545
uint256 size = count;
4646
uint256 hashBitField = (size ^ (size - 1)) & size;
4747

48-
for (uint256 height = 0; height < 32; height++) {
48+
for (uint256 height = 0; height < 64; height++) {
4949
if ((hashBitField & 1) == 1) {
5050
branch[height] = leaf;
5151
return;

0 commit comments

Comments
 (0)