Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: struct based live chain logging #54

Draft
wants to merge 48 commits into
base: devel
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
cbd1eb3
evm tracer updated to track all events
dhyaniarun1993 Oct 23, 2023
a61d19d
test bugfixes
dhyaniarun1993 Oct 23, 2023
dce97d1
tracing added in jsonrpc
dhyaniarun1993 Oct 25, 2023
7e543c5
code refactor
dhyaniarun1993 Oct 30, 2023
e273070
precompiled contarct exposed to public
dhyaniarun1993 Oct 30, 2023
d61649b
fix vm bugs
dhyaniarun1993 Nov 2, 2023
d9dba75
new changes and unit test fixes
dhyaniarun1993 Nov 6, 2023
c297b8a
devel merged and conflict resolved
dhyaniarun1993 Nov 6, 2023
ceba8e3
refactor
dhyaniarun1993 Nov 6, 2023
13ac227
tracer flag name updated
dhyaniarun1993 Nov 7, 2023
0c765e7
bugfixes
dhyaniarun1993 Nov 28, 2023
5d64c1d
statedb: precompile check before onNewAccount
dhyaniarun1993 Dec 8, 2023
122ccec
fix setBalance reasons
dhyaniarun1993 Dec 8, 2023
97c69bc
fix VMError.Unwrap
dhyaniarun1993 Dec 8, 2023
9f876d2
rm extra galloc capturing
dhyaniarun1993 Dec 11, 2023
312a0ed
add hooks for beacon block root processing
dhyaniarun1993 Jan 9, 2024
1616e34
add chainConfig to block events
dhyaniarun1993 Jan 10, 2024
18d7da4
assign values for balance reasons
dhyaniarun1993 Jan 10, 2024
d4428fb
Track burnt and selfdestruct withdraw bal changes
dhyaniarun1993 Jan 10, 2024
306266f
rename and document balance change reasons
dhyaniarun1993 Jan 10, 2024
61c3eae
fix value for Delegate call
dhyaniarun1993 Jan 11, 2024
0c3a9f0
fix comment
dhyaniarun1993 Feb 12, 2024
26fc6e7
has call reverted to snapshot
dhyaniarun1993 Feb 12, 2024
edf048c
emit onNewAccount when reseting account
dhyaniarun1993 Feb 12, 2024
e3855f6
fix self destruct burn condition
dhyaniarun1993 Feb 12, 2024
45af942
remove precompile check for newAccount
dhyaniarun1993 Feb 13, 2024
79bf2dc
live tracer err -> warn
dhyaniarun1993 Feb 13, 2024
93b61c7
rm OnNewAccount
dhyaniarun1993 Feb 13, 2024
5234bb4
devel merged and conflict resolved
dhyaniarun1993 Feb 14, 2024
8de8a48
merge bugfixes
dhyaniarun1993 Feb 16, 2024
07ee59c
added tracer to missing stages
dhyaniarun1993 Feb 20, 2024
fe95fa9
feat: struct based live chain logging
dhyaniarun1993 Mar 25, 2024
280ad59
removed geth specific hooks
dhyaniarun1993 Mar 25, 2024
76296f4
revert block init hook
dhyaniarun1993 Mar 25, 2024
92f25fc
Block init added
dhyaniarun1993 Mar 28, 2024
31702d8
minor improvements
dhyaniarun1993 Mar 28, 2024
4253a3e
fix nil checks in runtime
dhyaniarun1993 Mar 28, 2024
822cba0
move noopT to native
dhyaniarun1993 Mar 28, 2024
59e2752
rename config and flag to VMTraceJsonConfig
dhyaniarun1993 Apr 24, 2024
c584ff7
devel merged
dhyaniarun1993 May 8, 2024
9b0ea85
tracer hooks nil checks added
dhyaniarun1993 May 8, 2024
be8ea25
system call tracing added
dhyaniarun1993 May 8, 2024
01c4579
merge bugfixes
dhyaniarun1993 May 9, 2024
c3fb023
system tracer added to native tracer
dhyaniarun1993 May 9, 2024
11d5300
tracer test cases fixed
dhyaniarun1993 May 9, 2024
5d4ba1a
tracing bugfix
dhyaniarun1993 May 13, 2024
75f0a44
devel merged
dhyaniarun1993 May 14, 2024
17ce8c0
Revert "devel merged"
dhyaniarun1993 May 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .github/workflows/qa-clean-exit-block-downloading.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
set +e # Disable exit on error

# Run Erigon, send ctrl-c and check logs
python3 $ERIGON_QA_PATH/test_system/qa-tests/clean-exit/run_and_check_clean_exit.py ${{ github.workspace }}/build/bin $ERIGON_TESTBED_DATA_DIR $WORKING_TIME_SECONDS Erigon3
python3 $ERIGON_QA_PATH/test_system/qa-tests/clean-exit/run_and_check_clean_exit.py ${{ github.workspace }}/build/bin $ERIGON_TESTBED_DATA_DIR $WORKING_TIME_SECONDS

# Capture monitoring script exit status
test_exit_status=$?
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/qa-clean-exit-snapshot-downloading.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
set +e # Disable exit on error

# Run Erigon, send ctrl-c and check logs
python3 $ERIGON_QA_PATH/test_system/qa-tests/clean-exit/run_and_check_clean_exit.py ${{ github.workspace }}/build/bin $ERIGON_DATA_DIR $WORKING_TIME_SECONDS Erigon3
python3 $ERIGON_QA_PATH/test_system/qa-tests/clean-exit/run_and_check_clean_exit.py ${{ github.workspace }}/build/bin $ERIGON_DATA_DIR $WORKING_TIME_SECONDS

# Capture monitoring script exit status
test_exit_status=$?
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/qa-snap-download.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
set +e # Disable exit on error

# Run Erigon, monitor snapshot downloading and check logs
python3 $ERIGON_QA_PATH/test_system/qa-tests/snap-download/run_and_check_snap_download.py ${{ github.workspace }}/build/bin $ERIGON_DATA_DIR $TOTAL_TIME_SECONDS Erigon3
python3 $ERIGON_QA_PATH/test_system/qa-tests/snap-download/run_and_check_snap_download.py ${{ github.workspace }}/build/bin $ERIGON_DATA_DIR $TOTAL_TIME_SECONDS

# Capture monitoring script exit status
test_exit_status=$?
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/qa-tip-tracking.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
# 1. Launch the testbed Erigon instance
# 2. Allow time for the Erigon to achieve synchronization
# 3. Begin timing the duration that Erigon maintains synchronization
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
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

# Capture monitoring script exit status
test_exit_status=$?
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ mocks: mocks-clean

## mocks-clean: cleans all generated test mocks
mocks-clean:
grep -r -l --exclude-dir="erigon-lib" --exclude-dir="tests" --exclude-dir="*$(GOBINREL)*" "^// Code generated by MockGen. DO NOT EDIT.$$" . | xargs rm -r
grep -r -l --exclude-dir="erigon-lib" --exclude-dir="*$(GOBINREL)*" "^// Code generated by MockGen. DO NOT EDIT.$$" . | xargs rm -r

## solc: generate all solidity contracts
solc:
Expand Down
39 changes: 8 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,7 @@ Engine API.

#### Caplin's Usage.

Caplin is be enabled by default. to disable it and enable the Engine API, use the `--externalcl` flag. from that point
on, an external Consensus Layer will not be need
Caplin is be enabled by default. to disable it and enable the Engine API, use the `--externalcl` flag. from that point on, an external Consensus Layer will not be need
anymore.

Caplin also has an archivial mode for historical states and blocks. it can be enabled through the `--caplin.archive`
Expand Down Expand Up @@ -603,6 +602,7 @@ In order to configure the ports, use:
|-----------|------|----------|---------|---------------|
| REST | 5555 | TCP | REST | Public |


#### `shared` ports

| Component | Port | Protocol | Purpose | Should Expose |
Expand Down Expand Up @@ -786,14 +786,12 @@ Supported networks: all (except Mumbai).
stage_trace_index
- E3 can execute 1 historical transaction - without executing it's block - because history/indices have
transaction-granularity, instead of block-granularity.
- E3 doesn't store Logs (aka Receipts) - it always re-executing historical txn (but it's cheaper then in E2 - see point
above). Also Logs LRU added in E2 (release/2.60) and E3: https://github.com/ledgerwatch/erigon/pull/10112
- Doesn't store Receipts/Logs - it always re-executing historical transactions - but re-execution is cheaper (see point
above). We would like to see how it will impact users - welcome feedback. Likely we will try add some small LRU-cache
here. Likely later we will add optional flag "to persist receipts".
- `--sync.loop.block.limit` is enabled by default. (Default: `2_000`.
Set `--sync.loop.block.limit=10_000_000 --batchSize=1g` to increase sync speed on good hardware).
- datadir/chaindata is small now - to prevent it's grow: we recommend set `--batchSize <= 1G`. And it's fine
to `rm -rf chaindata`
- can symlink/mount latest state to fast drive and history to cheap drive
- More cold-start-friendly and os-pre-fetch-friendly.
- datadir/chaindata is small now - to prevent it's grow: we recommend set --batchSize <= 1G. Probably 512mb is
enough.

### E3 datadir structure

Expand All @@ -810,7 +808,7 @@ datadir
# There is 4 domains: account, storage, code, commitment
```

### E3 can store state on fast disk and history on cheap disk
### E3 can store state on fast disk and history on slow disk

If you can afford store datadir on 1 nvme-raid - great. If can't - it's possible to store history on cheap drive.

Expand Down Expand Up @@ -867,24 +865,3 @@ du -hsc /erigon/snapshots/*
1.3T /erigon/snapshots/idx
3.7T total
```

### E3 other perf trics

- `--sync.loop.block.limit=10_000_000 --batchSize=1g` - likely will help for sync speed.
- on cloud-drives (good throughput, bad latency) - can enable OS's brain to pre-fetch some data (`madv_normal` instead
of `madv_random`). For `snapshots/domain` folder (latest
state) `KV_MADV_NORMAL_NO_LAST_LVL=accounts,storage,commitment` (or if have enough
RAM: `KV_MADV_NORMAL=accounts,storage,commitment`). For `chaindata` folder (latest updates) `MDBX_READAHEAD=true`.
For all files - `SNAPSHOT_MADV_RND=false`

- can lock latest state in RAM - to prevent from eviction (node may face high historical RPC traffic without impacting
Chain-Tip perf):

```
vmtouch -vdlw /mnt/erigon/snapshots/domain/*bt
ls /mnt/erigon/snapshots/domain/*.kv | parallel vmtouch -vdlw

# if it failing with "can't allocate memory", try:
sync && sudo sysctl vm.drop_caches=3
echo 1 > /proc/sys/vm/compact_memory
```
3 changes: 2 additions & 1 deletion accounts/abi/bind/backends/simulated.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import (
"github.com/ledgerwatch/erigon/core"
"github.com/ledgerwatch/erigon/core/rawdb"
"github.com/ledgerwatch/erigon/core/state"
"github.com/ledgerwatch/erigon/core/tracing"
"github.com/ledgerwatch/erigon/core/types"
"github.com/ledgerwatch/erigon/core/vm"
"github.com/ledgerwatch/erigon/event"
Expand Down Expand Up @@ -714,7 +715,7 @@ func (b *SimulatedBackend) callContract(_ context.Context, call ethereum.CallMsg
}
// Set infinite balance to the fake caller account.
from := statedb.GetOrNewStateObject(call.From)
from.SetBalance(uint256.NewInt(0).SetAllOne())
from.SetBalance(uint256.NewInt(0).SetAllOne(), tracing.BalanceChangeUnspecified)
// Execute the call.
msg := callMsg{call}

Expand Down
17 changes: 5 additions & 12 deletions cl/abstract/beacon_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ type BeaconStateSSZ interface {
HashSSZ() (out [32]byte, err error)
}

//go:generate mockgen -typed=true -destination=./mock_services/beacon_state_mutator_mock.go -package=mock_services . BeaconStateMutator
type BeaconStateMutator interface {
SetVersion(version clparams.StateVersion)
SetSlot(slot uint64)
Expand Down Expand Up @@ -105,7 +104,7 @@ type BeaconStateMutator interface {
SetValidatorInactivityScore(index int, score uint64) error
SetCurrentEpochParticipationFlags(flags []cltypes.ParticipationFlags)
SetPreviousEpochParticipationFlags(flags []cltypes.ParticipationFlags)
SetPreviousEpochAttestations(attestations *solid.ListSSZ[*solid.PendingAttestation]) // temporarily skip this mock
SetPreviousEpochAttestations(attestations *solid.ListSSZ[*solid.PendingAttestation])

AddEth1DataVote(vote *cltypes.Eth1Data)
AddValidator(validator solid.Validator, balance uint64)
Expand Down Expand Up @@ -193,14 +192,8 @@ type BeaconStateMinimal interface {
PreviousEpochAttestationsLength() int
}

// BeaconStateReader is an interface for reading the beacon state.
//
//go:generate mockgen -typed=true -destination=./mock_services/beacon_state_reader_mock.go -package=mock_services . BeaconStateReader
type BeaconStateReader interface {
ValidatorPublicKey(index int) (common.Bytes48, error)
GetDomain(domainType [4]byte, epoch uint64) ([]byte, error)
CommitteeCount(epoch uint64) uint64
ValidatorForValidatorIndex(index int) (solid.Validator, error)
Version() clparams.StateVersion
GenesisValidatorsRoot() common.Hash
// TODO figure this out
type BeaconStateCopying interface {
//CopyInto(dst *raw.BeaconState) error
//Copy() (*raw.BeaconState, error)
}
Loading