Skip to content
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
21 changes: 17 additions & 4 deletions src/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,25 @@ const xavAbi = ABIContract.ofAbi(XAllocationVoting__factory.abi)
const rrpAbi = ABIContract.ofAbi(RelayerRewardsPool__factory.abi)
const vrAbi = ABIContract.ofAbi(VoterRewards__factory.abi)

const CALL_RETRIES = 3
const CALL_RETRY_MS = 500

async function call(thor: ThorClient, address: string, abi: any, method: string, args: any[] = []): Promise<any[]> {
const res = await thor.contracts.executeCall(address, abi.getFunction(method), args)
if (!res.success) {
throw new Error(`Call ${method} reverted: ${res.result?.errorMessage || "unknown"}`)
for (let attempt = 1; attempt <= CALL_RETRIES; attempt++) {
try {
const res = await thor.contracts.executeCall(address, abi.getFunction(method), args)
if (!res.success) {
throw new Error(`Call ${method} reverted: ${res.result?.errorMessage || "unknown"}`)
}
return res.result?.array ?? []
} catch (err) {
const msg = err instanceof Error ? err.message : String(err)
const isRevert = msg.includes("reverted")
if (isRevert || attempt === CALL_RETRIES) throw err
await new Promise((r) => setTimeout(r, CALL_RETRY_MS * attempt))
}
}
return res.result?.array ?? []
throw new Error("Unreachable")
}

// ── XAllocationVoting reads ─────────────────────────────────
Expand Down
4 changes: 2 additions & 2 deletions src/relayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ export async function runCastVoteCycle(
const unprocessed: string[] = []
let voted = 0
let ineligible = 0
const CHECK_BATCH = 50
const CHECK_BATCH = 10
for (let i = 0; i < allUsers.length; i += CHECK_BATCH) {
const chunk = allUsers.slice(i, i + CHECK_BATCH)
const checks = await Promise.all(chunk.map((u) => hasVoted(thor, config.xAllocationVotingAddress, roundId, u)))
Expand Down Expand Up @@ -288,7 +288,7 @@ export async function runClaimRewardCycle(
const unclaimed: string[] = []
let didNotVote = 0
let alreadyClaimed = 0
const CHECK_BATCH = 50
const CHECK_BATCH = 10
for (let i = 0; i < allUsers.length; i += CHECK_BATCH) {
const chunk = allUsers.slice(i, i + CHECK_BATCH)
const checks = await Promise.all(chunk.map((u) => hasVoted(thor, config.xAllocationVotingAddress, previousRoundId, u)))
Expand Down
Loading