Commit Graph

169 Commits

Author SHA1 Message Date
walker-16 1ea141ec95
fix pagination in governor notional available endpoint (#272) 2023-04-27 17:31:33 -03:00
walker-16 bae5f06afb
250 governornotionalavailable sending an invalid chainid returns invalid data (#270)
* Check supported chainID in endpoint governor available notional by chain

* check supported chainID in endpoint mx notional available by chainID
2023-04-27 13:56:18 -03:00
agodnic 09870f3d65
[tx-tracker / api] Avoid duplicating data (#256)
### Summary
Tracking issue: https://github.com/wormhole-foundation/wormhole-explorer/issues/254

For all chains except Solana, the data in `globalTransactions.sourceTx` was somewhat duplicated, since we already had that data in the `vaas` collection.
This pull request changes the `tx-tracker` service so that no redundant data will be written, and also changes the API to look up the data from the `vaas` collection instead.

The responses from the endpoint `/api/v1/global-tx` will no longer contain the field `originTx.from`.
2023-04-25 15:34:29 -03:00
walker-16 3ea4603baf
return empty array and not null in 200 empty repsonse governor limit … (#261)
return empty array and not null in 200 empty repsonse governor limit endpoint
2023-04-25 14:50:44 -03:00
walker-16 ffeb5927f8
Add notional cache client (#241)
* Add notional cache client

* gracefull shutdown pubsub and distributed cache
2023-04-20 17:02:25 -03:00
agodnic c8aba636e4
[API/ANALYTICS] Scorecards endpoint (#232)
### Summary

This pull request adds the `GET /api/v1/scorecards` endpoint, which is required by the wormscan frontend.

Most of the fields that this endpoint should return are being omitted because the data is not currently available on the backend. Those fields will be added iteratively as the data becomes available.

The current format of the response is:
```json
{
  "total_tx_count": "1300200",
  "24h_tx_count": "4200"
}
```

Tracking issue: https://github.com/wormhole-foundation/wormhole-explorer/issues/221

## Deployment details

In order to populate the `"total_tx_count"` metric, a task is needed in influxdb:

```
$ cat total-vaa-count.flux 
option task = {
	name: "Total number of emitted VAAs",
	every: 1m
}

from(bucket: "wormhole-explorer")
  |> range(start: 2018-01-01T00:00:00Z)
  |> filter(fn: (r) => r._measurement == "vaa_count")
  |> group(columns: ["_measurement"])
  |> set(key: "_measurement", value: "total_vaa_count")
  |> count()
  |> map(fn: (r) => ({r with _time: now()}))
  |> map(fn: (r) => ({r with _field: "total_vaa_count"}))
  |> to(bucket: "wormhole-explorer", org: "xlabs")

```
2023-04-20 16:01:10 -03:00
walker-16 ce83e1c3a6
Add gracefull shutdown to explorer api (#244) 2023-04-19 14:30:46 -03:00
agodnic 6fcf8f8270
Add route `GET /api/v1/address/{address}` (#228)
### Summary

This pull request adds the new route `GET /api/v1/address/{address}`, which returns the transactions in which the given address participated.

Examples:
* https://api.staging.wormscan.io/api/v1/address/0x0000000000000000000000001ef2e0219841d1a540d99c432a6eddb75deed1b7
* 000000000040d99c432a6eddb75deed1b7
* 000000000040d99c432a6eddb75deed1b7?page=0&pageSize=2
* 000000000040d99c432a6eddb75deed1b7?page=1&pageSize=2
* https://api.staging.wormscan.io/api/v1/address/1111111111114Sd894pYPPeXjZCDN5Gv8KCzwFGN

Tracking issue: https://github.com/wormhole-foundation/wormhole-explorer/issues/222
2023-04-12 15:51:33 -03:00
agodnic 1f47f887da
[API/TX-TRACKER] Add support for Solana tx hashes (#218)
### Summary
This pull request adds the functionality to search for VAAs using Solana tx hashes, e.g.:

`GET /api/v1/vaas?txHash=2qnNNBQQQ152sGkQ1Rnq2Kdr48LvdN4oXwnTWyEmJqYYWFusLWxbwhpGS5KTXH1bKKx9gg9BLZMKd3g1cXiy7QMz`.

Also, the VAA objects returned by the API now have a new field `nativeTxHash`, which contains the tx hash that generated the VAA in the native format of the emitter chain.

Tracking issues: https://github.com/wormhole-foundation/wormhole-explorer/issues/212, https://github.com/wormhole-foundation/wormhole-explorer/issues/214

### Testing guidelines

Endpoints affected:
* `GET /api/v1/vaas` now supports Solana tx hashes by using the `?txHash=` query parameter. This search is limited to VAAs created by the portal token bridge.
* Some VAAs returned by the API should have a new field `nativeTxHash`. All VAAs related to the portal token bridge should have this field set.
*  An internal refactoring affected pretty much all routes under `GET /api/v1/vaas*`, which should be re-tested.
* In the response of `/api/v1/global-tx/`, the field `originTx.signer` has been renamed to `originTx.from`
2023-04-05 10:33:28 -03:00
walker-16 a5df48c967
Add start_date, end_date validation controller (#216) 2023-04-04 10:49:27 -03:00
agodnic d0cf9cc04b
[API] Fix issue in VAA search filters (#211)
### Summary

Searching for VAAs with the `txHash` and the `parsedPayload` parameters simultaneously wasn't working correctly. This commit fixes the problem.

Tracking issue: https://github.com/wormhole-foundation/wormhole-explorer/issues/210
2023-03-27 16:14:38 -03:00
ftocal e1298f54ee
logging as json (#208) 2023-03-23 15:36:50 -03:00
agodnic 93427d6dfc
[API] Fix serialization issue in HTTP responses (#204)
### Summary

Several endpoints related to VAAs and observations returned `null` when no results were found.

This commit changes the behavior to return `[]` instead, which is more ergonomic for users.

Endpoints affected:
- `GET /api/v1/observations/:chain`
- `GET /api/v1/observations/:chain/:emitter`
- `GET /api/v1/observations/:chain/:emitter/:sequence`
- `GET /api/v1/observations/:chain/:emitter/:sequence/:signer/:hash`
- `GET /api/v1/vaas/{chain_id}`
- `GET /api/v1/vaas/{chain_id}/{emitter}`
- `GET /api/v1/vaas/{chain_id}/{emitter}/{seq}`
2023-03-22 14:18:11 -03:00
agodnic 50547e1140
[API] Fix governor endpoints (#202)
Fix governor endpoints

A few governor endpoints were handling addresses incorrectly,
which resulted in errors.
* `GET /api/v1/governor/config/{governor_address}`
* `GET /api/v1/governor/status/{governor_address}`

This commit fixes the issue and adds doc comments to prevent the
same caveat from happening again in the future.
2023-03-22 13:41:11 -03:00
ftocal 32c1361782
fix: use of decimal for huge numbers (#203) 2023-03-22 13:38:43 -03:00
agodnic 29f7900c7d
[API] Accept emitter addresses in Solana format (#200)
### Summary

This PR enables passing emitter addresses in Solana format when the `chainId` parameter is set to 1. If `chainId` is set to a different value, the API will expect a regular Wormhole address.

Tracking issue: https://github.com/wormhole-foundation/wormhole-explorer/issues/189

### Endpoints affected
- `GET /api/v1/global-tx/{chain_id}/{emitter}/{seq}`
- `GET /api/v1/observations/:chain/:emitter`
- `GET /api/v1/observations/:chain/:emitter/:sequence`
- `GET /api/v1/observations/:chain/:emitter/:sequence/:signer/:hash`
- `GET /api/v1/vaas/{chain_id}/{emitter}`
- `GET /api/v1/vaas/{chain_id}/{emitter}/{seq}`

### Example
These two calls should be equivalent:
- `GET /api/v1/vaas/1/ec7372995d5cc8732397fb0ad35c0121e0eaa90d26f828a534cab54391b3a4f5` (address in Wormhole format)
- `GET /api/v1/vaas/1/Gv1KWf8DT1jKv5pKBmGaTmVszqa56Xn8YGx2Pg7i7qAk` (the same address, in Solana format)
2023-03-21 16:12:23 -03:00
ftocal 5527268969
Fix destinationTx.timestamp type in globalTransactions collection (#198)
fix destinationTx.timestamp type in globalTransactions collection
2023-03-21 11:57:46 -03:00
ftocal db3a54270a
fix: use full address (#193) 2023-03-16 15:42:34 -03:00
ftocal 824ba3c7f9
Add contract watcher component (#190)
* init contract-watcher

* Add processor and blockain watchers

* Add pagination and save last blocknumber procesed by chain

* Add processing by blocks

* Add contract-watcher deploy manifest

* Add endpoint to get globalTransactions by Id

* Add originTX to get globalTransactionById endpoint

* Add wait time for new blocks

* Add initial block for evm watcher

* Add rate limit for evm watcher

* Handle testnet environment and small fixes

* Update wormhole dependencies

* Fix api documentation for swagger

---------

Co-authored-by: Agustin Pazos <agpazos85@gmail.com>
2023-03-15 16:52:50 -03:00
ftocal 867f1c2962
[API/PARSER] Chain activity and last transaction endpoints (#175)
* Fix analytic vaa metric and close metric client

* Add analytic component manifest

* Add metrics for cross chain activity endpoint

* Feature/add endpoint get vaa count (#171)

* Add trasaction controller + service

* Init getLastTrx endpoint

* Add endpoint for chain activity

* Add configmap and secrets for influx
Change Dockerfiles to support common library

* Add vaa_count endpoint

* Add cross-chain activity endpoint

* Fix vaa_count endpoint

* Add influx to api-service manifest

* Make response and add docs for chain activity endpoint

* Fix api deploy

* Fix lasl-trx json name

* Fix chain activity endpoint

* Fix doc and endpoint route last-txs

---------

Co-authored-by: Agustin Pazos <agpazos85@gmail.com>
2023-03-07 16:25:42 -03:00
agodnic b3ec0bcc9e
[API] Fix pagination in `GET /api/v1/governor/notional/available/{chainId}` (#168)
### Summary

Changes:
* Fix `page` and `pageSize` parameters in `GET /api/v1/governor/notional/available/{chainId}`.
* Sort results by ascending guardian address to enforce deterministic output.

Tracking issue: https://github.com/wormhole-foundation/wormhole-explorer/issues/162
2023-03-01 10:44:27 -03:00
agodnic 533b83ad28
[API] Accept additional address formats (#170)
### Summary

Context: https://github.com/wormhole-foundation/wormhole-explorer/issues/154

This PR modifies all endpoints that receive an emitter/guardian address to accept a wider range of formats.
After this pull request, all of these are equivalent:
* `0x000000000000000000000000f890982f9310df57d00f659cf4fd87e65aded8d7`
* `000000000000000000000000f890982f9310df57d00f659cf4fd87e65aded8d7`
* `0xf890982f9310df57d00f659cf4fd87e65aded8d7`
* `f890982f9310df57d00f659cf4fd87e65aded8d7`

### Testing plan
* Added unit tests for the parsing code.
* Tested manually a few of the affected endpoints.
2023-02-28 17:50:23 -03:00
agodnic cd99c446e1
[API] Format governor queries for readability (#167) 2023-02-27 11:32:12 -03:00
agodnic 4cf7577a03
[API] Remove unused query params from swagger docs (#166)
### Summary

* Swagger: remove `sortOrder` query parameter from several endpoints in which it didn't make sense.
* Swagger: remove query params `page` and `pageSize` from endpoints that return a single object.
* Sort the output of `GET /api/v1/governor/config` by ascending id.
* Refactor: remove duplicated code, format code for readability.
2023-02-24 10:47:20 -03:00
agodnic 3e01b42f20
[API] Fix incorrect route in swagger docs (#165)
The API's swagger documentation exposes a route
`GET /api/v1/governor/max_available/:chain`,
but instead it should be
`GET /api/v1/governor/notional/max_available/:chain`.
2023-02-23 16:54:40 -03:00
agodnic 4ca0bf1c0e
[API] Several fixes in `GET /api/v1/governor/limit` (#153)
### Summary

Changes to `GET /api/v1/governor/limit`:
* Fix the behavior of the parameters `page` and `pageSize` (which previously were being ignored).
* When no results are found, return an HTTP status code of 200 and set the response to an empty array.
* Remove the `sortOrder` query parameter.

The rationale for removing the `sortOrder` parameter is that sorting chains by ascending/descending chain ID doesn't seem to be a useful operation.
2023-02-10 15:58:10 -03:00
agodnic e85fa82784
[API] Remove redundant checks (#150)
Remove redundant nil checks in `api/handlers/governor/repository.go`.
2023-02-10 15:57:11 -03:00
agodnic e2195d420e
[API] Fix issue in MongoDB aggregation pipeline (#147)
### Summary

In some cases, the query parameters for a MongoDB aggregation pipeline were not being initialized.

This led to errors in `GET /api/v1/vaas/{chain}/{emitter}/{seq}`. 
Other endpoints could also have been affected.
2023-02-10 15:55:45 -03:00
agodnic c4b2e792b3
[API] Change status code for enqueued VAAs endpoint (#151)
Previously, when calling `GET /api/v1/governor/enqueued_vaas`, it returned a status code of 404 when there were no enqueued VAAs.

Now, the endpoint returns a status code of 200, and the response body contains an empty array.
2023-02-10 14:31:33 -03:00
agodnic dde87acf84
[API] Several fixes related to pagination (#144)
### Summary
* On all endpoints, fix the behavior of the `page` parameter (which was previously being ignored).
* On `GET /api/v1/vaas`, fix the behavior of the `sortBy` parameter (which wasn't working when `parsedPayload=true`).
* For all endpoints, validate the query parameters `page`, `pageNumber` and `sortOrder`.
* Return descriptive errors when pagination-related parameters happen to be invalid (`page`, `pageSize`, `sortOrder`).
* Validate guardian addresses in query params.

### Testing plan
All parameters involved were manually tested.
2023-02-09 14:28:39 -03:00
gipsh a155e6c99f add make to docker 2023-02-05 09:52:56 -03:00
walker-16 bb1fc8c3e2
feature/fix_api_v1_governor_responses_to_camelcase (#136) 2023-02-03 18:46:16 -03:00
agodnic 9018d9a51a
[API] Remove duplicated model for VAAs (#135)
The structs `VaaDoc` and `VaaWithPayload` were being used for similar purposes.

This commit merges both into the same struct.
2023-02-03 16:46:02 -03:00
agodnic 38c8e82879
[API] Remove unused path parameters (#131)
Remove unused path parameters in `GET /api/v1/vaas/{chain_id}/{emitter}/{seq}`
2023-02-03 15:44:46 -03:00
walker-16 7506ff0bf5
Add pprof all components (#134)
* Fix Config pprof in fly

* Refactor pprof explorer parser component

* Add pprof to spy component

* Add pprof to api [api/v1, /v1]
2023-02-03 15:18:44 -03:00
agodnic d32405f737
[API] Update swagger docs (#120)
Co-authored-by: Agustin Godnic <agustin@xlabs.xyz>
2023-02-01 14:11:40 -03:00
gipsh 0f47b6d64d
add version endpoint (#118)
Co-authored-by: gipsh <gipsh@gmail.com>
2023-02-01 10:46:22 -03:00
agodnic cd976bac96
[API] Add appId parameter to GET /api/v1/vaas (#114)
Add the `appId` query parameter to `GET /api/v1/vaas`.
2023-02-01 09:59:51 -03:00
agodnic ed0985d502
[API] Add parsed payloads to `GET /api/v1/vaas` (#113)
Add query parameter `parsedPayload` to the endpoint `GET /api/v1/vaas`.
2023-01-31 15:24:34 -03:00
walker-16 1c7e58a27a
Handle guardianSet by p2p enviroment in fly/api (#112) 2023-01-31 11:38:17 -03:00
walker-16 ca6710d5d5
Add parsedPayload query param to /vaa/:chainID/:address/:sequence (#102) 2023-01-27 13:47:17 -03:00
agodnic e929104ed9
[API] split api/v1 and v1 routing in different files (#101)
### Summary

Split `/v1` and `/api/v1` controllers into different packages (respectively `api/routes/guardian` and `api/routes/wormscan`).

Still need to move services/repositories/models according to the new package layout.
2023-01-27 12:58:37 -03:00
walker-16 f23f9f78ab
Enabled pprof fly and enable cors at app group in explorer api (#99) 2023-01-26 14:55:27 -03:00
agodnic 2a5b4db51a
[API] Fix issues related to swaggo v1.8.10 (#96)
### Summary

Updating from swaggo v1.8.9 to v1.8.10 caused issues with the generated swagger file.

The issue was solved by moving the handler for `GET /swagger.json` outside the `/doc` directory.
2023-01-26 12:04:01 -03:00
ftocal e20e73c636
Add txHash in VAA (#94)
* add vaaId and txHash relation in vaaIdTxHash collection

* add txHash in vaas collection

* add txHash in response vaa and as filter in find vaas endpoints
2023-01-26 11:54:41 -03:00
agodnic b6266b0776
[API] Fix typo in package name (#92)
Fix typo in package name
2023-01-26 11:00:02 -03:00
agodnic 0a382a0a5c
[API] Add route `GET /swagger.json` (#91)
Expose the API's swagger spec under the route `GET /swagger.json`
2023-01-26 10:32:20 -03:00
agodnic 6022d5fd14
[API] Increase documentation coverage (#90)
Add swagger documentation for all endpoints.

This addresses https://github.com/wormhole-foundation/wormhole-explorer/issues/68
2023-01-25 16:19:14 -03:00
agodnic cc1f1b440f
[API] Increase swagger documentation coverage (#89)
Add documentation coverage for endpoints related to VAAs.
2023-01-24 17:58:04 -03:00
ftocal 2f11affc53
fix: remove enqueued vaas duplicated (#88) 2023-01-24 16:01:00 -03:00
agodnic d93613b833
[API/FLY/SPY] Update .gitignore (#87)
Ignore files generated by `make build`
2023-01-24 12:02:41 -03:00
gipsh f4f543fc95
create cicd pipeline for deployments to staging environment - step 1 (#71)
* add missing makefiles and fix deps

* add parser makefile and github action for PR

* fix warning

* fix printf

Co-authored-by: gipsh <gipsh@gmail.com>
2023-01-23 18:41:19 -03:00
walker-16 5225cc13fa
Feature/add grpc support (#73)
* Add grpc web support

* Add endpoints GRPC
- GovernorGetAvailableNotionalByChain
- GovernorGetEnqueuedVAAs
- GovernorIsVAAEnqueued
- GovernorGetTokenList

* Add endpoint GRPC - GetSignedVAA, GetSignedBatchVAA, GetLastHeartbeats, GetCurrentGuardianSet

Co-authored-by: Fernando Torres <fert1335@gmail.com>
2023-01-23 11:45:09 -03:00
walker-16 cf274f1fd8
Fix counter int to string heartbeats endpoint (#70) 2023-01-20 13:38:40 -03:00
ftocal 303b731d60
Feature/add parser pipeline (#46)
* Add pipeline to parse vaa

* Add parser repository and start building pipeline publisher

* Add queue sqs and in-memory to pipeline

* Add ses publisher and queue sqs/memory

* Fix watcher query

* Fix type to marshall/unsmarshall chainID and emitterAddress

* Fix js execution is run many times

* Add comments

* Add comments and improvements

* Change VAA Parser implementation

* Fix and change integration-test vaa-payload-parser

* fix appID mongo field name

* Fix guardianSet version 3, add xlabs to position 8

Co-authored-by: Agustin Pazos <agpazos85@gmail.com>
2023-01-18 12:42:14 -03:00
Gabriel Zimmermann b5e5ce73c5
Query pythnet collection for pyth chain id in api (#57)
* Query pythnet collection for pyth chain id in api

* Delete api/vq FindForPythnet endpoint

Co-authored-by: Agustin Pazos <agpazos85@gmail.com>
2023-01-18 12:33:26 -03:00
walker-16 669fe6d16e
Fix observation endpoints, change setHash to hash (#61) 2023-01-18 12:31:25 -03:00
gipsh f4f96655a8
add new guardian set v3 (#59)
* add new guardian set v3

* update guardian set for fly

Co-authored-by: gipsh <gipsh@gmail.com>
2023-01-18 09:27:59 -03:00
gipsh 811e5e6f25
remove prefix (#55)
Co-authored-by: gipsh <gipsh@gmail.com>
2023-01-12 22:42:08 -03:00
gipsh 085d5ecd03
add swagger doc, makefile and readme (#53)
Co-authored-by: gipsh <gipsh@gmail.com>
2023-01-10 12:32:07 -03:00
walker-16 7255b214ca
18 fly api cache most recent data for most frequent queries (#51)
* Add use of sequence cache in API

* Add sequence cache in fly

* Deploy for API

* Improve use cache in API

* Remove sequence cache in fly for pythnet

Co-authored-by: Fernando Torres <fert1335@gmail.com>
2023-01-05 16:40:24 -03:00
walker-16 457471f51d
Add grpc api (#40) 2023-01-03 14:42:29 -03:00
Agustin Pazos 8775bafb00 Fix mongo types in API 2023-01-02 11:14:13 -03:00
ftocal af94eac721
Add k8s deployment (#39)
creation of manifests to deploy in k8s
2022-12-14 17:07:55 -03:00
walker-16 bfd68061a8
Fix: change sequence type to string (#42)
Co-authored-by: Fernando Torres <fert1335@gmail.com>
2022-12-14 16:26:45 -03:00
walker-16 e245d7a8b0
Add index collections and health/ready kubernetes (#37) 2022-12-05 17:41:37 -03:00
walker-16 bf8319bf10
Modify vaa count endpoint to use capped collection (#35) 2022-11-23 10:15:16 -03:00
walker-16 8ed4804d63
Feature/refactor api (#34)
* Refactor error handling and comments

* Refactor and improve error handling and logs
2022-11-23 09:06:29 -03:00
walker-16 d4f43e37d6
Adds go rest api (#29)
* Adds api in go

* renames observation import in api

* Add signed_vaa endpoint [guardian api]

* Add governor endpoints to API

* fix devnet/api.yaml to up with a fixed port

Co-authored-by: Gabriel Zimmermann <gabrielemanuel@gmail.com>
2022-11-17 12:37:29 -03:00