Skip to content

Commit

Permalink
Pass multiple storage slots
Browse files Browse the repository at this point in the history
  • Loading branch information
makoto committed Apr 26, 2024
1 parent 109e06c commit cf75a9f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
4 changes: 2 additions & 2 deletions scroll-gateway/src/ScrollProofService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@ export class ScrollProofService implements IProofService<ScrollProvableBlock> {
]);
const res:any = AbiCoder.defaultAbiCoder().encode(
[
'tuple(uint256 batchIndex, uint256 storageKey, bytes compressedProof)',
'tuple(uint256 batchIndex, uint256[] storageKeys, bytes compressedProof)',
'tuple(bytes[] stateTrieWitness, bytes[][] storageProofs)',
],
[
{
batchIndex,
storageKey:slots[0], // Check how to handle multiple storage
storageKeys:slots, // Check how to handle multiple storage
compressedProof
},
proof,
Expand Down
22 changes: 17 additions & 5 deletions scroll-verifier/contracts/ScrollVerifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ interface IScrollChainCommitmentVerifier {

struct ScrollWitnessData {
uint256 batchIndex;
bytes32 storageKey;
bytes32[] storageKeys;
bytes compressedProof;
}

Expand Down Expand Up @@ -55,9 +55,21 @@ contract ScrollVerifier is IEVMVerifier {
bytes[] memory constants,
bytes memory proof
) external view returns (bytes[] memory values) {
(ScrollWitnessData memory scrollData, StateProof memory stateProof) = abi.decode(proof, (ScrollWitnessData, StateProof));
(bytes32 stateRoot, bytes32 storageValue) = verifier.verifyZkTrieProof(target, scrollData.storageKey, scrollData.compressedProof);
values = new bytes[](1);
values[0] = abi.encodePacked(storageValue);
values = new bytes[](commands.length);
for(uint256 i = 0; i < commands.length; i++) {
bytes32 command = commands[i];
// (bool isDynamic, uint256 slot) = computeFirstSlot(command, constants, values);
// if(!isDynamic) {
// values[i] = abi.encode(getFixedValue(storageRoot, slot, proof.storageProofs[proofIdx++]));
// if(values[i].length > 32) {
// revert InvalidSlotSize(values[i].length);
// }
// } else {
// (values[i], proofIdx) = getDynamicValue(storageRoot, slot, proof, proofIdx);
// }
(ScrollWitnessData memory scrollData, StateProof memory stateProof) = abi.decode(proof, (ScrollWitnessData, StateProof));
(bytes32 stateRoot, bytes32 storageValue) = verifier.verifyZkTrieProof(target, scrollData.storageKeys[i], scrollData.compressedProof);
values[i] = abi.encodePacked(storageValue);
}
}
}

0 comments on commit cf75a9f

Please sign in to comment.