wormhole/event_database/cloud_functions
Justin Schuldt 42284a25e3 remote devnet config - GCP VM 2022-03-18 10:49:34 -05:00
..
.gcloudignore cloud function housekeeping 2022-03-10 14:26:41 -06:00
.gitignore BigTable: misc code cleanup and log improvements 2021-12-20 16:56:56 +01:00
README.md cloud functions - docs update 2022-03-17 18:25:48 -05:00
addresses-transferred-to-cumulative.go cloud function housekeeping 2022-03-10 14:26:41 -06:00
addresses-transferred-to.go cloud functions - handle 2 digit chainIDs 2022-03-17 18:25:48 -05:00
bigtable-endpoints.md BigTable historical queries 2021-10-13 16:20:10 +00:00
external-data.go cloud functions - quicker initialize 2022-03-17 18:25:48 -05:00
findvalues.go cloud function housekeeping 2022-03-10 14:26:41 -06:00
go.mod cloud function housekeeping 2022-03-10 14:26:41 -06:00
go.sum cloud functions - rm unsed deps (go mod tidy) 2022-03-17 18:25:48 -05:00
nfts.go Explorer functions - use GSC for cache documents 2022-03-02 13:18:16 -06:00
notional-transferred-to-cumulative.go cloud function housekeeping 2022-03-10 14:26:41 -06:00
notional-transferred-to.go cloud functions - handle 2 digit chainIDs 2022-03-17 18:25:48 -05:00
notional-transferred.go cloud functions - 60 second context deadline 2022-03-17 18:25:48 -05:00
notional-tvl-cumulative.go cloud functions - 60 second context deadline 2022-03-17 18:25:48 -05:00
notional-tvl.go cloud functions - 60 second context deadline 2022-03-17 18:25:48 -05:00
process-transfer.go cloud function housekeeping 2022-03-10 14:26:41 -06:00
process-vaa.go remote devnet config - GCP VM 2022-03-18 10:49:34 -05:00
readrow.go BigTable: query optimizations and return payloads 2021-12-20 16:56:56 +01:00
recent.go cloud functions - handle 2 digit chainIDs 2022-03-17 18:25:48 -05:00
shared.go cloud functions - quicker initialize 2022-03-17 18:25:48 -05:00
totals.go Explorer functions - use GSC for cache documents 2022-03-02 13:18:16 -06:00
transaction.go BigTable: query optimizations and return payloads 2021-12-20 16:56:56 +01:00
workspace.code-workspace cloud function housekeeping 2022-03-10 14:26:41 -06:00

README.md

Google Cloud functions for BigTable

This is a reference implementaion for getting data out of BigTable.

Contents

This directory holds GCP Cloud Functions, one per file, along with shared utilities in shared.go. The file names correspond to the hosted endpoints. ie endpoint .../*-notionaltvl is the file notional-tvl.go

Debugging with VSCode

prereqs

  • Golang >= 1.16 installed and available on your path.
  • The Go VSCode extension, and gopls installed.

IDE setup

  • open a new VSCode window
  • File menu --> "Open Workspace from File..."
  • Select event_database/cloud_functions/workspace.code-workspace

Opening the workspace file as described above will open both cloud_functions and functions_server, so that you get all the VSCode goodness of intellesense, ability to run the code with the Go debugger, set breakpoints, etc.

Add your environment variables to functions_server/.vscode/launch.json

Start the debug server by pressing F5. You can check your server is up by requesting http://localhost:8080/readyz.

deploying

First deploy (creation) must include all the flags to configure the environment:

gcloud functions --project your-project deploy testnet --region europe-west3 --entry-point Entry --runtime go116 --trigger-http --allow-unauthenticated --service-account=your-readonly@your-project.iam.gserviceaccount.com --update-env-vars GCP_PROJECT=your-project,BIGTABLE_INSTANCE=wormhole-testnet

gcloud functions --project your-project deploy processvaa-testnet --region europe-west3 --entry-point ProcessVAA --runtime go116 --trigger-topic new-vaa-testnet --service-account=your-readonly@your-project.iam.gserviceaccount.com --update-env-vars GCP_PROJECT=your-project,BIGTABLE_INSTANCE=wormhole-testnet

Subsequent deploys (updates) only need include flags to indentify the resource for updating: project, region, name.

gcloud functions --project your-project deploy testnet --region europe-west3 --entry-point Entry

gcloud functions --project your-project deploy processvaa-testnet --region europe-west3 --entry-point ProcessVAA

invocation

All routes accept their input(s) as query parameters, or request body. Just two different ways of querying:

GET

curl "https://region-project-id.cloudfunctions.net/testnet/readrow?emitterChain=2&emitterAddress=000000000000000000000000e982e462b094850f12af94d21d470e21be9d0e9c&sequence=0000000000000006"

POST

curl -X POST  https://region-project-id.cloudfunctions.net/testnet/readrow \
-H "Content-Type:application/json" \
-d \
'{"emitterChain":"2", "emitterAddress":"000000000000000000000000e982e462b094850f12af94d21d470e21be9d0e9c", "sequence":"0000000000000006"}'

See ./bigtable-endpoints.md for API patterns