Skip to content

feat: replace private token in testing#2304

Merged
LHerskind merged 6 commits into
masterfrom
lh/remove_private_token
Sep 18, 2023
Merged

feat: replace private token in testing#2304
LHerskind merged 6 commits into
masterfrom
lh/remove_private_token

Conversation

@LHerskind

@LHerskind LHerskind commented Sep 14, 2023

Copy link
Copy Markdown
Contributor

Fixes #2301.

Replaces the private token in most testing. Not altering docs and some of the cli_docs testing.

Checklist:

Remove the checklist to signal you've completed it. Enable auto-merge if the PR is ready to merge.

  • If the pull request requires a cryptography review (e.g. cryptographic algorithm implementations) I have added the 'crypto' tag.
  • I have reviewed my diff in github, line by line and removed unexpected formatting changes, testing logs, or commented-out code.
  • Every change is related to the PR description.
  • I have linked this pull request to relevant issues (if any exist).

@LHerskind LHerskind force-pushed the lh/remove_private_token branch from 9864fd1 to 87aa0a0 Compare September 14, 2023 16:08
@LHerskind LHerskind force-pushed the lh/removing_native_token branch from 2b379f7 to e284b94 Compare September 15, 2023 11:36
@LHerskind LHerskind force-pushed the lh/remove_private_token branch from 87aa0a0 to 7c8dc95 Compare September 15, 2023 11:55
Base automatically changed from lh/removing_native_token to master September 15, 2023 11:59
@LHerskind LHerskind force-pushed the lh/remove_private_token branch 2 times, most recently from 17466aa to 33225d8 Compare September 16, 2023 07:20
@LHerskind LHerskind changed the title feat: remove private token feat: replace private token in testing Sep 16, 2023
@LHerskind LHerskind force-pushed the lh/remove_private_token branch from b57a57e to 9fc02a8 Compare September 16, 2023 16:44
@LHerskind LHerskind marked this pull request as ready for review September 16, 2023 18:40

@Maddiaa0 Maddiaa0 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, have a few nits, just points for discussion though rather than issues

});

describe('private token contract', () => {
describe('stateful test contract contract', () => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: double contract

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean by double contract?

@Maddiaa0 Maddiaa0 Sep 17, 2023

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It says contract twice

stateful test contract contract

aztec-cli send _initialize \
--args $ALICE \
--contract-abi TokenContractAbi \
--contract-address 0x2d23acefa3ce07b3c308caf78d86c064cdf8957bcea48b38753cf58441796c8c \

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably worth making the address a param if its used alot / fixed. especially since its in the docs

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Josh has a PR open for this and we will probably nuke this file so I think it's ok to not do that change here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned in #2304 (comment), nuke it.

const secret = Fr.random();
const secretHash = await computeMessageSecretHash(secret);

await token.methods.mint_private(50, secretHash).send().wait();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in general all of these could probably be sped up in the tests by sending the promises together and doing a Promise.all.
Or is this not doable as we require the mint private to happen before the redeem

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If done with promise all it still got in as separate txs, so it cannot perform the second part that depends on the first. Might be replaces with requests I guess to do it in the same tx.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nvm, we can't do it in same tx because the mint_private is a public call and we need the result in private.

token = await Contract.deploy(owner, PrivateTokenArtifact, [100n, owner.getAddress()]).send().deployed();

token = await Contract.deploy(owner, TokenContractAbi, []).send().deployed();
await token.methods._initialize({ address: owner.getAddress() }).send().wait();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, we might want to move the docs:start:setup to another example now, as this has rough syntax with the initialise

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's ugly but I feel that if we explain it in the docs why it's necessary to call here it's ok given that we'll change in hopefully not-too-distant future. @LHerskind do you know if the work allowing for public calls from constructor has been mapped out?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think it might be fine to point out that you need to initialise if you need any private values set etc, and that it is horribly insecure but it will be addressed when constructor can do calls.

@benesjan benesjan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍

token = await Contract.deploy(owner, PrivateTokenArtifact, [100n, owner.getAddress()]).send().deployed();

token = await Contract.deploy(owner, TokenContractAbi, []).send().deployed();
await token.methods._initialize({ address: owner.getAddress() }).send().wait();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's ugly but I feel that if we explain it in the docs why it's necessary to call here it's ok given that we'll change in hopefully not-too-distant future. @LHerskind do you know if the work allowing for public calls from constructor has been mapped out?

aztec-cli send _initialize \
--args $ALICE \
--contract-abi TokenContractAbi \
--contract-address 0x2d23acefa3ce07b3c308caf78d86c064cdf8957bcea48b38753cf58441796c8c \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Josh has a PR open for this and we will probably nuke this file so I think it's ok to not do that change here.

@LHerskind

Copy link
Copy Markdown
Contributor Author

@LHerskind do you know if the work allowing for public calls from constructor has been mapped out?

Not sure, maybe @iAmMichaelConnor and @PhilWindle started on it?

@LHerskind LHerskind merged commit 934ba96 into master Sep 18, 2023
@LHerskind LHerskind deleted the lh/remove_private_token branch September 18, 2023 09:14
@iAmMichaelConnor

Copy link
Copy Markdown
Contributor

@LHerskind do you know if the work allowing for public calls from constructor has been mapped out?

Not sure, maybe @iAmMichaelConnor and @PhilWindle started on it?

There's just a github issue at the moment, sitting there for someone to pick up and discuss, then build, when they have time. #2249

spypsy pushed a commit that referenced this pull request Sep 18, 2023
🤖 I have created a release *beep* *boop*
---


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

##
[0.7.6](aztec-packages-v0.7.5...aztec-packages-v0.7.6)
(2023-09-18)


### Features

* New api to get note nonces
([#2327](#2327))
([8f5eb28](8f5eb28))
* Replace private token in testing
([#2304](#2304))
([934ba96](934ba96))


### Bug Fixes

* Exit with error log when COMMIT_TAG is not set properly on canary
([#2371](#2371))
([68fe053](68fe053))
* Preserve public function call ordering in account entrypoint
([#2348](#2348))
([5b2cf75](5b2cf75))
* Return output-debug flag
([#2364](#2364))
([af86580](af86580))
* Revert "fix: strip leading 'v' from dockerhub tags"
([#2367](#2367))
([53bc041](53bc041))
* Stale CLI docs
([#2336](#2336))
([f38873b](f38873b))
* Strip leading 'v' from dockerhub tags
([#2360](#2360))
([a4bb05c](a4bb05c))


### Miscellaneous

* Added docs for artifact files
([#2362](#2362))
([6d3ba3f](6d3ba3f)),
closes
[#2190](#2190)
* **aztec_noir:** Remove inputs from consume l1 to l2 message
([#2354](#2354))
([2235f7c](2235f7c))
* Remove "as unknown" casts for ABIs where possible
([#2331](#2331))
([bf2651e](bf2651e))
* Script to extract tag version
([#2368](#2368))
([4b686b0](4b686b0))
* Share e2e code with canary
([#2299](#2299))
([21224de](21224de))
</details>

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

##
[0.7.6](barretenberg.js-v0.7.5...barretenberg.js-v0.7.6)
(2023-09-18)


### Miscellaneous

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

<details><summary>barretenberg: 0.7.6</summary>

##
[0.7.6](barretenberg-v0.7.5...barretenberg-v0.7.6)
(2023-09-18)


### 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

No open projects
Archived in project

Development

Successfully merging this pull request may close these issues.

Replace private_token in testing

4 participants