Commit Graph

2685 Commits

Author SHA1 Message Date
Alex Sharov
7239387de0
fix devel build (#6154) 2022-11-30 08:35:31 +07:00
Alex Sharov
60cb4e2bbb
evm tracing interface to use uint256, to avoid value.ToBig() allocations (#5781) 2022-11-30 08:31:39 +07:00
Alex Sharov
16cd87748f
E3: fix unwind changes visibility (#6147) 2022-11-30 08:31:13 +07:00
J1ang
83dae8dad3
feat: enhance API erigon_getLatestLogs (#6078)
feat:
1. `erigon_getLatestLogs` doesn't have to match the exact position of
the topics. It will match logs that contain the topics regardless of the
topics' position with original bloom filter. And it accepts `blockCount`
& `crit.ToBlock` params for better pagination.
2022-11-29 15:14:41 +07:00
hexoscott
0094d1301a
reusable evm caller for purpose of eth_estimateGas (#6112)
One simple change to send the header in rather than the body allowing
re-use in a loop which saves the copy call when looping.

The other one for a reusable evm seems potentially dangerous so feedback
more than welcome on that one, local testing shows it gains me around
6k±rps so if it's safe is a good win, but I feel it will need more work.
I could only validate against goerli chain which seems to always return
the same value for eth_estimateGas so if anybody could validate it
against another chain that would be awesome.
2022-11-28 09:03:03 +07:00
Giulio rebuffo
54d1895542
updated go-verkle (#6126) 2022-11-26 19:36:10 +01:00
Andrew Ashikhmin
03057c4e61
Update consensus tests to v11.2 (#6111)
[v11.2](https://github.com/ethereum/tests/releases/tag/v11.2) includes,
among other things, tests for
[EIP-3860](https://eips.ethereum.org/EIPS/eip-3860): Limit and meter
initcode.
2022-11-22 16:07:31 +01:00
Philippe Schommers
6f61f556a2
test: add fork id tests for Gnosis and Chiado (#6110)
Feels like there's an issue with the latest hardfork
(https://docs.gnosischain.com/specs/hard-forks/21735000), as the fork id
didn't change?

Related: https://github.com/NethermindEth/nethermind/pull/4925
2022-11-22 16:03:36 +01:00
Andrew Ashikhmin
0b28c7ad13
Support genesis constructors for Chiado (#6103)
This is a continuation of PR #6058 and fixes Chiado genesis state root
by supporting genesis constructors (deployment code).
2022-11-21 17:21:59 +01:00
Alex Sharov
9bcd7fe6c3
e3: reduce state write lock (#6096) 2022-11-21 10:38:22 +07:00
Alex Sharov
40264fd4d9
E3: state lock reduce (#6088) 2022-11-20 12:34:45 +07:00
Alex Sharov
92e6e56120
Fix test e3 (#6087) 2022-11-20 10:58:20 +07:00
Philippe Schommers
806117fbab
feat: add chiado config (#6058)
Hey guys, I'm trying to add the Chiado network ([Gnosis'
testnet](https://docs.gnosischain.com/about/networks/chiado)) now that
Gnosis can be synced fully with Erigon, so we can test it on the testnet
as well.

This is mostly inspired from
cd5ef32f37.

Probably missing:
- [ ] The right consensus config (currently only a copy of Gnosis)
- [ ] Fixes to the chainspec?
- [ ] Presumably something in `cl/clparams/config.go`

Current state:
```
$ ./build/bin/erigon --chain=chiado --log.console.verbosity=debug
WARN[11-16|11:52:28.188] no log dir set, console logging only 
WARN[11-16|11:52:28.193] no log dir set, console logging only 
INFO[11-16|11:52:28.193] Build info                               git_branch=feat/chiado git_tag=v2021.10.03-2291-g17fae73f8 git_commit=17fae73f8af5348ba7c04684f2a2978daf81b67e
INFO[11-16|11:52:28.193] Starting Erigon on                       devnet=chiado
INFO[11-16|11:52:28.194] Maximum peer count                       ETH=100 total=100
INFO[11-16|11:52:28.194] starting HTTP APIs                       APIs=eth,erigon,engine
INFO[11-16|11:52:28.194] torrent verbosity                        level=WRN
INFO[11-16|11:52:30.300] Set global gas cap                       cap=50000000
INFO[11-16|11:52:30.302] Opening Database                         label=chaindata path=/home/filoozom/.local/share/erigon/chiado/chaindata
INFO[11-16|11:52:30.310] Initialised chain configuration          config="{ChainID: 10200, Homestead: 0, DAO: <nil>, DAO Support: false, Tangerine Whistle: 0, Spurious Dragon: 0, Byzantium: 0, Constantinople: 0, Petersburg: 0, Istanbul: 0, Muir Glacier: <nil>, Berlin: 0, London: 0, Arrow Glacier: <nil>, Gray Glacier: <nil>, Terminal Total Difficulty: <nil>, Merge Netsplit: <nil>, Shanghai: <nil>, Cancun: <nil>, Engine: aura}" genesis=0xf463abeb7ee27fa62be3ac36a264e8174ee3458da451e6403df47618fd2cf415
WARN[11-16|11:52:30.311] Incorrect snapshot enablement            got=true change_to=false
INFO[11-16|11:52:30.311] Effective                                prune_flags= snapshot_flags= history.v3=false
INFO[11-16|11:52:30.312] Initialising Ethereum protocol           network=10200
INFO[11-16|11:52:30.329] Starting private RPC server              on=127.0.0.1:9090
INFO[11-16|11:52:30.329] new subscription to logs established 
INFO[11-16|11:52:30.329] rpc filters: subscribing to Erigon events 
DBUG[11-16|11:52:30.330] Establishing event subscription channel with the RPC daemon ... 
INFO[11-16|11:52:30.330] New txs subscriber joined 
INFO[11-16|11:52:30.330] new subscription to newHeaders established 
INFO[11-16|11:52:30.330] Reading JWT secret                       path=/home/filoozom/.local/share/erigon/chiado/jwt.hex
INFO[11-16|11:52:30.331] HTTP endpoint opened for Engine API      url=localhost:8551 ws=true ws.compression=true
INFO[11-16|11:52:30.332] HTTP endpoint opened                     url=localhost:8545 ws=false ws.compression=true grpc=false
DBUG[11-16|11:52:30.336] Couldn't add port mapping                proto=tcp extport=30304 intport=30304 interface="UPnP or NAT-PMP" err="no UPnP or NAT-PMP router discovered"
DBUG[11-16|11:52:30.336] Couldn't add port mapping                proto=udp extport=30304 intport=30304 interface="UPnP or NAT-PMP" err="no UPnP or NAT-PMP router discovered"
DBUG[11-16|11:52:30.336] QuerySeeds read nodes from the node DB   count=0
DBUG[11-16|11:52:30.341] [1/16 Snapshots] DONE                    in=134.7µs
INFO[11-16|11:52:30.341] [txpool] Started 
INFO[11-16|11:52:30.341] [2/16 Headers] Waiting for headers...    from=0
DBUG[11-16|11:52:30.341] [Downloader] Request skeleton            anchors=0 top seen height=0 highestInDb=0
DBUG[11-16|11:52:30.343] Couldn't add port mapping                proto=tcp extport=30303 intport=30303 interface="UPnP or NAT-PMP" err="no UPnP or NAT-PMP router discovered"
DBUG[11-16|11:52:30.343] Couldn't add port mapping                proto=udp extport=30303 intport=30303 interface="UPnP or NAT-PMP" err="no UPnP or NAT-PMP router discovered"
DBUG[11-16|11:52:30.344] QuerySeeds read nodes from the node DB   count=0
DBUG[11-16|11:52:30.346] QuerySeeds read nodes from the node DB   count=0
INFO[11-16|11:52:30.347] Started P2P networking                   version=67 self=enode://47d2e31d90fe140bfd967f147c1d4e8a4834b4c6b895a4bb7082100be60aa5e9a73e98e996da9b0257f02f9ad39b683755abe6ca3e9aefe0170a478a8559dcfb@127.0.0.1:30304 name=erigon/v2.30.0-dev-17fae73f/linux-amd64/go1.18.1
DBUG[11-16|11:52:30.351] QuerySeeds read nodes from the node DB   count=0
INFO[11-16|11:52:30.351] Started P2P networking                   version=66 self=enode://47d2e31d90fe140bfd967f147c1d4e8a4834b4c6b895a4bb7082100be60aa5e9a73e98e996da9b0257f02f9ad39b683755abe6ca3e9aefe0170a478a8559dcfb@127.0.0.1:30303 name=erigon/v2.30.0-dev-17fae73f/linux-amd64/go1.18.1
DBUG[11-16|11:52:31.342] [Downloader] Request skeleton            anchors=0 top seen height=0 highestInDb=0
[...]
DBUG[11-16|11:52:32.342] [Downloader] Request skeleton            anchors=0 top seen height=0 highestInDb=0
INFO[11-16|11:37:00.062] [p2p] GoodPeers                          eth66=0 eth67=0
INFO[11-16|11:37:00.077] [txpool] stat                            block=0 pending=0 baseFee=0 queued=0 alloc=42.7MB sys=79.5MB
INFO[11-16|11:37:00.089] [2/16 Headers] No block headers to write in this log period block number=0
INFO[11-16|11:37:00.089] Req/resp stats                           req=0 reqMin=0 reqMax=0 skel=0 skelMin=0 skelMax=0 resp=0 respMin=0 respMax=0 dups=0
DBUG[11-16|11:37:00.089] [Downloader] Queue sizes                 anchors=0 links=0 persisted=1
DBUG[11-16|11:37:00.089] [Downloader] Request skeleton            anchors=0 top seen height=0 highestInDb=0
[...]
DBUG[11-16|11:37:06.095] [Downloader] Request skeleton            anchors=0 top seen height=0 highestInDb=0
```

I guess it comes down to:
```
--- FAIL: TestDefaultBSCGenesisBlock (0.34s)
    genesis_test.go:27: 
                Error Trace:    /home/filoozom/projects/erigon/core/genesis_test.go:27
                                                        /home/filoozom/projects/erigon/core/genesis_test.go:30
                Error:          Not equal: 
                                expected: []byte{0xe8, 0x72, 0x46, 0x2c, 0x6b, 0xd5, 0xf4, 0x2, 0xec, 0x81, 0xde, 0x7c, 0x5b, 0xd2, 0x82, 0x3e, 0x13, 0x7c, 0x66, 0x6b, 0x78, 0xe8, 0x2b, 0x7e, 0xb0, 0xbe, 0x95, 0xaf, 0x5e, 0xce, 0xa1, 0x8d}
                                actual  : []byte{0xad, 0xa4, 0x4f, 0xd8, 0xd2, 0xec, 0xab, 0x8b, 0x8, 0xf2, 0x56, 0xaf, 0x7, 0xad, 0x3e, 0x77, 0x7f, 0x17, 0xfb, 0x43, 0x4f, 0x8f, 0x8e, 0x67, 0x8b, 0x31, 0x2f, 0x57, 0x62, 0x12, 0xba, 0x9a}
                            
                                Diff:
                                --- Expected
                                +++ Actual
                                @@ -1,4 +1,4 @@
                                 ([]uint8) (len=32) {
                                - 00000000  e8 72 46 2c 6b d5 f4 02  ec 81 de 7c 5b d2 82 3e  |.rF,k......|[..>|
                                - 00000010  13 7c 66 6b 78 e8 2b 7e  b0 be 95 af 5e ce a1 8d  |.|fkx.+~....^...|
                                + 00000000  ad a4 4f d8 d2 ec ab 8b  08 f2 56 af 07 ad 3e 77  |..O.......V...>w|
                                + 00000010  7f 17 fb 43 4f 8f 8e 67  8b 31 2f 57 62 12 ba 9a  |...CO..g.1/Wb...|
                                 }
                Test:           TestDefaultBSCGenesisBlock
                Messages:       chiado
FAIL
FAIL    github.com/ledgerwatch/erigon/core      0.823s
```

----------

Turns out that the `code` in Erigon's chainspec is not the same as
`constructor` in Nethermind for example.
Comparison for Sokol:
- Erigon:
https://github.com/ledgerwatch/erigon/blob/devel/core/allocs/sokol.json#L20-L34
- Nethermind:
https://github.com/NethermindEth/nethermind/blob/master/src/Nethermind/Chains/sokol.json#L248-L252
2022-11-18 12:54:18 +01:00
Alex Sharov
874d96fb47
e3: Non parallel exec (with exec in RO goroutine) (#6073) 2022-11-17 20:52:12 +03:00
Giulio rebuffo
7ea8de4a3f
added checkpoint saving (#6060) 2022-11-16 16:19:40 +01:00
Giulio rebuffo
3a2d3be080
Added persistence in LightClient (#6056) 2022-11-15 20:39:18 +01:00
Andrew Ashikhmin
04e3a18463
Block difficulty can be really big on Gnosis Chain (#6028)
For example, see https://gnosisscan.io/block/24938312.

This fixes the following errors:
```
t=2022-11-11T12:39:01+0000 lvl=dbug msg="Handling incoming message" stream=RecvMessage err="newBlock66: too large block difficulty: bitlen 128"
t=2022-11-11T12:39:01+0000 lvl=dbug msg="Handling incoming message" stream=RecvMessage err="newBlock66: too large block difficulty: bitlen 128"
t=2022-11-11T12:39:01+0000 lvl=dbug msg="Handling incoming message" stream=RecvMessage err="newBlock66: too large block difficulty: bitlen 128"
```
2022-11-11 15:24:46 +01:00
Andrew Ashikhmin
e469afdff5
Rewrite bytecode of the token contract on Gnosis Chain (#5997)
See https://github.com/NethermindEth/nethermind/pull/3930
2022-11-08 13:03:06 +01:00
Andrew Ashikhmin
3280531644
Simplify Header.EncodeRLP (#5995)
Also cherry-pick https://github.com/ethereum/go-ethereum/pull/24666.

Co-authored-by: Felix Lange <fjl@twurst.com>
2022-11-08 11:07:27 +01:00
hexoscott
636586c1b5
cache state check (#5844)
draft for now to get some early feedback on approach
2022-11-07 13:04:31 +00:00
Andrew Ashikhmin
82bb408e99
Only zero-gas transactions may be service ones (#5989)
Correction to PR #5873.

See [Nethermind's
code](https://github.com/NethermindEth/nethermind/blob/1.14.5/src/Nethermind/Nethermind.Consensus.AuRa/Transactions/TxCertifierFilter.cs#L57).
2022-11-07 13:10:07 +01:00
Alex Sharov
d4fc7c7ef0
e3: reduce write-lock of rws (#5959) 2022-11-04 15:09:29 +07:00
a
ad7be30679
jsonrpc HTTP Get handler & logs topic filter with map (#5922)
this pr has two things in it

1. changed filter logs to use a map for the topics. this will speed up
queries with many topics in them. I still don't have a use case for this
though. i put is as a method of Logs, since that made sense to me, happy
to move it back out though.

2. allows json-rpc over http get request. since firefox is a great json
viewer (can search through, collapse large results) i often use it to
debug. it is also useful for sharing data with those who are less
familiar with command line / programming.
example get request:

http://rpcdaemon/?method=eth_getLogs&params=[{"fromBlock":"0xf2316b","toBlock":"0xf2316b"}]

it is based on the old jsonrpc http specification
https://www.jsonrpc.org/historical/json-rpc-over-http.html#encoded-parameters
except we also accept not base64 encoded params. since every eth rpc
request has a [], it will immediately fail validation for base64 and
attempt to use the parameters as a they are. otherwise it will attempt
to parse the rest of the payload as base64 and use that.

Co-authored-by: a <a@a.a>
Co-authored-by: gfx <86091021+gfxlabs@users.noreply.github.com>
2022-11-03 09:09:04 +07:00
Andrew Ashikhmin
7134d72738
Unify EVM Call flavours (#5939) 2022-11-02 15:04:37 +01:00
Alex Sharov
96deee29bb
e3: build files sequentially, flush indices in-advance before commit (#5935) 2022-11-02 10:04:12 +07:00
Andrew Ashikhmin
d4c2acc152
AuRa system calls to Certifier should be const (#5929)
This fixes gas used in
https://gnosisscan.io/tx/0x8f3b839a3d179102084a58dc4c3ec91fe13bb00cc1450cd69d22add7f25444e3
2022-11-01 14:37:45 +01:00
Andrew Ashikhmin
9ffc457cbb
EIP-3860: Limit and meter initcode (#5892)
[EIP-3860](https://eips.ethereum.org/EIPS/eip-3860) is
[included](https://github.com/ethereum/execution-specs/pull/633) into
[Shanghai](https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/shanghai.md).

TODO: similar changes to `txpool`.

Co-authored-by: Andrei Maiboroda <andrei@ethereum.org>
2022-10-31 13:40:41 +01:00
Andrew Ashikhmin
dd43d486f3
Enable London in AllEthashProtocolChanges (#5891)
`AllEthashProtocolChanges` should contain all the EIPs accepted by the
core developers into the Ethash consensus, including the
[London](https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/london.md)
protocol upgrade.
2022-10-28 17:19:18 +02:00
Alex Sharov
0074ad0e48
e3: parallel exec, rotate and partial-flush of indices wal - while main thread is idle (#5889)
While main thread is idle (apply is on RoTx now):
- periodically still hisotry/index etl collectors and load them to db 
- prune old history/index in db

Also:
- fixed RAM estimation calculation of State22
2022-10-28 21:13:53 +07:00
Andrew Ashikhmin
f46300e37e
core/vm: Rename SHA3 instruction to KECCAK256 (#5890)
Cherry-pick https://github.com/ethereum/go-ethereum/pull/23976

Co-authored-by: Alex Beregszaszi <alex@rtfs.hu>
2022-10-28 13:38:34 +02:00
Alex Sharov
8d1ed547b0
E3: parallel exec, apply on roTx (#5879) 2022-10-28 08:47:45 +07:00
Giulio rebuffo
5a321d6240
Dispersed fixes for incremental verkle trees (#5880) 2022-10-27 10:22:53 +02:00
Andrew Ashikhmin
6a5968e7f0
AuRa service transactions are free (#5873)
and the don't pay baseFee after EIP-1559.

See https://openethereum.github.io/Permissioning.html#gas-price
2022-10-26 13:03:47 +02:00
Alex Sharov
2d7cd0fae2
e3: better prune logs, apply thread can work without rwTx (#5860) 2022-10-25 16:08:01 +07:00
Alex Sharov
26fdf9169d
move all packages from "internal" folder - to simplify users live (#5857) 2022-10-25 09:58:25 +07:00
Alex Sharov
592ad57921
add DECOMPRESS_CONDENSITY env variable (#5853) 2022-10-24 10:00:55 +07:00
Alex Sharov
8d75d0dc4b
e3: return old reader version  (#5849) 2022-10-23 19:22:33 +07:00
Alex Sharov
993fde4d92
E3: par logs (#5839) 2022-10-23 18:51:14 +07:00
Alex Sharov
96233cfa7f
e3: metrics (#5846) 2022-10-23 17:05:26 +07:00
Alex Sharov
d6de913a34
e3: fix races (#5822) 2022-10-21 21:02:18 +07:00
Andrew Ashikhmin
da354bc01a
Unify Bor burntContract with Gnosis eip1559FeeCollector (#5798) 2022-10-21 13:03:38 +02:00
Andrew Ashikhmin
64a3156112
Support BaseFee in AuRa headers (#5820)
BaseFee is required in AuRa headers when
[EIP-1559](https://eips.ethereum.org/EIPS/eip-1559) is activated.

Also:
- Basic AuRa header verification
- Extract some common RLP methods
- Tiny log clean-up
2022-10-21 12:43:44 +02:00
Alex Sharov
86551e82f4
e3: parallel build missed indices (#5817) 2022-10-21 13:45:20 +07:00
Levi Aul
e85d4b76aa
Return bor receipts correctly in getTransactionReceipt and getBlockReceipts (#5787)
Fixes a nil-pointer dereference in Decode when attempting to call
`getTransactionReceipt` / `getBlockReceipts` on blocks containing
stateSync events.
2022-10-20 19:25:46 +01:00
Alex Sharov
0db6b9b44b
e3: move skip analysis out of the loop (#5803) 2022-10-20 10:39:40 +07:00
Andrew Ashikhmin
0fb74172a8
FinalizeTx after engine.Initialize (#5783)
AuRa storage changes made by `onEpochBegin` should be finalized.
Otherwise, `SSTORE` cost might be incorrect in block transactions when
[EIP-2200](https://eips.ethereum.org/EIPS/eip-2200) is active.
https://gnosisscan.io/tx/0xa6d45d903c977ad237165737ebc4e34fb7756675719d112a199af858bb1275e0
is an example of a transaction on Gnosis Chain whose gas used was
previously calculated incorrectly.
2022-10-18 10:44:56 +02:00
Andrew Ashikhmin
241348c5d4
core: implement EIP-3651, warm coinbase (#5745)
[EIP-3651](https://eips.ethereum.org/EIPS/eip-3651) is part of
[Shanghai](https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/shanghai.md).

Co-authored-by: Marius van der Wijden <m.vanderwijden@live.de>
2022-10-14 14:00:00 +02:00
Alex Sharov
1f8bd5de1b
e3: less allocations reconstitution (#5735) 2022-10-13 21:25:57 +07:00
Alex Sharov
63a6fb29ba
e3: cleanup (#5729) 2022-10-13 12:09:14 +07:00
Alex Sharov
86a03987d8
e3: header no copy (#5727) 2022-10-13 11:07:42 +07:00