This repository has been archived by the owner on Nov 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
imp: cache membership using transient store (#130)
* feat: implemented * imp: ran forge fmt * imp: regenerated abi * imp: generated new fixtures * test: added large membership test * style: forge fmt * fix: removed broken test * docs: improved natspec
- Loading branch information
Showing
14 changed files
with
363 additions
and
36 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
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
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.28; | ||
|
||
// solhint-disable-next-line no-global-import | ||
import "forge-std/console.sol"; | ||
import { MembershipTest } from "./MembershipTest.sol"; | ||
import { ILightClient } from "solidity-ibc/interfaces/ILightClient.sol"; | ||
|
||
contract SP1ICS07LargeMembershipTest is MembershipTest { | ||
SP1MembershipProof public proof; | ||
|
||
function setUpLargeMembershipTestWithFixture(string memory fileName) public { | ||
setUpTestWithFixtures(fileName); | ||
|
||
proof = abi.decode(fixture.membershipProof.proof, (SP1MembershipProof)); | ||
} | ||
|
||
function getOutput() public view returns (MembershipOutput memory) { | ||
return abi.decode(proof.sp1Proof.publicValues, (MembershipOutput)); | ||
} | ||
|
||
function test_ValidLargeCachedVerifyMembership_25_plonk() public { | ||
ValidCachedMulticallMembershipTest("membership_25-plonk_fixture.json", 25, "25 key-value pairs with plonk"); | ||
} | ||
|
||
function test_ValidLargeCachedVerifyMembership_100_groth16() public { | ||
ValidCachedMulticallMembershipTest( | ||
"membership_100-groth16_fixture.json", 100, "100 key-value pairs with groth16" | ||
); | ||
} | ||
|
||
function ValidCachedMulticallMembershipTest(string memory fileName, uint32 n, string memory metadata) public { | ||
require(n > 0, "n must be greater than 0"); | ||
|
||
setUpLargeMembershipTestWithFixture(fileName); | ||
|
||
bytes[] memory multicallData = new bytes[](n); | ||
|
||
multicallData[0] = abi.encodeCall( | ||
ILightClient.membership, | ||
MsgMembership({ | ||
proof: abi.encode(fixture.membershipProof), | ||
proofHeight: fixture.proofHeight, | ||
path: getOutput().kvPairs[0].path, | ||
value: getOutput().kvPairs[0].value | ||
}) | ||
); | ||
|
||
for (uint32 i = 1; i < n; i++) { | ||
multicallData[i] = abi.encodeCall( | ||
ILightClient.membership, | ||
MsgMembership({ | ||
proof: bytes(""), // cached kv pairs | ||
proofHeight: fixture.proofHeight, | ||
path: getOutput().kvPairs[i].path, | ||
value: getOutput().kvPairs[i].value | ||
}) | ||
); | ||
} | ||
|
||
ics07Tendermint.multicall(multicallData); | ||
console.log("Proved", metadata, ", gas used: ", vm.lastCallGas().gasTotalUsed); | ||
} | ||
} |
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
Oops, something went wrong.