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
32 changes: 27 additions & 5 deletions scripts/on-chain-data/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,30 @@ go run . <command> [flags]
| `find-workflow-report-id` | Find which feed contains a report ID |
| `get-account-balances` | Writer account balances |

### Environments

All commands take `--environment`/`-e`. Each environment maps to a set of Aptos writer (transmitter) accounts and an Aptos fullnode. Transmitter addresses are sourced from the CRE capability registry (`p2pToTransmitterMap` in `data-feeds-cre-{prod,staging}/state.json`).

| Environment | Aptos network | DON | Nodes | Notes |
|-------------|---------------|-----|-------|-------|
| `staging` | testnet | `feeds_chain_capabilities_zone-a` | 4 | |
| `staging-zone-b` | testnet | `feeds_chain_capabilities_zone-b` | 4 | |
| `prod-testnet` | testnet | `feeds_chain_capabilities_tnet_1_zone-a` | 4 | |
| `prod-testnet-zone-b` | testnet | `feeds_chain_capabilities_tnet_1_zone-b` | 4 | |
| `mainnet` | mainnet | `feeds_chain_capabilities_1_zone-a` | 10 | zone-a writers |
| `mainnet-zone-b` | mainnet | `feeds_chain_capabilities_1_zone-b` | 10 | zone-b writers |

Both `mainnet` and `mainnet-zone-b` write to the same feeds on the same aptos-mainnet chain; they only differ in which transmitter accounts are queried. To get full coverage across both zones, run a command for each environment and merge the CSVs (events are deduped by feed observation in `get-feed-gaps`, so overlapping reports collapse correctly).

### Get Data Feeds Events Emitted Across All Environments

This Go script retrieves data feed events emitted across all environments and transmitters. It generates different CSV files based on the specified environment (`staging`, `prod-testnet`, or `mainnet`). The output is sorted by block timestamp. This command also retrieves the timestamp of the most recent transaction.
This Go script retrieves data feed events emitted across all environments and transmitters. It generates different CSV files based on the specified environment. The output is sorted by block timestamp. This command also retrieves the timestamp of the most recent transaction.

**Flags:**

| Flag | Short | Description | Default |
|------|-------|-------------|---------|
| `--environment` | `-e` | Environment (`staging`, `prod-testnet`, `mainnet`) | `staging` |
| `--environment` | `-e` | Environment (see [Environments](#environments)) | `staging` |
| `--lookback` | `-l` | Lookback period in hours. Paginates backwards from the most recent transaction per account to ensure complete time coverage. Use `0` to fetch all history. | `24` |
| `--feed-id` | `-f` | Filter by a specific feed ID. If omitted, returns events for all feeds. | (all feeds) |

Expand All @@ -49,7 +64,7 @@ This Go script helps to locate a specific reportID in the FeedUpdated events of

| Flag | Short | Description | Default |
|------|-------|-------------|---------|
| `--environment` | `-e` | Environment (`staging`, `prod-testnet`, `mainnet`) | `staging` |
| `--environment` | `-e` | Environment (see [Environments](#environments)) | `staging` |
| `--reportId` | `-r` | Report ID to search | (required) |
| `--lookback` | `-l` | Lookback period in hours. Use `0` to fetch all history. | `24` |

Expand All @@ -69,7 +84,7 @@ Fetches all on-chain feed updates in a lookback window and computes the observat

| Flag | Short | Description | Default |
|------|-------|-------------|---------|
| `--environment` | `-e` | Environment (`staging`, `prod-testnet`, `mainnet`) | `staging` |
| `--environment` | `-e` | Environment (see [Environments](#environments)) | `staging` |
| `--minutes` | `-m` | Lookback period in minutes | (required) |

```bash
Expand Down Expand Up @@ -133,6 +148,12 @@ go run . compute-data-feed-updated-events-metrics \
-i aptos-data-feed-events-mainnet-latest.csv
```

To cover both zones on mainnet, repeat the fetch for `mainnet-zone-b` and merge (or run `get-feed-gaps` for each — overlapping observations are deduped):

```bash
go run . get-feed-updated-events -e mainnet-zone-b -l 2
```

### Compute Data Feed Events Metrics from previous step

This Go script computes metrics such as the average, minimum, maximum, p90, p95, p99, and SLA for the overall set of events, as well as split by feed. Additionally, it retrieves statistics on the gas used to process all feeds and identifies slow transactions. Use `-t` to include only events from the last N seconds.
Expand All @@ -146,5 +167,6 @@ go run . compute-data-feed-updated-events-metrics -i aptos-data-feed-events-prod
This Go script retrieves the balance of accounts in a given environment.

```bash
go run . get-account-balances -e prod-testnet
go run . get-account-balances -e prod-testnet
go run . get-account-balances -e mainnet-zone-b
```
88 changes: 50 additions & 38 deletions scripts/on-chain-data/environments.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,61 +2,71 @@ package main

import "log"

// Aptos transmitter addresses sourced from the CRE capability registry
// (p2pToTransmitterMap values in data-feeds-cre-{prod,staging}/state.json).
// DON: feeds_chain_capabilities[_tnet]_1_zone-{a,b}
var accountsByEnvironment = map[string][]string{
"staging": {
"0x426612d24bf1a44f20b0f957c96b940b9da20f72aaffaeddc47c0827c5725ac2", // node 0 (NodeID = '1') - RPC aptos_primary_quiknode
"0x3e29e2591e63b088c496f9d20d5ac71e049452c4f445b376de0ab9f90cfec0d6", // node 1 (NodeID = '2') - RPC aptos_primary_p2pify
"0xa9945161773dc6149748e2ce7baa65a5f4feacc34fa725b21f1762f4d3f0ed25", // node 2 (NodeID = '3') - RPC aptos_primary_linkpool
"0x60d4a83b62a6bfa828c6c555ea40b4a67a4b683f0ec559c3d85d796166455e3a", // node 3 (NodeID = '4') - RPC aptos_primary_linkpool
// feeds_chain_capabilities_zone-a (aptos-testnet, 4 nodes)
"0x5686d9cf95413f3570d6bec0e6a6294c43c7a4579c0f158398df87f6c6de93e6",
"0xf120d4786d2921ed856e937830f0c752ed7bcdfff09fb3049819a3837501ac2a",
"0x6ac0430dfd584bfa13d6b2090ea17c872e2e8d9c567046881ac61b21ca67e368",
"0xe6b5385039b210efd7cfb0ee2638b382f0f629941e94a239f3823e5841146238",
},
"staging-zone-b": {
"0x9a14574f1f99b1becb348cdef53deaef66f148d055f2e41c7021db9670453f20", // node 0 (NodeID = '1')
"0x4397633e4fba12054d6270f59094752642ab8445aa4c89e1f340759884cffa33", // node 1 (NodeID = '2')
"0x74b14f822a761e1e0d0436ac0a87cb7a984a260c9b6999a8a4282b9cf95ce3ba", // node 2 (NodeID = '3')
"0xe0f6be3bbf30eb6498957abf33f66ef50adb61bda4201b37d6ec53d0efb79146", // node 3 (NodeID = '4')
// feeds_chain_capabilities_zone-b (aptos-testnet, 4 nodes)
"0x292b79f146ccab1b8f0c811a08ae58b850a3532edb3715cea4ef17001f40b32b",
"0x2aff74345161f20b23b9570f108b35627ec7db30d5496f804464df0efdb5acc8",
"0x5b2620c7cec16a8dee6f0853867e0dac3e2b09da526d1819f1dd01b0b3f2b696",
"0x9395bffdd0f731ea3b1d0ab050d9741964fee954a6a84441c4b3c278b6eb9152",
},
"prod-testnet": {
"0x9a28fa835ea14231158c9b0aa7e874076c4b932b8d7f5d936410990a8735e065", // node 0 - RPC aptos_primary_p2pify
"0xd888353aea5c713ec3489bbd5eb81e09462c2ea24c5fddb75082c3f211eb7852", // node 1 - RPC aptos_primary_linkpool
"0x4f053f65e333c94997b068561d17a76ed71dce377e436fd088473c577b848aa6", // node 2 - RPC aptos_primary_quiknode
"0x4049c59004c446370aecff9f6c799198e18b735b398b81b45102f28afbdda18b", // node 3 - RPC aptos_primary_p2pify
"0x63d8d44b8568f97d97afc521e3964608ea530a6ef5ffe3ece52688699f80ff1b", // node 4 - RPC aptos_primary_linkpool
"0x47761f0c0dadb79b2fc1d3b0d975a2cb8ff906a809a97aadc3cec584d1da2282", // node 5 - RPC aptos_primary_quiknode
"0x24b3b178bd8408c5e5f3d5af5fe3395018cd190395037c054edd99ca0febc82f", // node 6 - RPC aptos_primary_p2pify
"0xa688106692e1b14853f1bf7ea6e84bfaa65f71adfc4bfd2a3a746367fec210fa", // node 7 - RPC aptos_primary_linkpool
"0x0e861e0f3abf2c0b0842b1d1c939c42cf5b121eaf296d4f9943c0cc18ac1a14e", // node 8 - RPC aptos_primary_quiknode
"0xe9f43f65ee39887ef15557194154942fcab8f11f5c8e73990f4523435435f846", // node 9 - RPC aptos_primary_p2pify
// feeds_chain_capabilities_tnet_1_zone-a (aptos-testnet, 4 nodes)
"0xee50b205bacf48920c0236c9b92d2a389ffc9a0082f3d65e1dd989bba361a25c",
"0x5cfee21155f5896515cba93120169422c2157242f3c084d6a1b8bd8e46f2fa1d",
"0x1841e0d886d2814dacce3eda13e7e283c2ca484247215395a1db4e517c0a7e3e",
"0x9a06d76f03d26294dd5fe361ba78ca7603b53474b32220211b1dd1645407f74f",
},
"prod-testnet-zone-b": {
"0x771ed5b608be49fb9ae805884543d9fbaedbaf7011e853a0e3c7290b61de1953",
"0x1b2b488dad2e2bacd396084f88f20da7688ac270b4cb8ea5190ec9a1146e9898",
"0x6956bfe2f588bc278aa6701dd03cb9f8e659081be2bd5af05acb7ef476918fb2",
"0x7e715f84a44b6dbbf3714c7cc3475e78464a072079eaf2d6f8353fddea969996",
"0x0770df60ea0df993eeee293398db59e07f6b46f6a5c1b2e3e54dd4269aaa6129",
"0xc161409c1790a673afe65db17e71a7ba2768e34c66fb1ecfac9617633a09d42b",
"0xf7a988f365327e7ee00b862f991ca4cb0011fab93a192358e11fd6d7870e7ce4",
"0xbfd481c87534aac0895fe1746531dd492c9321e02f7d830e922b166d4d6a511b",
"0x18180f506ae3b9a68155c66d1bb944d49ea3ab6eb6b69e7a0aa5ec4cea0c81bd",
"0xc85da50f7ef7a36752772cad11a26a6b77b65ce4749bc8106132e1102ab8ba04",
// feeds_chain_capabilities_tnet_1_zone-b (aptos-testnet, 4 nodes)
"0x9a476fb11688c1193116353b5a4677c7878ab6b0930139ba5236338d5e26dcf5",
"0x0b0e1564a48d7875291cd784cf96b300305caaf3f6fb535a0028716f59a85a4a",
"0xb0565b9837e51d05aa516948a47e6bc38fdcaafb3fb9d5a267e1fea7c13c9819",
"0x21e87ce40d4684e3b1bb04c9116d013e952ca8e5cd4111af5b56109748f28552",
},
"mainnet": {
"0x0ccb64f4a24f3791752ea3bad8d2e9dd451e7347b8975c263c02b2180d31b2b9", // writer_1-node-chainlayer
"0x080e899c2f3f5fb4f207953d9ecdedf86faa940756c6e4f47c55c45d8c1ae7b9", // writer_1-node-chainlinklabs
"0x4392652252a8289dcbe820a137c624408dbeec420cda4e2a7c5a3662cb956484", // writer_1-node-dextrac
"0xfb7ebc84ce674c3c1f7a789a30084d2227056982fb430dfd8b18c8f7737f4f57", // writer_1-node-fiews
"0xe7f459b0e6ceb3c3f35b6e8a4647eb6879bf21c78ebc0bee63cc0c6ff0cca276", // writer_1-node-inotel
"0xaba7a83b8aa67be1cf726d250abe687629c875d04c57de238bcc72c208bffce8", // writer_1-node-linkpool
"0x03caaf3f4e2b1510592890efcdd5e6ca6c61abe4238de323881ae768a0a39d73", // writer_1-node-linkriver
"0x5c013a770992f487e1e2f31e2b56b3f1655c54bae7ab6ff44c49b9f42bb9e3ec", // writer_1-node-piertwo
"0x9f303c5d6473437e4386318118020ff32ad09a97091a4470fa8b0ebe1dd67974", // writer_1-node-simplystaking
// feeds_chain_capabilities_1_zone-a (aptos-mainnet, 10 nodes)
"0x09646a5c9af6c278eaaa5e713326fa7c1e42d446a7b951c6f3ce23f65435293f",
"0x3ece24870cea5e986ba0562e394b83872297c3903eb5ca807c415cb1a8f5a9c5",
"0x7a5a113b7662d6f221af27185881d1afdc06e1d90bc36bd04342179d43404b5e",
"0xbe08c52ed419e367259e3d4e26499912ed01631e6731d81edcac4c25e93d5092",
"0x07c1039dbfbc4eee1aac18373eb0e0db80f4132829bda6d68ad3bee938a577db",
"0xaeb1b89ca4b05f2a2e0504f2bc002a70071a8895596c0acac25f4db67d8017a9",
"0xfd86b7aaa9f8dbd53167702741756eeb44c6da00f306c6c39ff76fdf21040dfa",
"0x5a6bf46fa48a6785af48e67886609e5197e0dfd555bbd8737aed4f5c4af298a2",
"0xcbccb01c99134756a60acec297c0fa648bb23b1e9016cd7e54313e3383eb2b00",
"0x6d22150fad3d65812bfc797bfd3ad5322435a6f73991d8ec8a6b498e19e331b5",
},
"mainnet-zone-b": {
// feeds_chain_capabilities_1_zone-b (aptos-mainnet, 10 nodes)
"0x771825d0cca6eb6c1eedc4ad76f2198ee59c0160c358d37ea2a3c036da85f3e7",
"0x55d395ec8dc2311d5fa2ac6b878741e3ba6291f249d3f4415e691586f3062220",
"0xd6484afa7c26aaacbc65a917213259944359ca5fc4e2c49fccd607a4f4d94094",
"0xb80e004d517d32a433c47e0643fe5d68db2d94c3415b51a062d3b9fd6a22b185",
"0xa8d846134256999076b56348836fd3995273e2d40b5a535f2554c15242319fb4",
"0xaa1f64ee54ff4b268e19c4ce6a8c45dc96c51038766a318e864e17cf3ac98f06",
"0xf7c47ccd3dc6ce0f75007ad309958032a1f67440a69b1d0f61038e8cdb7338be",
"0xa65e14b1dced61f9d6749aeaa4c4e9eb215fe2be316acdb3543ce60fed9c00bf",
"0x326f314d4059528508cffca4456a2978f788fe6197fc9e66687d9b599dee4c67",
"0x6b6da99067b1e5bf15670bf55f7f8789e1c7ad36c53b9279c72776f7127a8f49",
},
}

func GetAccountsByEnvironment(environment string) []string {
accounts, ok := accountsByEnvironment[environment]

if !ok {
log.Fatalf("Invalid environment: %s. Valid options are: staging, prod-testnet, mainnet", environment)
log.Fatalf("Invalid environment: %s. Valid options are: staging, staging-zone-b, prod-testnet, prod-testnet-zone-b, mainnet, mainnet-zone-b", environment)
}

return accounts
Expand All @@ -69,6 +79,7 @@ func GetAptosAPIBaseURL(environment string) string {
"prod-testnet": "https://fullnode.testnet.aptoslabs.com/v1",
"prod-testnet-zone-b": "https://fullnode.testnet.aptoslabs.com/v1",
"mainnet": "https://fullnode.mainnet.aptoslabs.com/v1",
"mainnet-zone-b": "https://fullnode.mainnet.aptoslabs.com/v1",
}

url, exists := environmentURLs[environment]
Expand All @@ -86,6 +97,7 @@ func GetAptosNetworkName(environment string) string {
"prod-testnet": "testnet",
"prod-testnet-zone-b": "testnet",
"mainnet": "mainnet",
"mainnet-zone-b": "mainnet",
}

network, exists := environmentNetworks[environment]
Expand Down
Loading