|
1 | 1 |
|
2 | 2 | ## Overview |
3 | 3 |
|
4 | | -The `trace_api_plugin` provides a consumer-focused long-term API for retrieving retired actions and related metadata from a specified block. The plugin stores serialized block trace data to the filesystem for later retrieval via HTTP RPC requests. For detailed information about the definition of this application programming interface see the [Trace API reference documentation](api-reference/index.md). |
| 4 | +The `trace_api_plugin` provides a consumer-focused long-term API for retrieving retired actions and related metadata from a specified block. The plugin stores serialized block trace data to the filesystem for later retrieval via HTTP RPC requests. For detailed information about the definition of this application programming interface see the [Trace API reference](api-reference/index.md). |
5 | 5 |
|
6 | 6 | ## Purpose |
7 | 7 |
|
@@ -32,37 +32,48 @@ These can be specified from both the `nodeos` command-line or the `config.ini` f |
32 | 32 | ```console |
33 | 33 | Config Options for eosio::trace_api_plugin: |
34 | 34 |
|
35 | | - --trace-dir (="traces") the location of the trace directory |
36 | | - (absolute path or relative to |
| 35 | + --trace-dir arg (="traces") the location of the trace directory |
| 36 | + (absolute path or relative to |
37 | 37 | application data dir) |
38 | | - --trace-slice-stride (=10000) the number of blocks each "slice" of |
39 | | - trace data will contain on the |
| 38 | + --trace-slice-stride arg (=10000) the number of blocks each "slice" of |
| 39 | + trace data will contain on the |
40 | 40 | filesystem |
41 | | - --trace-minimum-irreversible-history-blocks (=-1) |
42 | | - Number of blocks to ensure are kept |
43 | | - past LIB for retrieval before "slice" |
| 41 | + --trace-minimum-irreversible-history-blocks arg (=-1) |
| 42 | + Number of blocks to ensure are kept |
| 43 | + past LIB for retrieval before "slice" |
44 | 44 | files can be automatically removed. |
45 | | - A value of -1 indicates that automatic |
46 | | - removal of "slice" files will be |
| 45 | + A value of -1 indicates that automatic |
| 46 | + removal of "slice" files will be turned |
| 47 | + off. |
| 48 | + --trace-minimum-uncompressed-irreversible-history-blocks arg (=-1) |
| 49 | + Number of blocks to ensure are |
| 50 | + uncompressed past LIB. Compressed |
| 51 | + "slice" files are still accessible but |
| 52 | + may carry a performance loss on |
| 53 | + retrieval |
| 54 | + A value of -1 indicates that automatic |
| 55 | + compression of "slice" files will be |
47 | 56 | turned off. |
48 | | - --trace-rpc-abi ABIs used when decoding trace RPC |
| 57 | + --trace-rpc-abi arg ABIs used when decoding trace RPC |
49 | 58 | responses. |
50 | | - There must be at least one ABI |
51 | | - specified OR the flag trace-no-abis |
| 59 | + There must be at least one ABI |
| 60 | + specified OR the flag trace-no-abis |
52 | 61 | must be used. |
53 | 62 | ABIs are specified as "Key=Value" pairs |
54 | 63 | in the form <account-name>=<abi-def> |
55 | 64 | Where <abi-def> can be: |
56 | | - an absolute path to a file |
| 65 | + an absolute path to a file |
57 | 66 | containing a valid JSON-encoded ABI |
58 | 67 | a relative path from `data-dir` to a |
59 | | - file containing valid JSON-encoded ABI. |
60 | | - --trace-no-abis Use to indicate that the RPC responses |
| 68 | + file containing a valid JSON-encoded |
| 69 | + ABI |
| 70 | + |
| 71 | + --trace-no-abis Use to indicate that the RPC responses |
61 | 72 | will not use ABIs. |
62 | | - Failure to specify this option when |
63 | | - there are no trace-rpc-abi |
64 | | - configurations will result in an Error. |
65 | | - This option is mutually exclusive with |
| 73 | + Failure to specify this option when |
| 74 | + there are no trace-rpc-abi |
| 75 | + configuations will result in an Error. |
| 76 | + This option is mutually exclusive with |
66 | 77 | trace-rpc-api |
67 | 78 | ``` |
68 | 79 |
|
@@ -101,20 +112,74 @@ nodeos --data-dir data_dir --config-dir config_dir --trace-dir traces_dir |
101 | 112 | --trace-rpc-abi=eosio.wrap=abis/eosio.wrap.abi |
102 | 113 | ``` |
103 | 114 |
|
104 | | -## Maintenance Note |
| 115 | +## Definitions |
105 | 116 |
|
106 | | -To reduce the disk space consummed by the `trace_api_plugin`, configure the following option: |
| 117 | +This section provides an overview of *slices*, the *trace log* contents, and the *clog format*. Mastery of these concepts is beneficial for an effective use of the `trace_api_plugin` options. |
107 | 118 |
|
108 | | -```console |
| 119 | +### Slices |
| 120 | + |
| 121 | +In the context of the `trace_api_plugin`, a *slice* is defined as a collection of all relevant trace data between a given starting block height (inclusive) and a given ending block height (exclusive). For instance, a slice from 0 to 10,000 is a collection of all blocks with block numbers greater than or equal to 0 and less than 10,000. The trace directory contains a collection of slices. Each slice consists of a *trace data* log file and a *trace index* metadata log file: |
| 122 | + |
| 123 | + * `trace_<S>-<E>.log` |
| 124 | + * `trace_index_<S>-<E>.log` |
| 125 | + |
| 126 | +where `<S>` and `<E>` are the starting and ending block numbers for the slice padded with leading 0's to a stride. For instance if the start block is 5, the last is 15, and the stride is 4, then the resulting `<S>` is `0000000005` and `<E>` is `0000000015`. |
| 127 | + |
| 128 | +#### trace_<S>-<E>.log |
| 129 | + |
| 130 | +The trace data log is an append only log that stores the actual binary serialized block data. The contents include the transaction and action trace data needed to service the RPC requests augmented by the per-action ABIs. The trace log may include blocks that have been forked out of the blockchain as part of the normal operations of the chain. The next entry in the file will always have a block number one higher than the previous one or the same number or less because of forking. Every trace entry will have a corresponding entry in the corresponding slice file for trace indexes. Note that forked blocks can be avoided by running nodeos in `read-mode=irreversible`. The log begins with a basic header that includes versioning information about the data stored in the log. |
| 131 | + |
| 132 | +#### trace_index_<S>-<E>.log |
| 133 | + |
| 134 | +The trace index log or metadata log is an append only log that stores a sequence of binary-serialized types. Currently two types are supported: `block_entry_v0` and `lib_entry_v0`. The log begins with a basic header that includes versioning information about the data stored in the log. `block_entry_v0` includes a block ID and block number with an offset to the location of that block within the data log. `lib_entry_v0` includes an entry for the latest known LIB. The reader will use the LIB information for reporting to users an irreversible status. |
| 135 | + |
| 136 | +### clog format |
| 137 | + |
| 138 | +Compressed trace log files have the `.clog` file extension (see [Compression of log files](#compression-of-log-files) below). The clog is a generic compressed file with an index of seek-able decompression points appended at the end. The clog format layout looks as follows: |
| 139 | + |
| 140 | + |
| 141 | + |
| 142 | +The data is compressed into raw zlib form with full-flush *seek points* placed at regular intervals. A decompressor can start from any of these *seek points* without reading previous data and it can also traverse a seek point without issue if it appears within the data. |
| 143 | + |
| 144 | +[[info | Size reduction of trace logs]] |
| 145 | +| Data compression can reduce the space growth of trace logs twentyfold! For instance, with 512 seek points and using the test dataset on the EOS public network, data compression reduces the growth of the trace directory from ~50 GiB/day to ~2.5 GiB/day for full data. Due to the high redundancy of the trace log contents, the compression is still comparable to `gzip -9`. The decompressed data is also made immediately available via the [Trace RPC API](api-reference/index.md) without any service degradation. |
| 146 | + |
| 147 | +#### Role of seek points |
| 148 | + |
| 149 | +As the file is being compressed, the seek point index records the original uncompressed offset with the new compressed offset creating a mapping so that the original index values (uncompressed offsets) can be mapped to the nearest seek point before the uncompressed offset. This dramatically reduces the seek time to parts of the uncompressed file that appear later in the stream. |
| 150 | + |
| 151 | +## Automatic Maintenance |
| 152 | + |
| 153 | +One of the main design goals of the `trace_api_plugin` is to minimize the manual housekeeping and maintenance of filesystem resources. To that end, the plugin facilitates the automatic removal of trace log files and the automatic reduction of their disk footprint through data compression. |
| 154 | + |
| 155 | +### Removal of log files |
| 156 | + |
| 157 | +To allow the removal of previous trace log files created by the `trace_api_plugin`, you can use the following option: |
| 158 | + |
| 159 | +```sh |
109 | 160 | --trace-minimum-irreversible-history-blocks N (=-1) |
110 | 161 | ``` |
111 | 162 |
|
112 | | -Once the value is no longer `-1`, only `N` number of blocks before the current LIB block will be kept on disk. |
| 163 | +If the argument `N` is 0 or greater, the plugin will only keep `N` blocks on disk before the current LIB block. Any trace log file with block numbers lesser than then previous `N` blocks will be scheduled for automatic removal. |
| 164 | + |
| 165 | +### Compression of log files |
| 166 | + |
| 167 | +The `trace_api_plugin` also supports an option to optimize disk space by applying data compression on the trace log files: |
| 168 | + |
| 169 | +```sh |
| 170 | + --trace-minimum-uncompressed-irreversible-history-blocks N (=-1) |
| 171 | +``` |
| 172 | + |
| 173 | +If the argument `N` is 0 or greater, the plugin automatically sets a background thread to compress the irreversible sections of the trace log files. The previous N irreversible blocks past the current LIB block are left uncompressed. |
| 174 | + |
| 175 | +[[info | Trace API utility]] |
| 176 | +| The trace log files can also be compressed manually with the [trace_api_util](../../../10_utilities/trace_api_util.md) utility. |
113 | 177 |
|
114 | | -If resource usage cannot be effectively managed via the `trace-minimum-irreversible-history-blocks` configuration option, then there might be a need for ongoing maintenance. In that case, the user may prefer to manage resources with an external system or process. |
| 178 | +If resource usage cannot be effectively managed via the `trace-minimum-irreversible-history-blocks` and `trace-minimum-uncompressed-irreversible-history-blocks` options, then there might be a need for periodic manual maintenance. In that case, the user may opt to manage resources through an external system or recurrent process. |
115 | 179 |
|
116 | | -### Manual Filesystem Management |
| 180 | +## Manual Maintenance |
117 | 181 |
|
118 | | -The `trace-dir` configuration option defines a location on the filesystem where all artefacts created by the `trace_api_plugin` are stored. These files are stable once the LIB block has progressed past that slice and then can be deleted at any time to reclaim filesystem space. The conventions regarding these files are to be determined. However, the remainder of the system will tolerate any out-of-process management system that removes some or all of these files in this directory regardless of what data they represent, or whether there is a running `nodeos` instance accessing them or not. Data which would nominally be available, but is no longer so due to manual maintenance, will result in a HTTP 404 response from the appropriate API endpoint(s). |
| 182 | +The `trace-dir` option defines the directory on the filesystem where the trace log files are stored by the `trace_api_plugin`. These files are stable once the LIB block has progressed past a given slice and then can be deleted at any time to reclaim filesystem space. The deployed EOSIO system will tolerate any out-of-process management system that removes some or all of these files in this directory regardless of what data they represent, or whether there is a running `nodeos` instance accessing them or not. Data which would nominally be available, but is no longer so due to manual maintenance, will result in a HTTP 404 response from the appropriate API endpoint(s). |
119 | 183 |
|
120 | | -In conjunction with the `trace-minimum-irreversible-history-blocks=-1` option, administrators can take full control over the lifetime of the data available via the `trace-api-plugin` and the associated filesystem resources. |
| 184 | +[[info | For node operators]] |
| 185 | +| Node operators can take full control over the lifetime of the historical data available in their nodes via the `trace-api-plugin` and the `trace-minimum-irreversible-history-blocks` and `trace-minimum-uncompressed-irreversible-history-blocks` options in conjunction with any external filesystem resource manager. |
0 commit comments