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

use counter for rand input #16

Merged
merged 3 commits into from
Jun 4, 2024
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
5 changes: 3 additions & 2 deletions contracts/zkdvrf.sol
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ contract zkdvrf is Ownable {
Ready
}

string public constant INPUT_PREFIX = "zkRand-v1-2024:";

uint32 public memberCount;
uint32 public threshold;
uint32 public ppLength;
Expand Down Expand Up @@ -177,8 +179,7 @@ contract zkdvrf is Ownable {
}

currentRoundNum++;
uint256 currentTimestamp = block.timestamp;
roundInput[currentRoundNum] = currentTimestamp.toString();
roundInput[currentRoundNum] = string(abi.encodePacked(INPUT_PREFIX, currentRoundNum.toString()));

emit RandomInitiated(currentRoundNum, roundInput[currentRoundNum]);
}
Expand Down
6 changes: 3 additions & 3 deletions scripts/admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ async function main() {
async function listenRandThreshold() {
const eventRandThreshold = `RandomThresholdReached`
contract.on(eventRandThreshold, async (roundNum, input, event) => {
console.log("\nevent", eventRandThreshold, `round ${roundNum} input ${input}`)
console.log("\nevent", eventRandThreshold, `round ${roundNum} input "${input}"`)

console.log("begin sleep...")
await sleep(2000)
Expand Down Expand Up @@ -196,12 +196,12 @@ async function main() {
await sleep(2000)
console.log("end sleep")

const cmdCombine = `RUST_LOG=info ./target/release/client rand combine ${input}`
const cmdCombine = `RUST_LOG=info ./target/release/client rand combine "${input}"`
console.log("running command <", cmdCombine, ">...")
let result = await execPromise(cmdCombine)
console.log(result[`stderr`])

const cmdVerify = `RUST_LOG=info ./target/release/client rand verify-final ${input}`
const cmdVerify = `RUST_LOG=info ./target/release/client rand verify-final "${input}"`
console.log("running command <", cmdVerify, ">...")
result = await execPromise(cmdVerify)
console.log(result[`stderr`])
Expand Down
4 changes: 2 additions & 2 deletions scripts/random.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ async function main() {
const memberContract = contract.connect(memberWallet)

const index = await memberContract.getIndexPlus(memberAddress)
const cmdEval = `RUST_LOG=info ./target/release/client rand eval ${index} ${input}`
const cmdVerify = `RUST_LOG=info ./target/release/client rand verify ${index} ${input}`
const cmdEval = `RUST_LOG=info ./target/release/client rand eval ${index} "${input}"`
const cmdVerify = `RUST_LOG=info ./target/release/client rand verify ${index} "${input}"`

console.log("running command <", cmdEval, ">...")
let result = await execPromise(cmdEval)
Expand Down
Loading
Loading