Skip to content

Commit

Permalink
moar cli & complete address-watcher README
Browse files Browse the repository at this point in the history
  • Loading branch information
zramsay committed Jan 16, 2023
1 parent 85452a8 commit dd9f85f
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 117 deletions.
176 changes: 83 additions & 93 deletions docs/cli.md
Original file line number Diff line number Diff line change
@@ -1,137 +1,127 @@
## 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
yarn server
```
If the watcher is an `active` watcher, run the job-runner:

GQL console: http://localhost:3008/graphql
```bash
yarn job-runner
```

* If the watcher is an `active` watcher:
```
# For development.
yarn server:dev
* Run the job-runner:
# For specifying config file.
yarn server -f environments/local.toml
```

```bash
yarn job-runner
```
If the watcher is `lazy` omit the above step, then run the server:

* Run the server:
```bash
yarn server
```

```bash
yarn server
```
This will enable the GraphQL playground at: `http://localhost:<port>/graphql`

GQL console: http://localhost:3008/graphql
where `<port>` is set in the `environments/local.toml` of each watcher.

* To watch a contract:
To watch a contract:

```bash
yarn watch:contract --address <contract-address> --kind <contract-kind> --checkpoint <true | false> --starting-block [block-number]
```
```bash
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.
* `kind`: Kind of the contract.
* `checkpoint`: Turn checkpointing on (`true` | `false`).
* `starting-block`: Starting block for the contract (default: `1`).
* `address`: Address or identifier of the contract to be watched.
* `kind`: Kind of the contract.
* `checkpoint`: Turn checkpointing on (`true` | `false`).
* `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:

```bash
yarn watch:contract --address 0x1F78641644feB8b64642e833cE4AFE93DD6e7833 --kind ERC20 --checkpoint true
```
```bash
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
```
```bash
yarn fill --start-block <from-block> --end-block <to-block>
```

* To fill a block range:
* `start-block`: Block number to start filling from.
* `end-block`: Block number till which to fill.

```bash
yarn fill --start-block <from-block> --end-block <to-block>
```
To create a checkpoint for a contract:

* `start-block`: Block number to start filling from.
* `end-block`: Block number till which to fill.
```bash
yarn checkpoint create --address <contract-address> --block-hash <block-hash>
```

* To create a checkpoint for a contract:
* `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).

```bash
yarn checkpoint create --address <contract-address> --block-hash [block-hash]
```
To verify 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).
```bash
yarn checkpoint verify --cid <checkpoint-cid>
```

* To verify a checkpoint:
* `cid`: CID of the checkpoint for which to verify.

```bash
yarn checkpoint verify --cid <checkpoint-cid>
```
To reset the watcher to a previous block number:

`cid`: CID of the checkpoint for which to verify.
```bash
yarn reset watcher --block-number <previous-block-number>
```

* To reset the watcher to a previous block number:
* `block-number`: Block number to which to reset the watcher.

* Reset watcher:
To reset the job-queue:

```bash
yarn reset watcher --block-number <previous-block-number>
```
```bash
yarn reset job-queue
```

* Reset job-queue:
To reset the state:

```bash
yarn reset job-queue
```
```bash
yarn reset state --block-number <previous-block-number>
```

* Reset state:
## Import/Export State

```bash
yarn reset state --block-number <previous-block-number>
```
To export and import the watcher state:

* `block-number`: Block number to which to reset the watcher.
In the source watcher, export watcher state:

* To export and import the watcher state:
```bash
yarn export-state --export-file [export-file-path] --block-number [snapshot-block-height]
```

* In source watcher, export watcher state:
* `export-file`: Path of file to which to export the watcher data.
* `block-number`: Block height at which to take snapshot for export.

```bash
yarn export-state --export-file [export-file-path] --block-number [snapshot-block-height]
```
In the target watcher, run the job-runner:

* `export-file`: Path of file to which to export the watcher data.
* `block-number`: Block height at which to take snapshot for export.
```bash
yarn job-runner
```

* In target watcher, run job-runner:
Import watcher state:

```bash
yarn job-runner
```
```bash
yarn import-state --import-file <import-file-path>
```

* Import watcher state:
* `import-file`: Path of file from which to import the watcher data.

```bash
yarn import-state --import-file <import-file-path>
```
To inspect a CID:

* `import-file`: Path of file from which to import the watcher data.
```bash
yarn inspect-cid --cid <cid>
```

* Run server:

```bash
yarn server
```

* To inspect a CID:

```bash
yarn inspect-cid --cid <cid>
```

* `cid`: CID to be inspected.
* `cid`: CID to be inspected.
33 changes: 9 additions & 24 deletions packages/address-watcher/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

## Run

Run the following scripts in different terminals.

Build files:

```
yarn build
```bash
yarn && yarn build
```

GQL server:
## Run

```
yarn server
Run the following commands in different terminals:

# For development.
yarn server:dev
GraphQL server:

# For specifying config file.
yarn server -f environments/local.toml
```bash
yarn server
```

Job runner for processing the tracing requests queue:

```
```bash
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:

```
```bash
yarn fill --start-block 1 --end-block 1000
# For specifying config file.
yarn fill -f environments/local.toml --start-block 1 --end-block 1000
```

0 comments on commit dd9f85f

Please sign in to comment.