Add --statediff.db.logstatements option. #307

Merged
telackey merged 2 commits from telackey/dblog into v1.10.26-statediff-v4 2023-01-13 20:59:18 +00:00
Contributor

Add a new option --statediff.db.logstatements=true|false which will control the logging of statesdiff-related DB statements.

Example output:

INFO [01-13|19:55:37.564] Exec    time=13.723527ms  commandTag=BEGIN  pid=116 sql=begin  args=[]
INFO [01-13|19:55:37.578] Exec    pid=116 sql="INSERT INTO eth.header_cids (block_number, block_hash, parent_hash, cid, td, node_id, reward, state_root, tx_root, receipt_root, uncle_root, bloom, timestamp, mh_key, times_validated, coinbase)\n\t\t\tVALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16)\n\t\t\tON CONFLICT (block_hash, block_number) DO NOTHING" args="[60xc2e8c50927247be4bcefc13bb833055bb27605350a15522a24d72d42e6bd04 (truncated 2 bytes) 0x080cccc990712b44bfa1ac09269fd090f0217d0803873a37581d69cfdff317 (truncated 2 bytes) bagiacgzaylumkcjher56jphpye53qmyflozhmbjvbikvekre24wufzv5asma 131073 1 5000681080004767560 0xa8e92eb7dbd1a265329d9539575f45b37bcc1a40fb83bee49b63262cce2cd2 (truncated 2 bytes) 0xf500a40de2642     a3f52bc79d103511e446aaab35ab501d23e8b8b23c4c58040 (truncated 2 bytes) 0xe04eef37a26925528776834c6af2c369d6d44a3db2438f3776aa832f6ba597 (truncated 2 bytes) 0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d493 (truncated 2 bytes) 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 (truncated 192 bytes) 1673639735 /blocks/DMQMF2GFBETSI67EXTX4CO5YGMCVXMTWAU2QUFKSFISNOLKC426QJGA 1 0xe6CE22afe802CAf5fF7d3845cec8c736ecc8d61F]" time=12.984251ms  commandTag="INSERT 0 1"
INFO [01-13|19:55:37.599] Exec    sql="INSERT INTO eth.transaction_cids (block_number, header_id, tx_hash, cid, dst, src, index, mh_key, tx_data, tx_type, value) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)\n\t\t\tON CONFLICT (tx_hash, header_id, block_number) DO NOTHING" args="[6 0xc2e8c50927247be4bcefc13bb833055bb27605350a15522a24d72d42e6bd04 (truncated 2 bytes) 0x1875c9b082746dc76a12267491c45add07ac8c81cbe522462ab1836cdefa0d (truncated 2 bytes) bagjqcgzadb24tmecorw4o2qsez2jdrc23ud2zdebzpsserrkwgbwzxx2bunq 0xbA85C92cCB1dF0C51b6054C26662E771B     49DbbD7 0xf1ac8Dd1f6D6F5c0dA99097c57ebF50CD99Ce293 0 /blocks/DMQBQ5OJWCBHI3OHNIJCM5ERYRNN2B5MRSA4XZJCIYVLDA3M335A2GY 2802348a000000000000000000000000ba85c92ccb1df0c51b6054c26662e771b49dbbd700000000     000000000000000000000000000000000000000000000000 (truncated 4 bytes) 2 0]" time=20.450095ms  commandTag="INSERT 0 1"   pid=116
Add a new option `--statediff.db.logstatements=true|false` which will control the logging of statesdiff-related DB statements. Example output: ``` INFO [01-13|19:55:37.564] Exec time=13.723527ms commandTag=BEGIN pid=116 sql=begin args=[] INFO [01-13|19:55:37.578] Exec pid=116 sql="INSERT INTO eth.header_cids (block_number, block_hash, parent_hash, cid, td, node_id, reward, state_root, tx_root, receipt_root, uncle_root, bloom, timestamp, mh_key, times_validated, coinbase)\n\t\t\tVALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16)\n\t\t\tON CONFLICT (block_hash, block_number) DO NOTHING" args="[60xc2e8c50927247be4bcefc13bb833055bb27605350a15522a24d72d42e6bd04 (truncated 2 bytes) 0x080cccc990712b44bfa1ac09269fd090f0217d0803873a37581d69cfdff317 (truncated 2 bytes) bagiacgzaylumkcjher56jphpye53qmyflozhmbjvbikvekre24wufzv5asma 131073 1 5000681080004767560 0xa8e92eb7dbd1a265329d9539575f45b37bcc1a40fb83bee49b63262cce2cd2 (truncated 2 bytes) 0xf500a40de2642 a3f52bc79d103511e446aaab35ab501d23e8b8b23c4c58040 (truncated 2 bytes) 0xe04eef37a26925528776834c6af2c369d6d44a3db2438f3776aa832f6ba597 (truncated 2 bytes) 0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d493 (truncated 2 bytes) 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 (truncated 192 bytes) 1673639735 /blocks/DMQMF2GFBETSI67EXTX4CO5YGMCVXMTWAU2QUFKSFISNOLKC426QJGA 1 0xe6CE22afe802CAf5fF7d3845cec8c736ecc8d61F]" time=12.984251ms commandTag="INSERT 0 1" INFO [01-13|19:55:37.599] Exec sql="INSERT INTO eth.transaction_cids (block_number, header_id, tx_hash, cid, dst, src, index, mh_key, tx_data, tx_type, value) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)\n\t\t\tON CONFLICT (tx_hash, header_id, block_number) DO NOTHING" args="[6 0xc2e8c50927247be4bcefc13bb833055bb27605350a15522a24d72d42e6bd04 (truncated 2 bytes) 0x1875c9b082746dc76a12267491c45add07ac8c81cbe522462ab1836cdefa0d (truncated 2 bytes) bagjqcgzadb24tmecorw4o2qsez2jdrc23ud2zdebzpsserrkwgbwzxx2bunq 0xbA85C92cCB1dF0C51b6054C26662E771B 49DbbD7 0xf1ac8Dd1f6D6F5c0dA99097c57ebF50CD99Ce293 0 /blocks/DMQBQ5OJWCBHI3OHNIJCM5ERYRNN2B5MRSA4XZJCIYVLDA3M335A2GY 2802348a000000000000000000000000ba85c92ccb1df0c51b6054c26662e771b49dbbd700000000 000000000000000000000000000000000000000000000000 (truncated 4 bytes) 2 0]" time=20.450095ms commandTag="INSERT 0 1" pid=116 ```
dboreham reviewed 2023-01-13 19:58:54 +00:00
i-norden approved these changes 2023-01-13 20:12:35 +00:00
i-norden left a comment
Member

LGTM! The sqlx driver doesn't accept a logger, does it?

LGTM! The sqlx driver doesn't accept a logger, does it?
Author
Contributor

LGTM! The sqlx driver doesn't accept a logger, does it?

Possibly with this? https://github.com/simukti/sqldb-logger

> LGTM! The sqlx driver doesn't accept a logger, does it? Possibly with this? https://github.com/simukti/sqldb-logger
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: cerc-io/go-ethereum#307
No description provided.