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

Fix init() by removing optional key argument #908

Merged
merged 5 commits into from
May 10, 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: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,20 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

## [Unreleased](https://github.com/o1-labs/snarkyjs/compare/a632313a...HEAD)

### Breaking changes

- Remove optional `zkappKey` argument in `smartContract.init()`, and instead assert that `provedState` is false when `init()` is called https://github.com/o1-labs/snarkyjs/pull/908
- Breaks deployed zkApps which make `init()` a `@method`

### Changes

- New decorator `CatchAndPrettifyStacktrace` for printing better stack traces thrown from SnarkyJS https://github.com/o1-labs/snarkyjs/pull/890
- Cleans up stack traces by filtering out extra details, making them more readable

### Fixes

- Fix running SnarkyJS in Node.js on Windows https://github.com/o1-labs/snarkyjs-bindings/pull/19 (@wizicer)[https://github.com/wizicer]

Comment on lines +30 to +33
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Unrelated: this points to latest snarkyjs-bindings with a fix for windows o1-labs/o1js-bindings#19

## [0.10.1](https://github.com/o1-labs/snarkyjs/compare/bcc666f2...a632313a)

### Changes
Expand Down
2 changes: 1 addition & 1 deletion src/bindings
4 changes: 2 additions & 2 deletions src/examples/regression_test.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
},
"TokenContract": {
"verificationKey": {
"data": "AACta/9fFfUdI0/qW593tjrbbbFE+Yyo2Sg2k1qH1CiTD7qGZkbccABvD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ASFrms+8hDBqrUwB+fR7uD3QOdekokWKq3HkatRz0HOnNlV2Esg2+cNaFablTBnL+nxiAcTWns11tAJw49nqkN9kBA4TSgN+8kwgDpOptRD+NF2AuFyh5ZzPsWrlr+pHymZkVtJ/Q8zK+rLbNG5f+RkA6NgBRnZlNHyNdMZOv/Aeyn8rVtJNF9aockqfYZZ4ViDk=",
"hash": "1805618078121285332343482592243061319759675662039725571222151161035831907635"
"data": "AACta/9fFfUdI0/qW593tjrbbbFE+Yyo2Sg2k1qH1CiTD7qGZkbccABvDCr+rn1xhMtJo+ZGUtmSxSIgmbb4BDg8g+0rLvjL15gmqpb/xaDo3HupETgrrC7U3bYwQm3IDCNOzPJ0Cde9SFUy0tkoxiCYxcY9zTyS9RlVTXNFBDevBuwHuMHJtiW9WIimNXxrKxm+QKXHQxgDe+9xiKiWkJ4ZS9aC8IuYZsxAE5IHZzDb7aweTxT0R2LgVH1avTOO/hDVVV0hAk3MZEhPtTsEaZ5l1F7S2gsX4dvcN2pdcWFtA/rPKbDnVDqudFzx50yTR4ePr0L0ubwGMihHbaVqCJsOFBXuKJFDw5thozj3s3W1PzFCgVPC1Al6w6SSBOjoKSt4Lqi5kcBQA1aBrT450ATiIy0uKbAOO0eXjb4U1yHYM+xje0YVsVM1myDxp3mqj5YCZKsKYgw5lKEFR0iq5HEh7weO0nGyefncM0BUPxRzr6RUM/o7hHxI64W6psZ3sz3V3D3L6LGmbQX5fb6KLB7o4unLsqGzbXxd77DaRlzOP1XAnecP3cqQUsZZqEc5B5YrW+8VabpaGv5RYwCeCP4tAAveIBYbCMavukeOaC83X/6Dby4BwLcO9OD7pO10HNwAdRtGn/lp4kaqY144eWU9stRq1nG7kiUbG8n+8p3zWC5+0CD0QYYqQCksKAqEI4oFX06dfAGoazZf/vMKGp+XMGnoyW//xBN/5yH4LgRnnsPOd23iu9YFsBwT4Fz0g4ELqXxp+AhncscTMmicO34gS9YTWEIybcJ8rLZhwyo+Nx6zagDMRfYBS3lkKZRrZdU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Ka8Oyitiu6zf4SlgHiuDDMgrqT0Kf68KODEksNL+eEiN2yxpyDLBdA4OSu7er8rhqiukLw9t5eZT0Og0EmtZuijZvP0F174bFHRayRFqwHBuhXveo9vFg9eX3FxX6sBGaTPL9zd8JcUZzoLOMkHJIDu+LMcsD7fG0IxPDn1O+i1i8ZgNv3BnTOfO0DBeSoRJ9M/d3IwEvF4iJ+VlnIY46rNmbyzOC38Cg0Y6EF0KjxQ9M42+vcLrOJi+A4WxwLewg4EU/owmIk849hl5vuzIIaMQxI2alj4t1vzC6/ASFrms+8hDBqrUwB+fR7uD3QOdekokWKq3HkatRz0HOnNlV2Esg2+cNaFablTBnL+nxiAcTWns11tAJw49nqkN9kBA4TSgN+8kwgDpOptRD+NF2AuFyh5ZzPsWrlr+pHymZkVtJ/Q8zK+rLbNG5f+RkA6NgBRnZlNHyNdMZOv/Aeyn8rVtJNF9aockqfYZZ4ViDk=",
"hash": "28593848551742478364501667178690245108367789034973990488188545102321494099437"
}
},
"Dex": {
Expand Down
4 changes: 2 additions & 2 deletions src/examples/simple_zkapp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ class SimpleZkapp extends SmartContract {

events = { update: Field, payout: UInt64, payoutReceiver: PublicKey };

@method init(zkappKey: PrivateKey) {
super.init(zkappKey);
@method init() {
super.init();
this.x.set(initialState);
}

Expand Down
7 changes: 2 additions & 5 deletions src/lib/zkapp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,6 @@ class SmartContract {
!Mina.hasAccount(this.address) ||
Mina.getAccount(this.address).zkapp?.verificationKey === undefined;
if (!shouldInit) return;
if (zkappKey) this.init(zkappKey);
else this.init();
let initUpdate = this.self;
// switch back to the deploy account update so the user can make modifications to it
Expand Down Expand Up @@ -797,11 +796,9 @@ super.init();
* }
* ```
*/
init(zkappKey?: PrivateKey) {
init() {
// let accountUpdate = this.newSelf(); // this would emulate the behaviour of init() being a @method
// TODO: enable this if provedState is available, to make this callable only once
// this.account.provedState.assertEquals(Bool(false));
zkappKey?.toPublicKey().assertEquals(this.address);
this.account.provedState.assertEquals(Bool(false));
let accountUpdate = this.self;
for (let i = 0; i < ZkappStateLength; i++) {
AccountUpdate.setValue(accountUpdate.body.update.appState[i], Field(0));
Expand Down