Skip to content

Commit ffc2c24

Browse files
am1r021acolytec3holgerd77
authored
Update readmes with debugging info (#3663)
* blockchain: Update debugging section of README * devp2p: Update debugging section of README * client: Update debugging section of README * evm: Update debugging section of README * Rename evm journal debug symbol * Update statemanager DEVELOPER document with debuging documentation * Update statemanager debug symbol names * verkle: Update debugging section of README * Add information about guard rail being necessary to all package READMEs that provide logging but do not include it * Add initial sentence with link to debug library in package readmes * Remove sentence about exporting DEBUG env variable * statemanager: Make namespaces all lowercase * client: Make debug namespaces all lowercase * client: Add list of debug namespace options to debug docs * Make debug usage examples all use lowercase namespacing * Move info about guardrail to bottom of debugging section in docs and make example more concrete * Revert "Make debug usage examples all use lowercase namespacing" This reverts commit 30164f1. * Add trienode to list of correct words for cspell * Some doc updates and fixes --------- Co-authored-by: acolytec3 <[email protected]> Co-authored-by: Holger Drewes <[email protected]>
1 parent b44be5c commit ffc2c24

18 files changed

+136
-27
lines changed

config/cspell-md.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"language": "en-US",
33
"ignoreRegExpList": ["/0x[0-9A-Fa-f]+/"],
44
"words": [
5+
"trienode",
56
"t8ntool",
67
"calldatasize",
78
"Dencun",

packages/blockchain/README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,9 @@ The `Blockchain` class has a public property `events` which contains an `EventEm
239239
| ------------------------ | ------------------------------------------- |
240240
| `deletedCanonicalBlocks` | Emitted when blocks are reorged and deleted |
241241

242-
## Developer
242+
## Debugging
243243

244-
For debugging blockchain control flows the [debug](https://github.com/visionmedia/debug) library is used and can be activated on the CL with `DEBUG=[Logger Selection] node [Your Script to Run].js`.
244+
This library uses the [debug](https://github.com/visionmedia/debug) debugging utility package.
245245

246246
The following initial logger is currently available:
247247

@@ -257,6 +257,11 @@ Run with the clique logger:
257257
DEBUG=ethjs,blockchain:clique tsx test.ts
258258
```
259259

260+
`ethjs` **must** be included in the `DEBUG` environment variables to enable **any** logs.
261+
Additional log selections can be added with a comma separated list (no spaces). Logs with extensions can be enabled with a colon `:`, and `*` can be used to include all extensions (currently do not apply for blockchain debugging, example taken from another library).
262+
263+
`DEBUG=ethjs,statemanager:cache:*,trie,statemanager:merkle npx vitest test/statemanager.spec.ts`
264+
260265
## EthereumJS
261266

262267
See our organizational [documentation](https://ethereumjs.readthedocs.io) for an introduction to `EthereumJS` as well as information on current standards and best practices. If you want to join for work or carry out improvements on the libraries, please review our [contribution guidelines](https://ethereumjs.readthedocs.io/en/latest/contributing.html) first.

packages/client/README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,12 +457,28 @@ For more in-depth debugging on networking the underlying [devp2p](../devp2p) lib
457457
DEBUG=ethjs,*,-babel [CLIENT_START_COMMAND]
458458
```
459459
460-
The above command outputs the log messages from all `devp2p` debug loggers available. For a more targeted logging the different loggers can also be activated separately, e.g.:
460+
The above command outputs the log messages from all `devp2p` debug loggers available. For more targeted logging, the different loggers can also be activated separately, e.g.:
461461
462462
```shell
463463
DEBUG=ethjs,devp2p:rlpx,devp2p:eth,-babel [CLIENT_START_COMMAND]
464+
465+
The following options are available:
466+
467+
| Logger | Description |
468+
| ------------------- | ------------------------------------------------ |
469+
| `client:fetcher` | This option enables logging for all fetchers |
470+
| `client:fetcher:bytecode` | This option enables logging for the snap sync bytecode fetcher |
471+
| `client:fetcher:storage` | This option enables logging for the snap sync storage fetcher |
472+
| `client:fetcher:trienode` | This option enables logging for the snap sync trienode fetcher |
473+
| `client:fetcher:account` | This option enables logging for the snap sync account fetcher |
474+
464475
```
465476
477+
`ethjs` **must** be included in the `DEBUG` environment variables to enable **any** logs.
478+
Additional log selections can be added with a comma separated list (no spaces). Logs with extensions can be enabled with a colon `:`, and `*` can be used to include all extensions.
479+
480+
`DEBUG=ethjs,client:fetcher:*,devp2p:eth npm run client:start`
481+
466482
#### Hive testing
467483
468484
See [DEVELOPER.md](./DEVELOPER.md)

packages/client/src/sync/fetcher/accountfetcher.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export class AccountFetcher extends Fetcher<JobTask, AccountData[], AccountData>
9999
this.stateManager = options.stateManager ?? new MerkleStateManager()
100100
this.accountTrie = this.stateManager['_getAccountTrie']()
101101

102-
this.debug = debugDefault('client:AccountFetcher')
102+
this.debug = debugDefault('client:fetcher:account')
103103

104104
this.storageFetcher = new StorageFetcher({
105105
config: this.config,

packages/client/src/sync/fetcher/bytecodefetcher.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export class ByteCodeFetcher extends Fetcher<JobTask, Uint8Array[], Uint8Array>
6161

6262
this.keccakFunction = this.config.chainCommon.customCrypto.keccak256 ?? keccak256
6363

64-
this.debug = debug('client:ByteCodeFetcher')
64+
this.debug = debug('client:fetcher:bytecode')
6565
if (this.hashes.length > 0) {
6666
const fullJob = { task: { hashes: this.hashes } } as Job<JobTask, Uint8Array[], Uint8Array>
6767
this.DEBUG &&

packages/client/src/sync/fetcher/storagefetcher.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ export class StorageFetcher extends Fetcher<JobTask, StorageData[][], StorageDat
9494
this.fetcherDoneFlags.storageFetcher.count = BigInt(this.storageRequests.length)
9595

9696
this.accountToHighestKnownHash = new Map<String, Uint8Array>()
97-
this.debug = debugDefault('client:StorageFetcher')
97+
this.debug = debugDefault('client:fetcher:storage')
9898
if (this.storageRequests.length > 0) {
9999
const fullJob = {
100100
task: { storageRequests: this.storageRequests },

packages/client/src/sync/fetcher/trienodefetcher.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ export class TrieNodeFetcher extends Fetcher<JobTask, Uint8Array[], Uint8Array>
110110
this.codeDB = this.stateManager['_getCodeDB']()
111111

112112
this.nodeCount = 0
113-
this.debug = debug('client:TrieNodeFetcher')
113+
this.debug = debug('client:fetcher:trienode')
114114

115115
this.keccakFunction = this.config.chainCommon.customCrypto.keccak256 ?? keccak256
116116

packages/devp2p/README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -436,10 +436,7 @@ Events emitted:
436436
437437
This library uses the [debug](https://github.com/visionmedia/debug) debugging utility package.
438438
439-
For the debugging output to show up, set the `DEBUG` environment variable (e.g. in Linux/Mac OS:
440-
`export DEBUG=ethjs,*,-babel`).
441-
442-
Use the `DEBUG` environment variable to active the logger output you are interested in, e.g.:
439+
Use the `DEBUG` environment variable to activate the logger output you are interested in, e.g.:
443440
444441
```shell
445442
DEBUG=ethjs,devp2p:dpt:\*,devp2p:eth node -r tsx/register [YOUR_SCRIPT_TO_RUN.ts]
@@ -458,14 +455,19 @@ The following loggers are available:
458455
| `devp2p:eth` | ETH protocol message logging (`STATUS`, `GET_BLOCK_HEADER`, `TRANSACTIONS`,... messages) |
459456
| `devp2p:les` | LES protocol message logging (`STATUS`, `GET_BLOCK_HEADER`, `GET_PROOFS`,... messages) |
460457
458+
`ethjs` **must** be included in the `DEBUG` environment variables to enable **any** logs.
459+
Additional log selections can be added with a comma separated list (no spaces). Logs with extensions can be enabled with a colon `:`, and `*` can be used to include all extensions.
460+
461+
`DEBUG=ethjs,devp2p:dns:dns,devp2p:dpt:*,devp2p:rlpx:peer npx vitest test/dns.spec.ts`
462+
461463
### Debug Verbosity
462464
463465
For more verbose output on logging (e.g. to output the entire msg payload) use the `verbose` logger
464466
in addition:
465467
466468
DEBUG=ethjs,devp2p:dpt:\*,devp2p:eth,verbose node -r tsx/register [YOUR_SCRIPT_TO_RUN.ts]
467469
468-
Exemplary logging output:
470+
Example logging output:
469471
470472
```shell
471473
Add peer: 52.3.158.184:30303 Geth/v1.7.3-unstable-479aa61f/linux-amd64/go1.9 (eth63) (total: 2)
@@ -495,7 +497,7 @@ on two message names along `ETH` protocol debugging:
495497
DEBUG=ethjs,devp2p:eth:GET_BLOCK_HEADERS,devp2p:eth:BLOCK_HEADERS -r tsx/register [YOUR_SCRIPT_TO_RUN.ts]
496498
```
497499
498-
Exemplary logging output:
500+
Example logging output:
499501
500502
```shell
501503
devp2p:eth:GET_BLOCK_HEADERS Received GET_BLOCK_HEADERS message from 207.154.201.177:30303: d188659b37d8e321bc52c782198181c08080 +50ms
@@ -519,7 +521,7 @@ DEBUG=ethjs,devp2p:3.209.45.79 -r tsx/register [YOUR_SCRIPT_TO_RUN.ts]
519521
520522
#### First Connected
521523
522-
Logging can be limited to the peer the first successful subprotocol (e.g. `ETH`) connection could be established:
524+
Logging can be limited to the peer with which the first successful subprotocol (e.g. `ETH`) connection could be established:
523525
524526
```shell
525527
DEBUG=ethjs,devp2p:FIRST_PEER -r tsx/register [YOUR_SCRIPT_TO_RUN.ts]

packages/ethereum-tests

Submodule ethereum-tests updated 105 files

packages/evm/README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,9 +382,10 @@ The following loggers are currently available:
382382

383383
| Logger | Description |
384384
| ---------------------------------- | --------------------------------------------------- |
385-
| `evm` |  EVM control flow, CALL or CREATE message execution |
385+
| `evm:evm` |  EVM control flow, CALL or CREATE message execution |
386386
| `evm:gas` |  EVM gas logger |
387-
| `evm:eei:gas` |  EEI gas logger |
387+
| `evm:precompiles` |  EVM precompiles logger |
388+
| `evm:journal` |  EVM journal logger |
388389
| `evm:ops` |  Opcode traces |
389390
| `evm:ops:[Lower-case opcode name]` | Traces on a specific opcode |
390391

@@ -420,6 +421,11 @@ Run some specific loggers including a logger specifically logging the `SSTORE` e
420421
DEBUG=ethjs,evm,evm:ops:sstore,evm:*:gas tsx test.ts
421422
```
422423

424+
`ethjs` **must** be included in the `DEBUG` environment variables to enable **any** logs.
425+
Additional log selections can be added with a comma separated list (no spaces). Logs with extensions can be enabled with a colon `:`, and `*` can be used to include all extensions.
426+
427+
`DEBUG=ethjs,evm:journal,evm:ops:* npx vitest test/runCall.spec.ts`
428+
423429
### Internal Structure
424430

425431
The EVM processes state changes at many levels.

0 commit comments

Comments
 (0)