forked from 0xPolygon/pos-contracts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added mtpfix polygon v2.2.0 0xPolygon#19
- Loading branch information
Showing
7 changed files
with
57 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,3 @@ | ||
/* | ||
* @title MerklePatriciaVerifier | ||
* @author Sam Mayo ([email protected]) | ||
* | ||
* @dev Library for verifing merkle patricia proofs. | ||
*/ | ||
pragma solidity ^0.5.2; | ||
|
||
import {RLPReader} from "./RLPReader.sol"; | ||
|
@@ -69,30 +63,33 @@ library MerklePatriciaProof { | |
); | ||
pathPtr += 1; | ||
} else if (currentNodeList.length == 2) { | ||
bytes memory nodeValue = RLPReader.toBytes(currentNodeList[0]); | ||
uint256 traversed = _nibblesToTraverse( | ||
RLPReader.toBytes(currentNodeList[0]), | ||
nodeValue, | ||
path, | ||
pathPtr | ||
); | ||
//enforce correct nibble | ||
bytes1 prefix = _getNthNibbleOfBytes(0, nodeValue); | ||
if (pathPtr + traversed == path.length) { | ||
//leaf node | ||
if ( | ||
keccak256(RLPReader.toBytes(currentNodeList[1])) == | ||
keccak256(value) | ||
keccak256(RLPReader.toBytes(currentNodeList[1])) == keccak256(value) && | ||
(prefix == bytes1(uint8(2)) || prefix == bytes1(uint8(3))) | ||
) { | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
} | ||
|
||
//extension node | ||
if (traversed == 0) { | ||
if (traversed == 0 || (prefix != bytes1(uint8(0)) && prefix != bytes1(uint8(1)))) { | ||
return false; | ||
} | ||
|
||
pathPtr += traversed; | ||
nodeKey = bytes32(RLPReader.toUintStrict(currentNodeList[1])); | ||
|
||
} else { | ||
return false; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters