Skip to content

Commit

Permalink
Merge branch 'main' into custom_trace_upper_bound
Browse files Browse the repository at this point in the history
  • Loading branch information
AskAlexSharov committed Dec 12, 2024
2 parents 68de15e + 2e1582c commit 19c87e0
Show file tree
Hide file tree
Showing 266 changed files with 10,117 additions and 2,704 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ jobs:
if: runner.os == 'Linux'
uses: golangci/golangci-lint-action@v6
with:
version: v1.61.0
args: --help
version: v1.62.2
skip-cache: true

- name: Lint
if: runner.os == 'Linux'
Expand Down
25 changes: 18 additions & 7 deletions .github/workflows/qa-constrained-tip-tracking.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,26 @@ on:

jobs:
constrained-tip-tracking-test:
runs-on: [self-hosted, Erigon3]
timeout-minutes: 600
strategy:
fail-fast: false
matrix:
include:
- chain: mainnet
backend: Erigon3
cgroup_name: constrained_res_32G
- chain: bor-mainnet
backend: Polygon
cgroup_name: constrained_res_64G
runs-on: [ self-hosted, "${{ matrix.backend }}" ]
env:
ERIGON_REFERENCE_DATA_DIR: /opt/erigon-versions/reference-version/datadir
ERIGON_TESTBED_DATA_DIR: /opt/erigon-testbed/datadir
ERIGON_QA_PATH: /home/qarunner/erigon-qa
TRACKING_TIME_SECONDS: 14400 # 4 hours
TOTAL_TIME_SECONDS: 28800 # 8 hours
CHAIN: mainnet
CHAIN: ${{ matrix.chain }}
CGROUP_NAME: ${{ matrix.cgroup_name }}

steps:
- name: Check out repository
Expand Down Expand Up @@ -44,15 +55,15 @@ jobs:
set +e # Disable exit on error
# Run Erigon under memory constraints, wait sync and check ability to maintain sync
cgexec -g memory:constrained_res_32G python3 $ERIGON_QA_PATH/test_system/qa-tests/tip-tracking/run_and_check_tip_tracking.py \
cgexec -g memory:$CGROUP_NAME python3 $ERIGON_QA_PATH/test_system/qa-tests/tip-tracking/run_and_check_tip_tracking.py \
${{ github.workspace }}/build/bin $ERIGON_TESTBED_DATA_DIR $TRACKING_TIME_SECONDS $TOTAL_TIME_SECONDS Erigon3 $CHAIN standard_node statistics
# Capture monitoring script exit status
test_exit_status=$?

# Save the subsection reached status
echo "::set-output name=test_executed::true"

echo "test_executed=true" >> $GITHUB_OUTPUT
# Clean up Erigon process if it's still running
if kill -0 $ERIGON_PID 2> /dev/null; then
echo "Terminating Erigon"
Expand Down Expand Up @@ -94,14 +105,14 @@ jobs:
if: steps.test_step.outputs.test_executed == 'true'
uses: actions/upload-artifact@v4
with:
name: test-results
name: test-results-${{ env.CHAIN }}
path: ${{ github.workspace }}/result-${{ env.CHAIN }}.json

- name: Upload Erigon full log
if: steps.test_step.outputs.test_executed == 'true'
uses: actions/upload-artifact@v4
with:
name: erigon-log
name: erigon-log-${{ env.CHAIN }}
path: |
${{ env.ERIGON_TESTBED_DATA_DIR }}/logs/erigon.log
${{ env.ERIGON_TESTBED_DATA_DIR }}/proc_stat.log
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/scripts/run_rpc_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ disabled_tests=(
eth_coinbase/test_01.json
eth_createAccessList/test_16.json
eth_getTransactionByHash/test_02.json
# Small prune issue that leads to wrong ReceiptDomain data at 16999999 (probably at every million) block: https://github.com/erigontech/erigon/issues/13050
ots_searchTransactionsBefore/test_04.tar
eth_getWork/test_01.json
eth_mining/test_01.json
eth_protocolVersion/test_1.json
Expand Down
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ linters:
- testifylint #TODO: enable me
- gocheckcompilerdirectives
- protogetter
- recvcheck #TODO: enable me
enable:
- unconvert
# - predeclared #TODO: enable me
Expand Down
43 changes: 26 additions & 17 deletions accounts/abi/bind/backends/simulated.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func NewTestSimulatedBackendWithConfig(t *testing.T, alloc types.GenesisAlloc, c
t.Cleanup(b.Close)
return b
}
func (b *SimulatedBackend) DB() kv.RwDB { return b.m.DB }
func (b *SimulatedBackend) DB() kv.TemporalRwDB { return b.m.DB }
func (b *SimulatedBackend) Agg() *state2.Aggregator { return b.m.HistoryV3Components() }
func (b *SimulatedBackend) HistoryV3() bool { return b.m.HistoryV3 }
func (b *SimulatedBackend) Engine() consensus.Engine { return b.m.Engine }
Expand Down Expand Up @@ -190,7 +190,7 @@ func (b *SimulatedBackend) emptyPendingBlock() {
}

// stateByBlockNumber retrieves a state by a given blocknumber.
func (b *SimulatedBackend) stateByBlockNumber(db kv.Tx, blockNumber *big.Int) *state.IntraBlockState {
func (b *SimulatedBackend) stateByBlockNumber(db kv.TemporalTx, blockNumber *big.Int) *state.IntraBlockState {
if blockNumber == nil || blockNumber.Cmp(b.pendingBlock.Number()) == 0 {
return state.New(b.m.NewHistoryStateReader(b.pendingBlock.NumberU64()+1, db))
}
Expand All @@ -201,47 +201,47 @@ func (b *SimulatedBackend) stateByBlockNumber(db kv.Tx, blockNumber *big.Int) *s
func (b *SimulatedBackend) CodeAt(ctx context.Context, contract libcommon.Address, blockNumber *big.Int) ([]byte, error) {
b.mu.Lock()
defer b.mu.Unlock()
tx, err := b.m.DB.BeginRo(context.Background())
tx, err := b.m.DB.BeginTemporalRo(context.Background())
if err != nil {
return nil, err
}
defer tx.Rollback()
stateDB := b.stateByBlockNumber(tx, blockNumber)
return stateDB.GetCode(contract), nil
return stateDB.GetCode(contract)
}

// BalanceAt returns the wei balance of a certain account in the blockchain.
func (b *SimulatedBackend) BalanceAt(ctx context.Context, contract libcommon.Address, blockNumber *big.Int) (*uint256.Int, error) {
b.mu.Lock()
defer b.mu.Unlock()
tx, err := b.m.DB.BeginRo(context.Background())
tx, err := b.m.DB.BeginTemporalRo(context.Background())
if err != nil {
return nil, err
}
defer tx.Rollback()
stateDB := b.stateByBlockNumber(tx, blockNumber)
return stateDB.GetBalance(contract), nil
return stateDB.GetBalance(contract)
}

// NonceAt returns the nonce of a certain account in the blockchain.
func (b *SimulatedBackend) NonceAt(ctx context.Context, contract libcommon.Address, blockNumber *big.Int) (uint64, error) {
b.mu.Lock()
defer b.mu.Unlock()
tx, err := b.m.DB.BeginRo(context.Background())
tx, err := b.m.DB.BeginTemporalRo(context.Background())
if err != nil {
return 0, err
}
defer tx.Rollback()

stateDB := b.stateByBlockNumber(tx, blockNumber)
return stateDB.GetNonce(contract), nil
return stateDB.GetNonce(contract)
}

// StorageAt returns the value of key in the storage of an account in the blockchain.
func (b *SimulatedBackend) StorageAt(ctx context.Context, contract libcommon.Address, key libcommon.Hash, blockNumber *big.Int) ([]byte, error) {
b.mu.Lock()
defer b.mu.Unlock()
tx, err := b.m.DB.BeginRo(context.Background())
tx, err := b.m.DB.BeginTemporalRo(context.Background())
if err != nil {
return nil, err
}
Expand All @@ -258,14 +258,14 @@ func (b *SimulatedBackend) TransactionReceipt(ctx context.Context, txHash libcom
b.mu.Lock()
defer b.mu.Unlock()

tx, err := b.m.DB.BeginRo(context.Background())
tx, err := b.m.DB.BeginTemporalRo(context.Background())
if err != nil {
return nil, err
}
defer tx.Rollback()

// Retrieve the context of the receipt based on the transaction hash
blockNumber, err := rawdb.ReadTxLookupEntry(tx, txHash)
blockNumber, _, err := rawdb.ReadTxLookupEntry(tx, txHash)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -308,7 +308,7 @@ func (b *SimulatedBackend) TransactionByHash(ctx context.Context, txHash libcomm
if txn != nil {
return txn, true, nil
}
blockNumber, ok, err := b.BlockReader().TxnLookup(ctx, tx, txHash)
blockNumber, _, ok, err := b.BlockReader().TxnLookup(ctx, tx, txHash)
if err != nil {
return nil, false, err
}
Expand Down Expand Up @@ -518,7 +518,7 @@ func (b *SimulatedBackend) PendingCodeAt(ctx context.Context, contract libcommon
b.mu.Lock()
defer b.mu.Unlock()

return b.pendingState.GetCode(contract), nil
return b.pendingState.GetCode(contract)
}

func newRevertError(result *evmtypes.ExecutionResult) *revertError {
Expand Down Expand Up @@ -600,7 +600,7 @@ func (b *SimulatedBackend) PendingNonceAt(ctx context.Context, account libcommon
b.mu.Lock()
defer b.mu.Unlock()

return b.pendingState.GetNonce(account), nil
return b.pendingState.GetNonce(account)
}

// SuggestGasPrice implements ContractTransactor.SuggestGasPrice. Since the simulated
Expand Down Expand Up @@ -628,7 +628,10 @@ func (b *SimulatedBackend) EstimateGas(ctx context.Context, call ethereum.CallMs
}
// Recap the highest gas allowance with account's balance.
if call.GasPrice != nil && !call.GasPrice.IsZero() {
balance := b.pendingState.GetBalance(call.From) // from can't be nil
balance, err := b.pendingState.GetBalance(call.From) // from can't be nil
if err != nil {
return 0, err
}
available := balance.ToBig()
if call.Value != nil {
if call.Value.ToBig().Cmp(available) >= 0 {
Expand Down Expand Up @@ -724,7 +727,10 @@ func (b *SimulatedBackend) callContract(_ context.Context, call ethereum.CallMsg
call.Value = new(uint256.Int)
}
// Set infinite balance to the fake caller account.
from := statedb.GetOrNewStateObject(call.From)
from, err := statedb.GetOrNewStateObject(call.From)
if err != nil {
return nil, err
}
from.SetBalance(uint256.NewInt(0).SetAllOne(), tracing.BalanceChangeUnspecified)
// Execute the call.
msg := callMsg{call}
Expand Down Expand Up @@ -752,7 +758,10 @@ func (b *SimulatedBackend) SendTransaction(ctx context.Context, txn types.Transa
if senderErr != nil {
return fmt.Errorf("invalid transaction: %w", senderErr)
}
nonce := b.pendingState.GetNonce(sender)
nonce, err := b.pendingState.GetNonce(sender)
if err != nil {
return err
}
if txn.GetNonce() != nonce {
return fmt.Errorf("invalid transaction nonce: got %d, want %d", txn.GetNonce(), nonce)
}
Expand Down
9 changes: 6 additions & 3 deletions accounts/abi/bind/backends/simulated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func TestSimulatedBackend(t *testing.T) {
sim.Commit()
_, isPending, err = sim.TransactionByHash(context.Background(), txHash)
if err != nil {
t.Fatalf("error getting transaction with hash: %v", txHash.String())
t.Fatalf("error getting transaction with hash: %v %v", txHash.String(), err.Error())
}
if isPending {
t.Fatal("transaction should not have pending status")
Expand Down Expand Up @@ -137,7 +137,7 @@ func TestNewSimulatedBackend(t *testing.T) {
if sim.m.ChainConfig != params.TestChainConfig {
t.Errorf("expected sim blockchain config to equal params.TestChainConfig, got %v", sim.m.ChainConfig)
}
tx, err1 := sim.DB().BeginRo(context.Background())
tx, err1 := sim.DB().BeginTemporalRo(context.Background())
if err1 != nil {
t.Errorf("TestNewSimulatedBackend create tx: %v", err1)
}
Expand All @@ -152,7 +152,10 @@ func TestNewSimulatedBackend(t *testing.T) {
}

statedb := sim.stateByBlockNumber(tx, new(big.Int).SetUint64(num+1))
bal := statedb.GetBalance(testAddr)
bal, err := statedb.GetBalance(testAddr)
if err != nil {
t.Fatal(err)
}
if !bal.Eq(expectedBal) {
t.Errorf("expected balance for test address not received. expected: %v actual: %v", expectedBal, bal)
}
Expand Down
17 changes: 9 additions & 8 deletions cl/aggregation/mock_services/aggregation_pool_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 12 additions & 1 deletion cl/antiquary/antiquary.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"github.com/erigontech/erigon-lib/downloader/snaptype"
proto_downloader "github.com/erigontech/erigon-lib/gointerfaces/downloaderproto"
"github.com/erigontech/erigon-lib/kv"
"github.com/erigontech/erigon/cl/beacon/synced_data"
"github.com/erigontech/erigon/cl/clparams"
"github.com/erigontech/erigon/cl/persistence/beacon_indicies"
"github.com/erigontech/erigon/cl/persistence/blob_storage"
Expand Down Expand Up @@ -62,12 +63,13 @@ type Antiquary struct {

validatorsTable *state_accessors.StaticValidatorTable
genesisState *state.CachingBeaconState
syncedData synced_data.SyncedData
// set to nil
currentState *state.CachingBeaconState
balances32 []byte
}

func NewAntiquary(ctx context.Context, blobStorage blob_storage.BlobStorage, genesisState *state.CachingBeaconState, validatorsTable *state_accessors.StaticValidatorTable, cfg *clparams.BeaconChainConfig, dirs datadir.Dirs, downloader proto_downloader.DownloaderClient, mainDB kv.RwDB, stateSn *snapshotsync.CaplinStateSnapshots, sn *freezeblocks.CaplinSnapshots, reader freezeblocks.BeaconSnapshotReader, logger log.Logger, states, blocks, blobs, snapgen bool, snBuildSema *semaphore.Weighted) *Antiquary {
func NewAntiquary(ctx context.Context, blobStorage blob_storage.BlobStorage, genesisState *state.CachingBeaconState, validatorsTable *state_accessors.StaticValidatorTable, cfg *clparams.BeaconChainConfig, dirs datadir.Dirs, downloader proto_downloader.DownloaderClient, mainDB kv.RwDB, stateSn *snapshotsync.CaplinStateSnapshots, sn *freezeblocks.CaplinSnapshots, reader freezeblocks.BeaconSnapshotReader, syncedData synced_data.SyncedData, logger log.Logger, states, blocks, blobs, snapgen bool, snBuildSema *semaphore.Weighted) *Antiquary {
backfilled := &atomic.Bool{}
blobBackfilled := &atomic.Bool{}
backfilled.Store(false)
Expand All @@ -92,6 +94,7 @@ func NewAntiquary(ctx context.Context, blobStorage blob_storage.BlobStorage, gen
blobs: blobs,
snapgen: snapgen,
stateSn: stateSn,
syncedData: syncedData,
}
}

Expand Down Expand Up @@ -214,6 +217,14 @@ func (a *Antiquary) Loop() error {
}
}

if a.stateSn != nil {
if err := a.stateSn.OpenFolder(); err != nil {
return err
}
}
log.Info("[Caplin] Stat", "blocks-static", a.sn.BlocksAvailable(), "states-static", a.stateSn.BlocksAvailable(), "blobs-static", a.sn.FrozenBlobs(),
"state-history-enabled", a.states, "block-history-enabled", a.blocks, "blob-history-enabled", a.blobs, "snapgen", a.snapgen)

frozenSlots := a.sn.BlocksAvailable()
if frozenSlots != 0 {
if err := beacon_indicies.PruneBlocks(a.ctx, tx, frozenSlots); err != nil {
Expand Down
Loading

0 comments on commit 19c87e0

Please sign in to comment.