Commit Graph

21242 Commits

Author SHA1 Message Date
Mark Holt
1558fc7835
Refactored types to force runtime registrations to be type dependent (#10147)
This resolves https://github.com/ledgerwatch/erigon/issues/10135

All enums are constrained by their owning type which forces package
includsion and hence type registration.

Added tests for each type to check the construction cycle.
2024-05-01 06:41:19 +07:00
Kewei
01e4969f85
fix concurrent rw on map in operation_pool (#10140)
relates to https://github.com/ledgerwatch/erigon/issues/10139
2024-04-30 16:08:40 +07:00
milen
70dfadd303
core/types: disable go:generate codecgen for receipts and logs (#10105)
running `go generate ./...` fails with:
```
codecgen error: error running 'go run codecgen-main-2.generated.go': exit status 1, console: panic: encoding alphabet includes duplicate symbols

goroutine 1 [running]:
encoding/base64.NewEncoding(...)
    /usr/local/go/src/encoding/base64/base64.go:82
github.com/ugorji/go/codec.init()
    /Users/milen/go/pkg/mod/github.com/ugorji/go/codec@v1.1.13/gen.go:168 +0xf1c
exit status 2
```

this is a problem when using go1.22 and it has been fixed here:
-
8286c2dc98
- issue: https://github.com/ugorji/go/issues/407
2024-04-30 11:02:25 +02:00
Alex Sharov
9e7e8c33fc
align deps of e35 and devel (#10136)
- upgrade docker 
- remove tendermint
2024-04-30 16:01:28 +07:00
Alex Sharov
7edc0b8916
fix some flags parsing (#10134) 2024-04-30 08:40:57 +01:00
Michelangelo Riccobene
d8bf235f0d
qa-tests: small improvements (#10127)
This PR
- avoids installing Golang on every test run, 
- clean up the testbed datadir at the end of the test
2024-04-30 09:09:08 +07:00
Giulio rebuffo
dee2191718
Caplin: process new attesting indicies before block comes in to avoid occasiona Reorg (#10085) 2024-04-29 22:42:33 +02:00
Mark Holt
b7668209aa
Replace snaptype.AllTypes with local definitions (#10132)
When adding bor waypont types I have removed snaptype.AllTypes because
it causes package cross-dependencies.

This fixes the places where all types have been used post the merge
changes.
2024-04-29 18:43:43 +00:00
Mark Holt
714c259acc
Bor waypoint storage (#9793)
Implementation of db and snapshot storage for additional synced hiemdall
waypoint types

* Checkpoint
* Milestones

This is targeted at the Astrid downloader which uses waypoints to verify
headers during syncing and fork choice selection.

Post milestones for heimdall these types are currently downloaded by
erigon but not persisted locally. This change adds persistence for these
types.

In addition to the pure persistence changes this PR also contains a
refactor step which is part of the process of extracting polygon related
types from erigon core into a seperate package which may eventually be
extracted to a separate module and possibly repo.

The aim is rather than the core `turbo\snapshotsync\freezeblocks` having
to know about types it manages and how to exaract and index their
contents this can concern it self with a set of macro shard management
actions.

This process is partially completed by this PR, a final step will be to
remove BorSnapshots and to simplify the places in the code which has to
remeber to deal with them. This requires further testing so has been
left out of this PR to avoid delays in delivering the base types.

# Status

* Waypont types and storage are complete and integrated in to the
BorHeimdall stage, The code has been tested to check that types are
inserted into mdbx, extracted and merged correctly
* I have verified that when produced from block 0 the new snapshot
correctly follow the merging strategy of existing snapshots
* The functionality is enables by a **--bor.waypoints=true** this is
false by default.

# Testing

This has been tested as follows:

* Run a Mumbai instance to the tip and check current processing for
milestones and checkpoints

# Post merge steps

* Produce and release snapshots for mumbai and bor mainnet
* Check existing node upgrades
* Remove --bor.waypoints flags
2024-04-29 18:31:51 +01:00
Giulio rebuffo
287e4a2fb2
Revert "mdbx: pre-open read pagesize from db" (#10125)
Reverts ledgerwatch/erigon#10113
2024-04-29 14:31:26 +00:00
Dmytro
0967c5e52e
dvovk/enable_dignostic (#10083)
Enabled diagnostics by default to collect data. It will allow to connect
to node and get stored data. It includes three new flags:
- "diagnostics.disabled" - it's set to "false" by default. Set to "true"
if you want to disable diagnostics.
- "diagnostics.endpoint.addr" - address of HTTP endpoint to get
diagnostics data
- "diagnostics.endpoint.port" - port of HTTP endpoint to get diagnostics
data

[DO NOT MERGE] as it depend on: 
- https://github.com/ledgerwatch/erigon/pull/10069
- update support command
- update diagnostics UI
2024-04-29 15:28:44 +01:00
Giulio rebuffo
298e15398b
Revert "backward compatibility of .lock" and Backward compatibility by Giulio (#10077)
Reverts ledgerwatch/erigon#10006 and add a proper migration routine
2024-04-29 13:35:32 +00:00
luchenhan
06dfaea457
chore: fix some function names (#10117)
Signed-off-by: luchenhan <hanluchen@aliyun.com>
2024-04-29 12:48:26 +00:00
Dmytro
2b83da17a2
dvovk/limit mem usage (#10069)
Implemented limit for saving peers in an Erigon node memory to be able
to turn on diagnostics data collection by default.
2024-04-29 13:14:03 +01:00
milen
aed056fde3
use sonar for code coverage badge (#10107)
- use sonar badge for code coverage
- remove unnecessary "Coverage" GitHub action and unnecessary duplicate
test run on "devel" CI for it
- the existing coverage job + badge didn't seem to be accurate (wasn't
taking into account `erigon-lib` sub-module)

<img width="982" alt="Screenshot 2024-04-29 at 12 06 46"
src="https://github.com/ledgerwatch/erigon/assets/94537774/e47367ed-340d-42b5-ad00-2f59edce100c">
2024-04-29 14:46:31 +03:00
Alex Sharov
83c95ba486
RPC: Receipts LRU cache (#10112)
for https://github.com/ledgerwatch/erigon/issues/10099
for things like `eth_getTransactionReceipt`,
`ots_searchTransactionsAfter`, etc...

Also moved:
- moved `api.chainConfig()` inside `api.getReceipts()`
- switched `ots` to use blocks/receipts lru
- switched price oracle to use blocks/receipts
2024-04-29 15:38:59 +07:00
Alex Sharov
a12a99c874
mdbx: pre-open read pagesize from db (#10113)
Problem: if --pageSize parameter not set - we using `default pagesize`
instead of `real pagesize of db`. And it causing different `dirtySpace`
size (because it's accounted in "pages")
2024-04-29 10:02:14 +02:00
Giulio rebuffo
3b72b5ac0b
Caplin: tweaks to make staking more stable. (#10097)
Tweaks I did:
1) Decreased attestation expiry down to 30 minutes
2) Removed slot check in committeeSubAggregation
3) More reliable algorithm for the dependent root

Results:
* Better aggregates
* Less strain on the node
* No blocks/attestations missed
2024-04-29 11:44:34 +08:00
Alex Sharov
3ad651e286
nodedb: UpdateNode method to create 1 rwtx instead of 2 (#10109) 2024-04-29 09:47:51 +07:00
Dmytro
e6974593c7
added print DBs table sizes (#10111)
Added command to print databases tables basic info. There are two
options :
- print all info: ./build/bin/diag dbs all
- print only populated tables and dbs: ./build/bin/diag dbs pop   

Here is example output:
![Screenshot 2024-04-28 at 21 38
18](https://github.com/ledgerwatch/erigon/assets/29065143/f0a04931-8d87-4c45-b71a-71d75404f3fc)


@taratorio if you want I can add flag which will print specific DB.
2024-04-29 07:24:17 +07:00
milen
255be132cb
make: add gen commands (#10106)
adds:
- `make gen`
- `make solc`
- `make abigen`
- `make codecgen`
- `make gencodec`
- `make graphql`

tidies up `make devtools`
2024-04-29 07:22:12 +07:00
milen
4bc3bc6f09
mockgen: use typed mocks for compile time check (#10103)
Use `mockgen -typed=true` to generate mocks with type-safe `Return`,
`Do`, `DoAndReturn` function -
https://github.com/uber-go/mock?tab=readme-ov-file#flags
2024-04-28 11:43:28 +00:00
milen
63578a8ca3
make: mocks using mockgen (#10098)
- replaces usages of `moq` in `erigon-lib` with `mockgen` (gomock)
- adds a `make mocks` and `mocks-clean` command for `erigon`
- updates existing `make mocks` command and adds a `mocks-clean` common
for `erigon-lib`
2024-04-28 09:27:17 +07:00
Somnath
d7d0960149
mdbx: Return err early in iter.Next() (#10078)
`HasNext` will return true even with existing error and the application
will expect a next entry. The `Next` function can get into an internal
error (such as a `panic()`) while fetching the next cursor item and thus
fail to return the error.

---------

Co-authored-by: alex.sharov <AskAlexSharov@gmail.com>
2024-04-28 03:01:06 +04:00
Giulio rebuffo
b14b766e81
Caplin: Inclusion of VoluntaryExits, AttesterSlashings, ProposerSlashings, BlsExecutionToChanges and Attestations into block production (#10071)
This PR add operations inclusion.
## Normal operations

* BlsExecutionChange
* VoluntaryExit
* Slashings

Each of these operations blacklist the index they work on so we do not
have repeating indices for the same operations twice. we assume all
signatures are pre-validated and just see if it is a good time to
produce a block with them (by looking at their slot)
## Aggregated Attestations

There is a lot of trash attestations on the network so we separate our
algorithm in 3 steps:

### Eligibility

We iterate over the entire pool of accumulated attestations and filter
out all attestations who cannot be included at the current slot, and
compute their expected reward. (filter out if 0).

### Ranking

We rank the `Attestation`s by their expected reward (we just sort the
array of candidates) by expected reward in ascending order.

### Filtering by superset

We may have some supersets left-over, filter attestation which ends up
being supersets of other. this process is done from highest reward down
to lowest reward.
2024-04-27 14:11:36 +00:00
milen
00850e0b5f
abi: fix abigen issue with make devtools (#10091)
fixes https://github.com/ledgerwatch/erigon/pull/7593 

it introduced a regression: `"fmt"` and `"reflect"` imports were added
for all files generated by `abigen` assuming that they will be used in
all cases, however that assumption was wrong for some cases resulting in
invalid code being generated (in this case after running `make
devtools`):
<img width="982" alt="Screenshot 2024-04-27 at 10 50 37"
src="https://github.com/ledgerwatch/erigon/assets/94537774/9a1b93a5-2141-40d9-8c9e-01a1ff6c031c">
2024-04-27 12:49:39 +03:00
Andrew Ashikhmin
2241e1185d
EIP-2537 (BLS12-381): use gnark instead of kilic (#10082)
Cherry pick https://github.com/ethereum/go-ethereum/pull/29441

---------

Co-authored-by: Marius van der Wijden <m.vanderwijden@live.de>
Co-authored-by: Martin Holst Swende <martin@swende.se>
2024-04-27 12:28:10 +04:00
Mark Holt
5d92302004
Fetch and skip sync events (#10051)
For period where there are not many sync events (mostly testnets) sync
event fecthing can be slow becuase sync events are fetched at the end of
every sprint.

Fetching the next and looking at its block number optimizes this because
fetches can be skipped until the next known block with sync events.
2024-04-27 08:55:07 +01:00
Kewei
ab0f6336a2
wrong ttl value initialization in expirable lru cache (#10090)
fix issue https://github.com/ledgerwatch/erigon/issues/10089
2024-04-27 14:32:01 +07:00
Shoham Chakraborty
d4503578be
polygon/p2p: Add blk/s and bytes/s to periodic log (#9976) 2024-04-27 06:53:03 +00:00
Alex Sharov
7ac8b10344
downloader: docs on MMAP for data-files r/w and experiments with bufio (#10074)
Pros:
- it allows to not pre-alloc files:
https://github.com/ledgerwatch/erigon/issues/8688
- it allows to not "sig-bus" when no space left on disk (return
user-friendly error). see:
https://github.com/ledgerwatch/erigon/issues/8500 - but DB will be MMAP
anyway and may get "sig-bus"

FYI:
- seems no perf difference (but i tested only on cloud drives)
- erigon will anyway open it as mmap 
 
Cons: 
- i did implemented `fsync` for mmap (
https://github.com/anacrolix/torrent/pull/755 ) - probably will need
implement it for bufio: https://github.com/anacrolix/torrent/pull/937
- no zero-copy: more `alloc` memory will be holded by APP (PageCache
starvation). I see 2x mem usage (at `--torrent.download.slots=500` 20gb
vs 40gb)
- i see "10K threads exchaused" error earlier (on
`--torrent.download.slots=500`).
- what else?
2024-04-27 05:10:44 +00:00
Kewei
382f881244
AggregateAndProof put aggregated data into attestationsPool (#10079) 2024-04-26 16:05:25 +02:00
Giulio rebuffo
6e7efa2249
Revert "Fix new_heads Events Emission on Block Forks" (#10081)
Reverts ledgerwatch/erigon#10072
2024-04-26 12:49:57 +00:00
Alex Sharov
c83ee658bf
grafana: configurable datasource (#10073) 2024-04-26 11:41:20 +02:00
goofylfg
eac6f04e53
chore: remove repetitive words with tools (#10076)
use https://github.com/Abirdcfly/dupword to check repetitive words
2024-04-26 10:54:36 +02:00
Jonathan Otto
4e56433170
Fix new_heads Events Emission on Block Forks (#10072)
TL;DR: on a reorg, the common ancestor block is not being published to
subscribers of newHeads

#### Expected behavior

if the reorg's common ancestor is 2, I expect 2 to be republished

1, 2, **2**, **3**, **4**

#### Actual behavior

2 is not republished, and 3's parentHash points to a 2 header that was
never received

1, 2, **3**, **4**

This PR is the same thing as
https://github.com/ledgerwatch/erigon/pull/9738 except with a test.

Note... the test passes, but **this does not actually work in
production** (for Ethereum mainnet with prysm as external CL).

Why? Because in production, `h.sync.PrevUnwindPoint()` is always nil:
a5270bccf5/turbo/stages/stageloop.go (L291)
which means the initial "if block" is never entered, and thus we have
**no control** of increment/decrement `notifyFrom` during reorgs
a5270bccf5/eth/stagedsync/stage_finish.go (L137-L146)

I don't know why `h.sync.PrevUnwindPoint()` is seemingly always nil, or
how the test can pass if it fails in prod. I'm hoping to pass the baton
to someone who might. Thank you @indanielo for original fix.

If we can figure this bug out, it closes #8848 and closes #9568 and
closes #10056

---------

Co-authored-by: Daniel Gimenez <25278291+indanielo@users.noreply.github.com>
2024-04-26 06:53:05 +00:00
Delweng
aee77abf64
chore(config): json marshal chainName (#9865)
As the other fields are json marshaled into lowerUpper case, we should
use the same style.

---------

Signed-off-by: jsvisa <delweng@gmail.com>
2024-04-26 08:17:50 +02:00
carehabit
9001183632
all: use the built-in slices library (#9842)
In the current go 1.21 version used in the project, slices are no longer
an experimental feature and have entered the standard library

Co-authored-by: alex.sharov <AskAlexSharov@gmail.com>
2024-04-26 03:21:25 +00:00
Alex Sharov
a5270bccf5
RPC: --http.dbg.single=true and custom HTTP header dbg: true (#10039)
- Added method `tx.Context()` - because Tx already bounded to context by
`db.BeginRo(ctx)`
- Removed ctx parameter from `BlockWithSenders` method in interfaces
- Added `dbg.ToContext()` and `dbg.Enabled(ctx)` methods to set/get
debugging tag to `ctx`.

Added way to debug single http request: 
To print more detailed logs for 1 request - add `--http.dbg.single=true`
flag. Then can send HTTP header `"dbg: true"`:

```
curl -X POST -H "dbg: true" -H "Content-Type: application/json" --data '{"jsonrpc": "2.0", "method": "eth_blockNumber", "params": [], "id":1}' localhost:8545
```

---------

Co-authored-by: battlmonstr <battlmonstr@users.noreply.github.com>
2024-04-26 09:01:30 +07:00
Willian Mitsuda
3e1331a78f
[ots] Fix incorrect return type and overflow on total block fees calc (#10070)
For E2: fix incorrect type + overflow in certain blocks

Corresponding otterscan issue:
https://github.com/otterscan/otterscan/issues/1658
2024-04-26 08:55:39 +07:00
milen
d7cd1fa037
cmd/integration: print table sizes to filter deprecated tables (#10066) 2024-04-25 14:56:20 +00:00
adytzu2007
a0049fe968
Make logs subscription channel size configurable (#9810)
This PR makes the channel that is used to send logs to subscriptions
configurable so logs are not dropped when the channel gets filled. See
issue 9699.
This is just an initial version since I wanted to gather some feedback
and was unsure if this is the correct approach to solve this.
2024-04-25 14:10:35 +00:00
Alex Sharov
3829bfe778
backward compatibility of .lock (#10006)
In PR: 
- new .lock format introduced by
https://github.com/ledgerwatch/erigon/pull/9766 is not backward
compatible. In the past “empty .lock” did mean “all prohibited” and it
was changed to “all allowed”.
- commit

Not in PR: I have idea to make .lock also forward compatible - by making
it whitelist instead of blacklist: after adding new snap type it will
not be downloaded by accident. Will do it in next PR.

But I need one more confirmation - why do we need exceptions from .lock?
Why we breaking "download once" invariant for some type of files? Can we
avoid it?
2024-04-25 15:59:02 +02:00
galois
b9ebb6ca99
feat: add fullTx params to NewPendingTransactions (#9204)
feat: add `fullTx` params to `NewPendingTransactions`

Closes #9203
2024-04-25 15:51:16 +02:00
Giulio rebuffo
341bfea9b2
Caplin: fixed attestation broadcasting (#10041)
This PR fixes 2 things:
* Superset handling (should ignore)
* SSZ offset not set for custom ssz in attestation encoding after json
unmarshalling
2024-04-25 15:45:14 +02:00
milen
c973a1594a
cmd/integration: import erigon-lib/kv to execute init func (#10065) 2024-04-25 13:33:44 +00:00
Alex Sharov
bc18485bb0
downloader: remove deprecated manual fsync (#10064)
After switching to more durable db mode
https://github.com/ledgerwatch/erigon/pull/10010 - we don't need manual
fsync anymore.
2024-04-25 13:23:15 +00:00
Alex Sharov
cb73f9192d
Revert "StageSenders: --sync.loop.block.limit support" (#10060)
Reverts ledgerwatch/erigon#9982
2024-04-25 19:39:39 +07:00
milen
a700f92209
cmd/integration: print_table_sizes (#10061) 2024-04-25 12:31:48 +00:00
Alex Sharov
ee420adc6e
drop go 1.20 support (#10052)
drop go 1.20 support 

use ` github.com/erigontech/torrent v1.54.2-alpha` - to simplify future
support and features backport
2024-04-25 16:14:13 +07:00