-
Notifications
You must be signed in to change notification settings - Fork 275
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
chore: Use Noir javascript packages to execute the private kernel circuit init using the typescript generated types #2763
Merged
sirasistant
merged 18 commits into
feature_branch/private-kernel
from
kw/abi-types-encoding
Oct 11, 2023
Merged
Changes from 15 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
f2ad8b1
add package.json and initial test
kevaundray 45f2c34
add FixedLengthArray and change ReturnType to be an alias of the type…
kevaundray cd013f7
modify noir code to fix bug
kevaundray 03f47ec
regenerate bindings
kevaundray 6d6f9b9
modify type conversion code to cast to FixedSizeArrayLength -- typesc…
kevaundray f3f9f57
refactor test
kevaundray 2a287b6
remove .only
kevaundray 2bd6ac6
Merge remote-tracking branch 'origin/feature_branch/private-kernel' i…
kevaundray 5b6572f
fix import
kevaundray 105401e
remove now redundant test and cleanup import
kevaundray c886083
move logic to abiEncode/Decode and execute into a function in index.ts
kevaundray 737c6ca
comment update
kevaundray 6ed7f92
tech debt: expose makePrivateKernelInputsInit
kevaundray f5261c6
redo tests to use executeInit
kevaundray 93d33c5
given makePrivateKernelInputsInit, we can remove the manual instance …
kevaundray 1f77fd8
yarn formatting
kevaundray 4dc0526
style: formatting
sirasistant 7d11cca
chore: fix format and deps
sirasistant File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
yarn-project/noir-private-kernel/src/crates/bug-collecting-crate/tom-typechain.nr
This file was deleted.
Oops, something went wrong.
83 changes: 83 additions & 0 deletions
83
yarn-project/noir-private-kernel/src/crates/bug-collecting-crate/typechain-type-alias.nr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
The typescript binding generator has a bug when we use type aliases because | ||
the abi says that they have the same struct path. | ||
|
||
For example: | ||
|
||
|
||
|
||
struct Generic<N> { | ||
x : [Field; N] | ||
} | ||
|
||
struct Concrete { | ||
gen2 : Generic<2>, | ||
gen4 : Generic<4>, | ||
|
||
} | ||
|
||
fn main(input: Concrete) -> pub Field { | ||
0 | ||
} | ||
|
||
|
||
The following code will generate the json: | ||
|
||
{"hash":17271335012890464242,"backend":"acvm-backend-barretenberg","abi":{"parameters":[{"name":"input","type":{"kind":"struct","path":"Concrete","fields":[{"name":"gen2","type":{"kind":"struct","path":"Generic","fields":[{"name":"x","type":{"kind":"array","length":2,"type":{"kind":"field"}}}]}},{"name":"gen4","type":{"kind":"struct","path":"Generic","fields":[{"name":"x","type":{"kind":"array","length":4,"type":{"kind":"field"}}}]}}]},"visibility":"private"}],"param_witnesses":{"input":[1,2,3,4,5,6]},"return_type":{"kind":"field"},"return_witnesses":[7]},"bytecode":"H4sIAAAAAAAA/6WPSwqAMAxE69/jJE3SJjuvYrG9/xEsqFDQnQ8egVmEmdU517k3T7bdlyAw5+gzEu7gLakASwqKiqJyeCXKyhotWQRDpoxFjApcLM0v+MncdOyrQ3WsTtX5Y8PSZCeMnX6J8AAAAA=="} | ||
|
||
And subsequently generate this typescript file: | ||
|
||
export type FixedLengthArray<T, L extends number> = L extends 0 ? never[]: T[] & { length: L } | ||
|
||
export type Field = string; | ||
|
||
export interface Generic { | ||
x: FixedLengthArray<Field, 2>; | ||
} | ||
|
||
|
||
|
||
export interface Concrete { | ||
gen2: Generic; | ||
gen4: Generic; | ||
} | ||
|
||
export interface ReturnType { | ||
value: Field; | ||
} | ||
|
||
export interface InputType { | ||
input: Concrete; | ||
} | ||
|
||
---- | ||
|
||
The important thing to notice is that there is one Generic and it gets instantiated with | ||
the length of the first parameter. | ||
|
||
We can go two ways with this, either we end up with something like: | ||
|
||
export interface Generic<N extends number> { | ||
x: FixedLengthArray<Field, N>; | ||
} | ||
|
||
export interface Concrete { | ||
gen2: Generic<2>; | ||
gen4: Generic<4>; | ||
} | ||
|
||
or we do something like: | ||
|
||
export interface Generic2 { | ||
x: FixedLengthArray<Field, 2>; | ||
} | ||
export interface Generic4 { | ||
x: FixedLengthArray<Field, 2>; | ||
} | ||
|
||
export interface Concrete { | ||
gen2: Generic2; | ||
gen4: Generic4; | ||
} | ||
|
||
First seems to have better devex and less copy pasting but requires more complicated code. | ||
Perhaps this can be aided by the compiler, if we save this information before monomorphization |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
yarn-project/noir-private-kernel/src/target/private_kernel_init.json
Large diffs are not rendered by default.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
yarn-project/noir-private-kernel/src/target/private_kernel_inner.json
Large diffs are not rendered by default.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
yarn-project/noir-private-kernel/src/target/private_kernel_ordering.json
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is okay tech debt at the moment -- until we want to merge into master, without it we will need to manually make an instance of PrivateKernelInputsInit in noir-private-kernel in order to have tests