Skip to content

Commit f7e4be5

Browse files
committed
fix(maci): use blocks per batch/request
1 parent 9694a42 commit f7e4be5

File tree

6 files changed

+26
-10
lines changed

6 files changed

+26
-10
lines changed

.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ NEXT_PUBLIC_COORDINATOR_SERVICE_URL="http://localhost:3000/v1"
1515

1616
# UX improvements
1717
NEXT_MINIMUM_START_DELAY_IN_SECONDS="30"
18+
NEXT_MACI_BLOCKS_PER_BATCH="1000"
1819

1920
# Network and services
2021
NEXT_PUBLIC_CHAIN_NAME="arbitrumSepolia"

constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export const PUBLIC_COORDINATOR_SERVICE_URL = process.env.NEXT_PUBLIC_COORDINATO
1616

1717
// UX improvements
1818
export const NEXT_MINIMUM_START_DELAY_IN_SECONDS = Number(process.env.NEXT_MINIMUM_START_DELAY_IN_SECONDS ?? 30);
19+
export const NEXT_MACI_BLOCKS_PER_BATCH = Number(process.env.NEXT_MACI_BLOCKS_PER_BATCH ?? 1000);
1920

2021
// Target chain
2122
export const PUBLIC_CHAIN_NAME = (process.env.NEXT_PUBLIC_CHAIN_NAME ?? "sepolia") as ChainName;

context/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { AlertProvider } from "./Alerts";
2-
import { ReactNode } from "react";
2+
import { type ReactNode } from "react";
33
import { QueryClient } from "@tanstack/react-query";
44
import { config } from "@/context/Web3Modal";
55
import { createWeb3Modal } from "@web3modal/wagmi/react";
6-
import { State, WagmiProvider, deserialize, serialize } from "wagmi";
6+
import { type State, WagmiProvider, deserialize, serialize } from "wagmi";
77
import { PUBLIC_WALLET_CONNECT_PROJECT_ID } from "@/constants";
88
import AsyncStorage from "@react-native-async-storage/async-storage";
99
import { createAsyncStoragePersister } from "@tanstack/query-async-storage-persister";

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
"@layerzerolabs/lz-definitions": "^2.3.27",
2626
"@layerzerolabs/lz-v2-utilities": "^2.3.27",
2727
"@layerzerolabs/scan-client": "^0.0.8",
28-
"@maci-protocol/domainobjs": "0.0.0-ci.c62bc06",
29-
"@maci-protocol/sdk": "0.0.0-ci.c62bc06",
28+
"@maci-protocol/domainobjs": "0.0.0-ci.6818d7a",
29+
"@maci-protocol/sdk": "0.0.0-ci.6818d7a",
3030
"@react-native-async-storage/async-storage": "^1.23.1",
3131
"@shazow/whatsabi": "0.11.0",
3232
"@tanstack/query-async-storage-persister": "^5.49.1",

plugins/maciVoting/contexts/MaciContext.tsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,18 @@ export const MaciProvider = ({ children }: { children: ReactNode }) => {
114114

115115
isUserRegistered = _isRegistered;
116116
setIsRegistered(_isRegistered);
117-
} catch (error) {
118-
setError("Error checking if user is registered");
119-
setIsLoading(false);
120-
return;
117+
} catch (error: any) {
118+
// 0xb2d14184 => UserNotSignedUp()
119+
if (error.message?.includes("0xb2d14184")) {
120+
isUserRegistered = false;
121+
} else {
122+
// eslint-disable-next-line no-console
123+
console.error(error);
124+
125+
setError("Error checking if user is registered");
126+
setIsLoading(false);
127+
return;
128+
}
121129
}
122130

123131
if (isUserRegistered) {

plugins/maciVoting/hooks/poll/useJoinPoll.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
import { PUBLIC_CHAIN, PUBLIC_MACI_ADDRESS, PUBLIC_MACI_DEPLOYMENT_BLOCK } from "@/constants";
1+
import {
2+
NEXT_MACI_BLOCKS_PER_BATCH,
3+
PUBLIC_CHAIN,
4+
PUBLIC_MACI_ADDRESS,
5+
PUBLIC_MACI_DEPLOYMENT_BLOCK,
6+
} from "@/constants";
27
import { generateMaciStateTreeWithEndKey, getJoinedUserData, joinPoll } from "@maci-protocol/sdk/browser";
38
import { useCallback, useMemo, useState } from "react";
49
import { usePublicClient } from "wagmi";
@@ -79,6 +84,7 @@ export const useJoinPoll = (pollId?: bigint) => {
7984
signer,
8085
userPublicKey: maciKeypair.publicKey,
8186
startBlock: PUBLIC_MACI_DEPLOYMENT_BLOCK,
87+
blocksPerBatch: NEXT_MACI_BLOCKS_PER_BATCH,
8288
});
8389

8490
const inclusionProof = stateTree.signUpTree.generateProof(Number(stateIndex));
@@ -93,7 +99,7 @@ export const useJoinPoll = (pollId?: bigint) => {
9399
pollWasm: artifacts.wasm as unknown as string,
94100
sgDataArg: DEFAULT_SG_DATA,
95101
ivcpDataArg: DEFAULT_IVCP_DATA,
96-
blocksPerBatch: 1000,
102+
blocksPerBatch: NEXT_MACI_BLOCKS_PER_BATCH,
97103
});
98104

99105
if (joinedData) {

0 commit comments

Comments
 (0)