moar cli & complete address-watcher README

This commit is contained in:
zramsay 2023-01-10 08:31:58 -05:00
parent 85452a870f
commit dd9f85f268
No known key found for this signature in database
GPG Key ID: FECD2DBFAE9DBE63
2 changed files with 93 additions and 118 deletions

View File

@ -1,33 +1,35 @@
## Watcher CLI commands (yarn) ## Watcher CLI commands
* Run the server: Non-exhaustive list of (yarn) CLI commands available for watchers. Assumes you have an environment setup either [by hand](./README.md) or using [Stack Orchestrator](https://github.com/cerc-io/stack-orchestrator), and have built `yarn && yarn build` a specific watcher.
```bash If the watcher is an `active` watcher, run the job-runner:
yarn server
```
GQL console: http://localhost:3008/graphql
* If the watcher is an `active` watcher:
* Run the job-runner:
```bash ```bash
yarn job-runner yarn job-runner
``` ```
* Run the server: ```
# For development.
yarn server:dev
# For specifying config file.
yarn server -f environments/local.toml
```
If the watcher is `lazy` omit the above step, then run the server:
```bash ```bash
yarn server yarn server
``` ```
GQL console: http://localhost:3008/graphql This will enable the GraphQL playground at: `http://localhost:<port>/graphql`
* To watch a contract: where `<port>` is set in the `environments/local.toml` of each watcher.
To watch a contract:
```bash ```bash
yarn watch:contract --address <contract-address> --kind <contract-kind> --checkpoint <true | false> --starting-block [block-number] yarn watch:contract --address <contract-address> --kind <contract-kind> --checkpoint <true | false> --starting-block <block-number>
``` ```
* `address`: Address or identifier of the contract to be watched. * `address`: Address or identifier of the contract to be watched.
@ -35,7 +37,7 @@
* `checkpoint`: Turn checkpointing on (`true` | `false`). * `checkpoint`: Turn checkpointing on (`true` | `false`).
* `starting-block`: Starting block for the contract (default: `1`). * `starting-block`: Starting block for the contract (default: `1`).
Examples: Example:
Watch a contract with its address and checkpointing on: Watch a contract with its address and checkpointing on:
@ -43,13 +45,7 @@
yarn watch:contract --address 0x1F78641644feB8b64642e833cE4AFE93DD6e7833 --kind ERC20 --checkpoint true yarn watch:contract --address 0x1F78641644feB8b64642e833cE4AFE93DD6e7833 --kind ERC20 --checkpoint true
``` ```
Watch a contract with its identifier and checkpointing on: To fill a block range:
```bash
yarn watch:contract --address MyProtocol --kind protocol --checkpoint true
```
* To fill a block range:
```bash ```bash
yarn fill --start-block <from-block> --end-block <to-block> yarn fill --start-block <from-block> --end-block <to-block>
@ -58,48 +54,48 @@
* `start-block`: Block number to start filling from. * `start-block`: Block number to start filling from.
* `end-block`: Block number till which to fill. * `end-block`: Block number till which to fill.
* To create a checkpoint for a contract: To create a checkpoint for a contract:
```bash ```bash
yarn checkpoint create --address <contract-address> --block-hash [block-hash] yarn checkpoint create --address <contract-address> --block-hash <block-hash>
``` ```
* `address`: Address or identifier of the contract for which to create a checkpoint. * `address`: Address or identifier of the contract for which to create a checkpoint.
* `block-hash`: Hash of a block (in the pruned region) at which to create the checkpoint (default: latest canonical block hash). * `block-hash`: Hash of a block (in the pruned region) at which to create the checkpoint (default: latest canonical block hash).
* To verify a checkpoint: To verify a checkpoint:
```bash ```bash
yarn checkpoint verify --cid <checkpoint-cid> yarn checkpoint verify --cid <checkpoint-cid>
``` ```
`cid`: CID of the checkpoint for which to verify. * `cid`: CID of the checkpoint for which to verify.
* To reset the watcher to a previous block number: To reset the watcher to a previous block number:
* Reset watcher:
```bash ```bash
yarn reset watcher --block-number <previous-block-number> yarn reset watcher --block-number <previous-block-number>
``` ```
* Reset job-queue: * `block-number`: Block number to which to reset the watcher.
To reset the job-queue:
```bash ```bash
yarn reset job-queue yarn reset job-queue
``` ```
* Reset state: To reset the state:
```bash ```bash
yarn reset state --block-number <previous-block-number> yarn reset state --block-number <previous-block-number>
``` ```
* `block-number`: Block number to which to reset the watcher. ## Import/Export State
* To export and import the watcher state: To export and import the watcher state:
* In source watcher, export watcher state: In the source watcher, export watcher state:
```bash ```bash
yarn export-state --export-file [export-file-path] --block-number [snapshot-block-height] yarn export-state --export-file [export-file-path] --block-number [snapshot-block-height]
@ -108,13 +104,13 @@
* `export-file`: Path of file to which to export the watcher data. * `export-file`: Path of file to which to export the watcher data.
* `block-number`: Block height at which to take snapshot for export. * `block-number`: Block height at which to take snapshot for export.
* In target watcher, run job-runner: In the target watcher, run the job-runner:
```bash ```bash
yarn job-runner yarn job-runner
``` ```
* Import watcher state: Import watcher state:
```bash ```bash
yarn import-state --import-file <import-file-path> yarn import-state --import-file <import-file-path>
@ -122,13 +118,7 @@
* `import-file`: Path of file from which to import the watcher data. * `import-file`: Path of file from which to import the watcher data.
* Run server: To inspect a CID:
```bash
yarn server
```
* To inspect a CID:
```bash ```bash
yarn inspect-cid --cid <cid> yarn inspect-cid --cid <cid>

View File

@ -4,45 +4,30 @@
First try the [stack orchestrator](https://github.com/cerc-io/stack-orchestrator) to quickly get started. Advanced users can see [here](/docs/README.md) for instructions on setting up a local environment by hand. First try the [stack orchestrator](https://github.com/cerc-io/stack-orchestrator) to quickly get started. Advanced users can see [here](/docs/README.md) for instructions on setting up a local environment by hand.
## Run
Run the following scripts in different terminals.
Build files: Build files:
``` ```bash
yarn build yarn && yarn build
``` ```
GQL server: ## Run
``` Run the following commands in different terminals:
GraphQL server:
```bash
yarn server yarn server
# For development.
yarn server:dev
# For specifying config file.
yarn server -f environments/local.toml
``` ```
Job runner for processing the tracing requests queue: Job runner for processing the tracing requests queue:
``` ```bash
yarn job-runner yarn job-runner
# For development.
yarn job-runner:dev
# For specifying config file.
yarn job-runner -f environments/local.toml
``` ```
To fill a block range: To fill a block range:
``` ```bash
yarn fill --start-block 1 --end-block 1000 yarn fill --start-block 1 --end-block 1000
# For specifying config file.
yarn fill -f environments/local.toml --start-block 1 --end-block 1000
``` ```