Skip to content

Commit

Permalink
chore: deploy maci-indexer on fly
Browse files Browse the repository at this point in the history
  • Loading branch information
thelostone-mc committed Jun 19, 2024
1 parent 96a742f commit 956abdc
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ jobs:

- name: Smoke test
run: |
curl --silent --show-error --fail-with-body https://${{ env.FLY_APP_NAME }}.fly.dev/api/v1/status
curl --silent --show-error --fail-with-body https://${{ env.FLY_APP_NAME }}.fly.dev/api/v1/status
48 changes: 48 additions & 0 deletions .github/workflows/deploy-maci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Deploy MACI

on:
push:
branches: [MACI]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up fly
uses: superfly/flyctl-actions/setup-flyctl@master

- name: Set variables for production
run: |
echo "FLY_CONFIG=fly.maci.toml" >> $GITHUB_ENV
echo "GIT_SHA_SHORT=$(git rev-parse --short "$GITHUB_SHA")" >> $GITHUB_ENV
echo "FLY_APP_NAME=maci-indexer-v2" >> $GITHUB_ENV
if: ${{ github.ref == 'refs/heads/main' }}

- name: Build and test
run: |
flyctl -c ${{ env.FLY_CONFIG }} deploy --remote-only --build-only --push --image-label deployment-$GIT_SHA_SHORT
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN_PRODUCTION }}

- name: Deploy Indexer
run: |
flyctl -c ${{ env.FLY_CONFIG }} deploy --wait-timeout=7200 --env BUILD_TAG=`git rev-parse --short HEAD` --image registry.fly.io/$FLY_APP_NAME:deployment-$GIT_SHA_SHORT --process-groups=indexer
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN_PRODUCTION }}

- name: Deploy HTTP
run: |
flyctl -c ${{ env.FLY_CONFIG }} deploy --wait-timeout=7200 --env BUILD_TAG=`git rev-parse --short HEAD` --image registry.fly.io/$FLY_APP_NAME:deployment-$GIT_SHA_SHORT --process-groups=web
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN_PRODUCTION }}

- name: Smoke test
run: |
curl --silent --show-error --fail-with-body https://${{ env.FLY_APP_NAME }}.fly.dev/api/v1/status
66 changes: 66 additions & 0 deletions fly.maci.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# fly.toml app configuration file generated for maci-indexer-v2 on 2024-06-18T18:15:21+05:30
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#

app = 'maci-indexer-v2'
primary_region = 'den'
kill_signal = 'SIGINT'
kill_timeout = '5s'

[experimental]
auto_rollback = true

[build]

[deploy]
wait_timeout = '6h0m0s'

[env]
DEPLOYMENT_ENVIRONMENT = 'production'
ENABLE_RESOURCE_MONITOR = 'false'
ESTIMATES_LINEARQF_WORKER_POOL_SIZE = '10'
INDEXED_CHAINS = 'scroll,scroll-sepolia,sepolia'
LOG_LEVEL = 'debug'
NODE_OPTIONS = '--max-old-space-size=4096'
PASSPORT_SCORER_ID = '335'
PINO_PRETTY = 'true'
PORT = '8080'
STORAGE_DIR = '/mnt/indexer'

[processes]
indexer = 'npm start -- --indexer --http'
web = 'npm start -- --http --http-wait-for-sync=false'

[[mounts]]
source = 'indexer_maci'
destination = '/mnt/indexer'
initial_size = '10gb'
processes = ['indexer', 'web']

[http_service]
internal_port = 8080
force_https = true
auto_stop_machines = true
auto_start_machines = true
min_machines_running = 2
processes = ['web']

[http_service.concurrency]
type = 'requests'
hard_limit = 250
soft_limit = 200

[checks]
[checks.http]
port = 8080
type = 'http'
interval = '15s'
timeout = '10s'
grace_period = '30s'
method = 'get'
path = '/api/v1/status'
processes = ['web', 'indexer']

[[vm]]
size = 'performance-2x'
10 changes: 3 additions & 7 deletions src/indexer/allo/v2/handleEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ export async function handleEvent(
contract: "AlloV2/DirectGrantsLiteStrategy/V1",
address: strategyAddress,
});
break;
case "allov2.MACIQF":
subscribeToContract({
contract: "AlloV2/MACIQF/V1",
Expand Down Expand Up @@ -1369,7 +1370,6 @@ export async function handleEvent(
return [];
}

const recipientId = parseAddress(event.params.recipientId);
const amount = event.params.amount;
const token = parseAddress(event.params.token);
const origin = parseAddress(event.params.origin);
Expand Down Expand Up @@ -1424,7 +1424,7 @@ export async function handleEvent(
roundId: round.id,
applicationId: "undefined",
donorAddress: origin,
recipientAddress: zeroAddress as any,
recipientAddress: parseAddress(zeroAddress),
projectId: "undefined",
transactionHash: event.transactionHash,
blockNumber: event.blockNumber,
Expand Down Expand Up @@ -1553,7 +1553,7 @@ export async function handleEvent(

const message = {
msgType: BigInt(event.params._message.msgType).toString(),
data: event.params._message.data.map((x: any) => BigInt(x).toString()),
data: event.params._message.data.map((x) => BigInt(x).toString()),
};

const id = ethers.utils.solidityKeccak256(["bytes"], [bytes]);
Expand All @@ -1571,10 +1571,6 @@ export async function handleEvent(
// Create a unique ID for the message
const uuidId = ethers.utils.solidityKeccak256(["bytes"], [uuidBytes]);

logger.info({
msg: `data: ${message.data}`,
});

return [
{
type: "InsertMessage",
Expand Down

0 comments on commit 956abdc

Please sign in to comment.