Skip to content

Commit 8328ac7

Browse files
Merge pull request #1084 from ProvableHQ/feat/query-trait-extension
[Feature] Snapshot query trait extension for SnarkOS v4.2.1
2 parents ad57da5 + b97c96b commit 8328ac7

File tree

41 files changed

+781
-454
lines changed

Some content is hidden

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

41 files changed

+781
-454
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: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
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";
44

55
const programName = "hello_hello.aleo"
66

@@ -13,7 +13,7 @@ function hello:
1313
add r0 r1 into r2;
1414
output r2 as u32.private;`
1515

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

1919
// Create a temporary account for the execution of the program
@@ -25,19 +25,21 @@ async function localProgramExecution(program, programName, aleoFunction, inputs)
2525
keyProvider.useCache(true);
2626
programManager.setKeyProvider(keyProvider);
2727

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

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

3637
// Execute once using the key provider params defined above. This will use the cached proving keys and make
3738
// execution significantly faster.
39+
console.log("Executing hello_hello/hello");
3840
let executionResponse = await programManager.run(
3941
program,
40-
aleoFunction,
42+
functionName,
4143
inputs,
4244
true,
4345
undefined,
@@ -53,7 +55,33 @@ async function localProgramExecution(program, programName, aleoFunction, inputs)
5355
}
5456
}
5557

58+
// Create a remote program execution transaction.
59+
async function remoteProgramExecution(programName, functionName, inputs) {
60+
// Create a key provider in order to re-use the same key for each execution
61+
const keyProvider = new AleoKeyProvider();
62+
keyProvider.useCache(true);
63+
64+
const programManager = new ProgramManager("http://34.168.156.3:3030", keyProvider);
65+
66+
const tx = await programManager.buildExecutionTransaction(
67+
{
68+
programName,
69+
functionName,
70+
priorityFee: 0,
71+
privateFee: false,
72+
inputs,
73+
privateKey: PrivateKey.from_string(process.env["PUZZLE_PK"])
74+
}
75+
);
76+
console.log("Resulting transaction")
77+
}
78+
5679
const start = Date.now();
57-
console.log("Starting execute!");
80+
console.log("Starting local execute!");
5881
await localProgramExecution(hello_hello_program, programName, "hello", ["5u32", "5u32"]);
59-
console.log("Execute finished!", Date.now() - start);
82+
console.log("Local execute finished!", Date.now() - start);
83+
84+
console.log("Starting remote execute");
85+
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}";
86+
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}";
87+
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)