perf: replace memory with calldata

Former-commit-id: a54c2e4895af668f3cc07ed1ecfcad8bd98dad45 [formerly 3d99a8457df4e9d658c94be7c57bc4588f73a8ef] [formerly 27ab860dc0a11e2b19ee99e21d3daa06c3f0287d [formerly 3ecf5f5bd8cb2728dc74f7e1ea71b9848e711967]] [formerly 7137f5cb35ef184c7a97e6d1ac81ee22c92d3fa1 [formerly 9ff2398acf25ce5da50364b06bd2043c55c787d5] [formerly b8c32f4b9ff05e0643822b78acbb469ee2e8ffeb [formerly efecda4f30]]]
Former-commit-id: 1f0aa4cecd03632f1e0ad0056706ae9cf5f587f9 [formerly b6d82008e8ac8d54b93b6ce913d3c23dda6d5094] [formerly fc1e523f1ecbd931100e158df4481fe2c960377e [formerly d2c561b34536d4b7f255fb406b47bab1f0399490]]
Former-commit-id: 7c5c3b1330e85de7662cb6a654f0dc1199e11c6e [formerly 8e6e2480c186aea89b319a15dca8ebdffdeba3e4]
Former-commit-id: 1d2537056fbf9de25db0f332e0533d6fea386806
This commit is contained in:
cedoor
2022-02-03 10:13:41 +01:00
parent 8cba5c11c6
commit 9400a784d7
5 changed files with 15 additions and 15 deletions

View File

@@ -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"

View File

@@ -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");

View File

@@ -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(

View File

@@ -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(

View File

@@ -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");