Commit Graph

3369 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
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
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
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
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
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
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
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
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
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
persmor
b2cf6d2256
chore: fix comments (#9958)
Fix some comments
2024-04-25 08:30:28 +00:00
Andrew Ashikhmin
3323fdc348
Revert "Fix new_heads Events Emission on Block Forks (#9738)" (#10055)
This reverts commit f4aefdc32a.

See PR #9738
2024-04-25 07:04:09 +00:00
canepat
d2aaa68d1d
Build Silkworm RpcDaemon settings from Erigon ones (#10002)
This PR introduces support for customising Silkworm RpcDaemon settings
in Erigon++.

Common RPC settings between Erigon and Silkworm are simply translated
from the existing Erigon command-line options. They include:
- `--http.addr`
- `--http.port`
- `--http.compression`
- `--http.corsdomain`
- `--http.api`
- `--ws`
- `--ws.compression`

Moreover, the following Silkworm-specific command-line options are
added:
- `--silkworm.verbosity`
- `--silkworm.contexts`
- `--silkworm.rpc.log`
- `--silkworm.rpc.log.maxsize`
- `--silkworm.rpc.log.maxfiles`
- `--silkworm.rpc.log.response`
- `--silkworm.rpc.workers`
- `--silkworm.rpc.compatibility`

Default values cover the common usages of Erigon++ experimental
features, yet such options can be useful for testing some corner cases
or collecting information.

Finally, this PR adds a new `LogDirPath` function to `logging` module
just to determine the log dir path used by Erigon and put there also
Silkworm RPC interface logs, when enabled.
2024-04-25 08:25:44 +02:00
Somnath
d318f11c15
Optimize prune old chunks (#10019)
**Summary**
Fixes prune point for log (+index)
- Unnecessary to use ETL again for deleting `kv.Log` entries, can just
introduce `RwCursor` in the initial loop
- Put the last `pruneTo` block number in the `PruneState` - this will
begin pruning from that point. Earlier the `pruneFrom` point being
passed in was buggy as it used some other assumption for this value
2024-04-24 18:07:41 +07:00
goofylfg
475355448b
chore:fix typo (#9952) 2024-04-24 10:58:43 +00:00
Alex Sharov
2bd713bfa3
StageSenders: --sync.loop.block.limit support (#9982)
We reverted support of this flag in `updateForkChoice` because
implementation was too complex and fragile:
https://github.com/ledgerwatch/erigon/pull/9900

But it's good-enough if StageSenders will preserve this flag - then next
stages (exec) will also follow (because they look at prev stage
progress).

It's good-enough - because users just want to save some partial progress
after restoring node from backup (long downtime). And enforce "all
stages progress together" invariant
2024-04-24 12:24:32 +02:00
Mark Holt
d1340de7dc
Fix forward bor snaps (#10027)
This fixes this issue:

https://github.com/ledgerwatch/erigon/issues/9499

which is caused by restarting erigon during the bor-heimdall stage.

Previously after the initial call to bor-heimdall (header 0), forward
downloading was disabled, but backward
downloading recursively collects headers - holding results in memory
until it can roll them forward. This should
only be called for a limited number of headers, otherwise it leads to a
large amount of memory >45GB for bor
main net if the process is stopped at block 1.
2024-04-24 16:25:18 +07:00
Alex Sharov
ab361e4747
move temporal package to erigon-lib (#10015)
Co-authored-by: awskii <artem.tsskiy@gmail.com>
2024-04-22 15:29:25 +01:00
Alex Sharov
3af5c350a7
rename aggv3 to agg (#10011) 2024-04-22 11:18:29 +01:00
Shoham Chakraborty
80513aafad
polygon/sync: Clean shutdown (#10017) 2024-04-22 08:53:34 +02:00
Alex Sharov
86dd0e5558
downloader: rename TorrentFiles to AtomicTorrentFS (#10005) 2024-04-20 09:54:46 +01:00
Alex Sharov
c714044a1b
golangci-lint v1.57.2 (#9978)
remove some deprecated linters and fields:
https://golangci-lint.run/product/changelog/
2024-04-18 19:35:54 +01:00
Alex Sharov
3730cff83b
downloader torrent_create: print logs line about created amount (#9983) 2024-04-18 12:06:36 +01:00
Somnath
e3b87dd4dc
Fix missing prune log index (#9968)
Existing prune had some confusing logic (thanks to me).

In PR, change the logic to:
if receipt, or any individual log in the receipt contains an address in
`noPruneContracts` the entire log must be stored and indexed.

Also fixes a regression that logs were not getting indexed - this was
due to
```
if l.BlockNumber < pruneBlock && cfg.noPruneContracts != nil && !cfg.noPruneContracts[l.Address] {
```
Since the individual log object didn't have the block number - something
that shouldn't matter.
In PR, change the logic to:
Use `blockNum` from outer loop
2024-04-17 12:58:28 +00:00
milen
bca27f3b70
p2p/sentry/sentry_multi_client: flag to disable block download code (#9957)
### Change ### 
Adds a `disableBlockDownload` boolean flag to current implementation of
sentry multi client to disable built in header and body download
funcitonality.

### Long Term ###
Long term we are planning to refactor sentry multi client and de-couple
it from custom header and body download logic.

### Context ### 
Astrid uses its own body download logic which is de-coupled from sentry
multi client.

When both are used at the same time (using `--polygon.sync=true`) there
are 2 problematic scenarios:
- restarting Astrid takes a very long time due to the init logic of
sentry multi client. It calls `HeaderDownload.RecoverFromDb` which is
coupled to the Headers stage in the stage loop. So if Astrid has fetched
1 million headers but hasn't committed execution yet then this will
result in very slow start up since all 1 million blocks have to be read
from the DB. Example logs:
```
[INFO] [04-16|12:55:42.254] [downloader] recover headers from db     left=65536
...
[INFO] [04-16|13:03:42.254] [downloader] recover headers from db     left=65536
```

- debug log messages warning about sentry consuming being slow since
Astrid does not use `HeaderDownload` and `BodyDownload` so there is
nothing consuming the headers and bodies from these data structures.
This has no logical impact, however clogs resources. Example logs:
```
[DBUG] [04-16|14:03:15.311] [sentry] consuming is slow, drop 50% of old messages msgID=BLOCK_HEADERS_66
[DBUG] [04-16|14:03:15.311] [sentry] consuming is slow, drop 50% of old messages msgID=BLOCK_HEADERS_66
```
2024-04-17 14:57:02 +03:00
Giulio rebuffo
bd378f2533
Caplin: Make use of EthereumClock instead than Global functions (#9934) 2024-04-15 15:46:36 +08:00
Somnath
1248831c95
Fix older logs pruning (#9932)
Improves upon https://github.com/ledgerwatch/erigon/pull/9913
Closes https://github.com/ledgerwatch/erigon/issues/9889
2024-04-15 12:33:42 +07:00
Somnath
567d222f31
Chore: improve comments and readability with stageloop prune (#9902) 2024-04-12 20:11:43 +07:00
Alex Sharov
0f41159bd5
renaming step2 (#9920)
- Rename
  - state.AggregatorV3Context -> state.FilesRoTx
  - MakeContext() -> BeginFilesRo()
  - aggCtx -> aggTx
  - InvertedIndexContext -> InvertedIndexRoTx, ic -> iit
  - HistoryContext -> HistoryRoTx, hc -> ht
  - DomainContext -> DomainRoTx, dc -> dt

Remove
- Aggregator class
2024-04-12 19:46:30 +07:00
Mark Holt
6bfa6f8af0
Add cloudflare app firewall specific headers (#9904)
This PR adds headers which prevent the cloudflare firewall from banning
the downloaders http requests.

At the moment these are not obfuscated in the codebase.

This should be reviewed before this change is committed to the core
repo.
2024-04-12 18:30:16 +07:00
Dmytro
7e85689c89
Updating sync stages metrics along with DB update (#9907)
- added updating prometheus sync metrics once in 180 seconds log loop
https://github.com/ledgerwatch/erigon/issues/8438
2024-04-12 18:29:26 +07:00
Somnath
50be88d2c6
Add kv.log pruning alongside logIndex prune (#9913) 2024-04-11 16:37:13 +01:00
Alex Sharov
a5d82cff0b
Revert "updateForkChoice: support --sync.loop.block.limit (#9315)" (#9900)
we have this PR in release and don't have in devel

Co-authored-by: Andrew Ashikhmin <34320705+yperbasis@users.noreply.github.com>
2024-04-11 14:49:21 +01:00
Somnath
0f49aabd39
Fix log index gaps in debug_traceTransaction (#9827)
Fixes a whim reported in https://github.com/ledgerwatch/erigon/pull/9783
2024-04-10 11:36:20 +02:00
Dmytro
70406e6887
dvovk/headers info (#9748)
- collecting info for "Headers" stage
2024-04-08 19:45:43 +01:00
milen
1c851ae471
polygon/sync: integrate with erigon (#9729) 2024-04-08 16:54:17 +02:00
Giulio rebuffo
183dbf78ae
Caplin: Add sync committees aggregation (#9829)
# Sync Committee Contribution pooling

First of all, a distinction:
* Sync Committee Messages are single unaggregated messages from a
specific validator
* Sync Committee Contributions are aggregated messages from many
validators.

We get these 2 messages from 2 different gossip sources, and then after
validating the Gossip rules, we send everything to the pool which
aggregate the `sync committee` or `contribution` into another aggregate.

## Sync Committee subscription:
/eth/v1/validator/sync_committee_subscriptions

The subscription just starts to subscribe to the `Sync Committee`'s
Gossip channel. it is actually really simple, here is the pseudo-code
for how the subscription happen for each `ValidatorIndex` requested:

```vb
Function PostEthV1ValidatorSyncCommitteeSubscriptions
    Request: ValidatorIndicies []uint64


    Get the head state of the blockchain


    For each subRequest in ValidatorIndicies do

        
        Compute the subnets for the validator index from subRequest using the headState

        For each subnet in syncnets do
            Construct a topic name for the sync committee subnet
                    Subscribe to the topic with the sync committee subnet the topic with the calculated expiry time in sentinel
            
End Function
```

### Extras

* /eth/v1/validator/contribution_and_proofs - Submit to the node a
contribution to be republished on the Gossip.
* /eth/v1/validator/sync_committee_contribution - Retrieve a
contribution (from the pool) that we have aggregated from the gossip.
* /eth/v1/beacon/pool/sync_committees - Submit to the node a sync sync
committee messages to be republished on the Gossip.

---------

Co-authored-by: Kewei <kewei.train@gmail.com>
2024-04-06 12:15:42 +08:00
goofylfg
ed44953c10
chore:fix typo (#9861) 2024-04-04 21:28:07 +00:00
Jacek Glen
91772de63b
silkworm: int/ext txn split (#9745)
This PR splits the existing `silkworm_execute_blocks` endpoint in CAPI
and creates two separate endpoints:
- `silkworm_execute_blocks_ephemeral`: takes a db txn as a parameter and
uses it to flush the data, but does not commit the transaction
- `silkworm_execute_blocks_perpetual`: creates its own db txn, commits
the data and leaves the database in a coherent state

Associated PRs:
- https://github.com/erigontech/silkworm-go/pull/4
- https://github.com/erigontech/silkworm/pull/1917

---------

Co-authored-by: canepat <16927169+canepat@users.noreply.github.com>
Co-authored-by: battlmonstr <battlmonstr@users.noreply.github.com>
2024-03-29 10:26:21 +01:00
Andrew Ashikhmin
28944ef3f4
override.cancun -> override.prague (#9835)
Replaced the `--override.cancun` flag with `--override.prague`.

Also, removed `Txpool.OverrideCancunTime` as its counterpart isn't (yet)
needed for Prague.
2024-03-29 09:14:41 +01:00
Alex Sharov
ff709f9474
1 seed for all block indices (#9719)
this salt used for creating RecSplit indices. all nodes will have
different salt, but 1 node will use same salt for all files. it allows
using value of `murmur3(key)` to read from all files (importnat for
non-existing keys - which require all indices check).
	
- add `snapshots/salt-blocks.txt
- this PR doesn't require re-index 
- it's step1. in future releases we will add data_migration script which
will "check if all indices use same salt or re-index" (but at this time
most of users will not affected).
- new indices will use `salt-blocks.txt`
2024-03-28 14:52:11 +02:00
battlmonstr
f3f4756471
p2p/sentry: status data provider refactoring (#9747)
The responsibility to maintain the status data is moved from the
stageloop Hook and MultiClient to the new StatusDataProvider. It reads
the latest data from a RoDB when asked. That happens at the end of each
stage loop iteration, and sometimes when any sentry stream loop
reconnects a sentry client.

sync.Service and MultiClient require an instance of the
StatusDataProvider now. The MessageListener is updated to depend on an
external statusDataFactory.
2024-03-27 12:35:23 +00:00
milen
b4bb21b845
polygon/sync: block downloader limit mem usage (#9718) 2024-03-27 09:13:04 +01:00
Dmytro
010b23036a
dvovk/bodies collect (#9787)
This PR contains changes which related to gather information about
"Bodies" stage.
Change list is next: 
- added entities for block download, write, process and processing
- added listeners and collect info for above 
- added API to query this data
2024-03-26 11:39:46 +07:00
awskii
fa40ef6edf
added command to verify remote manifests from webseeds (#9762)
Cherry picked initial commit against devel. Beginning of discussion is
here https://github.com/ledgerwatch/erigon/pull/9750
2024-03-24 17:33:56 +07:00
Giulio rebuffo
c610e1bc4e
Fixed BenchmarkMining integration (#9789) 2024-03-22 14:57:10 +00:00
Daniel Gimenez
f4aefdc32a
Fix new_heads Events Emission on Block Forks (#9738)
new_heads events were not correctly emitted during block forks. This fix
ensures accurate event generation and emission in fork scenarios.
2024-03-22 10:45:14 +01:00