Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Caching membership witnesses of contracts breaks interaction after deployment #2397

Closed
sirasistant opened this issue Sep 19, 2023 · 0 comments · Fixed by #2398 or #2399
Closed

Caching membership witnesses of contracts breaks interaction after deployment #2397

sirasistant opened this issue Sep 19, 2023 · 0 comments · Fixed by #2398 or #2399
Assignees

Comments

@sirasistant
Copy link
Collaborator

The following sequence fails:

sirasistant@MacBook-Pro-de-Alvaro card_game % aztec-cli deploy \       
 PrivateTokenContractAbi \
  --args 1000000 $ALICE \                 
  --salt 27                                                                              

Contract deployed at 0x266ddc72093a1ca6d32877c37ab92bcffe3c4d14c27c4832352be992e297a29c

sirasistant@MacBook-Pro-de-Alvaro card_game % aztec-cli send transfer \
  --args 500 $BOB \
  --contract-abi PrivateTokenContractAbi \
  --contract-address 0x266ddc72093a1ca6d32877c37ab92bcffe3c4d14c27c4832352be992e297a29c \
  --private-key 0x2153536ff6628eee01cf4024889ff977a18d9fa61d0e414422f7681cf085c281

Transaction has been mined
Transaction hash: 23b37f59fb14f4c1f504ef6266059deafbe1a81292cd7522ab2930422619dc0b
Status: mined

Block number: 3
Block hash: f0477801ee3a1397fc3d258fb8b5c8302e3c27e38cb3e615b04553d09a6cd0f4
sirasistant@MacBook-Pro-de-Alvaro card_game % aztec-cli deploy \       
 PrivateTokenContractAbi \
  --args 1000000 $ALICE \                 
  --salt 28                                                                              

Contract deployed at 0x1e2af112bb60040672cfef526dfaacd03857fe1fccf78b0a81717dbf0f0fcbaa

sirasistant@MacBook-Pro-de-Alvaro card_game % aztec-cli send transfer \
  --args 500 $BOB \       
  --contract-abi PrivateTokenContractAbi \
  --contract-address 0x1e2af112bb60040672cfef526dfaacd03857fe1fccf78b0a81717dbf0f0fcbaa \
  --private-key 0x2153536ff6628eee01cf4024889ff977a18d9fa61d0e414422f7681cf085c281
Error in command execution
NoRetryError: computed_contract_tree_root doesn't match purported_contract_tree_root

On a fresh sandbox, deploy one contract with a specific salt, send a transaction to it, deploy the same ABI with a different salt, try to send a transaction to it, it doesn't compute correctly the contract tree root

The cause is that we are caching membership witnesses, so after the first transfer the witness for the account contract and the token contract is cached. Then we deploy another contract and the witnesses are invalid. We should switch to only cache contract indexes, that is the only data that is both expensive to calculate and shouldn't change.

@github-project-automation github-project-automation bot moved this to Todo in A3 Sep 19, 2023
@sirasistant sirasistant self-assigned this Sep 19, 2023
@github-project-automation github-project-automation bot moved this from Todo to Done in A3 Sep 19, 2023
sirasistant added a commit that referenced this issue Sep 19, 2023
PhilWindle pushed a commit that referenced this issue Sep 19, 2023
🤖 I have created a release *beep* *boop*
---


<details><summary>aztec-packages: 0.7.9</summary>

##
[0.7.9](aztec-packages-v0.7.8...aztec-packages-v0.7.9)
(2023-09-19)


### Bug Fixes

* Don't cache contract witnesses
([#2398](#2398))
([1092060](1092060)),
closes
[#2397](#2397)
</details>

<details><summary>barretenberg.js: 0.7.9</summary>

##
[0.7.9](barretenberg.js-v0.7.8...barretenberg.js-v0.7.9)
(2023-09-19)


### Miscellaneous

* **barretenberg.js:** Synchronize aztec-packages versions
</details>

<details><summary>barretenberg: 0.7.9</summary>

##
[0.7.9](barretenberg-v0.7.8...barretenberg-v0.7.9)
(2023-09-19)


### Miscellaneous

* **barretenberg:** Synchronize aztec-packages versions
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
1 participant