mirror of
https://github.com/privacy-scaling-explorations/zk-kit.git
synced 2026-04-22 03:00:15 -04:00
perf: replace memory with calldata
This commit is contained in:
@@ -97,8 +97,8 @@ contract Example {
|
||||
function removeLeaf(
|
||||
bytes32 _treeId,
|
||||
uint256 _leaf,
|
||||
uint256[] memory _proofSiblings,
|
||||
uint8[] memory _proofPathIndices
|
||||
uint256[] calldata _proofSiblings,
|
||||
uint8[] calldata _proofPathIndices
|
||||
) external {
|
||||
require(trees[_treeId].depth != 0, "Example: tree does not exist");
|
||||
|
||||
@@ -112,7 +112,7 @@ contract Example {
|
||||
|
||||
### Creating an Hardhat task to deploy the contract
|
||||
|
||||
```ts
|
||||
```typescript
|
||||
import { poseidon_gencontract as poseidonContract } from "circomlibjs"
|
||||
import { Contract } from "ethers"
|
||||
import { task, types } from "hardhat/config"
|
||||
|
||||
@@ -32,8 +32,8 @@ contract BinaryTreeTest {
|
||||
function removeLeaf(
|
||||
bytes32 _treeId,
|
||||
uint256 _leaf,
|
||||
uint256[] memory _proofSiblings,
|
||||
uint8[] memory _proofPathIndices
|
||||
uint256[] calldata _proofSiblings,
|
||||
uint8[] calldata _proofPathIndices
|
||||
) external {
|
||||
require(trees[_treeId].depth != 0, "BinaryTreeTest: tree does not exist");
|
||||
|
||||
|
||||
@@ -76,8 +76,8 @@ library IncrementalBinaryTree {
|
||||
function remove(
|
||||
IncrementalTreeData storage self,
|
||||
uint256 leaf,
|
||||
uint256[] memory proofSiblings,
|
||||
uint8[] memory proofPathIndices
|
||||
uint256[] calldata proofSiblings,
|
||||
uint8[] calldata proofPathIndices
|
||||
) public {
|
||||
require(verify(self, leaf, proofSiblings, proofPathIndices), "IncrementalBinaryTree: leaf is not part of the tree");
|
||||
|
||||
@@ -111,8 +111,8 @@ library IncrementalBinaryTree {
|
||||
function verify(
|
||||
IncrementalTreeData storage self,
|
||||
uint256 leaf,
|
||||
uint256[] memory proofSiblings,
|
||||
uint8[] memory proofPathIndices
|
||||
uint256[] calldata proofSiblings,
|
||||
uint8[] calldata proofPathIndices
|
||||
) private view returns (bool) {
|
||||
require(leaf < SNARK_SCALAR_FIELD, "IncrementalBinaryTree: leaf must be < SNARK_SCALAR_FIELD");
|
||||
require(
|
||||
|
||||
@@ -86,8 +86,8 @@ library IncrementalQuinTree {
|
||||
function remove(
|
||||
IncrementalTreeData storage self,
|
||||
uint256 leaf,
|
||||
uint256[4][] memory proofSiblings,
|
||||
uint8[] memory proofPathIndices
|
||||
uint256[4][] calldata proofSiblings,
|
||||
uint8[] calldata proofPathIndices
|
||||
) public {
|
||||
require(verify(self, leaf, proofSiblings, proofPathIndices), "IncrementalQuinTree: leaf is not part of the tree");
|
||||
|
||||
@@ -125,8 +125,8 @@ library IncrementalQuinTree {
|
||||
function verify(
|
||||
IncrementalTreeData storage self,
|
||||
uint256 leaf,
|
||||
uint256[4][] memory proofSiblings,
|
||||
uint8[] memory proofPathIndices
|
||||
uint256[4][] calldata proofSiblings,
|
||||
uint8[] calldata proofPathIndices
|
||||
) private view returns (bool) {
|
||||
require(leaf < SNARK_SCALAR_FIELD, "IncrementalQuinTree: leaf must be < SNARK_SCALAR_FIELD");
|
||||
require(
|
||||
|
||||
@@ -32,8 +32,8 @@ contract QuinTreeTest {
|
||||
function removeLeaf(
|
||||
bytes32 _treeId,
|
||||
uint256 _leaf,
|
||||
uint256[4][] memory _proofSiblings,
|
||||
uint8[] memory _proofPathIndices
|
||||
uint256[4][] calldata _proofSiblings,
|
||||
uint8[] calldata _proofPathIndices
|
||||
) external {
|
||||
require(trees[_treeId].depth != 0, "QuinTreeTest: tree does not exist");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user