Skip to content

Commit

Permalink
Merge pull request #39 from Poseidon-ZKP/akilesh/sync-from-higher-block
Browse files Browse the repository at this point in the history
sync events from higher block (depends on #37)
  • Loading branch information
dtebbs authored Jun 7, 2023
2 parents 50dc534 + fb8ebdc commit a223d62
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion scripts/committee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ const app = command({
// Run the vote tallier
console.log("Running vote tallier...");

let lastBlockFiltered = 0;
let lastBlockFiltered = zkv_descriptor.block_number_before_zkvote_deploy;
const intfc = zkv.interface;
let proposalIdToEndBlock: Map<number, number> = new Map<number, number>();
while (true) {
Expand Down
5 changes: 4 additions & 1 deletion scripts/deploy_dkg_zkvote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,13 @@ const app = command({
fs.writeFileSync(dc_descriptor_file, JSON.stringify(dkg_desc));
console.log("Descriptor written at: " + dc_descriptor_file);

// A reasonable lower bound on the block number from which committee members can start filtering for events.
const block_number_before_zkvote_deploy = await provider.getBlockNumber();

const zkv = await zkvote_contract.deploy(deployer, dkg.address, BigInt(max_total_voting_weight));
console.log("ZKVote deployed at: " + zkv.address);

const zkv_desc = await zkvote_contract.get_descriptor(zkv);
const zkv_desc = await zkvote_contract.get_descriptor(zkv, block_number_before_zkvote_deploy);
console.log("zkv_desc=" + JSON.stringify(zkv_desc));
fs.writeFileSync(zkv_descriptor_file, JSON.stringify(zkv_desc));
console.log("Descriptor written at: " + zkv_descriptor_file);
Expand Down
3 changes: 2 additions & 1 deletion scripts/nouns/nouns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ async function main(
10n, // total voting power
);

const zkv_descriptor = await zkvote_contract.get_descriptor(zkv);
const dummy_block_number_before_zkvote_deploy = 10;
const zkv_descriptor = await zkvote_contract.get_descriptor(zkv, 10);

// Deploy contract, and register voters
const nc = await nouns_contract.deploy(
Expand Down
5 changes: 4 additions & 1 deletion scripts/nouns/zkvote_contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export { ZKVote } from "../types";

export type ZKVoteContractDescriptor = {
address: string;
block_number_before_zkvote_deploy: number;
};

export async function deploy(
Expand All @@ -29,10 +30,12 @@ export async function deploy(
);
}

export async function get_descriptor(zkVote: ZKVote): Promise<ZKVoteContractDescriptor> {
export async function get_descriptor(zkVote: ZKVote, block_number_before_zkvote_deploy: number): Promise<ZKVoteContractDescriptor> {
console.log("address: " + zkVote.address);
console.log("block_number_before_zkvote_deploy: " + block_number_before_zkvote_deploy);
return {
address: zkVote.address,
block_number_before_zkvote_deploy,
};
}

Expand Down

0 comments on commit a223d62

Please sign in to comment.