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

Do not fail on assertions in test mode #807

Merged
merged 17 commits into from
Mar 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,17 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
_Security_ in case of vulnerabilities.
-->

## [Unreleased](https://github.com/o1-labs/snarkyjs/compare/21de489...HEAD)
## [Unreleased](https://github.com/o1-labs/snarkyjs/compare/4573252d...HEAD)

> No unreleased changes yet

## [0.9.5](https://github.com/o1-labs/snarkyjs/compare/21de489...4573252d)

### Fixed

- Failing `Mina.transaction` on Berkeley because of unsatisfied constraints caused by dummy data before we fetched account state https://github.com/o1-labs/snarkyjs/pull/807
- Previously, you could work around this by calling `fetchAccount()` for every account invovled in a transaction. This is not necessary anymore.

## [0.9.4](https://github.com/o1-labs/snarkyjs/compare/9acec55...21de489)

### Fixed
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
4d9d4ec526215f5b977f5ee9d48966398a4ad5f1
854ffb86571453e3e0a4356644f2e8e05e66da0d
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "snarkyjs",
"description": "JavaScript bindings for SnarkyJS",
"version": "0.9.4",
"version": "0.9.5",
"license": "Apache-2.0",
"type": "module",
"main": "./dist/web/index.js",
Expand Down
Binary file modified src/chrome_bindings/plonk_wasm_bg.wasm
Binary file not shown.
68 changes: 34 additions & 34 deletions src/chrome_bindings/snarky_js_chrome.bc.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/examples/zkapps/dex/dex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ function createDex({
// calculate dy outside circuit
let x = Account(this.address, Token.getId(this.tokenX)).balance.get();
let y = Account(this.address, Token.getId(this.tokenY)).balance.get();
if (x.value.isZero().toBoolean()) {
if (x.value.isConstant() && x.value.isZero().toBoolean()) {
throw Error(
'Cannot call `supplyLiquidity` when reserves are zero. Use `supplyLiquidityBase`.'
);
Expand Down
40 changes: 25 additions & 15 deletions src/examples/zkapps/hello_world/run_berkeley.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import {
AccountUpdate,
isReady,
shutdown,
fetchAccount,
PublicKey,
} from 'snarkyjs';
import { adminPrivateKey, HelloWorld } from './hello_world.js';
await isReady;
Expand Down Expand Up @@ -53,15 +51,19 @@ let transaction = await Mina.transaction(
transaction.sign([senderKey, zkappKey]);

console.log('Sending the transaction..');
await (
await transaction.send()
).wait({
maxAttempts: 90,
});
let pendingTx = await transaction.send();
if (pendingTx.hash() !== undefined) {
console.log(`
Success! Deploy transaction sent.

Your smart contract state will be deployed
as soon as the transaction is included in a block:
https://berkeley.minaexplorer.com/transaction/${pendingTx.hash()}
`);
}

console.log('Fetching updated accounts..');
await fetchAccount({ publicKey: senderKey.toPublicKey() });
await fetchAccount({ publicKey: zkappAddress });
console.log('Waiting for transaction inclusion..');
await pendingTx.wait({ maxAttempts: 90 });

console.log('Trying to update deployed zkApp..');

Expand All @@ -71,11 +73,19 @@ transaction = await Mina.transaction({ sender, fee: transactionFee }, () => {
await transaction.sign([senderKey]).prove();

console.log('Sending the transaction..');
await (
await transaction.send()
).wait({
maxAttempts: 90,
});
pendingTx = await transaction.send();

if (pendingTx.hash() !== undefined) {
console.log(`
Success! Update transaction sent.

Your smart contract state will be updated
as soon as the transaction is included in a block:
https://berkeley.minaexplorer.com/transaction/${pendingTx.hash()}
`);
}
console.log('Waiting for transaction inclusion..');
await pendingTx.wait({ maxAttempts: 90 });

console.log('Checking if the update was valid..');

Expand Down
7 changes: 2 additions & 5 deletions src/examples/zkapps/voting/membership.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import {
Permissions,
Bool,
PublicKey,
Experimental,
Circuit,
Reducer,
provablePure,
AccountUpdate,
} from 'snarkyjs';
import { Member } from './member.js';
import { ParticipantPreconditions } from './preconditions.js';
Expand Down Expand Up @@ -92,10 +92,7 @@ export class Membership_ extends SmartContract {
// even tho voters cant have a maximum balance, only candidates
// but for a voter we simply use UInt64.MAXINT() as the maximum

let accountUpdate = Experimental.createChildAccountUpdate(
this.self,
member.publicKey
);
let accountUpdate = AccountUpdate.create(member.publicKey);

accountUpdate.account.balance.assertEquals(
accountUpdate.account.balance.get()
Expand Down
Loading