Skip to content

Commit

Permalink
Merge branch 'ledgerwatch:devel' into devel
Browse files Browse the repository at this point in the history
  • Loading branch information
ddl-hust authored Jan 2, 2024
2 parents 46d8be1 + 415b17c commit 46d5819
Show file tree
Hide file tree
Showing 327 changed files with 20,921 additions and 3,539 deletions.
89 changes: 89 additions & 0 deletions .github/workflows/qa-clean-exit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: QA - Clean exit on Ctrl-C

on:
push:
branches:
- devel
- alpha
- 'release/**'
pull_request:
branches:
- devel
- alpha
- 'release/**'
types:
- opened
- reopened
- synchronize
- ready_for_review

jobs:
long-running-test:
#if: ${{ github.event_name == 'push' || !github.event.pull_request.draft }}
#strategy:
# matrix:
# os: [ ubuntu-22.04, macos-13-xlarge ]
#runs-on: ${{ matrix.os }}
runs-on: self-hosted
env:
ERIGON_DATA_DIR: ${{ github.workspace }}/erigon_data

steps:
- name: Check out repository
uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.20'

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'

#- name: Install dependencies
# run: |
# sudo apt-get update
# sudo apt-get install -y build-essential make gcc

- name: Clean Erigon Build Directory
run: |
make clean
- name: Build Erigon
run: |
make erigon
working-directory: ${{ github.workspace }}

#- name: Download Python Script for Logs Checking
# run: |
# curl -o check_erigon_exit.py 'https://gist.githubusercontent.com/mriccobene/8db4030a745de34d527f136f2caa104f/raw/3c1a860cb87d61075e78ce399e17f0ab157cacc6/check_erigon_exit.py'

- name: Run Erigon, send ctrl-c and check for clean exiting
run: |
# Run Erigon, send ctrl-c and check logs
python3 ${{ github.workspace }}/../../../../erigon-qa/test_system/qa-tests/clean-exit/run_and_check_clean_exit.py ${{ github.workspace }}/build/bin $ERIGON_DATA_DIR
# Capture monitoring script exit status
monitoring_exit_status=$?

# Clean up Erigon process if it's still running
if kill -0 $ERIGON_PID 2> /dev/null; then
echo "Terminating Erigon"
kill $ERIGON_PID
wait $ERIGON_PID
else
echo "Erigon has already terminated"
fi

# Clean up Erigon build and data directories
rm -rf $ERIGON_DATA_DIR

# Check monitoring script exit status
if [ $monitoring_exit_status -eq 0 ]; then
echo "Monitoring completed successfully"
else
echo "Error detected in Erigon logs or monitoring script exited unexpectedly"
exit 1
fi
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,5 @@ node_modules
/config.toml
/config.yaml
/config.yml

vendor
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ COMMANDS += sentinel
COMMANDS += caplin
COMMANDS += caplin-regression
COMMANDS += tooling
COMMANDS += snapshots




Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ in `erigon --help`). We don't allow change this flag after first start.
System Requirements
===================

* For an Archive node of Ethereum Mainnet we recommend >=3TB storage space: 1.8TB state (as of March 2022),
200GB temp files (can symlink or mount folder `<datadir>/temp` to another disk). Ethereum Mainnet Full node (
* For an Archive node of Ethereum Mainnet we recommend >=3.5TB storage space: 2.2TB state (as of December 2023),
470GB snapshots (can symlink or mount folder `<datadir>/snapshots` to another disk), 200GB temp files (can symlink or mount folder `<datadir>/temp` to another disk). Ethereum Mainnet Full node (
see `--prune*` flags): 400Gb (April 2022).

* Goerli Full node (see `--prune*` flags): 189GB on Beta, 114GB on Alpha (April 2022).

* Gnosis Chain Archive: 600GB (October 2023).

* Polygon Mainnet Archive: 5TB. (April 2022). `--prune.*.older 15768000`: 5.1Tb (Sept 2023). Polygon Mumbai Archive:
* Polygon Mainnet Archive: 8.5TiB (December 2023). `--prune.*.older 15768000`: 5.1Tb (September 2023). Polygon Mumbai Archive:
1TB. (April 2022).

SSD or NVMe. Do not recommend HDD - on HDD Erigon will always stay N blocks behind chain tip, but not fall behind.
Expand Down
4 changes: 3 additions & 1 deletion cl/abstract/beacon_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type BeaconStateUpgradable interface {
}

type BeaconStateExtension interface {
SlashValidator(slashedInd uint64, whistleblowerInd *uint64) error
SlashValidator(slashedInd uint64, whistleblowerInd *uint64) (uint64, error)
InitiateValidatorExit(index uint64) error
GetActiveValidatorsIndices(epoch uint64) (indicies []uint64)
GetTotalActiveBalance() uint64
Expand Down Expand Up @@ -162,6 +162,8 @@ type BeaconStateMinimal interface {
Eth1Data() *cltypes.Eth1Data
Eth1DataVotes() *solid.ListSSZ[*cltypes.Eth1Data]
Eth1DepositIndex() uint64
ValidatorSet() *solid.ValidatorSet
PreviousEpochParticipation() *solid.BitList

ForEachValidator(fn func(v solid.Validator, idx int, total int) bool)
ValidatorForValidatorIndex(index int) (solid.Validator, error)
Expand Down
19 changes: 10 additions & 9 deletions cl/antiquary/antiquary.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type Antiquary struct {
beaconDB persistence.BlockSource
backfilled *atomic.Bool
cfg *clparams.BeaconChainConfig
states bool
states, blocks bool
fs afero.Fs
validatorsTable *state_accessors.StaticValidatorTable
genesisState *state.CachingBeaconState
Expand All @@ -43,7 +43,7 @@ type Antiquary struct {
balances32 []byte
}

func NewAntiquary(ctx context.Context, genesisState *state.CachingBeaconState, validatorsTable *state_accessors.StaticValidatorTable, cfg *clparams.BeaconChainConfig, dirs datadir.Dirs, downloader proto_downloader.DownloaderClient, mainDB kv.RwDB, sn *freezeblocks.CaplinSnapshots, reader freezeblocks.BeaconSnapshotReader, beaconDB persistence.BlockSource, logger log.Logger, states bool, fs afero.Fs) *Antiquary {
func NewAntiquary(ctx context.Context, genesisState *state.CachingBeaconState, validatorsTable *state_accessors.StaticValidatorTable, cfg *clparams.BeaconChainConfig, dirs datadir.Dirs, downloader proto_downloader.DownloaderClient, mainDB kv.RwDB, sn *freezeblocks.CaplinSnapshots, reader freezeblocks.BeaconSnapshotReader, beaconDB persistence.BlockSource, logger log.Logger, states, blocks bool, fs afero.Fs) *Antiquary {
backfilled := &atomic.Bool{}
backfilled.Store(false)
return &Antiquary{
Expand All @@ -61,12 +61,13 @@ func NewAntiquary(ctx context.Context, genesisState *state.CachingBeaconState, v
fs: fs,
validatorsTable: validatorsTable,
genesisState: genesisState,
blocks: blocks,
}
}

// Antiquate is the function that starts transactions seeding and shit, very cool but very shit too as a name.
func (a *Antiquary) Loop() error {
if a.downloader == nil {
if a.downloader == nil || !a.blocks {
return nil // Just skip if we don't have a downloader
}
// Skip if we dont support backfilling for the current network
Expand Down Expand Up @@ -94,7 +95,6 @@ func (a *Antiquary) Loop() error {
return err
}
// Here we need to start mdbx transaction and lock the thread
log.Info("[Antiquary]: Stopping Caplin to process historical indicies")
tx, err := a.mainDB.BeginRw(a.ctx)
if err != nil {
return err
Expand All @@ -110,6 +110,7 @@ func (a *Antiquary) Loop() error {
return err
}
defer logInterval.Stop()
log.Info("[Antiquary]: Stopping Caplin to process historical indicies", "from", from, "to", a.sn.BlocksAvailable())

// Now write the snapshots as indicies
for i := from; i < a.sn.BlocksAvailable(); i++ {
Expand Down Expand Up @@ -204,11 +205,11 @@ func (a *Antiquary) Loop() error {
continue
}
to = utils.Min64(to, to-safetyMargin) // We don't want to retire snapshots that are too close to the finalized head
to = (to / snaptype.Erigon2RecentMergeLimit) * snaptype.Erigon2RecentMergeLimit
if to-from < snaptype.Erigon2RecentMergeLimit {
to = (to / snaptype.Erigon2MergeLimit) * snaptype.Erigon2MergeLimit
if to-from < snaptype.Erigon2MergeLimit {
continue
}
if err := a.antiquate(from, to); err != nil {
if err := a.antiquate(a.sn.Version(), from, to); err != nil {
return err
}
case <-a.ctx.Done():
Expand All @@ -217,12 +218,12 @@ func (a *Antiquary) Loop() error {
}

// Antiquate will antiquate a specific block range (aka. retire snapshots), this should be ran in the background.
func (a *Antiquary) antiquate(from, to uint64) error {
func (a *Antiquary) antiquate(version uint8, from, to uint64) error {
if a.downloader == nil {
return nil // Just skip if we don't have a downloader
}
log.Info("[Antiquary]: Antiquating", "from", from, "to", to)
if err := freezeblocks.DumpBeaconBlocks(a.ctx, a.mainDB, a.beaconDB, from, to, snaptype.Erigon2RecentMergeLimit, a.dirs.Tmp, a.dirs.Snap, 1, log.LvlDebug, a.logger); err != nil {
if err := freezeblocks.DumpBeaconBlocks(a.ctx, a.mainDB, a.beaconDB, version, from, to, snaptype.Erigon2MergeLimit, a.dirs.Tmp, a.dirs.Snap, 1, log.LvlDebug, a.logger); err != nil {
return err
}

Expand Down
Loading

0 comments on commit 46d5819

Please sign in to comment.