Skip to content

Commit

Permalink
commented some scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
aii23 committed Oct 9, 2024
1 parent 97dc73f commit cd67344
Show file tree
Hide file tree
Showing 19 changed files with 1,219 additions and 1,167 deletions.
42 changes: 21 additions & 21 deletions scripts/analyze.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
import { getPLottery } from '../src/PLottery.js';
import { DistributionProgram } from '../src/Proofs/DistributionProof.js';
import { writeFileSync } from 'fs';
import { PublicKey } from 'o1js';
import { findPlottery } from './utils.js';
// import { getPLottery } from '../src/PLottery.js';
// import { DistributionProgram } from '../src/Proofs/DistributionProof.js';
// import { writeFileSync } from 'fs';
// import { PublicKey } from 'o1js';
// import { findPlottery } from './utils.js';

let { PLottery } = findPlottery();
// let { PLottery } = findPlottery();

const lotteryResult = await PLottery.analyzeMethods();
const distributionResult = await DistributionProgram.analyzeMethods();
// const lotteryResult = await PLottery.analyzeMethods();
// const distributionResult = await DistributionProgram.analyzeMethods();

if (!PLottery._methods) {
console.log("Can't find methods for Lottery");
throw new Error("Can't find methods for Lottery");
}
// if (!PLottery._methods) {
// console.log("Can't find methods for Lottery");
// throw new Error("Can't find methods for Lottery");
// }

let result: { [name: string]: number } = {};
// let result: { [name: string]: number } = {};

for (const method of PLottery._methods) {
result[`Lottery_${method.methodName}`] =
lotteryResult[method.methodName].rows;
}
// for (const method of PLottery._methods) {
// result[`Lottery_${method.methodName}`] =
// lotteryResult[method.methodName].rows;
// }

result[`DistributionProof_init`] = distributionResult.init.rows;
result[`DistibutionProof_addTicket`] = distributionResult.addTicket.rows;
// result[`DistributionProof_init`] = distributionResult.init.rows;
// result[`DistibutionProof_addTicket`] = distributionResult.addTicket.rows;

console.log(result);
// console.log(result);

writeFileSync('analyze_result.json', JSON.stringify(result, null, 2));
// writeFileSync('analyze_result.json', JSON.stringify(result, null, 2));
44 changes: 22 additions & 22 deletions scripts/call_zkon.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
import { Field, Mina, Poseidon } from 'o1js';
import { RandomManagerManager } from '../src/StateManager/RandomManagerManager';
import {
compileRandomManager,
configDefaultInstance,
findPlottery,
findRandomManager,
getDeployer,
getRMStoreManager,
storeRMStoreManager,
} from './utils';
import { CommitValue } from '../src/Random/RandomManager';
// import { Field, Mina, Poseidon } from 'o1js';
// import { RandomManagerManager } from '../src/StateManager/RandomManagerManager';
// import {
// compileRandomManager,
// configDefaultInstance,
// findPlottery,
// findRandomManager,
// getDeployer,
// getRMStoreManager,
// storeRMStoreManager,
// } from './utils';
// import { CommitValue } from '../src/Random/RandomManager';

configDefaultInstance();
// configDefaultInstance();

let deploy_epoch = process.argv[2] ? process.argv[2] : 'current';
// let deploy_epoch = process.argv[2] ? process.argv[2] : 'current';

let { deployer, deployerKey } = getDeployer();
// let { deployer, deployerKey } = getDeployer();

let { randomManager } = findRandomManager(deploy_epoch);
// let { randomManager } = findRandomManager(deploy_epoch);

await compileRandomManager(deploy_epoch);
// await compileRandomManager(deploy_epoch);

let tx = await Mina.transaction(deployer, async () => {
await randomManager.callZkon();
});
// let tx = await Mina.transaction(deployer, async () => {
// await randomManager.callZkon();
// });

await tx.prove();
await tx.sign([deployerKey]).send();
// await tx.prove();
// await tx.sign([deployerKey]).send();
66 changes: 33 additions & 33 deletions scripts/commit_value.ts
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
import { Field, Mina } from 'o1js';
import { RandomManagerManager } from '../src/StateManager/RandomManagerManager';
import {
compileRandomManager,
configDefaultInstance,
findPlottery,
findRandomManager,
getDeployer,
getRMStoreManager,
storeRMStoreManager,
} from './utils';
import { CommitValue } from '../src/Random/RandomManager';
// import { Field, Mina } from 'o1js';
// import { RandomManagerManager } from '../src/StateManager/RandomManagerManager';
// import {
// compileRandomManager,
// configDefaultInstance,
// findPlottery,
// findRandomManager,
// getDeployer,
// getRMStoreManager,
// storeRMStoreManager,
// } from './utils';
// import { CommitValue } from '../src/Random/RandomManager';

configDefaultInstance();
// configDefaultInstance();

let round = process.argv[2];
// let round = process.argv[2];

if (!round) {
throw Error(`You should specify round`);
}
// if (!round) {
// throw Error(`You should specify round`);
// }

let deploy_epoch = process.argv[3] ? process.argv[3] : 'current';
// let deploy_epoch = process.argv[3] ? process.argv[3] : 'current';

let { deployer, deployerKey } = getDeployer();
// let { deployer, deployerKey } = getDeployer();

let { randomManager } = findRandomManager(deploy_epoch);
// let { randomManager } = findRandomManager(deploy_epoch);

await compileRandomManager(deploy_epoch);
// await compileRandomManager(deploy_epoch);

let rmStoreManager: RandomManagerManager = getRMStoreManager(deploy_epoch);
// let rmStoreManager: RandomManagerManager = getRMStoreManager(deploy_epoch);

let value = Field.random();
let salt = Field.random();
let commitValue = new CommitValue({ value, salt });
// let value = Field.random();
// let salt = Field.random();
// let commitValue = new CommitValue({ value, salt });

const { witness: commitRoundWitness } = rmStoreManager.getCommitWitness(+round);
// const { witness: commitRoundWitness } = rmStoreManager.getCommitWitness(+round);

let tx = await Mina.transaction(deployer, async () => {
await randomManager.commit(commitValue, commitRoundWitness);
});
// let tx = await Mina.transaction(deployer, async () => {
// await randomManager.commit(commitValue, commitRoundWitness);
// });

await tx.prove();
await tx.sign([deployerKey]).send();
// await tx.prove();
// await tx.sign([deployerKey]).send();

rmStoreManager.addCommit(+round, commitValue);
// rmStoreManager.addCommit(+round, commitValue);

storeRMStoreManager(rmStoreManager, deploy_epoch);
// storeRMStoreManager(rmStoreManager, deploy_epoch);
Loading

0 comments on commit cd67344

Please sign in to comment.