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

Callbacks via composability #428

Merged
merged 23 commits into from
Sep 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
399f1c7
make account update witnessing use Circuit.witness directly
mitschabaude Sep 20, 2022
a46cae1
Merge branch 'feature/flexible-circuit-values' into feature/prove-cal…
mitschabaude Sep 27, 2022
4eadc4d
proper link
mitschabaude Sep 28, 2022
8699922
make ./run handle files with internal imports
mitschabaude Sep 28, 2022
6005cdd
make AccountUpdate a valid method argument
mitschabaude Sep 28, 2022
44e11fb
add `this.authorize` to adopt update & witness its children
mitschabaude Sep 28, 2022
1af7709
restore old ./run behaviour if the new one fails
mitschabaude Sep 28, 2022
cab5f29
fix token example
mitschabaude Sep 28, 2022
d9ab18d
use struct
mitschabaude Sep 28, 2022
7d4f500
remove redundant function
mitschabaude Sep 28, 2022
e439a9a
tweak run script again
mitschabaude Sep 28, 2022
7620804
wip callback refactor
mitschabaude Sep 28, 2022
ac99d19
helpers for pretty-printing updates
mitschabaude Sep 28, 2022
d5993ab
tweak witness to just get & return fields
mitschabaude Sep 28, 2022
1dc386a
clone updates when witnessing, so prover doesn't interfere with tx
mitschabaude Sep 28, 2022
dfb14c5
Merge branch 'main' into feature/prove-callback
mitschabaude Sep 28, 2022
2bf421b
fixes
mitschabaude Sep 28, 2022
b012a9c
avert future name clash
mitschabaude Sep 29, 2022
b926b72
make unit tests rely on existing build
mitschabaude Sep 29, 2022
fb99676
merge accountUpdateFromCallback into authorize
mitschabaude Sep 29, 2022
b92044d
changelog
mitschabaude Sep 29, 2022
d528851
make child layout spec more verbose and understandable
mitschabaude Sep 29, 2022
3da779d
update bindings
mitschabaude Sep 29, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added `VerificationKey`, which is a `Struct` with auxiliary data, to pass verification keys to a `@method`
- BREAKING CHANGE: Change names related to circuit types: `AsFieldsAndAux<T>` -> `Provable<T>`, `AsFieldElement<T>` -> `ProvablePure<T>`, `circuitValue` -> `provable`
- BREAKING CHANGE: Change all `ofFields` and `ofBits` methods on circuit types to `fromFields` and `fromBits`
- BREAKING CHANGE: `tx.send()` is now asynchronous: old: `send(): TransactionId` new: `send(): Promise<TransactionId>` and `tx.send()` now directly sends the transaction to the network, as opposed to `tx.send().wait()`
- `SmartContract.experimental.authorize` to authorize a tree of child account updates https://github.com/o1-labs/snarkyjs/pull/428
- AccountUpdates are now valid `@method` arguments, and `authorize` is intended to be used on them when passed to a method
- Also replaces `Experimental.accountUpdateFromCallback`

### Changed

- BREAKING CHANGE: `tx.send()` is now asynchronous: old: `send(): TransactionId` new: `send(): Promise<TransactionId>` and `tx.send()` now directly waits for the network response, as opposed to `tx.send().wait()`

### Deprecated

Expand Down
2 changes: 1 addition & 1 deletion MINA_COMMIT
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
The mina commit used to generate the backends for node and chrome is
f8510eea3ba66dc877492f0218d83a9171576133
f6e1b20d62adc7db277bfcc6dfd7f5aed710928f
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"dev": "npx tsc -p tsconfig.node.json && cp src/snarky.d.ts dist/node/snarky.d.ts",
"make": "make -C ../../../.. snarkyjs",
"build": "rimraf ./dist/node && npx tsc -p tsconfig.node.json && cp -r src/node_bindings dist/node/_node_bindings && node src/build/buildNode.js && cp src/snarky.d.ts dist/node/snarky.d.ts",
"build:test": "rimraf ./dist/test && npx tsc -p tsconfig.test.json && cp -r src/node_bindings dist/test/_node_bindings && cp src/snarky.d.ts dist/test/snarky.d.ts",
"build:test": "npx tsc -p tsconfig.test.json && cp src/snarky.d.ts dist/node/snarky.d.ts",
"build:node": "npm run build",
"build:web": "rimraf ./dist/web && node src/build/buildWeb.js",
"build:examples": "rimraf ./dist/examples && npx tsc -p tsconfig.examples.json || exit 0",
Expand Down
6 changes: 3 additions & 3 deletions run-integration-tests.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
./run src/examples/zkapps/hello_world/run.ts || exit 1
./run src/examples/zkapps/voting/run.ts || exit 1
./run src/examples/zkapps/hello_world/run.ts --bundle || exit 1
./run src/examples/zkapps/voting/run.ts --bundle || exit 1
./run src/examples/simple_zkapp.ts || exit 1
./run src/examples/zkapps/reducer/reducer_composite.ts || exit 1
./run src/examples/zkapps/composability.ts || exit 1
./run src/examples/zkapps/token_with_proofs.ts || exit 1
./run src/examples/zkapps/dex/run.ts || exit 1
./run src/examples/zkapps/dex/run.ts --bundle || exit 1
2 changes: 1 addition & 1 deletion run-unit-tests.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
npm run build:test
for f in ./dist/test/**/*.unit-test.js; do
for f in ./dist/node/**/*.unit-test.js; do
echo "Running $f"
node $f || exit 1;
done
25 changes: 24 additions & 1 deletion src/build/buildExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import path from 'path';
import ts from 'typescript';
import esbuild from 'esbuild';

export { buildAndImport, build };
export { buildAndImport, build, buildOne };

async function buildAndImport(srcPath, { keepFile = false }) {
let absPath = await build(srcPath);
Expand Down Expand Up @@ -37,6 +37,29 @@ async function build(srcPath) {
return absPath;
}

async function buildOne(srcPath) {
let tsConfig = findTsConfig() ?? defaultTsConfig;

let outfile = path.resolve(
'./dist/node',
srcPath.replace('.ts', '.js').replace('src', '.')
);

await esbuild.build({
entryPoints: [srcPath],
format: 'esm',
platform: 'node',
outfile,
target: 'esnext',
resolveExtensions: ['.node.js', '.ts', '.js'],
logLevel: 'error',
plugins: [typescriptPlugin(tsConfig)],
});

let absPath = path.resolve('.', outfile);
return absPath;
}

const defaultTsConfig = {
compilerOptions: {
module: 'esnext',
Expand Down
27 changes: 17 additions & 10 deletions src/build/run.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,33 @@
#!/usr/bin/env node
import minimist from 'minimist';
import { buildAndImport } from './buildExample.js';
import { shutdown } from '../../dist/node/index.js';
import { buildAndImport, buildOne } from './buildExample.js';

let {
_: [filePath],
main,
default: runDefault,
keypair: keyPair,
keep,
bundle,
} = minimist(process.argv.slice(2));

if (!filePath) {
console.log(`Usage:
npx snarky-run [file]`);
process.exit(0);
}

let module = await buildAndImport(filePath, { keepFile: !!keep });
if (main) await module.main();
if (runDefault) await module.default();
if (keyPair) {
console.log(module.default.generateKeypair());
if (!bundle) {
let absPath = await buildOne(filePath);
console.log(`running ${absPath}`);
let module = await import(absPath);
if (main) await module.main();
if (runDefault) await module.default();
let { shutdown } = await import('../../dist/node/index.js');
shutdown();
} else {
let { isReady, shutdown } = await import('../../dist/node/index.js');
await isReady;
let module = await buildAndImport(filePath, { keepFile: !!keep });
if (main) await module.main();
if (runDefault) await module.default();
shutdown();
}
shutdown();
Loading