Skip to content

Commit

Permalink
turbo/jsonrpc: add support for bor state sync txn in Trace API endpoi…
Browse files Browse the repository at this point in the history
…nts (#9276)

Relates to: https://github.com/ledgerwatch/erigon/issues/7504

High-level changes:

- add support for bor state sync txn in Trace API endpoints
- refactor some code in `polygon/tracer` pkg for better re-usability of
common logic between Trace and Debug APIs
- tidy up some old code that is no longer needed
- handle some missed err-s and fix some misaligned stream writes
(invalid json cases) in err paths

Tests:
I've tested majority of the Trace API endpoints (trace_transaction,
trace_block, trace_filter, trace_replayTransaction,
trace_replayBlockTransactions) both with a bor state sync transaction
and with a normal one.

Here is an example of how the response of `trace_transaction` looks like
for a bor state sync transaction:
```
curl http://localhost:9545/ \
  -X POST \
  -H "Content-Type: application/json" \
  --data '{"method":"trace_transaction","params":["0xd2b8d76bb5e9b7ab24aa25e8fbe56e28a333587bb7df9311448c3cac103d8558"],"id":1,"jsonrpc":"2.0"}'  | jq

{
 "jsonrpc": "2.0",
 "id": 1,
 "result": [
   {
     "action": {
       "from": "0xfffffffffffffffffffffffffffffffffffffffe",
       "callType": "call",
       "gas": "0x0",
       "input": "0x",
       "to": "0x0000000000000000000000000000000000001001",
       "value": "0x0"
     },
     "blockHash": "0x469990aac1faf8009a9bc3bc83ebd54968bf1af92a1fd39c16d3748ef4203452",
     "blockNumber": 30167616,
     "result": {
       "gasUsed": "0x0",
       "output": "0x"
     },
     "subtraces": 13,
     "traceAddress": [],
     "transactionHash": "0xd2b8d76bb5e9b7ab24aa25e8fbe56e28a333587bb7df9311448c3cac103d8558",
     "transactionPosition": 163,
     "type": "call"
   },
   {
     "action": {
       "from": "0xfffffffffffffffffffffffffffffffffffffffe",
       "callType": "call",
       "gas": "0x1c962d0",
       "input": "0x19494a170000000000000000000000000000000000000000000000000000000062bd557500000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000147f9014483215cab94a6fa4fb5f76172d178d61b04b0ecd319c5d1c0aab9010087a7811f4bfedea3d341ad165680ae306b01aaeacc205d227629cf157dd9f821000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000dcbeac120c51030a911a93895f7b431e5952cee6000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee00000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000001550f7dca70000a00ce8ccdb67a7cfd5421bfb4438e2dc1fa7d2321161fadf4e5f3fe9bb0bb3ba5882011e8331333700000000000000000000000000000000000000000000000000",
       "to": "0x0000000000000000000000000000000000001001",
       "value": "0x0"
     },
     "blockHash": "0x469990aac1faf8009a9bc3bc83ebd54968bf1af92a1fd39c16d3748ef4203452",
     "blockNumber": 30167616,
     "result": {
       "gasUsed": "0x102de",
       "output": "0x0000000000000000000000000000000000000000000000000000000000000001"
     },
     "subtraces": 1,
     "traceAddress": [
       0
     ],
     "transactionHash": "0xd2b8d76bb5e9b7ab24aa25e8fbe56e28a333587bb7df9311448c3cac103d8558",
     "transactionPosition": 163,
     "type": "call"
   },
   {
     "action": {
       "from": "0x0000000000000000000000000000000000001001",
       "callType": "call",
       "gas": "0x4c4b40",
       "input": "0x26c53bea0000000000000000000000000000000000000000000000000000000000215cab0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000010087a7811f4bfedea3d341ad165680ae306b01aaeacc205d227629cf157dd9f821000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000dcbeac120c51030a911a93895f7b431e5952cee6000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee00000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000001550f7dca70000",
       "to": "0xa6fa4fb5f76172d178d61b04b0ecd319c5d1c0aa",
       "value": "0x0"
     },
     "blockHash": "0x469990aac1faf8009a9bc3bc83ebd54968bf1af92a1fd39c16d3748ef4203452",
     "blockNumber": 30167616,
     "result": {
       "gasUsed": "0xb9d0",
       "output": "0x"
     },
     "subtraces": 1,
     "traceAddress": [
       0,
       0
     ],
     "transactionHash": "0xd2b8d76bb5e9b7ab24aa25e8fbe56e28a333587bb7df9311448c3cac103d8558",
     "transactionPosition": 163,
     "type": "call"
   },
   {
     "action": {
       "from": "0xa6fa4fb5f76172d178d61b04b0ecd319c5d1c0aa",
       "callType": "delegatecall",
       "gas": "0x4b0577",
       "input": "0x26c53bea0000000000000000000000000000000000000000000000000000000000215cab0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000010087a7811f4bfedea3d341ad165680ae306b01aaeacc205d227629cf157dd9f821000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000dcbeac120c51030a911a93895f7b431e5952cee6000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee00000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000001550f7dca70000",
       "to": "0xa40fc0782bee28dd2cf8cb4ac2ecdb05c537f1b5",
       "value": "0x0"
     },
     "blockHash": "0x469990aac1faf8009a9bc3bc83ebd54968bf1af92a1fd39c16d3748ef4203452",
     "blockNumber": 30167616,
     "result": {
       "gasUsed": "0xa4ad",
       "output": "0x"
     },
     "subtraces": 1,
     "traceAddress": [
       0,
       0,
       0
     ],
     "transactionHash": "0xd2b8d76bb5e9b7ab24aa25e8fbe56e28a333587bb7df9311448c3cac103d8558",
     "transactionPosition": 163,
     "type": "call"
   },
   {
     "action": {
       "from": "0xa6fa4fb5f76172d178d61b04b0ecd319c5d1c0aa",
       "callType": "call",
       "gas": "0x49b56c",
       "input": "0xcf2c52cb000000000000000000000000dcbeac120c51030a911a93895f7b431e5952cee600000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000001550f7dca70000",
       "to": "0x7ceb23fd6bc0add59e62ac25578270cff1b9f619",
       "value": "0x0"
     },
     "blockHash": "0x469990aac1faf8009a9bc3bc83ebd54968bf1af92a1fd39c16d3748ef4203452",
     "blockNumber": 30167616,
     "result": {
       "gasUsed": "0x7fd0",
       "output": "0x"
     },
     "subtraces": 0,
     "traceAddress": [
       0,
       0,
       0,
       0
     ],
     "transactionHash": "0xd2b8d76bb5e9b7ab24aa25e8fbe56e28a333587bb7df9311448c3cac103d8558",
     "transactionPosition": 163,
     "type": "call"
   },
   {
     "action": {
       "from": "0xfffffffffffffffffffffffffffffffffffffffe",
       "callType": "call",
       "gas": "0x1c962d0",
       "input": "0x19494a170000000000000000000000000000000000000000000000000000000062bd557500000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000147f9014483215cac94a6fa4fb5f76172d178d61b04b0ecd319c5d1c0aab9010087a7811f4bfedea3d341ad165680ae306b01aaeacc205d227629cf157dd9f821000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000001b02ada9a41d8541441730ee43ea7d0effccaad9000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee00000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000002386f26fc10000a0c3a451b6d6cc319dcd797ac05887692fe44d63dc38b6322e563a3337fe6f305f82014a8331333700000000000000000000000000000000000000000000000000",
       "to": "0x0000000000000000000000000000000000001001",
       "value": "0x0"
     },
     "blockHash": "0x469990aac1faf8009a9bc3bc83ebd54968bf1af92a1fd39c16d3748ef4203452",
     "blockNumber": 30167616,
     "result": {
       "gasUsed": "0x102de",
       "output": "0x0000000000000000000000000000000000000000000000000000000000000001"
     },
     "subtraces": 1,
     "traceAddress": [
       1
     ],
     "transactionHash": "0xd2b8d76bb5e9b7ab24aa25e8fbe56e28a333587bb7df9311448c3cac103d8558",
     "transactionPosition": 163,
     "type": "call"
   },
   {
     "action": {
       "from": "0x0000000000000000000000000000000000001001",
       "callType": "call",
       "gas": "0x4c4b40",
       "input": "0x26c53bea0000000000000000000000000000000000000000000000000000000000215cac0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000010087a7811f4bfedea3d341ad165680ae306b01aaeacc205d227629cf157dd9f821000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000001b02ada9a41d8541441730ee43ea7d0effccaad9000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee00000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000002386f26fc10000",
       "to": "0xa6fa4fb5f76172d178d61b04b0ecd319c5d1c0aa",
       "value": "0x0"
     },
     "blockHash": "0x469990aac1faf8009a9bc3bc83ebd54968bf1af92a1fd39c16d3748ef4203452",
     "blockNumber": 30167616,
     "result": {
       "gasUsed": "0xb9d0",
       "output": "0x"
     },
     "subtraces": 1,
     "traceAddress": [
       1,
       0
     ],
     "transactionHash": "0xd2b8d76bb5e9b7ab24aa25e8fbe56e28a333587bb7df9311448c3cac103d8558",
     "transactionPosition": 163,
     "type": "call"
   },
   {
     "action": {
       "from": "0xa6fa4fb5f76172d178d61b04b0ecd319c5d1c0aa",
       "callType": "delegatecall",
       "gas": "0x4b0577",
       "input": "0x26c53bea0000000000000000000000000000000000000000000000000000000000215cac0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000010087a7811f4bfedea3d341ad165680ae306b01aaeacc205d227629cf157dd9f821000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000001b02ada9a41d8541441730ee43ea7d0effccaad9000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee00000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000002386f26fc10000",
       "to": "0xa40fc0782bee28dd2cf8cb4ac2ecdb05c537f1b5",
       "value": "0x0"
     },
     "blockHash": "0x469990aac1faf8009a9bc3bc83ebd54968bf1af92a1fd39c16d3748ef4203452",
     "blockNumber": 30167616,
     "result": {
       "gasUsed": "0xa4ad",
       "output": "0x"
     },
     "subtraces": 1,
     "traceAddress": [
       1,
       0,
       0
     ],
     "transactionHash": "0xd2b8d76bb5e9b7ab24aa25e8fbe56e28a333587bb7df9311448c3cac103d8558",
     "transactionPosition": 163,
     "type": "call"
   },
   {
     "action": {
       "from": "0xa6fa4fb5f76172d178d61b04b0ecd319c5d1c0aa",
       "callType": "call",
       "gas": "0x49b56c",
       "input": "0xcf2c52cb0000000000000000000000001b02ada9a41d8541441730ee43ea7d0effccaad900000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000002386f26fc10000",
       "to": "0x7ceb23fd6bc0add59e62ac25578270cff1b9f619",
       "value": "0x0"
     },
     "blockHash": "0x469990aac1faf8009a9bc3bc83ebd54968bf1af92a1fd39c16d3748ef4203452",
     "blockNumber": 30167616,
     "result": {
       "gasUsed": "0x7fd0",
       "output": "0x"
     },
     "subtraces": 0,
     "traceAddress": [
       1,
       0,
       0,
       0
     ],
     "transactionHash": "0xd2b8d76bb5e9b7ab24aa25e8fbe56e28a333587bb7df9311448c3cac103d8558",
     "transactionPosition": 163,
     "type": "call"
   },
   {
     "action": {
       "from": "0xfffffffffffffffffffffffffffffffffffffffe",
       "callType": "call",
       "gas": "0x1c962b4",
       "input": "0x19494a170000000000000000000000000000000000000000000000000000000062bd557500000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000185f9018283215cad948397259c983751daf40400790063935a11afa28ab9014000000000000000000000000003c545163bd114d756c65dda1d97d37b89da2236000000000000000000000000cd1c7c85113b16a5b9e09576112d162281b5f860000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000931eb9d2e9b0e496aac1dcdf778399ad762e3739000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000e3000000000000000000000000000000000000000000000000000000000000007700000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000a0c346dbd1115e4a8a70c678e2dfad37318035a5f36d5bad652a985d1b3e90dd006483313337000000000000000000000000000000000000000000000000000000",
       "to": "0x0000000000000000000000000000000000001001",
       "value": "0x0"
     },
     "blockHash": "0x469990aac1faf8009a9bc3bc83ebd54968bf1af92a1fd39c16d3748ef4203452",
     "blockNumber": 30167616,
     "result": {
       "gasUsed": "0x1dc19",
       "output": "0x0000000000000000000000000000000000000000000000000000000000000001"
     },
     "subtraces": 1,
     "traceAddress": [
       2
     ],
     "transactionHash": "0xd2b8d76bb5e9b7ab24aa25e8fbe56e28a333587bb7df9311448c3cac103d8558",
     "transactionPosition": 163,
     "type": "call"
   },
   {
     "action": {
       "from": "0x0000000000000000000000000000000000001001",
       "callType": "call",
       "gas": "0x4c4b40",
       "input": "0x26c53bea0000000000000000000000000000000000000000000000000000000000215cad0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000014000000000000000000000000003c545163bd114d756c65dda1d97d37b89da2236000000000000000000000000cd1c7c85113b16a5b9e09576112d162281b5f860000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000931eb9d2e9b0e496aac1dcdf778399ad762e3739000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000e3000000000000000000000000000000000000000000000000000000000000007700000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000",
       "to": "0x8397259c983751daf40400790063935a11afa28a",
       "value": "0x0"
     },
     "blockHash": "0x469990aac1faf8009a9bc3bc83ebd54968bf1af92a1fd39c16d3748ef4203452",
     "blockNumber": 30167616,
     "result": {
       "gasUsed": "0x191db",
       "output": "0x"
     },
     "subtraces": 1,
     "traceAddress": [
       2,
       0
     ],
     "transactionHash": "0xd2b8d76bb5e9b7ab24aa25e8fbe56e28a333587bb7df9311448c3cac103d8558",
     "transactionPosition": 163,
     "type": "call"
   },
   {
     "action": {
       "from": "0x8397259c983751daf40400790063935a11afa28a",
       "callType": "call",
       "gas": "0x4af990",
       "input": "0x9a7c4b710000000000000000000000000000000000000000000000000000000000215cad00000000000000000000000003c545163bd114d756c65dda1d97d37b89da2236000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000931eb9d2e9b0e496aac1dcdf778399ad762e3739000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000e3000000000000000000000000000000000000000000000000000000000000007700000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000",
       "to": "0xcd1c7c85113b16a5b9e09576112d162281b5f860",
       "value": "0x0"
     },
     "blockHash": "0x469990aac1faf8009a9bc3bc83ebd54968bf1af92a1fd39c16d3748ef4203452",
     "blockNumber": 30167616,
     "result": {
       "gasUsed": "0x1709f",
       "output": "0x"
     },
     "subtraces": 2,
     "traceAddress": [
       2,
       0,
       0
     ],
     "transactionHash": "0xd2b8d76bb5e9b7ab24aa25e8fbe56e28a333587bb7df9311448c3cac103d8558",
     "transactionPosition": 163,
     "type": "call"
   },
   {
     "action": {
       "from": "0xcd1c7c85113b16a5b9e09576112d162281b5f860",
       "callType": "staticcall",
       "gas": "0x49ac26",
       "input": "0x55064d85000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000e30000000000000000000000000000000000000000000000000000000000000077",
       "to": "0x9d305a42a3975ee4c1c57555bed5919889dce63f",
       "value": "0x0"
     },
     "blockHash": "0x469990aac1faf8009a9bc3bc83ebd54968bf1af92a1fd39c16d3748ef4203452",
     "blockNumber": 30167616,
     "result": {
       "gasUsed": "0x57a1",
       "output": "0x0000000000000000000000000000000000000000000000000000000000000000"
     },
     "subtraces": 1,
     "traceAddress": [
       2,
       0,
       0,
       0
     ],
     "transactionHash": "0xd2b8d76bb5e9b7ab24aa25e8fbe56e28a333587bb7df9311448c3cac103d8558",
     "transactionPosition": 163,
     "type": "call"
   },
   {
     "action": {
       "from": "0x9d305a42a3975ee4c1c57555bed5919889dce63f",
       "callType": "delegatecall",
       "gas": "0x4869fe",
       "input": "0x55064d85000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000e30000000000000000000000000000000000000000000000000000000000000077",
       "to": "0x16f78d75fabb869835236b5fb59c2b29f6cbbfcf",
       "value": "0x0"
     },
     "blockHash": "0x469990aac1faf8009a9bc3bc83ebd54968bf1af92a1fd39c16d3748ef4203452",
     "blockNumber": 30167616,
     "result": {
       "gasUsed": "0x3b90",
       "output": "0x0000000000000000000000000000000000000000000000000000000000000000"
     },
     "subtraces": 0,
     "traceAddress": [
       2,
       0,
       0,
       0,
       0
     ],
     "transactionHash": "0xd2b8d76bb5e9b7ab24aa25e8fbe56e28a333587bb7df9311448c3cac103d8558",
     "transactionPosition": 163,
     "type": "call"
   },
   {
     "action": {
       "from": "0xcd1c7c85113b16a5b9e09576112d162281b5f860",
       "callType": "call",
       "gas": "0x49526d",
       "input": "0x6e1e3bbf000000000000000000000000931eb9d2e9b0e496aac1dcdf778399ad762e3739000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000e3000000000000000000000000000000000000000000000000000000000000007700000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000",
       "to": "0x9d305a42a3975ee4c1c57555bed5919889dce63f",
       "value": "0x0"
     },
     "blockHash": "0x469990aac1faf8009a9bc3bc83ebd54968bf1af92a1fd39c16d3748ef4203452",
     "blockNumber": 30167616,
     "result": {
       "gasUsed": "0xe82a",
       "output": "0x"
     },
     "subtraces": 1,
     "traceAddress": [
       2,
       0,
       0,
       1
     ],
     "transactionHash": "0xd2b8d76bb5e9b7ab24aa25e8fbe56e28a333587bb7df9311448c3cac103d8558",
     "transactionPosition": 163,
     "type": "call"
   },
   {
     "action": {
       "from": "0x9d305a42a3975ee4c1c57555bed5919889dce63f",
       "callType": "delegatecall",
       "gas": "0x482a83",
       "input": "0x6e1e3bbf000000000000000000000000931eb9d2e9b0e496aac1dcdf778399ad762e3739000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000e3000000000000000000000000000000000000000000000000000000000000007700000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000",
       "to": "0x16f78d75fabb869835236b5fb59c2b29f6cbbfcf",
       "value": "0x0"
     },
     "blockHash": "0x469990aac1faf8009a9bc3bc83ebd54968bf1af92a1fd39c16d3748ef4203452",
     "blockNumber": 30167616,
     "result": {
       "gasUsed": "0xe559",
       "output": "0x"
     },
     "subtraces": 0,
     "traceAddress": [
       2,
       0,
       0,
       1,
       0
     ],
     "transactionHash": "0xd2b8d76bb5e9b7ab24aa25e8fbe56e28a333587bb7df9311448c3cac103d8558",
     "transactionPosition": 163,
     "type": "call"
   },
   {
     "action": {
       "from": "0xfffffffffffffffffffffffffffffffffffffffe",
       "callType": "call",
       "gas": "0x1c962b4",
       "input": "0x19494a170000000000000000000000000000000000000000000000000000000062bd557500000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000185f9018283215cae948397259c983751daf40400790063935a11afa28ab9014000000000000000000000000003c545163bd114d756c65dda1d97d37b89da2236000000000000000000000000cd1c7c85113b16a5b9e09576112d162281b5f860000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000931eb9d2e9b0e496aac1dcdf778399ad762e373900000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000007500000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000a0c346dbd1115e4a8a70c678e2dfad37318035a5f36d5bad652a985d1b3e90dd006683313337000000000000000000000000000000000000000000000000000000",
       "to": "0x0000000000000000000000000000000000001001",
       "value": "0x0"
     },
     "blockHash": "0x469990aac1faf8009a9bc3bc83ebd54968bf1af92a1fd39c16d3748ef4203452",
     "blockNumber": 30167616,
     "result": {
       "gasUsed": "0x26f18",
       "output": "0x0000000000000000000000000000000000000000000000000000000000000001"
     },
     "subtraces": 1,
     "traceAddress": [
       3
     ],
     "transactionHash": "0xd2b8d76bb5e9b7ab24aa25e8fbe56e28a333587bb7df9311448c3cac103d8558",
     "transactionPosition": 163,
     "type": "call"
   },
   {
     "action": {
       "from": "0x0000000000000000000000000000000000001001",
       "callType": "call",
       "gas": "0x4c4b40",
       "input": "0x26c53bea0000000000000000000000000000000000000000000000000000000000215cae0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000014000000000000000000000000003c545163bd114d756c65dda1d97d37b89da2236000000000000000000000000cd1c7c85113b16a5b9e09576112d162281b5f860000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000931eb9d2e9b0e496aac1dcdf778399ad762e373900000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000007500000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000",
       "to": "0x8397259c983751daf40400790063935a11afa28a",
       "value": "0x0"
     },
     "blockHash": "0x469990aac1faf8009a9bc3bc83ebd54968bf1af92a1fd39c16d3748ef4203452",
     "blockNumber": 30167616,
     "result": {
       "gasUsed": "0x224da",
       "output": "0x"
     },
     "subtraces": 1,
     "traceAddress": [
       3,
       0
     ],
     "transactionHash": "0xd2b8d76bb5e9b7ab24aa25e8fbe56e28a333587bb7df9311448c3cac103d8558",
     "transactionPosition": 163,
     "type": "call"
   },
   {
     "action": {
       "from": "0x8397259c983751daf40400790063935a11afa28a",
       "callType": "call",
       "gas": "0x4af990",
       "input": "0x9a7c4b710000000000000000000000000000000000000000000000000000000000215cae00000000000000000000000003c545163bd114d756c65dda1d97d37b89da2236000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000931eb9d2e9b0e496aac1dcdf778399ad762e373900000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000007500000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000",
       "to": "0xcd1c7c85113b16a5b9e09576112d162281b5f860",
       "value": "0x0"
     },
     "blockHash": "0x469990aac1faf8009a9bc3bc83ebd54968bf1af92a1fd39c16d3748ef4203452",
     "blockNumber": 30167616,
     "result": {
       "gasUsed": "0x2039e",
       "output": "0x"
     },
     "subtraces": 2,
     "traceAddress": [
       3,
       0,
       0
     ],
     "transactionHash": "0xd2b8d76bb5e9b7ab24aa25e8fbe56e28a333587bb7df9311448c3cac103d8558",
     "transactionPosition": 163,
     "type": "call"
   },
   {
     "action": {
       "from": "0xcd1c7c85113b16a5b9e09576112d162281b5f860",
       "callType": "staticcall",
       "gas": "0x49ac26",
       "input": "0x55064d85000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000075",
       "to": "0x9d305a42a3975ee4c1c57555bed5919889dce63f",
       "value": "0x0"
     },
     "blockHash": "0x469990aac1faf8009a9bc3bc83ebd54968bf1af92a1fd39c16d3748ef4203452",
     "blockNumber": 30167616,
     "result": {
       "gasUsed": "0xb67a",
       "output": "0x0000000000000000000000000000000000000000000000000000000000000000"
     },
     "subtraces": 1,
     "traceAddress": [
       3,
       0,
       0,
       0
     ],
     "transactionHash": "0xd2b8d76bb5e9b7ab24aa25e8fbe56e28a333587bb7df9311448c3cac103d8558",
     "transactionPosition": 163,
     "type": "call"
   },
   {
     "action": {
       "from": "0x9d305a42a3975ee4c1c57555bed5919889dce63f",
       "callType": "delegatecall",
       "gas": "0x4869fe",
       "input": "0x55064d85000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000075",
       "to": "0x16f78d75fabb869835236b5fb59c2b29f6cbbfcf",
       "value": "0x0"
     },
     "blockHash": "0x469990aac1faf8009a9bc3bc83ebd54968bf1af92a1fd39c16d3748ef4203452",
     "blockNumber": 30167616,
     "result": {
       "gasUsed": "0x9a69",
       "output": "0x0000000000000000000000000000000000000000000000000000000000000000"
     },
     "subtraces": 0,
     "traceAddress": [
       3,
       0,
       0,
       0,
       0
     ],
     "transactionHash": "0xd2b8d76bb5e9b7ab24aa25e8fbe56e28a333587bb7df9311448c3cac103d8558",
     "transactionPosition": 163,
     "type": "call"
   },
   {
     "action": {
       "from": "0xcd1c7c85113b16a5b9e09576112d162281b5f860",
       "callType": "call",
       "gas": "0x48f50f",
       "input": "0x6e1e3bbf000000000000000000000000931eb9d2e9b0e496aac1dcdf778399ad762e373900000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000007500000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000",
       "to": "0x9d305a42a3975ee4c1c57555bed5919889dce63f",
       "value": "0x0"
     },
     "blockHash": "0x469990aac1faf8009a9bc3bc83ebd54968bf1af92a1fd39c16d3748ef4203452",
     "blockNumber": 30167616,
     "result": {
       "gasUsed": "0x11c50",
       "output": "0x"
     },
     "subtraces": 1,
     "traceAddress": [
       3,
       0,
       0,
       1
     ],
     "transactionHash": "0xd2b8d76bb5e9b7ab24aa25e8fbe56e28a333587bb7df9311448c3cac103d8558",
     "transactionPosition": 163,
     "type": "call"
   },
   {
     "action": {
       "from": "0x9d305a42a3975ee4c1c57555bed5919889dce63f",
       "callType": "delegatecall",
       "gas": "0x47ce9b",
       "input": "0x6e1e3bbf000000000000000000000000931eb9d2e9b0e496aac1dcdf778399ad762e373900000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000007500000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000",
       "to": "0x16f78d75fabb869835236b5fb59c2b29f6cbbfcf",
       "value": "0x0"
     },
     "blockHash": "0x469990aac1faf8009a9bc3bc83ebd54968bf1af92a1fd39c16d3748ef4203452",
     "blockNumber": 30167616,
     "result": {
       "gasUsed": "0x1197f",
       "output": "0x"
     },
     "subtraces": 0,
     "traceAddress": [
       3,
       0,
       0,
       1,
       0
     ],
     "transactionHash": "0xd2b8d76bb5e9b7ab24aa25e8fbe56e28a333587bb7df9311448c3cac103d8558",
     "transactionPosition": 163,
     "type": "call"
   },
   {
     "action": {
       "from": "0xfffffffffffffffffffffffffffffffffffffffe",
       "callType": "call",
       "gas": "0x1c962dc",
       "input": "0x19494a170000000000000000000000000000000000000000000000000000000062bd557500000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000146f9014383215caf94a6fa4fb5f76172d178d61b04b0ecd319c5d1c0aab9010087a7811f4bfedea3d341ad165680ae306b01aaeacc205d227629cf157dd9f821000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000d649ec9b9acea96876909054219c2fdaa00742f8000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000021c0331d5dc000a0349272f2c8d6c53608b75ffb00e2bc792c1c4f6d4b2c9604942d58f1b4e5db6781e8833133370000000000000000000000000000000000000000000000000000",
       "to": "0x0000000000000000000000000000000000001001",
       "value": "0x0"
     },
     "blockHash": "0x469990aac1faf8009a9bc3bc83ebd54968bf1af92a1fd39c16d3748ef4203452",
     "blockNumber": 30167616,
     "result": {
       "gasUsed": "0xc012",
       "output": "0x0000000000000000000000000000000000000000000000000000000000000001"
     },
     "subtraces": 1,
     "traceAddress": [
       4
     ],
     "transactionHash": "0xd2b8d76bb5e9b7ab24aa25e8fbe56e28a333587bb7df9311448c3cac103d8558",
     "transactionPosition": 163,
     "type": "call"
   },
   {
     "action": {
       "from": "0x0000000000000000000000000000000000001001",
       "callType": "call",
       "gas": "0x4c4b40",
       "input": "0x26c53bea0000000000000000000000000000000000000000000000000000000000215caf0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000010087a7811f4bfedea3d341ad165680ae306b01aaeacc205d227629cf157dd9f821000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000d649ec9b9acea96876909054219c2fdaa00742f8000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000021c0331d5dc000",
       "to": "0xa6fa4fb5f76172d178d61b04b0ecd319c5d1c0aa",
       "value": "0x0"
     },
     "blockHash": "0x469990aac1faf8009a9bc3bc83ebd54968bf1af92a1fd39c16d3748ef4203452",
     "blockNumber": 30167616,
     "result": {
       "gasUsed": "0x7704",
       "output": "0x"
     },
     "subtraces": 1,
     "traceAddress": [
       4,
       0
     ],
     "transactionHash": "0xd2b8d76bb5e9b7ab24aa25e8fbe56e28a333587bb7df9311448c3cac103d8558",
     "transactionPosition": 163,
     "type": "call"
   },
   {
     "action": {
       "from": "0xa6fa4fb5f76172d178d61b04b0ecd319c5d1c0aa",
       "callType": "delegatecall",
       "gas": "0x4b0577",
       "input": "0x26c53bea0000000000000000000000000000000000000000000000000000000000215caf0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000010087a7811f4bfedea3d341ad165680ae306b01aaeacc205d227629cf157dd9f821000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000d649ec9b9acea96876909054219c2fdaa00742f8000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000021c0331d5dc000",
       "to": "0xa40fc0782bee28dd2cf8cb4ac2ecdb05c537f1b5",
       "value": "0x0"
     },
     "blockHash": "0x469990aac1faf8009a9bc3bc83ebd54968bf1af92a1fd39c16d3748ef4203452",
     "blockNumber": 30167616,
     "result": {
       "gasUsed": "0x61e1",
       "output": "0x"
     },
     "subtraces": 1,
     "traceAddress": [
       4,
       0,
       0
     ],
     "transactionHash": "0xd2b8d76bb5e9b7ab24aa25e8fbe56e28a333587bb7df9311448c3cac103d8558",
     "transactionPosition": 163,
     "type": "call"
   },
   {
     "action": {
       "from": "0xa6fa4fb5f76172d178d61b04b0ecd319c5d1c0aa",
       "callType": "call",
       "gas": "0x49b56c",
       "input": "0xcf2c52cb000000000000000000000000d649ec9b9acea96876909054219c2fdaa00742f8000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000021c0331d5dc000",
       "to": "0x7ceb23fd6bc0add59e62ac25578270cff1b9f619",
       "value": "0x0"
     },
     "blockHash": "0x469990aac1faf8009a9bc3bc83ebd54968bf1af92a1fd39c16d3748ef4203452",
     "blockNumber": 30167616,
     "result": {
       "gasUsed": "0x3d04",
       "output": "0x"
     },
     "subtraces": 0,
     "traceAddress": [
       4,
       0,
       0,
       0
     ],
     "transactionHash": "0xd2b8d76bb5e9b7ab24aa25e8fbe56e28a333587bb7df9311448c3cac103d8558",
     "transactionPosition": 163,
     "type": "call"
   },
   {
     "action": {
       "from": "0xfffffffffffffffffffffffffffffffffffffffe",
       "callType": "call",
       "gas": "0x1c962d0",
       "input": "0x19494a170000000000000000000000000000000000000000000000000000000062bd557500000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000147f9014483215cb094a6fa4fb5f76172d178d61b04b0ecd319c5d1c0aab9010087a7811f4bfedea3d341ad165680ae306b01aaeacc205d227629cf157dd9f821000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000001dafb2f175e729aa49eaa0d229676b32f548d176000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000429d069189e0000a09f94436b9b34a033851b1bad2357adbf6c8800c2e71336f927559bee95c17a858201b48331333700000000000000000000000000000000000000000000000000",
       "to": "0x0000000000000000000000000000000000001001",
       "value": "0x0"
     },
     "blockHash": "0x469990aac1faf8009a9bc3bc83ebd54968bf1af92a1fd39c16d3748ef4203452",
     "blockNumber": 30167616,
     "result": {
       "gasUsed": "0x102de",
       "output": "0x0000000000000000000000000000000000000000000000000000000000000001"
     },
     "subtraces": 1,
     "traceAddress": [
       5
     ],
     "transactionHash": "0xd2b8d76bb5e9b7ab24aa25e8fbe56e28a333587bb7df9311448c3cac103d8558",
     "transactionPosition": 163,
     "type": "call"
   },
   {
     "action": {
       "from": "0x0000000000000000000000000000000000001001",
       "callType": "call",
       "gas": "0x4c4b40",
       "input": "0x26c53bea0000000000000000000000000000000000000000000000000000000000215cb00000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000010087a7811f4bfedea3d341ad165680ae306b01aaeacc205d227629cf157dd9f821000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000001dafb2f175e729aa49eaa0d229676b32f548d176000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000429d069189e0000",
       "to": "0xa6fa4fb5f76172d178d61b04b0ecd319c5d1c0aa",
       "value": "0x0"
     },
     "blockHash": "0x469990aac1faf8009a9bc3bc83ebd54968bf1af92a1fd39c16d3748ef4203452",
     "blockNumber": 30167616,
     "result": {
       "gasUsed": "0xb9d0",
       "output": "0x"
     },
     "subtraces": 1,
     "traceAddress": [
       5,
       0
     ],
     "transactionHash": "0xd2b8d76bb5e9b7ab24aa25e8fbe56e28a333587bb7df9311448c3cac103d8558",
     "transactionPosition": 163,
     "type": "call"
   },
   {
     "action": {
       "from": "0xa6fa4fb5f76172d178d61b04b0ecd319c5d1c0aa",
       "callType": "delegatecall",
       "gas": "0x4b0577",
       "input": "0x26c53bea0000000000000000000000000000000000000000000000000000000000215cb00000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000010087a7811f4bfedea3d341ad165680ae306b01aaeacc205d227629cf157dd9f821000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000001dafb2f175e729aa49eaa0d229676b32f548d176000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000429d069189e0000",
       "to": "0xa40fc0782bee28dd2cf8cb4ac2ecdb05c537f1b5",
       "value": "0x0"
     },
     "blockHash": "0x469990aac1faf8009a9bc3bc83ebd54968bf1af92a1fd39c16d3748ef4203452",
     "blockNumber": 30167616,
     "result": {
       "gasUsed": "0xa4ad",
       "output": "0x"
     },
     "subtraces": 1,
     "traceAddress": [
       5,
       0,
       0
     ],
     "transactionHash": "0xd2b8d76bb5e9b7ab24aa25e8fbe56e28a333587bb7df9311448c3cac103d8558",
     "transactionPosition": 163,
     "type": "call"
   },
   {
     "action": {
       "from": "0xa6fa4fb5f76172d178d61b04b0ecd319c5d1c0aa",
       "callType": "call",
       "gas": "0x49b56c",
       "input": "0xcf2c52cb0000000000000000000000001dafb2f175e729aa49eaa0d229676b32f548d176000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000429d069189e0000",
       "to": "0x7ceb23fd6bc0add59e62ac25578270cff1b9f619",
       "value": "0x0"
     },
     "blockHash": "0x469990aac1faf8009a9bc3bc83ebd54968bf1af92a1fd39c16d3748ef4203452",
     "blockNumber": 30167616,
     "result": {
       "gasUsed": "0x7fd0",
       "output": "0x"
     },
     "subtraces": 0,
     "traceAddress": [
       5,
       0,
       0,
       0
     ],
     "transactionHash": "0xd2b8d76bb5e9b7ab24aa25e8fbe56e28a333587bb7df9311448c3cac103d8558",
     "transactionPosition": 163,
     "type": "call"
   },
   {
     "action": {
       "from": "0xfffffffffffffffffffffffffffffffffffffffe",
       "callType": "call",
       "gas": "0x1c962dc",
       "input": "0x19494a170000000000000000000000000000000000000000000000000000000062bd557500000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000145f9014283215cb194a6fa4fb5f76172d178d61b04b0ecd319c5d1c0aab9010087a7811f4bfedea3d341ad165680ae306b01aaeacc205d227629cf157dd9f821000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000b3126d09ebf9b5de9eaf9937bfc3e5dcececa856000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee0000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000001f4eec0c1548000a0a66e30b0161aad6d238da536d64e9619007fb26a5391c4244503efa53337ef6d0d83313337000000000000000000000000000000000000000000000000000000",
       "to": "0x0000000000000000000000000000000000001001",
       "value": "0x0"
     },
     "blockHash": "0x469990aac1faf8009a9bc3bc83ebd54968bf1af92a1fd39c16d3748ef4203452",
     "blockNumber": 30167616,
     "result": {
       "gasUsed": "0xbfac",
       "output": "0x0000000000000000000000000000000000000000000000000000000000000001"
     },
     "subtraces": 1,
     "traceAddress": [
       6
     ],
     "transactionHash": "0xd2b8d76bb5e9b7ab24aa25e8fbe56e28a333587bb7df9311448c3cac103d8558",
     "transactionPosition": 163,
     "type": "call"
   },
   {
     "action": {
       "from": "0x0000000000000000000000000000000000001001",
       "callType": "call",
       "gas": "0x4c4b40",
       "input": "0x26c53bea0000000000000000000000000000000000000000000000000000000000215cb10000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000010087a7811f4bfedea3d341ad165680ae306b01aaeacc205d227629cf157dd9f821000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000b3126d09ebf9b5de9eaf9937bfc3e5dcececa856000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee0000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000001f4eec0c1548000",
       "to": "0xa6fa4fb5f76172d178d61b04b0ecd319c5d1c0aa",
       "value": "0x0"
     },
     "blockHash": "0x469990aac1faf8009a9bc3bc83ebd54968bf1af92a1fd39c16d3748ef4203452",
     "blockNumber": 30167616,
     "result": {
       "gasUsed": "0x7704",
       "output": "0x"
     },
     "subtraces": 1,
     "traceAddress": [
       6,
       0
     ],
     "transactionHash": "0xd2b8d76bb5e9b7ab24aa25e8fbe56e28a333587bb7df9311448c3cac103d8558",
     "transactionPosition": 163,
     "type": "call"
   },
   {
     "action": {
       "from": "0xa6fa4fb5f76172d178d61b04b0ecd319c5d1c0aa",
       "callType": "delegatecall",
       "gas": "0x4b0577",
       "input": "0x26c53bea0000000000000000000000000000000000000000000000000000000000215cb10000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000010087a7811f4bfedea3d341ad165680ae306b01aaeacc205d227629cf157dd9f821000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000b3126d09ebf9b5de9eaf9937bfc3e5dcececa856000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee0000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000001f4eec0c1548000",
       "to": "0xa40fc0782bee28dd2cf8cb4ac2ecdb05c537f1b5",
       "value": "0x0"
     },
     "blockHash": "0x469990aac1faf8009a9bc3bc83ebd54968bf1af92a1fd39c16d3748ef4203452",
     "blockNumber": 30167616,
     "result": {
       "gasUsed": "0x61e1",
       "output": "0x"
     },
     "subtraces": 1,
     "traceAddress": [
       6,
       0,
       0
     ],
     "transactionHash": "0xd2b8d76bb5e9b7ab24aa25e8fbe56e28a333587bb7df9311448c3cac103d8558",
     "transactionPosition": 163,
     "type": "call"
   },
   {
     "action": {
       "from": "0xa6fa4fb5f76172d178d61b04b0ecd319c5d1c0aa",
       "callType": "call",
       "gas": "0x49b56c",
       "input": "0xcf2c52cb000000000000000000000000b3126d09ebf9b5de9eaf9937bfc3e5dcececa8560000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000001f4eec0c1548000",
       "to": "0x7ceb23fd6bc0add59e62ac25578270cff1b9f619",
       "value": "0x0"
     },
     "blockHash": "0x469990aac1faf8009a9bc3bc83ebd54968bf1af92a1fd39c16d3748ef4203452",
     "blockNumber": 30167616,
     "result": {
       "gasUsed": "0x3d04",
       "output": "0x"
     },
     "subtraces": 0,
     "traceAddress": [
       6,
       0,
       0,
       0
     ],
     "transactionHash": "0xd2b8d76bb5e9b7ab24aa25e8fbe56e28a333587bb7df9311448c3cac103d8558",
     "transactionPosition": 163,
     "type": "call"
   },
   {
     "action": {
       "from": "0xfffffffffffffffffffffffffffffffffffffffe",
       "callType": "call",
       "gas": "0x1c962c4",
       "input": "0x19494a170000000000000000000000000000000000000000000000000000000062bd557500000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000147f9014483215cb294a6fa4fb5f76172d178d61b04b0ecd319c5d1c0aab9010087a7811f4bfedea3d341ad165680ae306b01aaeacc205d227629cf157dd9f821000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000005395640f0d9d7e51428d1e11519ae9b8b1e547b3000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee00000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000007c585087238000a08e71ee5848a1519da380b8df689787abc315743ebb4353e774bca02406c062738201078331333700000000000000000000000000000000000000000000000000",
       "to": "0x0000000000000000000000000000000000001001",
       "value": "0x0"
     },
     "blockHash": "0x469990aac1faf8009a9bc3bc83ebd54968bf1af92a1fd39c16d3748ef4203452",
     "blockNumber": 30167616,
     "result": {
       "gasUsed": "0xc012",
       "output": "0x0000000000000000000000000000000000000000000000000000000000000001"
     },
     "subtraces": 1,
     "traceAddress": [
       7
     ],
     "transactionHash": "0xd2b8d76bb5e9b7ab24aa25e8fbe56e28a333587bb7df9311448c3cac103d8558",
     "transactionPosition": 163,
     "type": "call"
   },
   {
     "action": {
       "from": "0x0000000000000000000000000000000000001001",
       "callType": "call",
       "gas": "0x4c4b40",
       "input": "0x26c53bea0000000000000000000000000000000000000000000000000000000000215cb20000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000010087a7811f4bfedea3d341ad165680ae306b01aaeacc205d227629cf157dd9f821000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000005395640f0d9d7e51428d1e11519ae9b8b1e547b3000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee00000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000007c585087238000",
       "to": "0xa6fa4fb5f76172d178d61b04b0ecd319c5d1c0aa",
       "value": "0x0"
     },
     "blockHash": "0x469990aac1faf8009a9bc3bc83ebd54968bf1af92a1fd39c16d3748ef4203452",
     "blockNumber": 30167616,
     "result": {
       "gasUsed": "0x7704",
       "output": "0x"
     },
     "subtraces": 1,
     "traceAddress": [
       7,
       0
     ],
     "transactionHash": "0xd2b8d76bb5e9b7ab24aa25e8fbe56e28a333587bb7df9311448c3cac103d8558",
     "transactionPosition": 163,
     "type": "call"
   },
   {
     "action": {
       "from": "0xa6fa4fb5f76172d178d61b04b0ecd319c5d1c0aa",
       "callType": "delegatecall",
       "gas": "0x4b0577",
       "input": "0x26c53bea0000000000000000000000000000000000000000000000000000000000215cb20000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000010087a7811f4bfedea3d341ad165680ae306b01aaeacc205d227629cf157dd9f821000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000005395640f0d9d7e51428d1e11519ae9b8b1e547b3000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee00000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000007c585087238000",
       "to": "0xa40fc0782bee28dd2cf8cb4ac2ecdb05c537f1b5",
       "value": "0x0"
     },
     "blockHash": "0x469990aac1faf8009a9bc3bc83ebd54968bf1af92a1fd39c16d3748ef4203452",
     "blockNumber": 30167616,
     "result": {
       "gasUsed": "0x61e1",
       "output": "0x"
     },
     "subtraces": 1,
     "traceAddress": [
       7,
       0,
       0
     ],
     "transactionHash": "0xd2b8d76bb5e9b7ab24aa25e8fbe56e28a333587bb7df9311448c3cac103d8558",
     "transactionPosition": 163,
     "type": "call"
   },
   {
     "action": {
       "from": "0xa6fa4fb5f76172d178d61b04b0ecd319c5d1c0aa",
       "callType": "call",
       "gas": "0x49b56c",
       "input": "0xcf2c52cb0000000000000000000000005395640f0d9d7e51428d1e11519ae9b8b1e547b300000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000007c585087238000",
       "to": "0x7ceb23fd6bc0add59e62ac25578270cff1b9f619",
       "value": "0x0"
     },
     "blockHash": "0x469990aac1faf8009a9bc3bc83ebd54968bf1af92a1fd39c16d3748ef4203452",
     "blockNumber": 30167616,
     "result": {
       "gasUsed": "0x3d04",
       "output": "0x"
     },
     "subtraces": 0,
     "traceAddress": [
       7,
       0,
       0,
       0
     ],
     "transactionHash": "0xd2b8d76bb5e9b7ab24aa25e8fbe56e28a333587bb7df9311448c3cac103d8558",
     "transactionPosition": 163,
     "type": "call"
   },
   {
     "action": {
       "from": "0xfffffffffffffffffffffffffffffffffffffffe",
       "callType": "call",
       "gas": "0x1c962c4",
       "input": "0x19494a170000000000000000000000000000000000000000000000000000000062bd557500000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000147f9014483215cb394a6fa4fb5f76172d178d61b04b0ecd319c5d1c0aab9010087a7811f4bfedea3d341ad165680ae306b01aaeacc205d227629cf157dd9f821000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000f8eb9c2248ce3b6357c7e7067d4d16d62b7ed004000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee0000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000002ea11e32ad50000a0efb741123130fa8c575b71460ff9fae3251094f690cfbf0758e42cac26fa52b08201748331333700000000000000000000000000000000000000000000000000",
       "to": "0x0000000000000000000000000000000000001001",
       "value": "0x0"
     },
     "blockHash": "0x469990aac1faf8009a9bc3bc83ebd54968bf1af92a1fd39c16d3748ef4203452",
     "blockNumber": 30167616,
     "result": {
       "gasUsed": "0x102de",
       "output": "0x0000000000000000000000000000000000000000000000000000000000000001"
     },
     "subtraces": 1,
     "traceAddress": [
       8
     ],
     "transactionHash": "0xd2b8d76bb5e9b7ab24aa25e8fbe56e28a333587bb7df9311448c3cac103d8558",
     "transactionPosition": 163,
     "type": "call"
   },
   {
     "action": {
       "from": "0x0000000000000000000000000000000000001001",
       "callType": "call",
       "gas": "0x4c4b40",
       "input": "0x26c53bea0000000000000000000000000000000000000000000000000000000000215cb30000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000010087a7811f4bfedea3d341ad165680ae306b01aaeacc205d227629cf157dd9f821000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000f8eb9c2248ce3b6357c7e7067d4d16d62b7ed004000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee0000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000002ea11e32ad50000",
       "to": "0xa6fa4fb5f76172d178d61b04b0ecd319c5d1c0aa",
       "value": "0x0"
     },
     "blockHash": "0x469990aac1faf8009a9bc3bc83ebd54968bf1af92a1fd39c16d3748ef4203452",
     "blockNumber": 30167616,
     "result": {
       "gasUsed": "0xb9d0",
       "output": "0x"
     },
     "subtraces": 1,
     "traceAddress": [
       8,
       0
     ],
     "transactionHash": "0xd2b8d76bb5e9b7ab24aa25e8fbe56e28a333587bb7df9311448c3cac103d8558",
     "transactionPosition": 163,
     "type": "call"
   },
   {
     "action": {
       "from": "0xa6fa4fb5f76172d178d61b04b0ecd319c5d1c0aa",
       "callType": "delegatecall",
       "gas": "0x4b0577",
       "input": "0x26c53bea0000000000000000000000000000000000000000000000000000000000215cb30000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000010087a7811f4bfedea3d341ad165680ae306b01aaeacc205d227629cf157dd9f821000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000f8eb9c2248ce3b6357c7e7067d4d16d62b7ed004000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee0000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000002ea11e32ad50000",
       "to": "0xa40fc0782bee28dd2cf8cb4ac2ecdb05c537f1b5",
       "value": "0x0"
     },
     "blockHash": "0x469990aac1faf8009a9bc3bc83ebd54968bf1af92a1fd39c16d3748ef4203452",
     "blockNumber": 30167616,
     "result": {
       "gasUsed": "0xa4ad",
       "output": "0x"
     },
     "subtraces": 1,
     "traceAddress": [
       8,
       0,
       0
     ],
     "transactionHash": "0xd2b8d76bb5e9b7ab24aa25e8fbe56e28a333587bb7df9311448c3cac103d8558",
     "transactionPosition": 163,
     "type": "call"
   },
   {
     "action": {
       "from": "0xa6fa4fb5f76172d178d61b04b0ecd319c5d1c0aa",
       "callType": "call",
       "gas": "0x49b56c",
       "input": "0xcf2c52cb000000000000000000000000f8eb9c2248ce3b6357c7e7067d4d16d62b7ed0040000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000002ea11e32ad50000",
       "to": "0x7ceb23fd6bc0add59e62ac25578270cff1b9f619",
       "value": "0x0"
     },
     "blockHash": "0x469990aac1faf8009a9bc3bc83ebd54968bf1af92a1fd39c16d3748ef4203452",
     "blockNumber": 30167616,
     "result": {
       "gasUsed": "0x7fd0",
       "output": "0x"
     },
     "subtraces": 0,
     "traceAddress": [
       8,
       0,
       0,
       0
     ],
     "transactionHash": "0xd2b8d76bb5e9b7ab24aa25e8fbe56e28a333587bb7df9311448c3cac103d8558",
     "transactionPosition": 163,
     "type": "call"
   },
   {
     "action": {
       "from": "0xfffffffffffffffffffffffffffffffffffffffe",
       "callType": "call",
       "gas": "0x1c962b8",
       "input": "0x19494a170000000000000000000000000000000000000000000000000000000062bd55b100000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000147f9014483215cb494a6fa4fb5f76172d178d61b04b0ecd319c5d1c0aab9010087a7811f4bfedea3d341ad165680ae306b01aaeacc205d227629cf157dd9f821000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000075099eada4834fc93140906e5186b695d7cfd115000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee00000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000e0303b699986ba07a9ef397ed31baaaed28ad5b5737908341b9bdcd3aba7c3bb9934258426b42338202548331333700000000000000000000000000000000000000000000000000",
       "to": "0x0000000000000000000000000000000000001001",
       "value": "0x0"
     },
     "blockHash": "0x469990aac1faf8009a9bc3bc83ebd54968bf1af92a1fd39c16d3748ef4203452",
     "blockNumber": 30167616,
     "result": {
       "gasUsed": "0x102de",
       "output": "0x0000000000000000000000000000000000000000000000000000000000000001"
     },
     "subtraces": 1,
     "traceAddress": [
       9
     ],
     "transactionHash": "0xd2b8d76bb5e9b7ab24aa25e8fbe56e28a333587bb7df9311448c3cac103d8558",
     "transactionPosition": 163,
     "type": "call"
   },
   {
     "action": {
       "from": "0x0000000000000000000000000000000000001001",
       "callType": "call",
       "gas": "0x4c4b40",
       "input": "0x26c53bea0000000000000000000000000000000000000000000000000000000000215cb40000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000010087a7811f4bfedea3d341ad165680ae306b01aaeacc205d227629cf157dd9f821000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000075099eada4834fc93140906e5186b695d7cfd115000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee00000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000e0303b699986b",
       "to": "0xa6fa4fb5f76172d178d61b04b0ecd319c5d1c0aa",
       "value": "0x0"
     },
     "blockHash": "0x469990aac1faf8009a9bc3bc83ebd54968bf1af92a1fd39c16d3748ef4203452",
     "blockNumber": 30167616,
     "result": {
       "gasUsed": "0xb9d0",
       "output": "0x"
     },
     "subtraces": 1,
     "traceAddress": [
       9,
       0
     ],
     "transactionHash": "0xd2b8d76bb5e9b7ab24aa25e8fbe56e28a333587bb7df9311448c3cac103d8558",
     "transactionPosition": 163,
     "type": "call"
   },
   {
     "action": {
       "from": "0xa6fa4fb5f76172d178d61b04b0ecd319c5d1c0aa",
       "callType": "delegatecall",
       "gas": "0x4b0577",
       "input": "0x26c53bea0000000000000000000000000000000000000000000000000000000000215cb40000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000010087a7811f4bfedea3d341ad165680ae306b01aaeacc205d227629cf157dd9f821000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000075099eada4834fc93140906e5186b695d7cfd115000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee00000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000e0303b699986b",
       "to": "0xa40fc0782bee28dd2cf8cb4ac2ecdb05c537f1b5",
       "value": "0x0"
     },
     "blockHash": "0x469990aac1faf8009a9bc3bc83ebd54968bf1af92a1fd39c16d3748ef4203452",
     "blockNumber": 30167616,
     "result": {
       "gasUsed": "0xa4ad",
       "output": "0x"
     },
     "subtraces": 1,
     "traceAddress": [
       9,
       0,
       0
     ],
     "transactionHash": "0xd2b8d76bb5e9b7ab24aa25e8fbe56e28a333587bb7df9311448c3cac103d8558",
     "transactionPosition": 163,
     "type": "call"
   },
   {
     "action": {
       "from": "0xa6fa4fb5f76172d178d61b04b0ecd319c5d1c0aa",
       "callType": "call",
       "gas": "0x49b56c",
       "input": "0xcf2c52cb00000000000000000000000075099eada4834fc93140906e5186b695d7cfd11500000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000e0303b699986b",
       "to": "0x7ceb23fd6bc0add59e62ac25578270cff1b9f619",
       "value": "0x0"
     },
     "blockHash": "0x469990aac1faf8009a9bc3bc83ebd54968bf1af92a1fd39c16d3748ef4203452",
     "blockNumber": 30167616,
     "result": {
       "gasUsed": "0x7fd0",
       "output": "0x"
     },
     "subtraces": 0,
     "traceAddress": [
       9,
       0,
       0,
       0
     ],
     "transactionHash": "0xd2b8d76bb5e9b7ab24aa25e8fbe56e28a333587bb7df9311448c3cac103d8558",
     "transactionPosition": 163,
     "type": "call"
   },
   {
     "action": {
       "from": "0xfffffffffffffffffffffffffffffffffffffffe",
       "callType": "call",
       "gas": "0x1c962b8",
       "input": "0x19494a170000000000000000000000000000000000000000000000000000000062bd55b100000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000147f9014483215cb594a6fa4fb5f76172d178d61b04b0ecd319c5d1c0aab9010087a7811f4bfedea3d341ad165680ae306b01aaeacc205d227629cf157dd9f821000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000852a1868ba523d787ee9306a3281f76458aa5e7b000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee00000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000e0303b699986ba011ea0586618611cf4e8782e41af70f41671ba28c555fa5aefe0e0c3c4748f1d282026f8331333700000000000000000000000000000000000000000000000000",
       "to": "0x0000000000000000000000000000000000001001",
       "value": "0x0"
     },
     "blockHash": "0x469990aac1faf8009a9bc3bc83ebd54968bf1af92a1fd39c16d3748ef4203452",
     "blockNumber": 30167616,
     "result": {
       "gasUsed": "0xc012",
       "output": "0x0000000000000000000000000000000000000000000000000000000000000001"
     },
     "subtraces": 1,
     "traceAddress": [
       10
     ],
     "transactionHash": "0xd2b8d76bb5e9b7ab24aa25e8fbe56e28a333587bb7df9311448c3cac103d8558",
     "transactionPosition": 163,
     "type": "call"
   },
   {
     "action": {
       "from": "0x0000000000000000000000000000000000001001",
       "callType": "call",
       "gas": "0x4c4b40",
       "input": "0x26c53bea0000000000000000000000000000000000000000000000000000000000215cb50000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000010087a7811f4bfedea3d341ad165680ae306b01aaeacc205d227629cf157dd9f821000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000852a1868ba523d787ee9306a3281f76458aa5e7b000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee00000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000e0303b699986b",
       "to": "0x…
  • Loading branch information
taratorio authored Jan 29, 2024
1 parent 867957d commit 4f76c6d
Show file tree
Hide file tree
Showing 10 changed files with 337 additions and 298 deletions.
87 changes: 9 additions & 78 deletions core/rawdb/bor_receipts.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@ package rawdb

import (
"bytes"
"errors"
"fmt"
"github.com/ledgerwatch/erigon-lib/kv/dbutils"
"math/big"

"github.com/ledgerwatch/log/v3"

libcommon "github.com/ledgerwatch/erigon-lib/common"
"github.com/ledgerwatch/erigon-lib/common/hexutility"
"github.com/ledgerwatch/erigon-lib/kv"
"github.com/ledgerwatch/log/v3"

"github.com/ledgerwatch/erigon-lib/kv/dbutils"
"github.com/ledgerwatch/erigon/core/types"
"github.com/ledgerwatch/erigon/ethdb/cbor"
"github.com/ledgerwatch/erigon/rlp"
Expand All @@ -22,8 +21,7 @@ var (
borReceiptKey = types.BorReceiptKey
)

// HasBorReceipt verifies the existence of all block receipt belonging
// to a block.
// HasBorReceipts verifies the existence of all block receipt belonging to a block.
func HasBorReceipts(db kv.Has, number uint64) bool {
if has, err := db.Has(kv.BorReceipts, borReceiptKey(number)); !has || err != nil {
return false
Expand Down Expand Up @@ -85,11 +83,13 @@ func ReadBorReceipt(db kv.Tx, blockHash libcommon.Hash, blockNumber uint64, rece
return borReceipt, nil
}

// WriteBorReceipt stores all the bor receipt belonging to a block (storing the state sync recipt and log).
func WriteBorReceipt(tx kv.RwTx, hash libcommon.Hash, number uint64, borReceipt *types.Receipt) error {
// WriteBorReceipt stores all the bor receipt belonging to a block (storing the state sync receipt and log).
func WriteBorReceipt(tx kv.RwTx, number uint64, borReceipt *types.Receipt) error {
// Convert the bor receipt into their storage form and serialize them
buf := bytes.NewBuffer(make([]byte, 0, 1024))
cbor.Marshal(buf, borReceipt.Logs)
if err := cbor.Marshal(buf, borReceipt.Logs); err != nil {
return err
}
if err := tx.Append(kv.Log, dbutils.LogKey(number, uint32(borReceipt.TransactionIndex)), buf.Bytes()); err != nil {
return err
}
Expand All @@ -107,63 +107,6 @@ func WriteBorReceipt(tx kv.RwTx, hash libcommon.Hash, number uint64, borReceipt
return nil
}

/*
// DeleteBorReceipt removes receipt data associated with a block hash.
func DeleteBorReceipt(tx kv.RwTx, hash libcommon.Hash, number uint64) {
key := borReceiptKey(number)
// we delete Bor Receipt log too
borReceipt, err := ReadBorReceipt(tx, number)
if err != nil {
log.Error("Failted to read bor receipt", "err", err)
}
if borReceipt != nil {
if err := tx.Delete(kv.Log, dbutils.LogKey(number, uint32(borReceipt.TransactionIndex))); err != nil {
log.Error("Failed to delete bor log", "err", err)
}
}
if err := tx.Delete(kv.BorReceipts, key); err != nil {
log.Error("Failed to delete bor receipt", "err", err)
}
}
// ReadBorTransactionWithBlockHash retrieves a specific bor (fake) transaction by tx hash and block hash, along with
// its added positional metadata.
func ReadBorTransactionWithBlockHash(db kv.Tx, borTxHash libcommon.Hash, blockHash libcommon.Hash) (*types.Transaction, libcommon.Hash, uint64, uint64, error) {
blockNumber, err := ReadTxLookupEntry(db, borTxHash)
if err != nil {
return nil, libcommon.Hash{}, 0, 0, err
}
if blockNumber == nil {
return nil, libcommon.Hash{}, 0, 0, errors.New("missing block number")
}
bodyForStorage, err := ReadStorageBody(db, blockHash, *blockNumber)
if err != nil {
return nil, libcommon.Hash{}, 0, 0, nil
}
var tx types.Transaction = types.NewBorTransaction()
return &tx, blockHash, *blockNumber, uint64(bodyForStorage.TxAmount), nil
}
*/

// ReadBorTransaction returns a specific bor (fake) transaction by txn hash, along with
// its added positional metadata.
func ReadBorTransaction(db kv.Tx, borTxHash libcommon.Hash) (types.Transaction, error) {
blockNumber, err := ReadBorTxLookupEntry(db, borTxHash)
if err != nil {
return nil, err
}
if blockNumber == nil {
return nil, errors.New("missing block number")
}

borTx, err := computeBorTransactionForBlockNumber(db, *blockNumber)
return borTx, err
}

func ReadBorTxLookupEntry(db kv.Getter, borTxHash libcommon.Hash) (*uint64, error) {
blockNumBytes, err := db.GetOne(kv.BorTxLookup, borTxHash.Bytes())
if err != nil {
Expand All @@ -177,18 +120,6 @@ func ReadBorTxLookupEntry(db kv.Getter, borTxHash libcommon.Hash) (*uint64, erro
return &blockNum, nil
}

func computeBorTransactionForBlockNumber(db kv.Tx, blockNumber uint64) (types.Transaction, error) {
blockHash, err := ReadCanonicalHash(db, blockNumber)
if err != nil {
return nil, err
}
if blockHash == (libcommon.Hash{}) {
return nil, errors.New("missing block hash")
}

return types.NewBorTransaction(), nil
}

// ReadBorTransactionForBlock retrieves a specific bor (fake) transaction associated with a block, along with
// its added positional metadata.
func ReadBorTransactionForBlock(db kv.Tx, blockNum uint64) types.Transaction {
Expand Down
39 changes: 3 additions & 36 deletions core/types/bor_receipt.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package types

import (
"github.com/ledgerwatch/erigon-lib/kv/dbutils"
"math/big"
"sort"

"github.com/holiman/uint256"
libcommon "github.com/ledgerwatch/erigon-lib/common"

libcommon "github.com/ledgerwatch/erigon-lib/common"
"github.com/ledgerwatch/erigon-lib/kv/dbutils"
"github.com/ledgerwatch/erigon/crypto"
)

Expand All @@ -34,7 +33,7 @@ func NewBorTransaction() *LegacyTx {

// DeriveFieldsForBorReceipt fills the receipts with their computed fields based on consensus
// data and contextual infos like containing block and transactions.
func DeriveFieldsForBorReceipt(receipt *Receipt, blockHash libcommon.Hash, blockNumber uint64, receipts Receipts) error {
func DeriveFieldsForBorReceipt(receipt *Receipt, blockHash libcommon.Hash, blockNumber uint64, receipts Receipts) {
txHash := ComputeBorTxHash(blockNumber, blockHash)
txIndex := uint(len(receipts))

Expand All @@ -58,36 +57,4 @@ func DeriveFieldsForBorReceipt(receipt *Receipt, blockHash libcommon.Hash, block
receipt.Logs[j].Index = uint(logIndex)
logIndex++
}

return nil
}

// DeriveFieldsForBorLogs fills the receipts with their computed fields based on consensus
// data and contextual infos like containing block and transactions.
func DeriveFieldsForBorLogs(logs []*Log, blockHash libcommon.Hash, blockNumber uint64, txIndex uint, logIndex uint) {
txHash := ComputeBorTxHash(blockNumber, blockHash)

// the derived log fields can simply be set from the block and transaction
for j := 0; j < len(logs); j++ {
logs[j].BlockNumber = blockNumber
logs[j].BlockHash = blockHash
logs[j].TxHash = txHash
logs[j].TxIndex = txIndex
logs[j].Index = logIndex
logIndex++
}
}

// MergeBorLogs merges receipt logs and block receipt logs
func MergeBorLogs(logs []*Log, borLogs []*Log) []*Log {
result := append(logs, borLogs...)

sort.SliceStable(result, func(i int, j int) bool {
if result[i].BlockNumber == result[j].BlockNumber {
return result[i].Index < result[j].Index
}
return result[i].BlockNumber < result[j].BlockNumber
})

return result
}
6 changes: 3 additions & 3 deletions eth/stagedsync/stage_execute.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import (
"github.com/ledgerwatch/erigon/eth/ethconfig"
"github.com/ledgerwatch/erigon/eth/ethconfig/estimate"
"github.com/ledgerwatch/erigon/eth/stagedsync/stages"
trace_logger "github.com/ledgerwatch/erigon/eth/tracers/logger"
tracelogger "github.com/ledgerwatch/erigon/eth/tracers/logger"
"github.com/ledgerwatch/erigon/ethdb/prune"
"github.com/ledgerwatch/erigon/turbo/services"
"github.com/ledgerwatch/erigon/turbo/shards"
Expand Down Expand Up @@ -162,7 +162,7 @@ func executeBlock(
}

getTracer := func(txIndex int, txHash common.Hash) (vm.EVMLogger, error) {
return trace_logger.NewStructLogger(&trace_logger.LogConfig{}), nil
return tracelogger.NewStructLogger(&tracelogger.LogConfig{}), nil
}

callTracer := calltracer.NewCallTracer()
Expand All @@ -187,7 +187,7 @@ func executeBlock(
}

if stateSyncReceipt != nil && stateSyncReceipt.Status == types.ReceiptStatusSuccessful {
if err := rawdb.WriteBorReceipt(tx, block.Hash(), block.NumberU64(), stateSyncReceipt); err != nil {
if err := rawdb.WriteBorReceipt(tx, block.NumberU64(), stateSyncReceipt); err != nil {
return err
}
}
Expand Down
143 changes: 94 additions & 49 deletions polygon/tracer/trace_bor_state_sync_txn.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ import (
"github.com/ledgerwatch/erigon/core/vm/evmtypes"
"github.com/ledgerwatch/erigon/eth/tracers"
"github.com/ledgerwatch/erigon/polygon/bor/borcfg"
"github.com/ledgerwatch/erigon/rlp"
"github.com/ledgerwatch/erigon/turbo/services"
"github.com/ledgerwatch/erigon/turbo/transactions"
)

func TraceBorStateSyncTxn(
func TraceBorStateSyncTxnDebugAPI(
ctx context.Context,
dbTx kv.Tx,
chainConfig *chain.Config,
Expand All @@ -42,66 +43,110 @@ func TraceBorStateSyncTxn(
return err
}

rules := chainConfig.Rules(blockNum, blockTime)
stateReceiverContract := libcommon.HexToAddress(chainConfig.Bor.(*borcfg.BorConfig).StateReceiverContract)
borStateSyncTxHash := types.ComputeBorTxHash(blockNum, blockHash)
tracer, streaming, cancel, err := transactions.AssembleTracer(ctx, traceConfig, borStateSyncTxHash, stream, callTimeout)
txCtx := initStateSyncTxContext(blockNum, blockHash)
tracer, streaming, cancel, err := transactions.AssembleTracer(ctx, traceConfig, txCtx.TxHash, stream, callTimeout)
if err != nil {
stream.WriteNil()
return err
}

defer cancel()
stateReceiverContract := libcommon.HexToAddress(chainConfig.Bor.(*borcfg.BorConfig).StateReceiverContract)
tracer = NewBorStateSyncTxnTracer(tracer, len(stateSyncEvents), stateReceiverContract)
rules := chainConfig.Rules(blockNum, blockTime)
stateWriter := state.NewNoopWriter()
execCb := func(evm *vm.EVM, refunds bool) (*core.ExecutionResult, error) {
return traceBorStateSyncTxn(ctx, ibs, stateWriter, stateReceiverContract, stateSyncEvents, evm, rules, txCtx, refunds)
}

txCtx := evmtypes.TxContext{
TxHash: borStateSyncTxHash,
Origin: libcommon.Address{},
GasPrice: uint256.NewInt(0),
return transactions.ExecuteTraceTx(blockCtx, txCtx, ibs, traceConfig, chainConfig, stream, tracer, streaming, execCb)
}

func TraceBorStateSyncTxnTraceAPI(
ctx context.Context,
dbTx kv.Tx,
vmConfig *vm.Config,
chainConfig *chain.Config,
blockReader services.FullBlockReader,
ibs *state.IntraBlockState,
stateWriter state.StateWriter,
blockCtx evmtypes.BlockContext,
blockHash libcommon.Hash,
blockNum uint64,
blockTime uint64,
) (*core.ExecutionResult, error) {
stateSyncEvents, err := blockReader.EventsByBlock(ctx, dbTx, blockHash, blockNum)
if err != nil {
return nil, err
}

execCb := func(evm *vm.EVM, refunds bool) (*core.ExecutionResult, error) {
for _, eventData := range stateSyncEvents {
select {
case <-ctx.Done():
stream.WriteArrayEnd()
return nil, ctx.Err()
default:
}

msg := types.NewMessage(
state.SystemAddress, // from
&stateReceiverContract,
0, // nonce
u256.Num0, // amount
core.SysCallGasLimit,
u256.Num0, // gasPrice
nil, // feeCap
nil, // tip
eventData,
nil, // accessList
false, // checkNonce
true, // isFree
nil, // maxFeePerBlobGas
)

gp := new(core.GasPool).AddGas(msg.Gas()).AddBlobGas(msg.BlobGas())
_, err := core.ApplyMessage(evm, msg, gp, refunds, false /* gasBailout */)
if err != nil {
return nil, err
}

err = ibs.FinalizeTx(rules, state.NewNoopWriter())
if err != nil {
return nil, err
}

// reset to reuse
evm.Reset(txCtx, ibs)
stateReceiverContract := libcommon.HexToAddress(chainConfig.Bor.(*borcfg.BorConfig).StateReceiverContract)
if vmConfig.Tracer != nil {
vmConfig.Tracer = NewBorStateSyncTxnTracer(vmConfig.Tracer, len(stateSyncEvents), stateReceiverContract)
}

txCtx := initStateSyncTxContext(blockNum, blockHash)
rules := chainConfig.Rules(blockNum, blockTime)
evm := vm.NewEVM(blockCtx, txCtx, ibs, chainConfig, *vmConfig)
return traceBorStateSyncTxn(ctx, ibs, stateWriter, stateReceiverContract, stateSyncEvents, evm, rules, txCtx, true)
}

func traceBorStateSyncTxn(
ctx context.Context,
ibs *state.IntraBlockState,
stateWriter state.StateWriter,
stateReceiverContract libcommon.Address,
stateSyncEvents []rlp.RawValue,
evm *vm.EVM,
rules *chain.Rules,
txCtx evmtypes.TxContext,
refunds bool,
) (*core.ExecutionResult, error) {
for _, eventData := range stateSyncEvents {
select {
case <-ctx.Done():
return nil, ctx.Err()
default:
}

return &core.ExecutionResult{}, nil
msg := types.NewMessage(
state.SystemAddress, // from
&stateReceiverContract,
0, // nonce
u256.Num0, // amount
core.SysCallGasLimit,
u256.Num0, // gasPrice
nil, // feeCap
nil, // tip
eventData,
nil, // accessList
false, // checkNonce
true, // isFree
nil, // maxFeePerBlobGas
)

gp := new(core.GasPool).AddGas(msg.Gas()).AddBlobGas(msg.BlobGas())
_, err := core.ApplyMessage(evm, msg, gp, refunds, false /* gasBailout */)
if err != nil {
return nil, err
}

err = ibs.FinalizeTx(rules, stateWriter)
if err != nil {
return nil, err
}

// reset to reuse
evm.Reset(txCtx, ibs)
}

return transactions.ExecuteTraceTx(blockCtx, txCtx, ibs, traceConfig, chainConfig, stream, tracer, streaming, execCb)
return &core.ExecutionResult{}, nil
}

func initStateSyncTxContext(blockNum uint64, blockHash libcommon.Hash) evmtypes.TxContext {
return evmtypes.TxContext{
TxHash: types.ComputeBorTxHash(blockNum, blockHash),
Origin: libcommon.Address{},
GasPrice: uint256.NewInt(0),
}
}
Loading

0 comments on commit 4f76c6d

Please sign in to comment.