Skip to content

Commit

Permalink
minor adjust
Browse files Browse the repository at this point in the history
  • Loading branch information
kitounliu committed Aug 9, 2024
1 parent 8db7d77 commit 96afd33
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion services/admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export class AdminZkRandService extends BaseService<AdminZkRandOptions> {
}

async _start(): Promise<void> {
console.log('----------------- admin started ------------------')
console.log('\n------------------------------ admin starts ------------------------------')

let adminFromContract = await this.state.zkRandContract.owner()
console.log("admin in contract:", adminFromContract)
Expand Down
11 changes: 5 additions & 6 deletions services/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export class NodeZkRandService extends BaseService<NodeZkRandOptions> {
}

async _start(): Promise<void> {
console.log('---------------- node started ----------------')
console.log('\n------------------------------ node starts ------------------------------')
const threshold = await this.state.zkRandContract.threshold()

while (this.running) {
Expand All @@ -109,19 +109,19 @@ export class NodeZkRandService extends BaseService<NodeZkRandOptions> {
await this.submitPP()
}
} else if (contractPhase == Status.Ready) {
let currentRound = await this.state.zkRandContract.currentRoundNum()
console.log("currentRound", currentRound.toString())
let lastRoundSubmitted = await this.state.zkRandContract.lastSubmittedRound(this.options.l2Wallet.address)
console.log("lastRoundSubmitted", lastRoundSubmitted.toString())

if (this.state.nidkgDerived == false && lastRoundSubmitted == 0) {
await this.nidkgDerive()
}

const currentRound = await this.state.zkRandContract.currentRoundNum()
console.log("currentRound", currentRound.toString())
const roundSubmissionCount = await this.state.zkRandContract.roundSubmissionCount(currentRound)
console.log("roundSubmissionCount", roundSubmissionCount.toString())
if (currentRound > lastRoundSubmitted && roundSubmissionCount < threshold) {
await this.submitPartialEval(threshold)
await this.submitPartialEval(threshold, currentRound)
}
}
}
Expand Down Expand Up @@ -269,8 +269,7 @@ export class NodeZkRandService extends BaseService<NodeZkRandOptions> {
this.state.nidkgDerived = true
}

async submitPartialEval(threshold: number) {
const currentRound = await this.state.zkRandContract.currentRoundNum()
async submitPartialEval(threshold: number, currentRound: number) {
const input = await this.state.zkRandContract.roundInput(currentRound)
const index = await this.state.zkRandContract.getIndexPlus(this.options.l2Wallet.address)

Expand Down

0 comments on commit 96afd33

Please sign in to comment.