Commit Graph

648 Commits

Author SHA1 Message Date
Andrew Ashikhmin
f33993b43c
GetEffectiveGasTip in getTxValueForBlockValue (#6559)
Small simplification to PR #6554.
2023-01-12 10:41:27 +01:00
Alex Sharov
7e9522d2d0
e3: abstract 1 tx exec, to avoid variables bloating (#6563) 2023-01-12 11:09:47 +07:00
Alex Sharov
41e9356f61
e3: stream.ToBitamp() (#6562) 2023-01-12 09:58:21 +07:00
Alex Sharov
731569bbb7
e3: invalid txnum table (#6540) 2023-01-12 09:31:41 +07:00
Max Revitt
4d09a697d0
GetPayloadV2 change (#6554)
- calculates blockValue for updated engine_getPayloadV2 spec
- adds tests for pre/post Shanghai RawBody RLP
2023-01-11 18:33:55 +01:00
alex.sharov
e22e5f933a linter 2023-01-11 15:45:18 +07:00
alex.sharov
2db82a8e4f Revert "save"
This reverts commit b080f3fcdf.
2023-01-11 15:33:25 +07:00
alex.sharov
b080f3fcdf save 2023-01-11 15:33:09 +07:00
Alex Sharov
2f97c7bf8b
extract traceFilterBitmaps method (prepare for kv.temporal) (#6553) 2023-01-11 15:01:18 +07:00
Alex Sharov
381d90a52a
eth_getLogs: add getAddrsBitmap method (#6551) 2023-01-11 11:55:16 +07:00
ledgerwatch
1149b59641
Fix for regression in trace_ processing SELFDESTRUCT (#6547)
Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local>
2023-01-10 16:41:40 +00:00
Alex Sharov
2621ef45f6
e3: fix trace json (#6535) 2023-01-09 17:33:18 +07:00
alex.sharov
7aa056e179 save 2023-01-09 10:59:34 +07:00
ledgerwatch
389a2e8392
Eth call limits (#6523)
Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro-2.local>
Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local>
2023-01-07 21:16:43 +00:00
Alex Sharov
4c3bb1cca5
kv_temporal: DomainGet (#6511) 2023-01-06 14:27:54 +07:00
alex.sharov
9d1f0a9a33 save 2023-01-06 12:43:32 +07:00
a
06de4aeb91
filterlogs deadlock fix (#6429)
Refactors filters.go such that map+locks are now in their own class 

Move logic for safely canceling & draining channel to its own class

changed subscriptions to ask for size of buffer and construct its own
channel

marked as draft b/c need to do live testing.
2023-01-02 11:42:40 +07:00
Alex Sharov
4a9c871628
a bit rename 22 to v3 (#6476) 2022-12-30 21:53:42 +07:00
Alex Sharov
fa6f6038e7
kv: tx.Prefix method (#6441) 2022-12-26 17:58:21 +07:00
ledgerwatch
387b4d7f35
Native tracers step 10 - remove duplicate SelfDestruct capture, clean up (#6440)
Moved some of the tracers to `eth/tracers/logger` to make it more
similar to go-ethereum.

Removed Erigon-specific `Capture-` functions

Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro-2.local>
2022-12-26 04:56:39 +00:00
ledgerwatch
24040f3044
Native tracers step 9 - add native tracers (#6434)
Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro-2.local>
2022-12-25 07:28:41 +00:00
Alex Sharov
ade933be6b
kv_remote: server to support thread-safe multi-streams per 1 tx (#6402) 2022-12-24 13:11:15 +07:00
ledgerwatch
f364eff389
Native tracers step 7 - restructure js tracer files (#6415)
Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro-2.local>
2022-12-23 18:10:37 +00:00
ledgerwatch
a49e287618
Native tracers step 6: Rename Tracer to EVMLogger, reduce args CaptureExit (#6410)
Getting closer to Geth's tracer interfaces

Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro-2.local>
2022-12-23 05:43:08 +00:00
ledgerwatch
8433afd99a
Native tracers step 5 - tests for debug_traceBlock and trace_block before transformations (#6405)
Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro-2.local>
2022-12-22 10:13:38 +00:00
Alex Sharov
130ab85bea
e3: kv/temporal prototype 3 (#6395) 2022-12-22 09:37:32 +07:00
Ariel Tempelhof
870b5baa19
Finalize state after each call in callMany (#6381)
In `debug_traceCallMany` and `eth_callMany` the `IntraBlockState` is not
being finalized after each replayed transaction and after each call.
This can cause several problems:

- False gas consumption calculation. Specifically in `SSTORE` dynamic
gas calculation being affected by "warm" and "cold" storage slots, and
by "original" value comparison.
- Ability to call contracts that were `SELFDESTRUCT`ed in the replayed
transactions or during previous calls, as the self-destruction has not
been finalized.

see https://github.com/ledgerwatch/erigon/issues/6373 as an example.

This pull request adds a call to `FinalizeTx` after each `ApplyMessage`
and `TraceTx`
2022-12-21 16:32:36 +07:00
Alex Sharov
c32d88f729
simplify StageLoopStep (#6390) 2022-12-21 14:39:19 +07:00
Alex Sharov
65f3af30eb
use one state reader type (#6380) 2022-12-21 11:27:14 +07:00
Willian Mitsuda
0b9eec66d0
Fix otterscan tx tracing for delegatecall (#6368)
This fixes Otterscan tx tracer, which broke on the following
refactoring:
60cb4e2bbb

It used to receive value == -1 for delegatecall, now it is receiving
nil, so we safeguard against it now.
2022-12-20 13:29:12 +07:00
Alex Sharov
dfa6505f93
e3: kv/temporal prototype (#6367) 2022-12-19 15:38:54 +07:00
ledgerwatch
97c9a9108d
Native tracers - step 4 (#6363)
Remove `callType` argument from `CaptureStart`, and change `callType
vm.CallType` to `typ vm.OpCode` in `CaptureEnter` and move to the first
position (as it is in geth)

Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro-2.local>
2022-12-19 03:12:08 +00:00
ledgerwatch
0761671607
Native tracers step 3 (#6362)
Remove `env` argument from all Capture functions except for
`CaptureStart`

Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro-2.local>
2022-12-18 17:06:40 +00:00
ledgerwatch
b8c6a4d263
Native tracers - step 2 (#6360)
Splitting function `CaptureStart` into `CaptureStart` (when depth == 0)
and `CaptureEnter` (when depth > 0), while removing argument `depth`.
Same with splitting `CaptureEnd` into `CaptureEnd` and `CaptureExit`

Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro-2.local>
2022-12-18 16:11:31 +00:00
ledgerwatch
3999c46046
Native tracers - step 1 (#6356)
In this first step, the new functions `CaptureTxStart` and
`CaptureTxEnd` are introduced to all tracers

Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local>
Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro-2.local>
2022-12-18 04:36:57 +00:00
Alex Sharov
d45bddc5ad
StagedSync: break dependency to CurrentHeader. Always run non-initial cycle in 1 RwTx (#6348)
cc: @AlexeyAkhunov
2022-12-18 07:59:31 +07:00
Andrew Ashikhmin
0fc2022a0e
Extend fork ID to timestamp-based forks (#6324)
Starting from
[Shanghai](https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/shanghai.md),
forks are based on timestamps rather than block heights (see PR #6238).
This PR extends [EIP-2124](https://eips.ethereum.org/EIPS/eip-2124) Fork
ID to include timestamp-based blocks. See also
https://github.com/ethereum/go-ethereum/pull/25878.

Co-authored-by: Marius van der Wijden <m.vanderwijden@live.de>
2022-12-16 12:08:54 +01:00
Alex Sharov
2f143523d5
e3: to fix integration test (#6337) 2022-12-16 14:21:38 +07:00
ledgerwatch
cb04e1166c
Fix precompile filtering in trace_ methods (#6328) 2022-12-15 18:54:05 +00:00
formatting
7fee016cf4
Fix eth_getBlockByNumber and eth_getTransactionReceipt some bugs for polygon (#6319)
Get bor state sync tx and receipt has some error:

```
Reqeust:
curl -X "POST" "{{polygon_rpc_endpoint}}" -H 'Content-Type: application/json; charset=utf-8' -d $'{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "eth_getTransactionByHash",
  "params": [
    "0x9916e99b24daba1fb01e093105bc6988b49125ea15fd4b3c4cfa18719e1631ad"
  ]
}'

Response:
{"jsonrpc":"2.0","id":1,"result":null}
```

```
Reqeust:
curl -X "POST" "{{polygon_rpc_endpoint}}" -H 'Content-Type: application/json; charset=utf-8' -d $'{
  "id": 1,
  "method": "eth_getTransactionReceipt",
  "jsonrpc": "2.0",
  "params": [
    "0x9916e99b24daba1fb01e093105bc6988b49125ea15fd4b3c4cfa18719e1631ad"
  ]
}'

Response
{"jsonrpc":"2.0","id":1,"error":{"code":-32000,"message":"EOF"}}
```


fixed:

```
Request:
curl -X "POST" "{{polygon_rpc_endpoint}}" -H 'Content-Type: application/json; charset=utf-8' -d $'{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "eth_getTransactionByHash",
  "params": [
    "0x9916e99b24daba1fb01e093105bc6988b49125ea15fd4b3c4cfa18719e1631ad"
  ]
}'

Response:
{"jsonrpc":"2.0","id":1,"result":{"blockHash":"0xb308eeda80e2a20e1f934d5d37e5f82a078b828128a60283978286ddf0a25264","blockNumber":"0x1c317c0","from":"0x0000000000000000000000000000000000000000","gas":"0x0","gasPrice":"0x0","hash":"0x9916e99b24daba1fb01e093105bc6988b49125ea15fd4b3c4cfa18719e1631ad","input":"0x","nonce":"0x0","to":"0x0000000000000000000000000000000000000000","transactionIndex":"0x89","value":"0x0","type":"0x0","chainId":"0x89","v":"0x0","r":"0x0","s":"0x0"}}
```

```
curl -X "POST" "{{polygon_rpc_endpoint}}" -H 'Content-Type: application/json; charset=utf-8' -d $'{
  "id": 1,
  "method": "eth_getTransactionReceipt",
  "jsonrpc": "2.0",
  "params": [
    "0x9916e99b24daba1fb01e093105bc6988b49125ea15fd4b3c4cfa18719e1631ad"
  ]
}'
{"jsonrpc":"2.0","id":1,"result":{"blockHash":"0xb308eeda80e2a20e1f934d5d37e5f82a078b828128a60283978286ddf0a25264","blockNumber":"0x1c317c0","contractAddress":null,"cumulativeGasUsed":"0x0","effectiveGasPrice":"0xd532a03e6","from":"0x0000000000000000000000000000000000000000","gasUsed":"0x0","logs":[{"address":"0x7ceb23fd6bc0add59e62ac25578270cff1b9f619","topics":["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef","0x0000000000000000000000000000000000000000000000000000000000000000","0x00000000000000000000000038830f36f752ed29039f441cfb543639a6e07b41"],"data":"0x000000000000000000000000000000000000000000000000009c51c4521e0000","blockNumber":"0x1c317c0","transactionHash":"0x9916e99b24daba1fb01e093105bc6988b49125ea15fd4b3c4cfa18719e1631ad","transactionIndex":"0x89","blockHash":"0xb308eeda80e2a20e1f934d5d37e5f82a078b828128a60283978286ddf0a25264","logIndex":"0x2ee","removed":false},{"address":"0x7ceb23fd6bc0add59e62ac25578270cff1b9f619","topics":["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef","0x0000000000000000000000000000000000000000000000000000000000000000","0x000000000000000000000000f93bcb6f00c1a90050a60a9f737b4cb87126b8f8"],"data":"0x000000000000000000000000000000000000000000000000006a6674f260d000","blockNumber":"0x1c317c0","transactionHash":"0x9916e99b24daba1fb01e093105bc6988b49125ea15fd4b3c4cfa18719e1631ad","transactionIndex":"0x89","blockHash":"0xb308eeda80e2a20e1f934d5d37e5f82a078b828128a60283978286ddf0a25264","logIndex":"0x2ef","removed":false},{"address":"0x7ceb23fd6bc0add59e62ac25578270cff1b9f619","topics":["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef","0x0000000000000000000000000000000000000000000000000000000000000000","0x000000000000000000000000fd1091c0e49bf1d44b4786747e034d65ab46f36e"],"data":"0x000000000000000000000000000000000000000000000000002386f26fc10000","blockNumber":"0x1c317c0","transactionHash":"0x9916e99b24daba1fb01e093105bc6988b49125ea15fd4b3c4cfa18719e1631ad","transactionIndex":"0x89","blockHash":"0xb308eeda80e2a20e1f934d5d37e5f82a078b828128a60283978286ddf0a25264","logIndex":"0x2f0","removed":false},{"address":"0x7f280dac515121dcda3eac69eb4c13a52392cace","topics":["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef","0x0000000000000000000000000000000000000000000000000000000000000000","0x000000000000000000000000882d04c3d8410ddf2061b3cba2c3522854316feb"],"data":"0x000000000000000000000000000000000000000000001850e2f557310490f925","blockNumber":"0x1c317c0","transactionHash":"0x9916e99b24daba1fb01e093105bc6988b49125ea15fd4b3c4cfa18719e1631ad","transactionIndex":"0x89","blockHash":"0xb308eeda80e2a20e1f934d5d37e5f82a078b828128a60283978286ddf0a25264","logIndex":"0x2f1","removed":false},{"address":"0x7ceb23fd6bc0add59e62ac25578270cff1b9f619","topics":["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef","0x0000000000000000000000000000000000000000000000000000000000000000","0x00000000000000000000000028515b56512cb168ad6e6a2428bb39cb696d8bee"],"data":"0x0000000000000000000000000000000000000000000000000058d15e17628000","blockNumber":"0x1c317c0","transactionHash":"0x9916e99b24daba1fb01e093105bc6988b49125ea15fd4b3c4cfa18719e1631ad","transactionIndex":"0x89","blockHash":"0xb308eeda80e2a20e1f934d5d37e5f82a078b828128a60283978286ddf0a25264","logIndex":"0x2f2","removed":false}],"logsBloom":"0x000000000100a0000000000000000000000000000040000000000000000000000000000000000020000000000000000000000000000080000000000000000800000000000000000000000008000000000800000000000000040000000000000000000000020000000000000000000800000000000000000000000010000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000020000002000000000008000000001000000000000002000000000000000020001000040000008000000000000000000080000000000000000000000000000000","status":"0x1","to":"0x0000000000000000000000000000000000000000","transactionHash":"0x9916e99b24daba1fb01e093105bc6988b49125ea15fd4b3c4cfa18719e1631ad","transactionIndex":"0x89","type":"0x0"}}
```
2022-12-15 11:13:52 +00:00
Enrique Jose Avila Asapche
941a228ec9
fixed tx index being empty (#6316)
#6309
2022-12-15 09:53:14 +07:00
Igor Mandrigin
94d12a5d3c
fix debug_traceBlock* methods for Gnosis Chain (#6312) 2022-12-14 16:06:24 +01:00
Enrique Jose Avila Asapche
287a3d1d6c
added erigon_GetBlockReceiptsByBlockHash (#6292)
I added a way to get canonical receipts through block hash under the
erigon name space
#6229


Tested: 
BlockHash:
0xb5d50393734894e02a94a500a5a5aade9c66f388438aeed8d7775b3b344745f1
<img width="1727" alt="Screenshot 2022-12-12 at 22 16 18"
src="https://user-images.githubusercontent.com/19207637/207166860-436ecf26-a777-4b2f-8377-22acec732486.png">
2022-12-13 20:41:51 +00:00
Changyoung Koh
27ec4f02d7
Fix Trace RPCs for Bor Transactions (#6288)
FIrst of all, thanks in advance for your advice.

I've found that `trace_replayTransaction` is having trouble tracing some
Polygon State Sync transactions such as
[`0xd5f4f8c3cd85cf65e8df23a2c1ae02aefda1e6293db0c3a9ddcc08cee8ca1131`](https://polygonscan.com/tx/0xd5f4f8c3cd85cf65e8df23a2c1ae02aefda1e6293db0c3a9ddcc08cee8ca1131),
just like [the case of the previous PR][p].

[p]: https://github.com/ledgerwatch/erigon/pull/6286

```shell
$ curl -XPOST 'http://localhost:8545' \
      -H 'Content-Type: application/json' \
     --data '{"method":"trace_replayTransaction","params":["0xd5f4f8c3cd85cf65e8df23a2c1ae02aefda1e6293db0c3a9ddcc08cee8ca1131",["trace","stateDiff"]],"id":1,"jsonrpc":"2.0"}'
{"jsonrpc":"2.0","id":1,"result":null}
```

This is because RPCDaemon doesn't query for blocks by Bor Hash, even
though `api.txnLookup` has failed. Same as #6286.
2022-12-12 16:39:17 +00:00
Changyoung Koh
72de9410d7
Fix eth_getTransactionReceipt for Bor Transactions (#6289)
Same as #6286 and #6288

This patch closes #6276 

```shell
$ curl -XPOST 'http://localhost:8545' \
     -H 'Content-Type: application/json' \
     --data '{"method":"eth_getTransactionReceipt","params":["0x31ce15ce9a1ff347f4204a1ed3625861165c53ae08743c1f36a32865c62744c6"],"id":1,"jsonrpc":"2.0"}'
{"jsonrpc":"2.0","id":1,"error":{"code":-32000,"message":"block has less receipts than expected: 0 \u003c= 0, block: 36635776"}}
```

cc. @0xKrishna
2022-12-12 15:21:30 +00:00
Changyoung Koh
4c02fef323
Fix eth_getTransactionByHash for Bor Transactions (#6286)
FIrst of all, thanks in advance for your advice.

I've found that `eth_getTransactionByHash` is having trouble retrieving
some Polygon State Sync transactions such as
[`0xd5f4f8c3cd85cf65e8df23a2c1ae02aefda1e6293db0c3a9ddcc08cee8ca1131`](https://polygonscan.com/tx/0xd5f4f8c3cd85cf65e8df23a2c1ae02aefda1e6293db0c3a9ddcc08cee8ca1131),
while `eth_getBlockByNumber` can retrieve them without problem.

```shell
$ curl -XPOST 'http://localhost:8545' \
     -H 'Content-Type: application/json' \
     --data '{"method":"eth_getTransactionByHash","params":["0xd5f4f8c3cd85cf65e8df23a2c1ae02aefda1e6293db0c3a9ddcc08cee8ca1131"],"id":1,"jsonrpc":"2.0"}'
{"jsonrpc":"2.0","id":1,"result":null}
```

This is because RPCDaemon doesn't query for blocks by Bor Hash, even
though `api.txnLookup` has failed.
2022-12-12 13:26:00 +00:00
ledgerwatch
df21079ae0
vmTrace - prevent panic at stack underflow (#6275)
Fixes https://github.com/ledgerwatch/erigon/issues/4778

Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local>
2022-12-10 22:41:14 +00:00
ledgerwatch
0a31f5ac2a
Workaround for the code history of BSC system contracts (#6274)
Works around a flaw in the upgrade logic of the system contracts. Since
they are updated directly, without first being self-destructed and then
re-created, the usual incarnation logic does not get activated, and all
historical records of the code of these contracts are retrieved as the
most recent version. This problem will not exist in erigon3, but until
then, a workaround will be used to access code of such contracts through
a special structure, `SystemContractCodeLookup`

Fixes https://github.com/ledgerwatch/erigon/issues/5865

Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local>
2022-12-10 22:41:04 +00:00
ledgerwatch
983f41790d
Fetch header correctly (including snapshots) for debug_traceCall, fix… (#6273)
… formatting when error

Fixes https://github.com/ledgerwatch/erigon/issues/5365

Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local>
2022-12-10 15:22:07 +00:00
ledgerwatch
3d7b36e09a
Trace block formatting fix, error handling formatting fix (#6266)
Fixes https://github.com/ledgerwatch/erigon/issues/4935

Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local>
2022-12-09 22:16:41 +00:00