Skip to content

e2e test for a public token transfer#325

Merged
PhilWindle merged 36 commits into
masterfrom
janb/e2e_public_token
May 5, 2023
Merged

e2e test for a public token transfer#325
PhilWindle merged 36 commits into
masterfrom
janb/e2e_public_token

Conversation

@benesjan

@benesjan benesjan commented Apr 21, 2023

Copy link
Copy Markdown
Contributor

Description

Fixes #265

Checklist:

  • I have reviewed my diff in github, line by line.
  • Every change is related to the PR description.
  • I have linked this pull request to the issue(s) that it resolves.
  • There are no unexpected formatting changes, superfluous debug logs, or commented-out code.
  • The branch has been merged or rebased against the head of its merge target.
  • I'm happy for the PR to be merged at the reviewer's next convenience.

@benesjan benesjan marked this pull request as draft April 21, 2023 09:31
@benesjan benesjan force-pushed the janb/e2e_public_token branch 3 times, most recently from 17c5d71 to d4c7774 Compare April 25, 2023 07:55
@benesjan benesjan force-pushed the janb/e2e_public_token branch from abe7659 to b83a2d9 Compare April 25, 2023 13:25
@spypsy spypsy marked this pull request as ready for review May 3, 2023 14:17

describe('mint', () => {
it('should run the mint function', async () => {
it.only('should run the mint function', async () => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why did this change?

// Retry fetching from the storage slot until it's non-zero
const fn = async () => {
const storageSlot = await calculateStorageSlot(accountIdx);
console.log('storage slot', storageSlot.toString());

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Remove the console logs. If we want to log we should use the logger object.

this.sequencer.restart();
}

public getStateTransitions() {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I don't think we want this.

const privateDataTreeInfo = await this.db.getTreeInfo(MerkleTreeId.PRIVATE_DATA_TREE);
const nullifierTreeInfo = await this.db.getTreeInfo(MerkleTreeId.NULLIFIER_TREE);

publicKernelOutput.constants.historicTreeRoots.privateHistoricTreeRoots.nullifierTreeRoot = Fr.fromBuffer(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@spalladino we had to add these as there is a validation step in the circuit block builder that failed otherwise. It looks like there is a bit of a hack in aztec node to supply these values for private functions.

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.

Heh, that's exactly what I pushed yesterday for private functions, see #425

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.

So I think we should not be adding these manually to the kernel circuit output, but rather we should make sure they are available as part of the inputs, and the circuit should be forwarding them to the outputs.

I think the problem is that the PublicKernelInputsNoPreviousKernel, having no previous kernel, has no access to the constants, so it never receives the tree roots as input and cannot forward them to the outputs (as the private kernel circuit does here).

The fix would be to modify the PublicKernelInputsNoPreviousKernel so it also receives a CombinedConstantData which is used to populate the outputs. However, if we're removing this circuit, maybe we can just live with this hack a bit longer.

WDYT @PhilWindle?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think the plan is to modify the private kernel circuit so it also has a 'no previous kernel' mode which would result in the same issue. A question for @iAmMichaelConnor really. In the case of 'no previous kernel' iterations, should the constant data (tree roots) be supplied as an input to the circuit so the circuit can forward it to the circuit's public inputs? Currently the caller of the circuit (aztec rpc or sequencer) has to enrich this data after the 'no previous kernel' iteration.


// Pad arrays to reach required length
const result = await execution.run();
const args = tx.args;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@sirasistant we had an issue running the acvm that it was complaining of arrays not being padded. So for example the args array only had 3 items instead of 8. I couldn't find if/where you were padding the arrays in the private client.

Comment on lines +259 to +260
const isSynced = await accountState?.isSynchronised();
if (accountState && !isSynced) {

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.

This change causes isSynchronised to be queried always, which involves a roundtrip to the node. Should we revert this?

Comment on lines +89 to +92
if (storageValue === undefined) {
throw new Error(`Storage slot ${storageSlot} not found`);
}

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.

Suggested change
if (storageValue === undefined) {
throw new Error(`Storage slot ${storageSlot} not found`);
}

Duplicated

Comment thread yarn-project/end-to-end/src/e2e_public_token_contract.test.ts Outdated
args.push(...new Array<Fr>(ARGS_LENGTH - tx.args.length).fill(Fr.ZERO));

const { stateReads, stateTransitions, returnValues } = result;
returnValues.push(...new Array<Fr>(RETURN_VALUES_LENGTH - result.returnValues.length).fill(Fr.ZERO));

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.

We need a nicer pad function :-P

@spypsy spypsy force-pushed the janb/e2e_public_token branch from ba89fcc to c9ca30f Compare May 5, 2023 13:57
@spypsy spypsy requested a review from PhilWindle May 5, 2023 15:41
@PhilWindle PhilWindle merged commit dfbe051 into master May 5, 2023
@PhilWindle PhilWindle deleted the janb/e2e_public_token branch May 5, 2023 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Write the e2e test for a public token transfer

4 participants