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

Upstream v2.49.0 #22

Open
wants to merge 60 commits into
base: op-erigon
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
aaa51ec
mdbx bug in DeleteCurrentDuplicates() workaround (#1039)
AskAlexSharov Jul 6, 2023
41ae71f
Engine methods moved to separate service (#1035)
Giulio2002 Jul 6, 2023
371e708
unified pending block (#1041)
Giulio2002 Jul 10, 2023
797e6dd
fsync: don't skip error, ability to disable in tests (#1043)
AskAlexSharov Jul 11, 2023
441634e
Parse EIP-4844 transactions wrapped with blobs (#1037)
yperbasis Jul 11, 2023
7764cf6
crypto lib up (#1044)
AskAlexSharov Jul 11, 2023
a85175e
Removed engine (#1045)
Giulio2002 Jul 12, 2023
18f4c2a
fix nil ptr background.progress object (#1048)
AskAlexSharov Jul 13, 2023
e7661ad
Updated interfaces (#1049)
Giulio2002 Jul 14, 2023
886a982
Added struct to hold bor sprints in numeric order (#1038)
mh0lt Jul 14, 2023
738be55
EIP-4844: TxPool::validateTx extension to meet specs (#1046)
racytech Jul 17, 2023
32df191
add map size setter (#1050)
mh0lt Jul 17, 2023
1d6b5a3
Revert "add map size setter" (#1054)
AlexeyAkhunov Jul 22, 2023
588e1ea
Better handling of insertion (#1055)
Giulio2002 Jul 23, 2023
ff28c8f
[WIP] decompress::Match (#1056)
racytech Jul 25, 2023
3bd3a4c
Added AssembleBlockRequest (#1057)
Giulio2002 Jul 27, 2023
0e71e9b
added MemDB() (#1059)
Giulio2002 Jul 27, 2023
c07cefc
EIP-4844: Rename "data gas" to "blob gas" (#1058)
yperbasis Jul 28, 2023
da71e64
moreeeeee (#1060)
Giulio2002 Jul 28, 2023
c89353e
added NewMemoryBatchWithCustomDB (#1061)
Giulio2002 Jul 30, 2023
ddfe099
Better status codes for execution.proto (#1062)
Giulio2002 Aug 1, 2023
3a056bb
Bump max size of blob transactions (#1063)
yperbasis Aug 1, 2023
f33b0bc
Fix blob transaction panic in txpool (#1065)
yperbasis Aug 1, 2023
d4f8da7
init kzg ctx from file (trusted_setup.json) (#1066)
racytech Aug 3, 2023
0a6037d
OverrideShanghaiTime -> OverrideCancunTime (#1067)
yperbasis Aug 3, 2023
73d985f
Added memory diff to memory mutation (#1068)
Giulio2002 Aug 4, 2023
3f118db
save (#1070)
Giulio2002 Aug 5, 2023
6fc9f7e
removed missingHash (#1071)
Giulio2002 Aug 6, 2023
563a681
interfaces: Add parent_beacon_block_root (EIP-4788) (#1069)
yperbasis Aug 6, 2023
a17eaec
Recsplit: cancelable build (#1073)
AskAlexSharov Aug 11, 2023
309e0bd
pool: don't warn at Ctrl+C
AskAlexSharov Aug 11, 2023
8d0bcd0
tmpdb: move to tmpdir (#1074)
AskAlexSharov Aug 11, 2023
1881b49
Gnosis fields for execution.proto (#1072)
Giulio2002 Aug 11, 2023
36aec4c
added sentinel direct (#1077)
Giulio2002 Aug 11, 2023
de16cd6
up 'x' packages versions (#1076)
AskAlexSharov Aug 12, 2023
fdd3982
log file unmap/close errors (#1036)
AskAlexSharov Aug 12, 2023
0f311ab
Update README.md (#1079)
AskAlexSharov Aug 18, 2023
f84bd53
Fix broadcast issue for blob transactions (#1080)
somnathb1 Aug 18, 2023
3aa5249
Add BorEvents snapshot type (#1051)
AlexeyAkhunov Aug 18, 2023
ac13f43
torrent lib to support go21 (#1081)
AskAlexSharov Aug 23, 2023
ec899e4
metrics: prevent commit metrics duplication (#1082)
AskAlexSharov Aug 24, 2023
3c4b0d4
move mdbx to new org (#1083)
AskAlexSharov Aug 24, 2023
c344806
rename torquem-ch project
AskAlexSharov Aug 24, 2023
0cdb085
Torrent: add trackers list (#1084)
AskAlexSharov Aug 25, 2023
bae527e
Ranges in execution.proto (#1087)
Giulio2002 Aug 26, 2023
c2851b6
Added Mdbx sizing to txpool config (#1086)
mh0lt Aug 26, 2023
e3850da
ci: check source code licenses compatibility (#1089)
battlmonstr Aug 30, 2023
34cb800
Compress: graceful shutdown support (#1090)
AskAlexSharov Aug 30, 2023
a019c29
doc: third-party readme and license files (#1091)
battlmonstr Aug 30, 2023
88e9d7a
mdbx: m1 segfault (#1093)
AskAlexSharov Aug 31, 2023
21f96bf
up linter version
AskAlexSharov Sep 1, 2023
b08f183
demoted txpool logs to Debug instead of Warn (#1094)
Giulio2002 Sep 1, 2023
82448e2
Revert most txpool errors to Warn (#1095)
yperbasis Sep 1, 2023
568d783
save
AskAlexSharov Sep 4, 2023
dde477f
shutdown deadlock (#1107)
AskAlexSharov Sep 6, 2023
173f7cf
Merge commit 'dde477f' into upstream-v2.49.0-dde477f
ImTei Sep 21, 2023
806ea07
Update erigon-interfaces version
ImTei Sep 21, 2023
ac842e4
make gen
ImTei Sep 21, 2023
260274a
Fix build error
ImTei Sep 21, 2023
f27eeca
Update erigon-interfaces version
ImTei Sep 25, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,8 @@ jobs:
if: matrix.os == 'ubuntu-20.04'
uses: golangci/golangci-lint-action@v3
with:
version: v1.52
version: v1.54

- name: Lint source code licenses
if: matrix.os == 'ubuntu-20.04'
run: make lint-licenses-deps lint-licenses
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ linters:
- unused
- performance
disable:
- gosec
- exhaustive
- musttag
- contextcheck
Expand Down
12 changes: 10 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ mocks: $(GOBINREL)/moq
rm -f gointerfaces/sentry/mocks.go
PATH="$(GOBIN):$(PATH)" go generate ./...

lint: $(GOBINREL)/golangci-lint
lintci: $(GOBINREL)/golangci-lint
@"$(GOBIN)/golangci-lint" run --config ./.golangci.yml

# force re-make golangci-lint
Expand All @@ -80,11 +80,19 @@ lintci-deps-clean: golangci-lint-clean

# download and build golangci-lint (https://golangci-lint.run)
$(GOBINREL)/golangci-lint: | $(GOBINREL)
curl -sSfL https://github.com/raw/golangci/golangci-lint/master/install.sh | sh -s -- -b "$(GOBIN)" v1.53.2
curl -sSfL https://github.com/raw/golangci/golangci-lint/master/install.sh | sh -s -- -b "$(GOBIN)" v1.54.2

golangci-lint-clean:
rm -f "$(GOBIN)/golangci-lint"

lint-licenses-deps:
@./tools/licenses_check.sh --install-deps
lint-licenses:
@./tools/licenses_check.sh

lint-deps: lintci-deps lint-licenses-deps
lint: lintci lint-licenses

test:
$(GOTEST) --count 1 -p 2 ./...

Expand Down
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,22 @@
# erigon-lib
Dependencies of Erigon project, rewritten from scratch and licensed under Apache 2.0

## Dev workflow

In erigon folder create go.work file (it’s already in .gitignore)
```
go 1.20

use (
.

./../erigon-lib
)
```

Create PR in erigon-lib, don’t merge PR, refer from erigon to non-merged erigon-lib branch (commit) by:
go get github.com/ledgerwatch/erigon-lib/kv@<commit_hash>

Create Erigon PR

When both CI are green - merge 2 PR. That’s it.
92 changes: 91 additions & 1 deletion chain/chain_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,8 @@ type BorConfig struct {

IndoreBlock *big.Int `json:"indoreBlock"` // Indore switch block (nil = no fork, 0 = already on indore)
StateSyncConfirmationDelay map[string]uint64 `json:"stateSyncConfirmationDelay"` // StateSync Confirmation Delay, in seconds, to calculate `to`

sprints sprints
}

// String implements the stringer interface, returning the consensus engine details.
Expand All @@ -489,7 +491,62 @@ func (c *BorConfig) CalculateProducerDelay(number uint64) uint64 {
}

func (c *BorConfig) CalculateSprint(number uint64) uint64 {
return borKeyValueConfigHelper(c.Sprint, number)
if c.sprints == nil {
c.sprints = asSprints(c.Sprint)
}

for i := 0; i < len(c.sprints)-1; i++ {
if number >= c.sprints[i].from && number < c.sprints[i+1].from {
return c.sprints[i].size
}
}

return c.sprints[len(c.sprints)-1].size
}

func (c *BorConfig) CalculateSprintCount(from, to uint64) int {
switch {
case from > to:
return 0
case from < to:
to--
}

if c.sprints == nil {
c.sprints = asSprints(c.Sprint)
}

count := uint64(0)
startCalc := from

zeroth := func(boundary uint64, size uint64) uint64 {
if boundary%size == 0 {
return 1
}

return 0
}

for i := 0; i < len(c.sprints)-1; i++ {
if startCalc >= c.sprints[i].from && startCalc < c.sprints[i+1].from {
if to >= c.sprints[i].from && to < c.sprints[i+1].from {
if startCalc == to {
return int(count + zeroth(startCalc, c.sprints[i].size))
}
return int(count + zeroth(startCalc, c.sprints[i].size) + (to-startCalc)/c.sprints[i].size)
} else {
endCalc := c.sprints[i+1].from - 1
count += zeroth(startCalc, c.sprints[i].size) + (endCalc-startCalc)/c.sprints[i].size
startCalc = endCalc + 1
}
}
}

if startCalc == to {
return int(count + zeroth(startCalc, c.sprints[len(c.sprints)-1].size))
}

return int(count + zeroth(startCalc, c.sprints[len(c.sprints)-1].size) + (to-startCalc)/c.sprints[len(c.sprints)-1].size)
}

func (c *BorConfig) CalculateBackupMultiplier(number uint64) uint64 {
Expand Down Expand Up @@ -560,6 +617,39 @@ func sortMapKeys(m map[string]uint64) []string {
return keys
}

type sprint struct {
from, size uint64
}

type sprints []sprint

func (s sprints) Len() int {
return len(s)
}

func (s sprints) Swap(i, j int) {
s[i], s[j] = s[j], s[i]
}

func (s sprints) Less(i, j int) bool {
return s[i].from < s[j].from
}

func asSprints(configSprints map[string]uint64) sprints {
sprints := make(sprints, len(configSprints))

i := 0
for key, value := range configSprints {
sprints[i].from, _ = strconv.ParseUint(key, 10, 64)
sprints[i].size = value
i++
}

sort.Sort(sprints)

return sprints
}

// Rules is syntactic sugar over Config. It can be used for functions
// that do not have or require information about the block.
//
Expand Down
24 changes: 0 additions & 24 deletions chain/protocol_param.go

This file was deleted.

25 changes: 12 additions & 13 deletions commitment/bin_patricia_hashed.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func binToCompact(bin []byte) []byte {
binary.BigEndian.PutUint16(compact, uint16(len(bin)))
for i := 0; i < len(bin); i++ {
if bin[i] != 0 {
compact[2+i/8] |= (byte(1) << (i % 8))
compact[2+i/8] |= byte(1) << (i % 8)
}
}
return compact
Expand Down Expand Up @@ -804,10 +804,9 @@ func (bph *BinPatriciaHashed) needUnfolding(hashedKey []byte) int {
if cell.hl == 0 {
// cell is empty, no need to unfold further
return 0
} else {
// unfold branch node
return 1
}
// unfold branch node
return 1
}
cpl := commonPrefixLen(hashedKey[depth:], cell.downHashedKey[:cell.downHashedLen-1])
if bph.trace {
Expand Down Expand Up @@ -1028,11 +1027,11 @@ func (bph *BinPatriciaHashed) fold() (branchData BranchData, updateKey []byte, e
} else if upDepth == halfKeySize {
// Special case - all storage items of an account have been deleted, but it does not automatically delete the account, just makes it empty storage
// Therefore we are not propagating deletion upwards, but turn it into a modification
bph.touchMap[row-1] |= (uint16(1) << col)
bph.touchMap[row-1] |= uint16(1) << col
} else {
// Deletion is propagated upwards
bph.touchMap[row-1] |= (uint16(1) << col)
bph.afterMap[row-1] &^= (uint16(1) << col)
bph.touchMap[row-1] |= uint16(1) << col
bph.afterMap[row-1] &^= uint16(1) << col
}
}
upBinaryCell.hl = 0
Expand Down Expand Up @@ -1060,7 +1059,7 @@ func (bph *BinPatriciaHashed) fold() (branchData BranchData, updateKey []byte, e
bph.rootTouched = true
} else {
// Modifiction is propagated upwards
bph.touchMap[row-1] |= (uint16(1) << col)
bph.touchMap[row-1] |= uint16(1) << col
}
}
nibble := bits.TrailingZeros16(bph.afterMap[row])
Expand Down Expand Up @@ -1089,7 +1088,7 @@ func (bph *BinPatriciaHashed) fold() (branchData BranchData, updateKey []byte, e
bph.rootTouched = true
} else {
// Modifiction is propagated upwards
bph.touchMap[row-1] |= (uint16(1) << col)
bph.touchMap[row-1] |= uint16(1) << col
}
}
bitmap := bph.touchMap[row] & bph.afterMap[row]
Expand Down Expand Up @@ -1212,8 +1211,8 @@ func (bph *BinPatriciaHashed) deleteBinaryCell(hashedKey []byte) {
cell = &bph.grid[row][col]
if bph.afterMap[row]&(uint16(1)<<col) != 0 {
// Prevent "spurios deletions", i.e. deletion of absent items
bph.touchMap[row] |= (uint16(1) << col)
bph.afterMap[row] &^= (uint16(1) << col)
bph.touchMap[row] |= uint16(1) << col
bph.afterMap[row] &^= uint16(1) << col
if bph.trace {
fmt.Printf("deleteBinaryCell setting (%d, %x)\n", row, col)
}
Expand All @@ -1240,8 +1239,8 @@ func (bph *BinPatriciaHashed) updateBinaryCell(plainKey, hashedKey []byte) *Bina
depth = bph.depths[row]
col = int(hashedKey[bph.currentKeyLen])
cell = &bph.grid[row][col]
bph.touchMap[row] |= (uint16(1) << col)
bph.afterMap[row] |= (uint16(1) << col)
bph.touchMap[row] |= uint16(1) << col
bph.afterMap[row] |= uint16(1) << col
if bph.trace {
fmt.Printf("updateBinaryCell setting (%d, %x), depth=%d\n", row, col, depth)
}
Expand Down
5 changes: 2 additions & 3 deletions commitment/hex_patricia_hashed.go
Original file line number Diff line number Diff line change
Expand Up @@ -780,10 +780,9 @@ func (hph *HexPatriciaHashed) needUnfolding(hashedKey []byte) int {
if cell.hl == 0 {
// cell is empty, no need to unfold further
return 0
} else {
// unfold branch node
return 1
}
// unfold branch node
return 1
}
cpl := commonPrefixLen(hashedKey[depth:], cell.downHashedKey[:cell.downHashedLen-1])
if hph.trace {
Expand Down
9 changes: 8 additions & 1 deletion common/background/progress.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,14 @@ func (s *ProgressSet) String() string {
var sb strings.Builder
var i int
s.list.Scan(func(_ int, p *Progress) bool {
sb.WriteString(fmt.Sprintf("%s=%d%%", *p.Name.Load(), p.percent()))
if p == nil {
return true
}
namePtr := p.Name.Load()
if namePtr == nil {
return true
}
sb.WriteString(fmt.Sprintf("%s=%d%%", *namePtr, p.percent()))
i++
if i != s.list.Len() {
sb.WriteString(", ")
Expand Down
2 changes: 2 additions & 0 deletions common/dbg/leak_detector.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"github.com/ledgerwatch/log/v3"
)

const FileCloseLogLevel = log.LvlTrace

// LeakDetector - use it to find which resource was created but not closed (leaked)
// periodically does print in logs resources which living longer than 1min with their creation stack trace
// For example db transactions can call Add/Del from Begin/Commit/Rollback methods
Expand Down
10 changes: 9 additions & 1 deletion common/fixedgas/protocol.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2021 Erigon contributors
Copyright 2021 The Erigon contributors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -158,4 +158,12 @@ const (
// EIP-3860 to limit size of initcode
MaxInitCodeSize = 2 * MaxCodeSize // Maximum initcode to permit in a creation transaction and create instructions
InitCodeWordGas = 2

// EIP-4844: Shard Blob Transactions
FieldElementsPerBlob = 4096 // each field element is 32 bytes
BlobSize = FieldElementsPerBlob * 32
BlobGasPerBlob uint64 = 0x20000
TargetBlobGasPerBlock uint64 = 0x60000
MaxBlobGasPerBlock uint64 = 0xC0000
MaxBlobsPerBlock uint64 = MaxBlobGasPerBlock / BlobGasPerBlob
)
Loading
Loading