Skip to content

Commit

Permalink
Merge pull request #16 from bobanetwork/input
Browse files Browse the repository at this point in the history
use counter for rand input
  • Loading branch information
kitounliu committed Jun 4, 2024
2 parents 7f5ded6 + 9902acb commit d3a0085
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 76 deletions.
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

0 comments on commit d3a0085

Please sign in to comment.