Skip to content

Commit e4f0998

Browse files
committed
refactor: update readme and add best practices
1 parent 0b49d15 commit e4f0998

File tree

1 file changed

+9
-45
lines changed

1 file changed

+9
-45
lines changed

README.md

Lines changed: 9 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -34,58 +34,22 @@ through the `RUST_LOG` environment variable using the standard
3434
`error|warn|info|debug|trace`.
3535

3636
#### Plain/JSON logging
37-
By default, pyth-agent will print plaintext log statements. This can be switched to structured JSON output with `-l json`.
38-
39-
#### Code location in logs
40-
For debugging purposes, you can specify `-L` to print file/line information with each log statement. This option is disabled by default.
41-
42-
### Key Store Config Migration [v1.x.x LEGACY]
43-
Pyth agent v2.0.0 introduces a simplified program and mapping key configuration. This breaking change alters how you define program/mapping key options in your agent config:
44-
```toml
45-
# Old v1.x.x way
46-
[primary network]
47-
key_store.root_path = "/path/to/keystore"
48-
key_store.publish_keypair_path = "publish_key_pair.json" # Relative path from root_path, "publish_key_pair.json" by default
49-
key_store.program_key_path = "program_key.json" # Relative path from root_path, "program_key.json" by default
50-
key_store.mapping_key_path = "mapping_key.json" # Relative path from root_path, "mapping_key.json" by default
51-
52-
# [...]
53-
54-
# New v2.0.0 way
55-
[primary_network]
56-
key_store.publish_keypair_path = "/path/to/keypair.json" # The root_path is gone, we specify the full path
57-
# Not using separate files anymore
58-
key_store.program_key = "LiteralProgramPubkeyInsideTheConfig" # contents of legacy program_key.json;
59-
key_store.mapping_key = "LiteralMappingPubkeyInsideTheConfig" # contents of legacy mapping_key.json
60-
61-
# [...]
62-
63-
```
64-
65-
#### Automatic Migration
66-
If you are upgrading to agent v2.0.0 with an existing config, you can use the provided automatic migrator program:
67-
```shell
68-
# Build
69-
$ cargo build --release
70-
# Run the migrator, making sure that the key store with previous keys is reachable
71-
$ target/release/agent-migrate-config -c <existing_config_file>.toml > my_new_config.toml
72-
```
73-
74-
#### `Could not open {mapping|program|...} key file`
75-
This error can appear if some of your program/mapping/publish key
76-
files are not reachable under their `key_store.*` setting values.
77-
78-
Ensure that your current working directory is correct for reaching the
79-
key store path inside your config. You may also migrate manually by
80-
changing `key_store.*_key_path` and `key_store.publish_keypair_path`
81-
options by hand, as described in the config example above.
37+
Pyth agent will print logs in plaintext in terminal and JSON format in non-terminal environments (e.g. when writing to a file).
8238

8339
## Run
8440
`cargo run --release -- --config <your_config.toml>` will build and run the agent in a single step.
8541

8642
## Publishing API
8743
A running agent will expose a WebSocket serving the JRPC publishing API documented [here](https://docs.pyth.network/documentation/publish-data/pyth-client-websocket-api). See `config/config.toml` for related settings.
8844

45+
## Best practices
46+
If your publisher is publishing updates to more than 50 price feeds, it is recommended that you do the following to reduce the connection overhead to the agent:
47+
- Batch your messages together and send them as a single request to the agent (as an array of messages). The agent will respond to the batch messages
48+
with a single response containing an array of individual responses (in the same order). If batching is not possible, you can disable the `instant_flush` option
49+
in the configuration file to let agent send the responses every `flush_interval` seconds.
50+
- Do not use subscribe to the price schedule. Instead, define a schedule on the client side and send the messages based on your own schedule. Ideally
51+
you should send price updates as soon as you have them to increase the latency of the data on the Pyth Network.
52+
8953
# Development
9054
## Unit Testing
9155
A collection of Rust unit tests is provided, ran with `cargo test`.

0 commit comments

Comments
 (0)