diff --git a/iac/Erpc.ts b/iac/Erpc.ts index 082a7c3..0a89d06 100644 --- a/iac/Erpc.ts +++ b/iac/Erpc.ts @@ -1,3 +1,4 @@ +import { Duration } from "aws-cdk-lib"; import { Repository } from "aws-cdk-lib/aws-ecr"; import { ContainerImage } from "aws-cdk-lib/aws-ecs"; import { Service, type StackContext, use } from "sst/constructs"; @@ -80,6 +81,16 @@ export function ErpcStack({ app, stack }: StackContext) { containerName: "erpc", image: erpcImage, secrets: cdkSecretsMap, + healthCheck: { + command: [ + "CMD-SHELL", + "curl -f http://localhost:4001 || exit 1", + ], + interval: Duration.seconds(30), + timeout: Duration.seconds(15), + retries: 3, + startPeriod: Duration.seconds(30), + }, }, }, }); diff --git a/iac/Indexer.ts b/iac/Indexer.ts index 5cf48fc..21e7b9e 100644 --- a/iac/Indexer.ts +++ b/iac/Indexer.ts @@ -84,6 +84,16 @@ export function IndexerStack({ app, stack }: StackContext) { containerName: "indexer", image: indexerImage, secrets: cdkSecretsMap, + /*healthCheck: { + command: [ + "CMD-SHELL", + "curl -f http://localhost:42069/status || exit 1", + ], + interval: Duration.seconds(30), + timeout: Duration.seconds(5), + retries: 3, + startPeriod: Duration.seconds(30), + },*/ }, }, }); diff --git a/packages/erpc/erpc.yaml b/packages/erpc/erpc.yaml index 2c01445..288f96c 100644 --- a/packages/erpc/erpc.yaml +++ b/packages/erpc/erpc.yaml @@ -49,14 +49,40 @@ projects: delay: 1000ms maxCount: 2 upstreams: - - id: alchemy-multi-chain - endpoint: alchemy://${ALCHEMY_API_KEY} +# todo: Disabled for now since api endpoints seems to be fcked up +# - id: alchemy-multi-chain +# endpoint: alchemy://${ALCHEMY_API_KEY} +# type: evm-alchemy +# rateLimitBudget: alchemy +# healthCheckGroup: default-hcg +# failsafe: +# timeout: +# duration: 15s +# retry: +# maxCount: 2 +# delay: 1000ms +# backoffMaxDelay: 10s +# backoffFactor: 0.3 +# jitter: 500ms + - id: alchemy-arb-sepolia + endpoint: https://arb-sepolia.g.alchemy.com/v2/${ALCHEMY_API_KEY} + type: evm-alchemy + rateLimitBudget: alchemy + healthCheckGroup: default-hcg + failsafe: + timeout: + duration: 15s + retry: + maxCount: 2 + delay: 1000ms + backoffMaxDelay: 10s + backoffFactor: 0.3 + jitter: 500ms + - id: alchemy-arb + endpoint: https://arb-mainnet.g.alchemy.com/v2/${ALCHEMY_API_KEY} + type: evm-alchemy rateLimitBudget: alchemy healthCheckGroup: default-hcg - allowMethods: - - "alchemy_*" - ignoreMethods: - - "trace_transaction" failsafe: timeout: duration: 15s diff --git a/packages/ponder/src/stats.ts b/packages/ponder/src/stats.ts index 23ca018..c4e2d8d 100644 --- a/packages/ponder/src/stats.ts +++ b/packages/ponder/src/stats.ts @@ -55,37 +55,44 @@ export async function increaseCampaignsInteractions({ console.error("Campaign id not found", campaign); continue; } - // Create the stats if not found - await PressCampaignStats.upsert({ - id: campaign.id, - create: { - campaignId: campaign.id, - totalInteractions: 0n, - openInteractions: 0n, - readInteractions: 0n, - referredInteractions: 0n, - createReferredLinkInteractions: 0n, - totalRewards: 0n, - }, - // Update the given field by incrementing them - update: ({ current }) => { - return { - ...current, - totalInteractions: current.totalInteractions + 1n, - openInteractions: - current.openInteractions + - (increments.openInteractions ?? 0n), - readInteractions: - current.readInteractions + - (increments.readInteractions ?? 0n), - referredInteractions: - current.referredInteractions + - (increments.referredInteractions ?? 0n), - createReferredLinkInteractions: - current.createReferredLinkInteractions + - (increments.createReferredLinkInteractions ?? 0n), - }; - }, - }); + try { + // Create the stats if not found + await PressCampaignStats.upsert({ + id: campaign.id, + create: { + campaignId: campaign.id, + totalInteractions: 0n, + openInteractions: 0n, + readInteractions: 0n, + referredInteractions: 0n, + createReferredLinkInteractions: 0n, + totalRewards: 0n, + }, + // Update the given field by incrementing them + update: ({ current }) => { + return { + ...current, + totalInteractions: current.totalInteractions + 1n, + openInteractions: + current.openInteractions + + (increments.openInteractions ?? 0n), + readInteractions: + current.readInteractions + + (increments.readInteractions ?? 0n), + referredInteractions: + current.referredInteractions + + (increments.referredInteractions ?? 0n), + createReferredLinkInteractions: + current.createReferredLinkInteractions + + (increments.createReferredLinkInteractions ?? 0n), + }; + }, + }); + } catch (error) { + console.error("Error while incrementing campaign stats", error, { + campaign, + increments, + }); + } } }