Skip to content

Commit 8e56de5

Browse files
Merge pull request #1073 from ProvableHQ/feat/query-trait
Implement snapshot query trait
2 parents 0f3c60c + 545848d commit 8e56de5

File tree

49 files changed

+2363
-1489
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+2363
-1489
lines changed

.github/workflows/staging-website.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
uses: actions-rs/toolchain@v1
1919
with:
2020
profile: minimal
21-
toolchain: nightly-2025-01-16
21+
toolchain: nightly-2025-08-28
2222
override: true
2323
components: rustfmt, rust-src
2424

.github/workflows/test-website.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
uses: actions-rs/toolchain@v1
1616
with:
1717
profile: minimal
18-
toolchain: nightly-2025-01-16
18+
toolchain: nightly-2025-08-28
1919
override: true
2020
components: rustfmt, rust-src
2121

.github/workflows/website.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
uses: actions-rs/toolchain@v1
1919
with:
2020
profile: minimal
21-
toolchain: nightly-2025-01-16
21+
toolchain: nightly-2025-08-28
2222
override: true
2323
components: rustfmt, rust-src
2424

create-leo-app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "create-leo-app",
3-
"version": "0.9.7",
3+
"version": "0.9.8",
44
"type": "module",
55
"license": "GPL-3.0",
66
"collaborators": [

create-leo-app/template-extension/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"build": "rimraf static/js && rollup --config"
88
},
99
"devDependencies": {
10-
"@provablehq/sdk": "^0.9.7",
10+
"@provablehq/sdk": "^0.9.8",
1111
"@web/rollup-plugin-import-meta-assets": "^2.2.1",
1212
"rimraf": "^6.0.1",
1313
"rollup": "^4.32.0"

create-leo-app/template-nextjs-ts/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"lint": "next lint"
1010
},
1111
"dependencies": {
12-
"@provablehq/sdk": "^0.9.7",
12+
"@provablehq/sdk": "^0.9.8",
1313
"next": "15.2.3",
1414
"react": "^19.0.0",
1515
"react-dom": "^19.0.0",

create-leo-app/template-node-ts/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"dev": "npm run build && node dist/index.js"
99
},
1010
"dependencies": {
11-
"@provablehq/sdk": "^0.9.7"
11+
"@provablehq/sdk": "^0.9.8"
1212
},
1313
"devDependencies": {
1414
"rimraf": "^6.0.1",

create-leo-app/template-node/index.js

Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
import {Account, initThreadPool, ProgramManager, AleoKeyProvider, AleoKeyProviderParams} from "@provablehq/sdk";
1+
import {Account, AleoKeyProvider, AleoKeyProviderParams, initThreadPool, ProgramManager, PrivateKey} from "@provablehq/sdk";
22

3-
await initThreadPool();
3+
import * as process from "node:process";
4+
5+
// await initThreadPool();
46

57
const programName = "hello_hello.aleo"
68

@@ -13,7 +15,7 @@ function hello:
1315
add r0 r1 into r2;
1416
output r2 as u32.private;`
1517

16-
async function localProgramExecution(program, programName, aleoFunction, inputs) {
18+
async function localProgramExecution(program, programName, functionName, inputs) {
1719
const programManager = new ProgramManager();
1820

1921
// Create a temporary account for the execution of the program
@@ -25,19 +27,21 @@ async function localProgramExecution(program, programName, aleoFunction, inputs)
2527
keyProvider.useCache(true);
2628
programManager.setKeyProvider(keyProvider);
2729

28-
// Pre-synthesize the program keys and then cache them in memory using key provider
29-
const keyPair = await programManager.synthesizeKeys(hello_hello_program, aleoFunction, inputs);
30-
programManager.keyProvider.cacheKeys(`${programName}:${aleoFunction}`, keyPair);
30+
// Pre-synthesize the program keys and then cache them in memory using key provider.
31+
console.log("Synthesizing hello_hello/hello keys");
32+
const keyPair = await programManager.synthesizeKeys(hello_hello_program, functionName, inputs);
33+
programManager.keyProvider.cacheKeys(`${programName}:${functionName}`, keyPair);
3134

3235
// Specify parameters for the key provider to use search for program keys. In particular specify the cache key
3336
// that was used to cache the keys in the previous step.
34-
const keyProviderParams = new AleoKeyProviderParams({cacheKey: `${programName}:${aleoFunction}`});
37+
const keyProviderParams = new AleoKeyProviderParams({cacheKey: `${programName}:${functionName}`});
3538

3639
// Execute once using the key provider params defined above. This will use the cached proving keys and make
3740
// execution significantly faster.
41+
console.log("Executing hello_hello/hello");
3842
let executionResponse = await programManager.run(
3943
program,
40-
aleoFunction,
44+
functionName,
4145
inputs,
4246
true,
4347
undefined,
@@ -53,7 +57,33 @@ async function localProgramExecution(program, programName, aleoFunction, inputs)
5357
}
5458
}
5559

56-
const start = Date.now();
57-
console.log("Starting execute!");
58-
await localProgramExecution(hello_hello_program, programName, "hello", ["5u32", "5u32"]);
59-
console.log("Execute finished!", Date.now() - start);
60+
// Create a remote program execution transaction.
61+
async function remoteProgramExecution(programName, functionName, inputs) {
62+
// Create a key provider in order to re-use the same key for each execution
63+
const keyProvider = new AleoKeyProvider();
64+
keyProvider.useCache(true);
65+
66+
const programManager = new ProgramManager("http://34.168.156.3:3030", keyProvider);
67+
68+
const tx = await programManager.buildExecutionTransaction(
69+
{
70+
programName,
71+
functionName,
72+
priorityFee: 0,
73+
privateFee: false,
74+
inputs,
75+
privateKey: PrivateKey.from_string(process.env["PUZZLE_PK"])
76+
}
77+
);
78+
console.log("Resulting transaction")
79+
}
80+
81+
// const start = Date.now();
82+
// console.log("Starting local execute!");
83+
// await localProgramExecution(hello_hello_program, programName, "hello", ["5u32", "5u32"]);
84+
// console.log("Local execute finished!", Date.now() - start);
85+
//
86+
// console.log("Starting remote execute");
87+
// const auctionTicket = "{\n owner: aleo12a4wll9ax6w5355jph0dr5wt2vla5sss2t4cnch0tc3vzh643v8qcfvc7a.private,\n auction: {\n starting_bid: 1000u64.private,\n name: 35399035103896773146887283777field.private,\n item: {\n id: 2711777270856651361584090827715149911900945757872672230578290769243507539617field.private,\n offchain_data: [\n 988474637487226873250021955104421895943605632761729320744454284792013483886field.private,\n 1018595503607749325560812785092303652308909717269501712857428145700763090203field.private,\n 1866354748676879328546224733327549476838379876255164483333908854380501015560field.private,\n 17649382157field.private\n ]\n }\n },\n auction_id: 4494702806735512695876583707511065751304542460719196393147692059573188109243field.private,\n settings: {\n auction_privacy: 1field.private,\n bid_types_accepted: 2field.private\n },\n _nonce: 3369967065799891136255379173673996324404175734426175774361522329924029135340group.public,\n _version: 0u8.public\n}";
88+
// const privateBid = "{\n owner: aleo12a4wll9ax6w5355jph0dr5wt2vla5sss2t4cnch0tc3vzh643v8qcfvc7a.private,\n bid: {\n amount: 50000u64.private,\n auction_id: 4494702806735512695876583707511065751304542460719196393147692059573188109243field.private,\n bid_public_key: 7957235921075215080384898776027711008106448988910535634014947882222019778701group.private\n },\n bid_id: 7560059211950188901208146469854635725646381155467709838136796808753178551929field.private,\n _nonce: 6603986437928263590097393830337419611438422585243442121397081002092267314422group.public,\n _version: 0u8.public\n}";
89+
// await remoteProgramExecution("private_auction_test_3.aleo", "select_winner_private", [auctionTicket, privateBid]);

create-leo-app/template-node/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
"dev": "node index.js"
88
},
99
"dependencies": {
10-
"@provablehq/sdk": "^0.9.7"
10+
"@provablehq/sdk": "^0.9.8"
1111
}
1212
}

create-leo-app/template-offline-public-transaction-ts/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"dev": "npm run build && node dist/index.js"
99
},
1010
"dependencies": {
11-
"@provablehq/sdk": "^0.9.7"
11+
"@provablehq/sdk": "^0.9.8"
1212
},
1313
"devDependencies": {
1414
"rimraf": "^6.0.1",

0 commit comments

Comments
 (0)