Skip to content

Commit

Permalink
fix: proof lenght check (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
nmlinaric authored Mar 13, 2024
1 parent cb2d7ae commit 6e1d38d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/contracts/proxies/SpectreProxy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import "@openzeppelin/contracts/access/AccessControl.sol";
contract SpectreProxy is AccessControl {

uint8 public constant STATE_ROOT_INDEX = 34;
uint8 public constant STATE_ROOT_DEPTH = 4;

// source domainID => slot => state root
mapping(uint8 => mapping(uint256 => bytes32)) public stateRoots;
Expand Down Expand Up @@ -129,7 +130,7 @@ contract SpectreProxy is AccessControl {
) internal pure returns (bool) {
bytes32 value = leaf;

for (uint256 i = 0; i < proof.length; i++) {
for (uint256 i = 0; i < STATE_ROOT_DEPTH; i++) {
if ((index / (2**i)) % 2 == 1) {
value = sha256(abi.encodePacked(proof[i], value));
} else {
Expand Down
1 change: 1 addition & 0 deletions test/proxies/spectre/spectreProxy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ describe("Spectre Proxy", () => {
"0x0c2e45ec77206f3b0cac1da903c4bc05cf177da367c428c1ba3cab0f654f4f78",
"0xdf581c183b1083cf6be31fde9f6073dfacfc252f8b514577f2ca03955b921552",
"0x59dac95a8278295a3a05d809156f69b45007af3f3df94bcabe4bbbdd9cce5c5a",
"0xcc69885fda6bcc1a4ace058b4a62bf5e179ea78fd58a1ccd71c22cc9b688792f",
];

const stepInput: ISpectre.SyncStepInputStruct = {
Expand Down

0 comments on commit 6e1d38d

Please sign in to comment.