Skip to content

Commit

Permalink
[rpc-test] debug_getModifiedAccountsByNumber (#12634)
Browse files Browse the repository at this point in the history
  • Loading branch information
AskAlexSharov authored Nov 6, 2024
1 parent 94bc4d3 commit afc45cc
Show file tree
Hide file tree
Showing 26 changed files with 146 additions and 193 deletions.
69 changes: 16 additions & 53 deletions .github/workflows/qa-rpc-integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,73 +87,36 @@ jobs:
# Run RPC integration test runner via http
python3 ./run_tests.py -p 8545 --continue -f --json-diff -x \
debug_accountRange,debug_getModifiedAccountsByHash,debug_getModifiedAccountsByNumber,debug_storageRangeAt,debug_traceBlockByHash,\
debug_traceCallMany/test_02.tar,debug_traceCallMany/test_04.tar,debug_traceCallMany/test_05.tar,debug_traceCallMany/test_06.tar,debug_traceCallMany/test_07.tar,debug_traceCallMany/test_09.json,debug_traceCallMany/test_10.tar,\
# false positives: Erigon return expected response. but rpc-test somehow doesn't see 1 field.
erigon_getHeaderByHash,erigon_getHeaderByNumber,eth_feeHistory,\
# total difficulty field was removed, then added back
eth_getBlockByHash,eth_getBlockByNumber,\
# Erigon bugs
debug_accountRange,debug_storageRangeAt,\
# need update rpc-test - because Erigon is correct (@AskAlexSharov will do after https://github.com/erigontech/erigon/pull/12634)
debug_getModifiedAccountsByHash,debug_getModifiedAccountsByNumber,\
# Erigon bug https://github.com/erigontech/erigon/issues/12603
erigon_getLatestLogs,erigon_getLogsByHash/test_04.json,\
# Erigon bug https://github.com/erigontech/erigon/issues/12637
debug_traceBlockByNumber/test_05.tar,debug_traceBlockByNumber/test_08.tar,debug_traceBlockByNumber/test_09.tar,debug_traceBlockByNumber/test_10.tar,debug_traceBlockByNumber/test_11.tar,debug_traceBlockByNumber/test_12.tar,\
# remove this line after https://github.com/erigontech/rpc-tests/pull/281
parity_getBlockReceipts,\
# to investigate
debug_traceBlockByHash,\
debug_traceCallMany/test_02.tar,debug_traceCallMany/test_04.tar,debug_traceCallMany/test_05.tar,debug_traceCallMany/test_06.tar,debug_traceCallMany/test_07.tar,debug_traceCallMany/test_09.json,debug_traceCallMany/test_10.tar,\
debug_traceTransaction,\
engine_exchangeCapabilities/test_1.json,\
engine_exchangeTransitionConfigurationV1/test_01.json,\
engine_getClientVersionV1/test_1.json,\
erigon_getLogsByHash/test_04.json,\
erigon_getHeaderByHash/test_02.json,\
erigon_getHeaderByHash/test_03.json,\
erigon_getHeaderByHash/test_04.json,\
erigon_getHeaderByHash/test_06.json,\
erigon_getHeaderByNumber/test_01.json,\
erigon_getHeaderByNumber/test_02.json,\
erigon_getHeaderByNumber/test_03.json,\
erigon_getHeaderByNumber/test_04.json,\
erigon_getHeaderByNumber/test_05.json,\
erigon_getHeaderByNumber/test_06.json,\
erigon_getHeaderByNumber/test_07.json,\
erigon_getHeaderByNumber/test_08.json,\
erigon_getLatestLogs/test_01.json,\
erigon_getLatestLogs/test_02.json,\
erigon_getLatestLogs/test_03.json,\
erigon_getLatestLogs/test_04.json,\
erigon_getLatestLogs/test_05.json,\
erigon_getLatestLogs/test_06.json,\
erigon_getLatestLogs/test_08.json,\
erigon_getLatestLogs/test_09.json,\
erigon_getLatestLogs/test_10.json,\
erigon_getLatestLogs/test_11.json,\
erigon_getLatestLogs/test_12.json,\
erigon_getBalanceChangesInBlock,\
eth_createAccessList/test_16.json,\
# parity_getBlockReceipts was renamet to eth_getBlockReceipts
parity_getBlockReceipts,\
trace_filter/test_16.json,\
trace_rawTransaction/test_01.json,\
trace_rawTransaction/test_03.json,\
admin_nodeInfo/test_01.json,\
admin_peers/test_01.json,\
erigon_nodeInfo/test_1.json,\
eth_coinbase/test_01.json,\
eth_feeHistory/test_01.json,\
eth_feeHistory/test_02.json,\
eth_feeHistory/test_03.json,\
eth_feeHistory/test_04.json,\
eth_feeHistory/test_05.json,\
eth_feeHistory/test_06.json,\
eth_feeHistory/test_08.json,\
eth_feeHistory/test_09.json,\
eth_feeHistory/test_10.json,\
eth_feeHistory/test_11.json,\
eth_getBlockByHash/test_01.json,\
eth_getBlockByHash/test_02.json,\
eth_getBlockByHash/test_05.json,\
eth_getBlockByHash/test_06.json,\
eth_getBlockByHash/test_07.json,\
eth_getBlockByHash/test_08.json,\
eth_getBlockByNumber/test_01.json,\
eth_getBlockByNumber/test_02.json,\
eth_getBlockByNumber/test_04.json,\
eth_getBlockByNumber/test_05.json,\
eth_getBlockByNumber/test_06.json,\
eth_getBlockByNumber/test_07.json,\
eth_getBlockByNumber/test_08.json,\
eth_getBlockByNumber/test_12.json,\
eth_getBlockByNumber/test_13.json,\
eth_getTransactionByHash/test_02.json,\
eth_getWork/test_01.json,\
eth_mining/test_01.json,\
Expand Down
26 changes: 14 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,18 +203,20 @@ du -hsc /erigon/snapshots/*

### Erigon3 changes from Erigon2

- Initial sync does download LatestState and it's history - no re-exec from 0 anymore.
- ExecutionStage included many E2 stages: stage_hash_state, stage_trie, log_index, history_index, 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).
- Restart doesn't loose much partial progress: `--sync.loop.block.limit=5_000` enabled by default
- `chaindata` is less than `15gb`. It's ok to `rm -rf chaindata`. To prevent it's grow: recommend `--batchSize <= 1G`
- can symlink/mount latest state to fast drive and history to cheap drive
- `--internalcl` is enabled by default. to disable use `--externalcl`
- `--prune` flags changed: default `--prune.mode=archive`, FullNode: `--prune.mode=full`, MinimalNode (EIP-4444):
`--prune.mode=minimal`.
- **Initial sync doesn't re-exec from 0:** downloading 99% LatestState and History
- **Per-Transaction granularity of history** (Erigon2 had per-block). Means:
- Can execute 1 historical transaction - without executing it's block
- If account X change V1->V2->V1 within 1 block (different transactions): `debug_getModifiedAccountsByNumber` return
it
- Erigon3 doesn't store Logs (aka Receipts) - it always re-executing historical txn (but it's cheaper)
- **Validator mode**: added. `--internalcl` is enabled by default. to disable use `--externalcl`.
- **Store most of data in immutable files (segments/snapshots):**
- can symlink/mount latest state to fast drive and history to cheap drive
- `chaindata` is less than `15gb`. It's ok to `rm -rf chaindata`. (to prevent grow: recommend `--batchSize <= 1G`)
- **`--prune` flags changed**: see `--prune.mode` (default: `archive`, full: `full`, EIP-4444: `minimal`)
- **Other changes:**
- ExecutionStage included many E2 stages: stage_hash_state, stage_trie, log_index, history_index, trace_index
- Restart doesn't loose much partial progress: `--sync.loop.block.limit=5_000` enabled by default

### Logging

Expand Down
14 changes: 7 additions & 7 deletions cmd/devnet/devnetutils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,14 @@ func UniqueIDFromEnode(enode string) (string, error) {
return enode[:i], nil
}

func RandomInt(max int) int {
if max == 0 {
func RandomInt(_max int) int {
if _max == 0 {
return 0
}

var n uint16
binary.Read(rand.Reader, binary.LittleEndian, &n)
return int(n) % (max + 1)
return int(n) % (_max + 1)
}

// NamespaceAndSubMethodFromMethod splits a parent method into namespace and the actual method
Expand All @@ -142,10 +142,10 @@ func GenerateTopic(signature string) []libcommon.Hash {
}

// RandomNumberInRange returns a random number between min and max NOT inclusive
func RandomNumberInRange(min, max uint64) (uint64, error) {
if max <= min {
return 0, fmt.Errorf("Invalid range: upper bound %d less or equal than lower bound %d", max, min)
func RandomNumberInRange(_min, _max uint64) (uint64, error) {
if _max <= _min {
return 0, fmt.Errorf("Invalid range: upper bound %d less or equal than lower bound %d", _max, _min)
}

return uint64(RandomInt(int(max-min)) + int(min)), nil
return uint64(RandomInt(int(_max-_min)) + int(_min)), nil
}
6 changes: 3 additions & 3 deletions common/fdlimit/fdlimit_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ const hardlimit = 10240
// Raise tries to maximize the file descriptor allowance of this process
// to the maximum hard-limit allowed by the OS.
// Returns the size it was set to (may differ from the desired 'max')
func Raise(max uint64) (uint64, error) {
func Raise(_max uint64) (uint64, error) {
// Get the current limit
var limit syscall.Rlimit
if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &limit); err != nil {
return 0, err
}
// Try to update the limit to the max allowance
limit.Cur = limit.Max
if limit.Cur > max {
limit.Cur = max
if limit.Cur > _max {
limit.Cur = _max
}
if err := syscall.Setrlimit(syscall.RLIMIT_NOFILE, &limit); err != nil {
return 0, err
Expand Down
6 changes: 3 additions & 3 deletions common/fdlimit/fdlimit_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ import "syscall"
// Raise tries to maximize the file descriptor allowance of this process
// to the maximum hard-limit allowed by the OS.
// Returns the size it was set to (may differ from the desired 'max')
func Raise(max uint64) (uint64, error) {
func Raise(_max uint64) (uint64, error) {
// Get the current limit
var limit syscall.Rlimit
if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &limit); err != nil {
return 0, err
}
// Try to update the limit to the max allowance
limit.Cur = limit.Max
if limit.Cur > max {
limit.Cur = max
if limit.Cur > _max {
limit.Cur = _max
}
if err := syscall.Setrlimit(syscall.RLIMIT_NOFILE, &limit); err != nil {
return 0, err
Expand Down
6 changes: 3 additions & 3 deletions common/fdlimit/fdlimit_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@ const hardlimit = 16384

// Raise tries to maximize the file descriptor allowance of this process
// to the maximum hard-limit allowed by the OS.
func Raise(max uint64) (uint64, error) {
func Raise(_max uint64) (uint64, error) {
// This method is NOP by design:
// * Linux/Darwin counterparts need to manually increase per process limits
// * On Windows Go uses the CreateFile API, which is limited to 16K files, non
// changeable from within a running process
// This way we can always "request" raising the limits, which will either have
// or not have effect based on the platform we're running on.
if max > hardlimit {
if _max > hardlimit {
return hardlimit, fmt.Errorf("file descriptor limit (%d) reached", hardlimit)
}
return max, nil
return _max, nil
}

// Current retrieves the number of file descriptors allowed to be opened by this
Expand Down
4 changes: 2 additions & 2 deletions consensus/ethash/consensus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ func TestCalcDifficulty(t *testing.T) {
}
}

func randSlice(min, max uint32) []byte {
func randSlice(_min, _max uint32) []byte {
var b = make([]byte, 4)
rand.Read(b)
a := binary.LittleEndian.Uint32(b)
size := min + a%(max-min)
size := _min + a%(_max-_min)
out := make([]byte, size)
rand.Read(out)
return out
Expand Down
4 changes: 2 additions & 2 deletions core/types/encdec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ func NewTRand() *TRand {
return &TRand{rnd: rand.New(src)}
}

func (tr *TRand) RandIntInRange(min, max int) int {
return (tr.rnd.Intn(max-min) + min)
func (tr *TRand) RandIntInRange(_min, _max int) int {
return (tr.rnd.Intn(_max-_min) + _min)
}

func (tr *TRand) RandUint64() *uint64 {
Expand Down
4 changes: 2 additions & 2 deletions core/types/transaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -549,8 +549,8 @@ const N = 50
var dummyBlobTxs = [N]*BlobTx{}
var dummyBlobWrapperTxs = [N]*BlobTxWrapper{}

func randIntInRange(min, max int) int {
return (rand.Intn(max-min) + min)
func randIntInRange(_min, _max int) int {
return (rand.Intn(_max-_min) + _min)
}

func randAddr() *libcommon.Address {
Expand Down
22 changes: 11 additions & 11 deletions erigon-lib/chain/snapcfg/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ func (p Preverified) Versioned(preferredVersion snaptype.Version, minVersion sna
}

func (p Preverified) MaxBlock(version snaptype.Version) (uint64, error) {
max := uint64(0)
_max := uint64(0)
for _, p := range p {
_, fileName := filepath.Split(p.Name)
ext := filepath.Ext(fileName)
Expand All @@ -261,16 +261,16 @@ func (p Preverified) MaxBlock(version snaptype.Version) (uint64, error) {
return 0, err
}

if max < to {
max = to
if _max < to {
_max = to
}

}
if max == 0 { // to prevent underflow
if _max == 0 { // to prevent underflow
return 0, nil
}

return max*1_000 - 1, nil
return _max*1_000 - 1, nil
}

var errWrongVersion = errors.New("wrong version")
Expand Down Expand Up @@ -464,17 +464,17 @@ func MergeLimitFromCfg(cfg *Cfg, snapType snaptype.Enum, fromBlock uint64) uint6
}

func MaxSeedableSegment(chain string, dir string) uint64 {
var max uint64
var _max uint64

if list, err := snaptype.Segments(dir); err == nil {
for _, info := range list {
if Seedable(chain, info) && info.Type.Enum() == snaptype.MinCoreEnum && info.To > max {
max = info.To
if Seedable(chain, info) && info.Type.Enum() == snaptype.MinCoreEnum && info.To > _max {
_max = info.To
}
}
}

return max
return _max
}

var oldMergeSteps = append([]uint64{snaptype.Erigon2OldMergeLimit}, snaptype.MergeSteps...)
Expand All @@ -498,14 +498,14 @@ func KnownCfg(networkName string) *Cfg {
return newCfg(networkName, c.Typed(knownTypes[networkName]))
}

func VersionedCfg(networkName string, preferred snaptype.Version, min snaptype.Version) *Cfg {
func VersionedCfg(networkName string, preferred snaptype.Version, _min snaptype.Version) *Cfg {
c, ok := knownPreverified[networkName]

if !ok {
return newCfg(networkName, Preverified{})
}

return newCfg(networkName, c.Versioned(preferred, min))
return newCfg(networkName, c.Versioned(preferred, _min))
}

var KnownWebseeds = map[string][]string{
Expand Down
10 changes: 5 additions & 5 deletions erigon-lib/common/cmp/cmp.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ import (
)

// InRange - ensure val is in [min,max] range
func InRange[T cmp.Ordered](min, max, val T) T {
if min >= val {
return min
func InRange[T cmp.Ordered](_min, _max, val T) T {
if _min >= val {
return _min
}
if max <= val {
return max
if _max <= val {
return _max
}
return val
}
2 changes: 1 addition & 1 deletion erigon-lib/crypto/bn256/cloudflare/gfp_decl.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

var hasBMI2 = cpu.X86.HasBMI2

// go:noescape
//go:noescape
func gfpNeg(c, a *gfP)

//go:noescape
Expand Down
8 changes: 4 additions & 4 deletions erigon-lib/downloader/downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func insertCloudflareHeaders(req *http.Request) {
// It also tries to parse Retry-After response header when a http.StatusTooManyRequests
// (HTTP Code 429) is found in the resp parameter. Hence it will return the number of
// seconds the server states it may be ready to process more requests from this client.
func calcBackoff(min, max time.Duration, attemptNum int, resp *http.Response) time.Duration {
func calcBackoff(_min, _max time.Duration, attemptNum int, resp *http.Response) time.Duration {
if resp != nil {
if resp.StatusCode == http.StatusTooManyRequests || resp.StatusCode == http.StatusServiceUnavailable {
if s, ok := resp.Header["Retry-After"]; ok {
Expand All @@ -185,10 +185,10 @@ func calcBackoff(min, max time.Duration, attemptNum int, resp *http.Response) ti
}
}

mult := math.Pow(2, float64(attemptNum)) * float64(min)
mult := math.Pow(2, float64(attemptNum)) * float64(_min)
sleep := time.Duration(mult)
if float64(sleep) != mult || sleep > max {
sleep = max
if float64(sleep) != mult || sleep > _max {
sleep = _max
}

return sleep
Expand Down
2 changes: 1 addition & 1 deletion erigon-lib/rlp2/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func identifyToken(b byte) Token {
return TokenLongBlob
case b >= 192 && b <= 247:
return TokenShortList
case b >= 248 && b <= 255:
case b >= 248:
return TokenLongList
}
return TokenUnknown
Expand Down
4 changes: 0 additions & 4 deletions erigon-lib/seg/decompress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -566,10 +566,6 @@ func generateRandWords() {
WORDS[N-1] = []byte{}
}

func randIntInRange(min, max int) int {
return (rand.Intn(max-min) + min)
}

func clearPrevDict() {
WORDS = [N][]byte{}
WORD_FLAGS = [N]bool{}
Expand Down
Loading

0 comments on commit afc45cc

Please sign in to comment.