Skip to content

Instantly share code, notes, and snippets.

@banteg
Last active Jul 22, 2022
Embed
What would you like to do?
tx bytes_raw bytes_data elapsed block_number
0x9ef7a35012286fef17da12624aa124ebc785d9e7621e1fd538550d1209eb9f7d 2227272883 41365028007 1037.0734836910851 14174380
0xd770356649f1e60e7342713d483bd8946f967e544db639bd056dfccc8d534d8e 2443027079 43851356338 462.4402022489812 14111772
0x2428a69601105c365b9fe9d2f30688b91710b6a43bc6d2026344674ae7ffcac3 2947518853 50350613625 457.4804815109819 15127211
0xb9e6b6f275212824215e8f50818f12b37b7ca4c2e0b943785357c35b23743b94 3478126580 71479914637 948.5805297840852 13678567
import sys
import zlib
import httpx
def stream_trace(tx):
payload = {"jsonrpc": "2.0", "id": 1, "method": "debug_traceTransaction", "params": [tx]}
bytes_raw = 0
bytes_data = 0
d = zlib.decompressobj(zlib.MAX_WBITS | 16)
with httpx.stream("POST", "http://127.0.0.1:8545", json=payload) as r:
for chunk in r.iter_raw():
bytes_raw += len(chunk)
chunk_fat = d.decompress(chunk)
bytes_data += len(chunk_fat)
print({'tx': tx, 'bytes_raw': bytes_raw, 'bytes_data': bytes_data})
if __name__ == "__main__":
stream_trace(sys.argv[1])
@banteg
Copy link
Author

banteg commented Jul 22, 2022

chart

@banteg
Copy link
Author

banteg commented Jul 22, 2022

trace-size

@banteg
Copy link
Author

banteg commented Jul 22, 2022

elapsed-size

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment