Skip to content

Commit

Permalink
Merge pull request #428 from o1-labs/feature/prove-callback
Browse files Browse the repository at this point in the history
Callbacks via composability
  • Loading branch information
mitschabaude committed Sep 29, 2022
2 parents c58d9ba + 3da779d commit 3196fef
Show file tree
Hide file tree
Showing 30 changed files with 16,221 additions and 16,150 deletions.
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

0 comments on commit 3196fef

Please sign in to comment.