Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eth/tracers/logger: use JSON struct tag ",omitempty" to reduce log bloat from blank fields #24491

Commits on Mar 2, 2022

  1. eth/tracers/logger: use JSON struct tag ",omitempty" to reduce log bl…

    …oat from blank fields
    
    Noticed while debugging Tharsis/EVMOS logs that the logs were
    extraneous with empty fields such as
    ```json
    {"pc":4716,"op":80,"gas":"0x688e5","gasCost":"0x2","memory":"0x","memSize":352,"stack":["0xfa31de01","0x29a","0x7d0","0xabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd","0x80","0x534","0xc0","0x5f646b5592c4159d4963fbf901f81144ef53cc51a7082435e3a6120a45002ff7","0x15dc","0x34","0x5f646b5592c4159d4963fbf901f81144ef53cc51a7082435e3a6120a45002ff7"],"returnData":"0x","depth":2,"refund":0,"opName":"POP","error":""}
    {"pc":4717,"op":80,"gas":"0x688e3","gasCost":"0x2","memory":"0x","memSize":352,"stack":["0xfa31de01","0x29a","0x7d0","0xabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd","0x80","0x534","0xc0","0x5f646b5592c4159d4963fbf901f81144ef53cc51a7082435e3a6120a45002ff7","0x15dc","0x34"],"returnData":"0x","depth":2,"refund":0,"opName":"POP","error":""}
    ```
    
    with empty fields like "error", "refund", "memory", "returnData".
    
    This change adds the JSON tag ",omitempty" to remove the bloat from the
    above empty fields which shows immediate impact of reducing the logs to
    
    ```json
    {"pc":4716,"op":80,"gas":"0x688e5","gasCost":"0x2","memSize":352,"stack":["0xfa31de01","0x29a","0x7d0","0xabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd","0x80","0x534","0xc0","0x5f646b5592c4159d4963fbf901f81144ef53cc51a7082435e3a6120a45002ff7","0x15dc","0x34","0x5f646b5592c4159d4963fbf901f81144ef53cc51a7082435e3a6120a45002ff7"],"depth":2,"opName":"POP"}
    {"pc":4717,"op":80,"gas":"0x688e3","gasCost":"0x2","memSize":352,"stack":["0xfa31de01","0x29a","0x7d0","0xabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd","0x80","0x534","0xc0","0x5f646b5592c4159d4963fbf901f81144ef53cc51a7082435e3a6120a45002ff7","0x15dc","0x34"],"depth":2,"opName":"POP"}
    ```
    
    and not only does that reduce the size of logs but it also makes it much
    easier to quickly debug and grep for errors, which will only be present if
    erroring.
    
    Fixes ethereum#24487
    odeke-em committed Mar 2, 2022
    Configuration menu
    Copy the full SHA
    dd4551b View commit details
    Browse the repository at this point in the history