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

represent whether signed and/or proven within Transaction type + rework prove method #1567

Merged
merged 27 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
688304b
enable chaining prove, typedocs
harrysolovay Apr 12, 2024
4b359d2
get rid of needless console log in example
harrysolovay Apr 12, 2024
abdf47d
improve TransactionPromise typing
harrysolovay Apr 12, 2024
ed4d448
revert example change
harrysolovay Apr 12, 2024
e8a23da
typing mania
harrysolovay Apr 12, 2024
d718c28
remove default type param and clean up example
harrysolovay Apr 12, 2024
a10a4c4
add signed type to Transaction and TransactionPromise
harrysolovay Apr 12, 2024
f365521
fix signature of sendTransaction in mina-instance
harrysolovay Apr 12, 2024
38e0874
add todo comment
harrysolovay Apr 12, 2024
f990ce6
make proof plural
harrysolovay Apr 12, 2024
1ad5726
add to changelog
harrysolovay Apr 12, 2024
9a4354c
clean up changelog sentence
harrysolovay Apr 12, 2024
f3a0276
more changelog cleanup
harrysolovay Apr 12, 2024
02c6f47
Transaction shadowing in the same file
harrysolovay Apr 13, 2024
9b4bfe8
remove changelog heading
harrysolovay Apr 13, 2024
e9f47ab
fix merge conflicts
harrysolovay Apr 16, 2024
dc59a79
fix integration test error
harrysolovay Apr 16, 2024
3bf2b8e
sync w upstream and fix merge conflicts
harrysolovay Apr 17, 2024
ea5e13b
make proofs into a method
harrysolovay Apr 17, 2024
442c340
clean up reducer-composite eg
harrysolovay Apr 17, 2024
68c7fab
Merge branch 'main' into prove-in-chain
MartinMinkov Apr 17, 2024
ed7b7c0
Merge branch 'prove-in-chain' of github.com:harrysolovay/o1js into pr…
MartinMinkov Apr 17, 2024
c60ac20
feat(local-blockchain): fix support for actions
MartinMinkov Apr 17, 2024
02f9777
feat(examples): fixup examples causing issues in integration tests
MartinMinkov Apr 17, 2024
c60ecf0
chore(mina): update mina submodule to latest commit for up-to-date fe…
MartinMinkov Apr 17, 2024
155a12b
fix(fake-proof.ts): change the way contractProof is extracted from tx…
MartinMinkov Apr 17, 2024
8e76633
fix(on-chain-state-mgmt-zkapp-ui.js): change proof extraction from tr…
MartinMinkov Apr 17, 2024
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,14 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- `Mina.LocalBlockchain` no longer supports the network kind configuration https://github.com/o1-labs/o1js/pull/1581
- `Poseidon.hashToGroup()` now returns a `Group` directly, and constrains it to be deterministic https://github.com/o1-labs/o1js/pull/1546
- Added `Poseidon.Unsafe.hashToGroup()` as a more efficient, non-deterministic version for advanced use cases
- A `Transaction`'s `prove` method no longer returns the proofs promise directly, but rather returns a `Transaction` promise, the resolved value of which contains a `proofs` prop. https://github.com/o1-labs/o1js/pull/1567
- The `Transaction` type now has two type params `Proven extends boolean` and `Signed extends boolean`, which are used to conditionally show/hide relevant state. https://github.com/o1-labs/o1js/pull/1567

### Added

- Export `Events` under `AccountUpdate.Events`. https://github.com/o1-labs/o1js/pull/1563
- `Mina.transaction` has been reworked such that one can call methods directly on the returned promise (now a `TransactionPromise`). This enables a fluent / method-chaining API. https://github.com/o1-labs/o1js/pull/1567
- `TransactionPendingPromise` enables calling `wait` directly on the promise returned by calling `send` on a `Transaction`. https://github.com/o1-labs/o1js/pull/1567
- `initializeBindings()` to explicitly trigger setup work that is needed when running provable code https://github.com/o1-labs/o1js/pull/1583
- calling this function is optional

Expand Down
2 changes: 1 addition & 1 deletion src/bindings
Submodule bindings updated 0 files
20 changes: 16 additions & 4 deletions src/examples/chaining-tx-methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
SmartContract,
Mina,
AccountUpdate,
TransactionPromise,
} from 'o1js';

class SimpleZkapp extends SmartContract {
Expand Down Expand Up @@ -52,10 +53,21 @@ await Mina.transaction(sender, async () => {
console.log('initial state: ' + zkapp.x.get());

console.log('increment');
const incrementTx = Mina.transaction(sender, async () => {

await Mina.transaction(sender, async () => {
await zkapp.increment();
}).sign([sender.key]);
await incrementTx.then((v) => v.prove());
await incrementTx.send().wait();
})
.prove()
.sign([sender.key])
.send()
.wait();

console.log('final state: ' + zkapp.x.get());

const a = Mina.transaction(sender, async () => {
await zkapp.increment();
});
a satisfies TransactionPromise<false, false>;
const b = a.prove() satisfies TransactionPromise<true, false>;
const c = b.sign([sender.key]) satisfies TransactionPromise<true, true>;
await c.send().wait();
4 changes: 2 additions & 2 deletions src/examples/zkapps/hello-world/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ let txn, txn2, txn3, txn4;
let Local = await Mina.LocalBlockchain({ proofsEnabled: false });
Mina.setActiveInstance(Local);

// test accounts that pays all the fees, and puts additional funds into the zkapp
// test accounts that pays all the fees, and puts additional funds into the contract
const [feePayer1, feePayer2, feePayer3, feePayer4] = Local.testAccounts;

// zkapp account
// contract account
const contractAccount = Mina.TestPublicKey.random();
const contract = new HelloWorld(contractAccount);

Expand Down
45 changes: 26 additions & 19 deletions src/examples/zkapps/simple-zkapp-with-proof.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ let { verificationKey: trivialVerificationKey } = await TrivialZkapp.compile();
// submitting transactions? or is this an irrelevant use case?
// would also improve the return type -- `Proof` instead of `(Proof | undefined)[]`
console.log('prove (trivial zkapp)');
let [trivialProof] = await (
await Mina.transaction(feePayer, async () => {
await new TrivialZkapp(notSoSimpleContractAccount).proveSomething(Field(1));
})
).prove();
let [trivialProof] = await Mina.transaction(feePayer, async () => {
await new TrivialZkapp(notSoSimpleContractAccount).proveSomething(Field(1));
})
.prove()
.proofs();

trivialProof = await testJsonRoundtripAndVerify(
TrivialProof,
Expand All @@ -73,19 +73,22 @@ let { verificationKey } = await NotSoSimpleZkapp.compile();
let zkapp = new NotSoSimpleZkapp(trivialContractAccount);

console.log('deploy');
let tx = await Mina.transaction(feePayer, async () => {
await Mina.transaction(feePayer, async () => {
AccountUpdate.fundNewAccount(feePayer);
await zkapp.deploy();
});
await tx.prove();
await tx.sign([feePayer.key, trivialContractAccount.key]).send();
})
.prove()
.sign([feePayer.key, trivialContractAccount.key])
.send();

console.log('initialize');
tx = await Mina.transaction(feePayer, async () => {
let tx = await Mina.transaction(feePayer, async () => {
await zkapp.initialize(trivialProof!);
});
let [proof] = await tx.prove();
await tx.sign([feePayer.key]).send();
})
.prove()
.sign([feePayer.key]);
let [proof] = tx.proofs;
await tx.send();

proof = await testJsonRoundtripAndVerify(
NotSoSimpleZkapp.Proof(),
Expand All @@ -98,9 +101,11 @@ console.log('initial state: ' + zkapp.x.get());
console.log('update');
tx = await Mina.transaction(feePayer, async () => {
await zkapp.update(Field(3), proof!, trivialProof!);
});
[proof] = await tx.prove();
await tx.sign([feePayer.key]).send();
})
.prove()
.sign([feePayer.key]);
[proof] = tx.proofs;
await tx.send();

proof = await testJsonRoundtripAndVerify(
NotSoSimpleZkapp.Proof(),
Expand All @@ -113,9 +118,11 @@ console.log('state 2: ' + zkapp.x.get());
console.log('update');
tx = await Mina.transaction(feePayer, async () => {
await zkapp.update(Field(3), proof!, trivialProof!);
});
[proof] = await tx.prove();
await tx.sign([feePayer.key]).send();
})
.prove()
.sign([feePayer.key]);
[proof] = tx.proofs;
await tx.send();

proof = await testJsonRoundtripAndVerify(
NotSoSimpleZkapp.Proof(),
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export { MerkleList, MerkleListIterator } from './lib/provable/merkle-list.js';

export * as Mina from './lib/mina/mina.js';
export {
type Transaction,
Transaction,
type TransactionPromise,
type PendingTransaction,
type IncludedTransaction,
Expand Down
Loading
Loading