Skip to content

Commit ecba75a

Browse files
committed
improve events_keys docs
1 parent 4523e8a commit ecba75a

File tree

1 file changed

+61
-45
lines changed

1 file changed

+61
-45
lines changed

stackslib/src/config/mod.rs

Lines changed: 61 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,8 @@ pub struct ConfigFile {
188188
/// ```
189189
///
190190
/// This is intended strictly for testing purposes.
191-
/// Attempting to specify initial balances if [`BurnchainConfig::mode`] is "mainnet" will result in an error.
191+
/// Attempting to specify initial balances if [`BurnchainConfig::mode`] is "mainnet" will
192+
/// result in an invalid config error.
192193
///
193194
/// Default: `None`
194195
pub ustx_balance: Option<Vec<InitialBalanceFile>>,
@@ -4165,56 +4166,73 @@ pub struct EventObserverConfigFile {
41654166
///
41664167
/// Default: No default. This field is required.
41674168
pub endpoint: String,
4168-
/// List of event types that this observer wants to receive.
4169+
/// List of event types that this observer is configured to receive.
41694170
///
41704171
/// Each string in the list specifies an event category or a specific event to subscribe to.
4172+
/// For an observer to receive any notifications, this list must contain at least one valid key.
41714173
/// Providing an invalid string that doesn't match any of the valid formats below will cause
41724174
/// the node to panic on startup when parsing the configuration.
4173-
/// For an observer to receive any notifications, this list must contain at least one valid key.
41744175
///
4175-
/// Valid string values and their corresponding event types:
4176-
/// - `"*"`: Subscribes to a broad set of events. Specifically, an observer with `"*"` will receive:
4177-
/// - Payloads on `/new_block` if the block contains any transactions generating STX, FT, NFT, or smart contract events.
4178-
/// - Payloads on `/new_microblocks` for all new microblock streams. NOTE: Only until epoch 2.5.
4179-
/// - Payloads on `/new_mempool_tx` for new mempool transactions.
4180-
/// - Payloads on `/drop_mempool_tx` for dropped mempool transactions.
4181-
/// - Payloads on `/new_burn_block` for new burnchain blocks.
4182-
/// - (Implicitly, like all observers) Payloads on `/attachments/new`.
4183-
/// It does NOT by itself subscribe to `/stackerdb_chunks` or `/proposal_response`.
4176+
/// All observers, regardless of their `events_keys` configuration, implicitly receive
4177+
/// payloads on the `/attachments/new` endpoint.
4178+
///
4179+
/// **Valid Event Keys:**
4180+
///
4181+
/// - `"*"`: Subscribes to a broad set of common events.
4182+
/// - **Events delivered to:**
4183+
/// - `/new_block`: For blocks containing transactions that generate STX, FT, NFT, or smart contract events.
4184+
/// - `/new_microblocks`: For all new microblock streams. **Note:** Only until epoch 2.5.
4185+
/// - `/new_mempool_tx`: For new mempool transactions.
4186+
/// - `/drop_mempool_tx`: For dropped mempool transactions.
4187+
/// - `/new_burn_block`: For new burnchain blocks.
4188+
/// - **Note:** This key does NOT by itself subscribe to `/stackerdb_chunks` or `/proposal_response`.
4189+
///
41844190
/// - `"stx"`: Subscribes to STX token operation events (transfer, mint, burn, lock).
4185-
/// These are delivered as part of new block or microblock event payloads sent to
4186-
/// the `/new_block` or `/new_microblocks` paths, with the "events" array filtered to include STX-related events.
4191+
/// - **Events delivered to:** `/new_block`, `/new_microblocks`.
4192+
/// - **Payload details:** The "events" array in the delivered payloads will be filtered to include only STX-related events.
4193+
///
41874194
/// - `"memtx"`: Subscribes to new and dropped mempool transaction events.
4188-
/// Payloads are sent to `/new_mempool_tx` and `/drop_mempool_tx` paths respectively.
4195+
/// - **Events delivered to:** `/new_mempool_tx`, `/drop_mempool_tx`.
4196+
///
41894197
/// - `"burn_blocks"`: Subscribes to new burnchain block events.
4190-
/// Payloads are sent to the `/new_burn_block` path.
4191-
/// - `"microblocks"`: Subscribes to new microblock stream events. NOTE: Only until epoch 2.5.
4192-
/// Payloads are sent to the `/new_microblocks` path.
4193-
/// The payload's "transactions" field will contain all transactions from the microblocks.
4194-
/// The payload's "events" field will contain STX, FT, NFT, or specific smart contract events
4195-
/// *only if* this observer is also subscribed to those more specific event types (e.g., via `"stx"`, `"*"`,
4196-
/// a specific contract event key, or a specific asset identifier key).
4198+
/// - **Events delivered to:** `/new_burn_block`.
4199+
///
4200+
/// - `"microblocks"`: Subscribes to new microblock stream events.
4201+
/// - **Events delivered to:** `/new_microblocks`.
4202+
/// - **Payload details:**
4203+
/// - The "transactions" field will contain all transactions from the microblocks.
4204+
/// - The "events" field will contain STX, FT, NFT, or specific smart contract events
4205+
/// *only if* this observer is also subscribed to those more specific event types
4206+
/// (e.g., via `"stx"`, `"*"`, a specific contract event key, or a specific asset identifier key).
4207+
/// - **Note:** Only until epoch 2.5.
4208+
///
41974209
/// - `"stackerdb"`: Subscribes to StackerDB chunk update events.
4198-
/// Payloads are sent to the `/stackerdb_chunks` path.
4210+
/// - **Events delivered to:** `/stackerdb_chunks`.
4211+
///
41994212
/// - `"block_proposal"`: Subscribes to block proposal response events (for Nakamoto consensus).
4200-
/// Payloads are sent to the `/proposal_response` path.
4201-
/// - Smart Contract Event (format: `"{contract_address}.{contract_name}::{event_name}"`):
4202-
/// Subscribes to a specific smart contract event. The `{contract_address}.{contract_name}` part identifies the contract,
4203-
/// and `::{event_name}` specifies the event defined within that contract.
4204-
/// Example: `"ST0000000000000000000000000000000000000000.my-contract::my-custom-event"`
4205-
/// These are delivered as part of `/new_block` or `/new_microblocks` payloads, with the "events" array filtered for this specific event.
4206-
/// - Asset Identifier for FT/NFT Events (format: `"{contract_address}.{contract_name}.{asset_name}"`):
4207-
/// Subscribes to events (mint, burn, transfer) for a specific Fungible Token (FT) or Non-Fungible Token (NFT).
4208-
/// Example for an FT: `"ST0000000000000000000000000000000000000000.my-ft-contract.my-fungible-token"`
4209-
/// These are delivered as part of `/new_block` or `/new_microblocks` payloads, with the "events" array filtered for the specified asset.
4210-
///
4211-
/// **Example `events_keys` in TOML:**
4213+
/// - **Events delivered to:** `/proposal_response`.
4214+
///
4215+
/// - **Smart Contract Event**: Subscribes to a specific smart contract event.
4216+
/// - **Format:** `"{contract_address}.{contract_name}::{event_name}"`
4217+
/// (e.g., `ST0000000000000000000000000000000000000000.my-contract::my-custom-event`)
4218+
/// - **Events delivered to:** `/new_block`, `/new_microblocks`.
4219+
/// - **Payload details:** The "events" array in the delivered payloads will be filtered for this specific event.
4220+
///
4221+
/// - **Asset Identifier for FT/NFT Events**: Subscribes to events (mint, burn, transfer) for a specific Fungible Token (FT) or Non-Fungible Token (NFT).
4222+
/// - **Format:** `"{contract_address}.{contract_name}.{asset_name}"`
4223+
/// (e.g., for an FT: `ST0000000000000000000000000000000000000000.my-ft-contract.my-fungible-token`)
4224+
/// - **Events delivered to:** `/new_block`, `/new_microblocks`.
4225+
/// - **Payload details:** The "events" array in the delivered payloads will be filtered for events related to the specified asset.
4226+
///
4227+
/// **Configuration:**
4228+
///
42124229
/// ```toml
4230+
/// # Example events_keys in TOML configuration:
42134231
/// events_keys = [
42144232
/// "burn_blocks",
42154233
/// "memtx",
4216-
/// "ST0000000000000000000000000000000000000000.my-contract::my-custom-event", // Smart contract event
4217-
/// "ST0000000000000000000000000000000000000000.token-contract.my-ft" // Fungible token asset event
4234+
/// "ST0000000000000000000000000000000000000000.my-contract::my-custom-event", # Smart contract event
4235+
/// "ST0000000000000000000000000000000000000000.token-contract.my-ft" # Fungible token asset event
42184236
/// ]
42194237
/// ```
42204238
///
@@ -4232,16 +4250,14 @@ pub struct EventObserverConfigFile {
42324250
/// Controls whether the node should retry sending event notifications if delivery fails or times out.
42334251
///
42344252
/// - If `false` (default): The node will attempt to deliver event notifications persistently.
4235-
/// If an attempt fails (due to network error, timeout, or a non-200 HTTP response),
4236-
/// the event payload is typically saved to a local database (if [`NodeConfig::working_dir`] is configured for the node)
4237-
/// and retried indefinitely. This ensures that, under normal circumstances, all events will eventually be delivered.
4238-
/// However, this can cause the node's own block processing to stall if an observer is down,
4239-
/// or fails to process the event.
4253+
/// If an attempt fails (due to network error, timeout, or a non-200 HTTP response), the event
4254+
/// payload is saved and retried indefinitely. This ensures that all events will eventually be
4255+
/// delivered. However, this can cause the node's block processing to stall if an observer is
4256+
/// down, or indefinitely fails to process the event.
42404257
///
42414258
/// - If `true`: The node will make only a single attempt to deliver each event notification.
4242-
/// If this single attempt fails for any reason, the event is discarded, and no further
4243-
/// retries will be made for that specific event. The local database for pending payloads is
4244-
/// not used for this observer.
4259+
/// If this single attempt fails for any reason, the event is discarded, and no further retries
4260+
/// will be made for that specific event.
42454261
///
42464262
/// **Warning:** Setting this to `true` can lead to missed events if the observer endpoint is
42474263
/// temporarily unavailable or experiences issues. This setting should only be used for observers

0 commit comments

Comments
 (0)