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

Public kernel cbind errors #437

Merged
merged 4 commits into from
May 4, 2023
Merged

Public kernel cbind errors #437

merged 4 commits into from
May 4, 2023

Conversation

rahul-kothari
Copy link
Contributor

@rahul-kothari rahul-kothari commented May 3, 2023

Description

  • Capture public kernel circuit failures and bubble up in TS (commit 1)
  • Fix mocks in circuits.js (commit 2)
  • Fix tests in sequencer, circuits! (commit 2)
    PS: Ignore test.cpp -> just linting changes

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.

@rahul-kothari rahul-kothari force-pushed the rk/kernel_cbind_errors branch 5 times, most recently from 930ba00 to f6a3ea9 Compare May 3, 2023 15:41
@rahul-kothari rahul-kothari marked this pull request as ready for review May 3, 2023 15:41
@rahul-kothari rahul-kothari changed the title Rk/kernel cbind errors Public kernel cbind errors May 3, 2023
@rahul-kothari rahul-kothari force-pushed the rk/kernel_cbind_errors branch from f6a3ea9 to d9e1cab Compare May 3, 2023 16:13
Copy link
Member

@Maddiaa0 Maddiaa0 left a comment

Choose a reason for hiding this comment

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

I've only commented on a small number of things, leaving out the majority of the public circuits stuff as I'm not 100% familiar

yarn-project/circuits.js/src/tests/factories.ts Outdated Show resolved Hide resolved
yarn-project/circuits.js/src/tests/factories.ts Outdated Show resolved Hide resolved
Copy link
Collaborator

@PhilWindle PhilWindle left a comment

Choose a reason for hiding this comment

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

Looks good to me

Copy link
Collaborator

@dbanks12 dbanks12 left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines +108 to +123
// set the msgSender for each call in the call stack
for (let i = 0; i < publicCallStackPreimages.length; i++) {
const isDelegateCall = publicCallStackPreimages[i].publicInputs.callContext.isDelegateCall;
publicCallStackPreimages[i].publicInputs.callContext.msgSender = isDelegateCall
? callStackItem.publicInputs.callContext.msgSender
: callStackItem.contractAddress;
}
Copy link
Collaborator

@spalladino spalladino May 3, 2023

Choose a reason for hiding this comment

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

Shouldn't the circuit skip these checks for empty call stack items? I'd expect that, in general, zero-items are not being checked.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm, it currently doesn't, but it probably should. I wonder though if there should be a specific flag on the call stack item indicating if it is 'empty' rather than simply testing if 'xyz == 0' which seems rather arbitrary. What do you think @iAmMichaelConnor ?

Copy link
Contributor Author

@rahul-kothari rahul-kothari May 4, 2023

Choose a reason for hiding this comment

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

I do see what you mean although there is a school of thought that that dictates we should not modify our actual code to handle testing variants

Also in a real circuit we can't skip things anyway

Copy link
Collaborator

Choose a reason for hiding this comment

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

we should not modify our actual code to handle testing variants

Fully agree. The problem here is that these are not testing variants: it's that these empty values are used in actual code to pad to the necessary number of items in the array of call stack items. Anyhow, I think @PhilWindle was tackling this in the circuit. so we should be able to remove this once the isEmpty check is added there.

yarn-project/circuits.js/src/tests/factories.ts Outdated Show resolved Hide resolved
@@ -127,7 +130,7 @@ export function makeEmptyAccumulatedData(seed = 1): CombinedAccumulatedData {
fr(seed + 13),
range(KERNEL_NEW_COMMITMENTS_LENGTH, seed + 0x100).map(fr),
range(KERNEL_NEW_NULLIFIERS_LENGTH, seed + 0x200).map(fr),
range(KERNEL_PRIVATE_CALL_STACK_LENGTH, seed + 0x300).map(fr),
new Array(KERNEL_PRIVATE_CALL_STACK_LENGTH).fill(Fr.ZERO), // private call stack must be empty
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looking at the function name, shouldn't all of these fields actually be empty?

Copy link
Collaborator

Choose a reason for hiding this comment

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

It's a badly named function (by me). Some items need to be empty and others not. It's coming back to that discussion around crafting a range of inputs in TS to satisfy circuit 'modes'.

yarn-project/circuits.js/src/tests/factories.ts Outdated Show resolved Hide resolved
@@ -838,7 +838,7 @@ current_value: 0x1514
storage_slot: 0x1514
current_value: 0x1515
]
public_call_stack: [ 0x1611 0x1612 0x1613 0x1614 ]
public_call_stack: [ 0x1f7ec2163f0e78b25257ca693b8606d5e6c940c36e2e77cd0aa1afbbf167e95a 0xbfa6e6e8892f68b806bca1fd20cf704dd5c449440b54ef2957a3d267342bda6 0x29618099103194faea4e2c1c2a77bbb165bfe89961c16369b797cfd38671a2ba 0x1403602a993517c978fd5ea6ea17c02280692bb4b84e38e1a92f8c6d1d7b858b ]
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm on the fence about this change. On one hand, it's great to have "real" values for our factories. On the other, it makes it a lot more difficult to identify issues with the serialization.

I guess that troubleshooting serialization will become less important given @ludamad's upcoming changes, so we can keep going in this direction. WDYT?

yarn-project/circuits.js/src/abis/abis.ts Show resolved Hide resolved
yarn-project/types/src/tx.ts Outdated Show resolved Hide resolved
yarn-project/types/src/tx.ts Outdated Show resolved Hide resolved
@rahul-kothari rahul-kothari force-pushed the rk/kernel_cbind_errors branch 2 times, most recently from 7fe95b0 to 1e6370b Compare May 4, 2023 11:29
@rahul-kothari rahul-kothari force-pushed the rk/kernel_cbind_errors branch from 1e6370b to ddde716 Compare May 4, 2023 11:51
Copy link
Contributor

@LHerskind LHerskind left a comment

Choose a reason for hiding this comment

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

Looks good to me.

Copy link
Collaborator

@spalladino spalladino left a comment

Choose a reason for hiding this comment

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

Looks good, thanks for the changes! Feel free to merge.

@rahul-kothari rahul-kothari force-pushed the rk/kernel_cbind_errors branch from ddde716 to d56ca5d Compare May 4, 2023 14:40
@rahul-kothari rahul-kothari force-pushed the rk/kernel_cbind_errors branch from d56ca5d to 416557d Compare May 4, 2023 14:42
@rahul-kothari rahul-kothari requested review from Maddiaa0 and PhilWindle and removed request for Maddiaa0 and PhilWindle May 4, 2023 14:43
@rahul-kothari
Copy link
Contributor Author

Ah merging is blocked until @PhilWindle approves

@rahul-kothari rahul-kothari dismissed PhilWindle’s stale review May 4, 2023 16:23

sufficient reviews

@rahul-kothari rahul-kothari merged commit 8c2810b into master May 4, 2023
@rahul-kothari rahul-kothari deleted the rk/kernel_cbind_errors branch May 4, 2023 16:23
ludamad pushed a commit that referenced this pull request Jul 14, 2023
* verification takes a pre-hashed message : Note: if len(hash) > 32 bytes, then bigfield will fail

* use hashed_message when generating signature

* modify acir structure and function to now use prehashed variant

* message -> hashed_message
codygunton pushed a commit that referenced this pull request Jan 23, 2024
* verification takes a pre-hashed message : Note: if len(hash) > 32 bytes, then bigfield will fail

* use hashed_message when generating signature

* modify acir structure and function to now use prehashed variant

* message -> hashed_message
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.

6 participants