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 alpha2 #471

Merged
merged 209 commits into from
Aug 7, 2024
Merged

Upstream alpha2 #471

merged 209 commits into from
Aug 7, 2024

Conversation

blxdyx
Copy link
Collaborator

@blxdyx blxdyx commented Aug 7, 2024

Upstream erigon3 alpha2

AskAlexSharov and others added 30 commits July 13, 2024 10:24
…ine (erigontech#11137)

reason: 
- we already have 1 goroutine for saving data:
```
func (d *DiagnosticClient) runSaveProcess(rootCtx context.Context) {
	ticker := time.NewTicker(5 * time.Minute)
	go func() {
		for {
			select {
			case <-ticker.C:
				d.SaveData()
			case <-rootCtx.Done():
				ticker.Stop()
				return
			}
		}
	}()
}
```
no reason to save it from one more goroutine. just save it right here -
in `case <-rootCtx.Done()` section. less concurrency - better.

rootContext already subscribed to sigterm
Co-authored-by: antonis19 <antonis19@users.noreply.github.com>
- attempt to upgrade speedtest - to fix race:
showwin/speedtest-go#109 (comment)

It didn't help. Created:
showwin/speedtest-go#223

I see: 
```
==================
WARNING: DATA RACE
Write at 0x00c2167c2088 by goroutine 70275:
  github.com/showwin/speedtest-go/speedtest.(*TestDirection).Start.func1.1()
      /home/ubuntu/go/pkg/mod/github.com/showwin/speedtest-go@v1.7.5/speedtest/data_manager.go:203 +0x84
  sync.(*Once).doSlow()
      /usr/local/go/src/sync/once.go:74 +0xf0
  sync.(*Once).Do()
      /usr/local/go/src/sync/once.go:65 +0x44
  github.com/showwin/speedtest-go/speedtest.(*TestDirection).Start.func1()
      /home/ubuntu/go/pkg/mod/github.com/showwin/speedtest-go@v1.7.5/speedtest/data_manager.go:200 +0xb1

Previous read at 0x00c2167c2088 by goroutine 69927:
  github.com/showwin/speedtest-go/speedtest.(*DataChunk).Read()
      /home/ubuntu/go/pkg/mod/github.com/showwin/speedtest-go@v1.7.5/speedtest/data_manager.go:452 +0x64
  io.(*nopCloser).Read()
      <autogenerated>:1 +0x6c
  io.(*LimitedReader).Read()
      /usr/local/go/src/io/io.go:479 +0xc5
  io.copyBuffer()
      /usr/local/go/src/io/io.go:429 +0x29a
  io.Copy()
      /usr/local/go/src/io/io.go:388 +0x6f
  net.genericReadFrom()
      /usr/local/go/src/net/net.go:689 +0x12
  net.(*TCPConn).readFrom()
      /usr/local/go/src/net/tcpsock_posix.go:54 +0xc9
  net.(*TCPConn).ReadFrom()
      /usr/local/go/src/net/tcpsock.go:130 +0x64
  io.copyBuffer()
      /usr/local/go/src/io/io.go:415 +0x22e
  io.Copy()
      /usr/local/go/src/io/io.go:388 +0x95
  net/http.persistConnWriter.ReadFrom()
      /usr/local/go/src/net/http/transport.go:1824 +0x12
  bufio.(*Writer).ReadFrom()
      /usr/local/go/src/bufio/bufio.go:794 +0x2b0
  io.copyBuffer()
      /usr/local/go/src/io/io.go:415 +0x22e
  io.CopyBuffer()
      /usr/local/go/src/io/io.go:402 +0x8f
  net/http.(*transferWriter).doBodyCopy()
      /usr/local/go/src/net/http/transfer.go:416 +0x144
  net/http.(*transferWriter).writeBody()
      /usr/local/go/src/net/http/transfer.go:371 +0x75c
  net/http.(*Request).write()
      /usr/local/go/src/net/http/request.go:755 +0x1413
  net/http.(*persistConn).writeLoop()
      /usr/local/go/src/net/http/transport.go:2447 +0x379
  net/http.(*Transport).dialConn.gowrap3()
      /usr/local/go/src/net/http/transport.go:1800 +0x33

Goroutine 70275 (running) created at:
  github.com/showwin/speedtest-go/speedtest.(*TestDirection).rateCapture.func1()
      /home/ubuntu/go/pkg/mod/github.com/showwin/speedtest-go@v1.7.5/speedtest/data_manager.go:267 +0x3ef
  github.com/showwin/speedtest-go/speedtest.(*TestDirection).rateCapture.gowrap1()
      /home/ubuntu/go/pkg/mod/github.com/showwin/speedtest-go@v1.7.5/speedtest/data_manager.go:279 +0x41

Goroutine 69927 (running) created at:
  net/http.(*Transport).dialConn()
      /usr/local/go/src/net/http/transport.go:1800 +0x27fe
  net/http.(*Transport).dialConnFor()
      /usr/local/go/src/net/http/transport.go:1485 +0x124
  net/http.(*Transport).queueForDial.gowrap1()
      /usr/local/go/src/net/http/transport.go:1449 +0x44
==================

==================
WARNING: DATA RACE
Write at 0x00c2167c2088 by goroutine 63832:
  github.com/showwin/speedtest-go/speedtest.(*TestDirection).Start.func1.1()
      /home/ubuntu/go/pkg/mod/github.com/showwin/speedtest-go@v1.7.5/speedtest/data_manager.go:203 +0x84
  sync.(*Once).doSlow()
      /usr/local/go/src/sync/once.go:74 +0xf0
  sync.(*Once).Do()
      /usr/local/go/src/sync/once.go:65 +0x44
  github.com/showwin/speedtest-go/speedtest.(*TestDirection).Start.func1()
      /home/ubuntu/go/pkg/mod/github.com/showwin/speedtest-go@v1.7.5/speedtest/data_manager.go:200 +0xb1

Previous read at 0x00c2167c2088 by goroutine 57836:
  github.com/showwin/speedtest-go/speedtest.(*DataChunk).DownloadHandler()
      /home/ubuntu/go/pkg/mod/github.com/showwin/speedtest-go@v1.7.5/speedtest/data_manager.go:408 +0x3ee
  github.com/showwin/speedtest-go/speedtest.downloadRequest()
      /home/ubuntu/go/pkg/mod/github.com/showwin/speedtest-go@v1.7.5/speedtest/request.go:183 +0x624
  github.com/showwin/speedtest-go/speedtest.(*Server).downloadTestContext.func1()
      /home/ubuntu/go/pkg/mod/github.com/showwin/speedtest-go@v1.7.5/speedtest/request.go:119 +0x85
  github.com/showwin/speedtest-go/speedtest.(*TestDirection).Start.func2()
      /home/ubuntu/go/pkg/mod/github.com/showwin/speedtest-go@v1.7.5/speedtest/data_manager.go:218 +0xca

Goroutine 63832 (running) created at:
  time.goFunc()
      /usr/local/go/src/time/sleep.go:177 +0x44

Goroutine 57836 (running) created at:
  github.com/showwin/speedtest-go/speedtest.(*TestDirection).Start()
      /home/ubuntu/go/pkg/mod/github.com/showwin/speedtest-go@v1.7.5/speedtest/data_manager.go:212 +0x70a
  github.com/showwin/speedtest-go/speedtest.(*Server).downloadTestContext()
      /home/ubuntu/go/pkg/mod/github.com/showwin/speedtest-go@v1.7.5/speedtest/request.go:122 +0x2e8
  github.com/showwin/speedtest-go/speedtest.(*Server).DownloadTestContext()
      /home/ubuntu/go/pkg/mod/github.com/showwin/speedtest-go@v1.7.5/speedtest/request.go:109 +0x1ee
  github.com/ledgerwatch/erigon-lib/diagnostics.(*DiagnosticClient).runSpeedTest()
      /home/ubuntu/erigon/erigon-lib/diagnostics/speedtest.go:66 +0x1d2
  github.com/ledgerwatch/erigon-lib/diagnostics.(*DiagnosticClient).setupSpeedtestDiagnostics.func1()
      /home/ubuntu/erigon/erigon-lib/diagnostics/speedtest.go:35 +0xf2
==================
==================
WARNING: DATA RACE
Write at 0x00c2167c2068 by goroutine 63836:
  github.com/showwin/speedtest-go/speedtest.(*DataChunk).UploadHandler()
      /home/ubuntu/go/pkg/mod/github.com/showwin/speedtest-go@v1.7.5/speedtest/data_manager.go:440 +0x247
  github.com/showwin/speedtest-go/speedtest.uploadRequest()
      /home/ubuntu/go/pkg/mod/github.com/showwin/speedtest-go@v1.7.5/speedtest/request.go:188 +0x113
  github.com/showwin/speedtest-go/speedtest.(*Server).uploadTestContext.func1()
      /home/ubuntu/go/pkg/mod/github.com/showwin/speedtest-go@v1.7.5/speedtest/request.go:150 +0x85
  github.com/showwin/speedtest-go/speedtest.(*TestDirection).Start.func2()
      /home/ubuntu/go/pkg/mod/github.com/showwin/speedtest-go@v1.7.5/speedtest/data_manager.go:218 +0xca

Previous read at 0x00c2167c2068 by goroutine 63840:
  github.com/showwin/speedtest-go/speedtest.(*DataChunk).UploadHandler()
      /home/ubuntu/go/pkg/mod/github.com/showwin/speedtest-go@v1.7.5/speedtest/data_manager.go:438 +0x179
  github.com/showwin/speedtest-go/speedtest.uploadRequest()
      /home/ubuntu/go/pkg/mod/github.com/showwin/speedtest-go@v1.7.5/speedtest/request.go:188 +0x113
  github.com/showwin/speedtest-go/speedtest.(*Server).uploadTestContext.func1()
      /home/ubuntu/go/pkg/mod/github.com/showwin/speedtest-go@v1.7.5/speedtest/request.go:150 +0x85
  github.com/showwin/speedtest-go/speedtest.(*TestDirection).Start.func2()
      /home/ubuntu/go/pkg/mod/github.com/showwin/speedtest-go@v1.7.5/speedtest/data_manager.go:218 +0xca

Goroutine 63836 (running) created at:
  github.com/showwin/speedtest-go/speedtest.(*TestDirection).Start()
      /home/ubuntu/go/pkg/mod/github.com/showwin/speedtest-go@v1.7.5/speedtest/data_manager.go:212 +0x70a
  github.com/showwin/speedtest-go/speedtest.(*Server).uploadTestContext()
      /home/ubuntu/go/pkg/mod/github.com/showwin/speedtest-go@v1.7.5/speedtest/request.go:153 +0x2e8
  github.com/showwin/speedtest-go/speedtest.(*Server).UploadTestContext()
      /home/ubuntu/go/pkg/mod/github.com/showwin/speedtest-go@v1.7.5/speedtest/request.go:140 +0x25c
  github.com/ledgerwatch/erigon-lib/diagnostics.(*DiagnosticClient).runSpeedTest()
      /home/ubuntu/erigon/erigon-lib/diagnostics/speedtest.go:71 +0x240
  github.com/ledgerwatch/erigon-lib/diagnostics.(*DiagnosticClient).setupSpeedtestDiagnostics.func1()
      /home/ubuntu/erigon/erigon-lib/diagnostics/speedtest.go:35 +0xf2

Goroutine 63840 (running) created at:
  github.com/showwin/speedtest-go/speedtest.(*TestDirection).Start()
      /home/ubuntu/go/pkg/mod/github.com/showwin/speedtest-go@v1.7.5/speedtest/data_manager.go:212 +0x70a
  github.com/showwin/speedtest-go/speedtest.(*Server).uploadTestContext()
      /home/ubuntu/go/pkg/mod/github.com/showwin/speedtest-go@v1.7.5/speedtest/request.go:153 +0x2e8
  github.com/showwin/speedtest-go/speedtest.(*Server).UploadTestContext()
      /home/ubuntu/go/pkg/mod/github.com/showwin/speedtest-go@v1.7.5/speedtest/request.go:140 +0x25c
  github.com/ledgerwatch/erigon-lib/diagnostics.(*DiagnosticClient).runSpeedTest()
      /home/ubuntu/erigon/erigon-lib/diagnostics/speedtest.go:71 +0x240
  github.com/ledgerwatch/erigon-lib/diagnostics.(*DiagnosticClient).setupSpeedtestDiagnostics.func1()
      /home/ubuntu/erigon/erigon-lib/diagnostics/speedtest.go:35 +0xf2
==================
==================
WARNING: DATA RACE
Write at 0x00c2167c2068 by goroutine 63840:
  github.com/showwin/speedtest-go/speedtest.(*DataChunk).UploadHandler()
      /home/ubuntu/go/pkg/mod/github.com/showwin/speedtest-go@v1.7.5/speedtest/data_manager.go:440 +0x247
  github.com/showwin/speedtest-go/speedtest.uploadRequest()
      /home/ubuntu/go/pkg/mod/github.com/showwin/speedtest-go@v1.7.5/speedtest/request.go:188 +0x113
  github.com/showwin/speedtest-go/speedtest.(*Server).uploadTestContext.func1()
      /home/ubuntu/go/pkg/mod/github.com/showwin/speedtest-go@v1.7.5/speedtest/request.go:150 +0x85
  github.com/showwin/speedtest-go/speedtest.(*TestDirection).Start.func2()
      /home/ubuntu/go/pkg/mod/github.com/showwin/speedtest-go@v1.7.5/speedtest/data_manager.go:218 +0xca

Previous write at 0x00c2167c2068 by goroutine 63835:
  github.com/showwin/speedtest-go/speedtest.(*DataChunk).UploadHandler()
      /home/ubuntu/go/pkg/mod/github.com/showwin/speedtest-go@v1.7.5/speedtest/data_manager.go:440 +0x247
  github.com/showwin/speedtest-go/speedtest.uploadRequest()
      /home/ubuntu/go/pkg/mod/github.com/showwin/speedtest-go@v1.7.5/speedtest/request.go:188 +0x113
  github.com/showwin/speedtest-go/speedtest.(*Server).uploadTestContext.func1()
      /home/ubuntu/go/pkg/mod/github.com/showwin/speedtest-go@v1.7.5/speedtest/request.go:150 +0x85
  github.com/showwin/speedtest-go/speedtest.(*TestDirection).Start.func2()
      /home/ubuntu/go/pkg/mod/github.com/showwin/speedtest-go@v1.7.5/speedtest/data_manager.go:218 +0xca

Goroutine 63840 (running) created at:
  github.com/showwin/speedtest-go/speedtest.(*TestDirection).Start()
      /home/ubuntu/go/pkg/mod/github.com/showwin/speedtest-go@v1.7.5/speedtest/data_manager.go:212 +0x70a
  github.com/showwin/speedtest-go/speedtest.(*Server).uploadTestContext()
      /home/ubuntu/go/pkg/mod/github.com/showwin/speedtest-go@v1.7.5/speedtest/request.go:153 +0x2e8
  github.com/showwin/speedtest-go/speedtest.(*Server).UploadTestContext()
      /home/ubuntu/go/pkg/mod/github.com/showwin/speedtest-go@v1.7.5/speedtest/request.go:140 +0x25c
  github.com/ledgerwatch/erigon-lib/diagnostics.(*DiagnosticClient).runSpeedTest()
      /home/ubuntu/erigon/erigon-lib/diagnostics/speedtest.go:71 +0x240
  github.com/ledgerwatch/erigon-lib/diagnostics.(*DiagnosticClient).setupSpeedtestDiagnostics.func1()
      /home/ubuntu/erigon/erigon-lib/diagnostics/speedtest.go:35 +0xf2

Goroutine 63835 (running) created at:
  github.com/showwin/speedtest-go/speedtest.(*TestDirection).Start()
      /home/ubuntu/go/pkg/mod/github.com/showwin/speedtest-go@v1.7.5/speedtest/data_manager.go:212 +0x70a
  github.com/showwin/speedtest-go/speedtest.(*Server).uploadTestContext()
      /home/ubuntu/go/pkg/mod/github.com/showwin/speedtest-go@v1.7.5/speedtest/request.go:153 +0x2e8
  github.com/showwin/speedtest-go/speedtest.(*Server).UploadTestContext()
      /home/ubuntu/go/pkg/mod/github.com/showwin/speedtest-go@v1.7.5/speedtest/request.go:140 +0x25c
  github.com/ledgerwatch/erigon-lib/diagnostics.(*DiagnosticClient).runSpeedTest()
      /home/ubuntu/erigon/erigon-lib/diagnostics/speedtest.go:71 +0x240
  github.com/ledgerwatch/erigon-lib/diagnostics.(*DiagnosticClient).setupSpeedtestDiagnostics.func1()
      /home/ubuntu/erigon/erigon-lib/diagnostics/speedtest.go:35 +0xf2
==================
==================
WARNING: DATA RACE
Read at 0x00c2167c2100 by goroutine 63833:
  github.com/showwin/speedtest-go/speedtest.(*TestDirection).rateCapture.func1()
      /home/ubuntu/go/pkg/mod/github.com/showwin/speedtest-go@v1.7.5/speedtest/data_manager.go:258 +0x1c6
  github.com/showwin/speedtest-go/speedtest.(*TestDirection).rateCapture.gowrap1()
      /home/ubuntu/go/pkg/mod/github.com/showwin/speedtest-go@v1.7.5/speedtest/data_manager.go:279 +0x41

Previous write at 0x00c2167c2100 by goroutine 63888:
  sync/atomic.AddInt64()
      /usr/local/go/src/runtime/race_amd64.s:289 +0xb
  sync/atomic.AddInt64()
      <autogenerated>:1 +0x15
  io.(*nopCloser).Read()
      <autogenerated>:1 +0x6c
  io.(*LimitedReader).Read()
      /usr/local/go/src/io/io.go:479 +0xc5
  io.copyBuffer()
      /usr/local/go/src/io/io.go:429 +0x29a
  io.Copy()
      /usr/local/go/src/io/io.go:388 +0x6f
  net.genericReadFrom()
      /usr/local/go/src/net/net.go:689 +0x12
  net.(*TCPConn).readFrom()
      /usr/local/go/src/net/tcpsock_posix.go:54 +0xc9
  net.(*TCPConn).ReadFrom()
      /usr/local/go/src/net/tcpsock.go:130 +0x64
  io.copyBuffer()
      /usr/local/go/src/io/io.go:415 +0x22e
  io.Copy()
      /usr/local/go/src/io/io.go:388 +0x95
  net/http.persistConnWriter.ReadFrom()
      /usr/local/go/src/net/http/transport.go:1824 +0x12
  bufio.(*Writer).ReadFrom()
      /usr/local/go/src/bufio/bufio.go:794 +0x2b0
  io.copyBuffer()
      /usr/local/go/src/io/io.go:415 +0x22e
  io.CopyBuffer()
      /usr/local/go/src/io/io.go:402 +0x8f
  net/http.(*transferWriter).doBodyCopy()
      /usr/local/go/src/net/http/transfer.go:416 +0x144
  net/http.(*transferWriter).writeBody()
      /usr/local/go/src/net/http/transfer.go:371 +0x75c
  net/http.(*Request).write()
      /usr/local/go/src/net/http/request.go:755 +0x1413
  net/http.(*persistConn).writeLoop()
      /usr/local/go/src/net/http/transport.go:2447 +0x379
  net/http.(*Transport).dialConn.gowrap3()
      /usr/local/go/src/net/http/transport.go:1800 +0x33

Goroutine 63833 (running) created at:
  github.com/showwin/speedtest-go/speedtest.(*TestDirection).rateCapture()
      /home/ubuntu/go/pkg/mod/github.com/showwin/speedtest-go@v1.7.5/speedtest/data_manager.go:253 +0x464
  github.com/showwin/speedtest-go/speedtest.(*TestDirection).Start()
      /home/ubuntu/go/pkg/mod/github.com/showwin/speedtest-go@v1.7.5/speedtest/data_manager.go:195 +0x4a4
  github.com/showwin/speedtest-go/speedtest.(*Server).uploadTestContext()
      /home/ubuntu/go/pkg/mod/github.com/showwin/speedtest-go@v1.7.5/speedtest/request.go:153 +0x2e8
  github.com/showwin/speedtest-go/speedtest.(*Server).UploadTestContext()
      /home/ubuntu/go/pkg/mod/github.com/showwin/speedtest-go@v1.7.5/speedtest/request.go:140 +0x25c
  github.com/ledgerwatch/erigon-lib/diagnostics.(*DiagnosticClient).runSpeedTest()
      /home/ubuntu/erigon/erigon-lib/diagnostics/speedtest.go:71 +0x240
  github.com/ledgerwatch/erigon-lib/diagnostics.(*DiagnosticClient).setupSpeedtestDiagnostics.func1()
      /home/ubuntu/erigon/erigon-lib/diagnostics/speedtest.go:35 +0xf2

Goroutine 63888 (running) created at:
  net/http.(*Transport).dialConn()
      /usr/local/go/src/net/http/transport.go:1800 +0x27fe
  net/http.(*Transport).dialConnFor()
      /usr/local/go/src/net/http/transport.go:1485 +0x124
  net/http.(*Transport).queueForDial.gowrap1()
      /usr/local/go/src/net/http/transport.go:1449 +0x44
==================
```
- also i don't understand why do we need cached client object
erigontech#10259
- no behavior changes
- move encbuffer and encreader to `encbuffer.go`
- copy-paste rlpgen package
```
==================
WARNING: DATA RACE
Write at 0x00c015bf2208 by goroutine 110:
  github.com/ledgerwatch/erigon/polygon/bor/finality/whitelist.(*milestone).RemoveMilestoneID()
      /home/ubuntu/erigon/polygon/bor/finality/whitelist/milestone.go:190 +0x164
  github.com/ledgerwatch/erigon/polygon/bor/finality.handleNoAckMilestone()
      /home/ubuntu/erigon/polygon/bor/finality/whitelist.go:237 +0x12c
  github.com/ledgerwatch/erigon/polygon/bor/finality.retryHeimdallHandler()
      /home/ubuntu/erigon/polygon/bor/finality/whitelist.go:159 +0x5c4
  github.com/ledgerwatch/erigon/polygon/bor/finality.RetryHeimdallHandler()
      /home/ubuntu/erigon/polygon/bor/finality/whitelist.go:117 +0x57
  github.com/ledgerwatch/erigon/polygon/bor/finality.startNoAckMilestoneService()
      /home/ubuntu/erigon/polygon/bor/finality/whitelist.go:102 +0x2a
  github.com/ledgerwatch/erigon/polygon/bor/finality.Whitelist.gowrap3()
      /home/ubuntu/erigon/polygon/bor/finality/whitelist.go:65 +0x17

Previous read at 0x00c015bf2208 by goroutine 109:
  github.com/ledgerwatch/erigon/polygon/bor/finality/whitelist.(*milestone).ProcessFutureMilestone()
      /home/ubuntu/erigon/polygon/bor/finality/whitelist/milestone.go:277 +0x166
  github.com/ledgerwatch/erigon/polygon/bor/finality.handleMilestone()
      /home/ubuntu/erigon/polygon/bor/finality/whitelist.go:208 +0x1e5
  github.com/ledgerwatch/erigon/polygon/bor/finality.retryHeimdallHandler()
      /home/ubuntu/erigon/polygon/bor/finality/whitelist.go:159 +0x5c4
  github.com/ledgerwatch/erigon/polygon/bor/finality.RetryHeimdallHandler()
      /home/ubuntu/erigon/polygon/bor/finality/whitelist.go:117 +0x5c
  github.com/ledgerwatch/erigon/polygon/bor/finality.startMilestoneWhitelistService()
      /home/ubuntu/erigon/polygon/bor/finality/whitelist.go:93 +0x2a
  github.com/ledgerwatch/erigon/polygon/bor/finality.Whitelist.gowrap2()
      /home/ubuntu/erigon/polygon/bor/finality/whitelist.go:64 +0x17
```
…ech#11141)

they was vendored because of go1.19 compatibility which we dropped
updating to version
[devnet-1@v1.3.0](https://github.com/ethereum/execution-spec-tests/releases/tag/devnet-1%40v1.3.0)

- update to 7702: some extra json fields displayed in fixtures (rather
than just rlps)
- some refactoring to fixture json ordering means that a huge number of
test files were changed
- [refactor
requested](erigontech#10812 (comment))
by Alex done in this pr
[here](https://github.com/ledgerwatch/erigon/pull/11127/files#diff-8c398ef0a79f97ba6d497a99247a815b3a51918de9e16954215b6073f907c92e).
Signed-off-by: stellrust <gohunter@foxmail.com>
Refactor to pattern which was suggested by @AskAlexSharov 

- move business-logic inside private methods
- move mutex locking inside public methods
- call private methods from public. don't call public methods from
private.
closes erigontech#10320 and closes erigontech#11014

---------

Co-authored-by: JkLondon <ilya@mikheev.fun>
Co-authored-by: alex.sharov <AskAlexSharov@gmail.com>
…f Goroutines (erigontech#11058)

Optimizations:

1) Single goroutine for tracking expiry of gossip subscriptions
2) tweaking of parameters on operations retention in cache
3) moving the dumping of BeaconState after forkchoice, so that we do not
mess up block times with I/O
Actually look for peers of needed subnet for better performance on
holesky and mainnet

---------

Co-authored-by: Kewei <kewei.train@gmail.com>
AskAlexSharov and others added 27 commits August 3, 2024 11:12
use it in `SimulatedBackend` and `TestFeeHistory`
Hi, I'm diving into the merkle tree calculation step and thanks for such
a detailed doc in `guide.md`, it is very helpful for understanding the
entire process.

I found a logical error in the article that could mislead others'
understanding, so I hope to help Erigon fix it.
I found the [corresponding
position](https://github.com/erigontech/erigon/blob/main/turbo/trie/gen_struct_step.go#L270)
in the code and proved that only the case of 'less' will cause a prefix
group closing, while the original' equal 'will not cause it.
Co-authored-by: Kewei <kewei.train@gmail.com>
closes erigontech#11453

Co-authored-by: JkLondon <ilya@mikheev.fun>
Custom chains started using `init` may put nil genesis here. I am
working on a design fix for this, but this PR will prevent a panic
Fixes the following issue:
This function is invoked regardless of the chain being known. For custom
chains with `init` command, the network name is blank and this panic is
triggered on restarting the node
…ech#11339)

part of erigontech#11032

adds 2 new types and corresponding logic:
- `SpanBlockProducerSelection` - explanation can be found in the doc
string
- `spanBlockProducersTracker` - in high-level: it is an internal
component of the heimdall service which registers for span updates. It
accumulates the block producer priorities from span 0 to latest and
persists them in the heimdall db (or in the stage loop db if run as part
of the stage loop integration mode). Provides a `Producers(blockNum)`
API which returns correct accumulated producer priorities.

In subsequent PRs, I will start using the new `Producers(blockNum)` API
in the Astrid chain tip mode (PR
erigontech#11499) and also add unit tests
(PR erigontech#11426) for the entire
heimdall service.
part of erigontech#11032

Fixes "block too soon error" which was due to incorrectly calculated
block producer priorities.
```
DBUG[08-06|13:31:23.898] [sync] onNewBlockEvent: couldn't connect a header to the local chain tip, ignoring err="canonicalChainBuilder.Connect: invalid header error Block 10391894 was created too soon. Signer turn-ness number is 2\n"
```

Removes `SpansCache` in favour of `heimdallService.Producers` which
returns correct producer priorities.
Simplifies PatriciaContext interface: return state Update instead of
filling the Cell is more general and allows other trie implementation
follow that interface without converting their inner representation of
Cell/Node/etc.

Slightly reduces code complexity as now Cell has state part (Update) and
intrinsic parts (lens and other unexproted fields like
apk/spk/downHashedKey).

Finally that allows us as of next step to remove batch of `Process*`
functions and keep just `Process(context.Context, updates *Updates,
logPrefix string) ([]byte, error)`. In that case `Updates.mode` only
will decide if need to collect `Update` during execution or not. In
general, we don't really need keep Update close to key because it's
already in `SharedDomains` if it's just a regular exec.
Part of erigontech#11149
Teku vc is able to work properly with this pr.
 
known issue: teku's event source client periodically disconnects, but vc
is still can well work
event to be added:
block_gossip
chain_reorg
light_client_finality_update
light_client_optimistic_update
payload_attributes
# Conflicts:
#	.github/workflows/ci.yml
#	.github/workflows/release.yml
#	.goreleaser.yml
#	Makefile
#	README.md
#	accounts/abi/bind/backends/simulated.go
#	cl/beacon/beaconevents/emitter_test.go
#	cl/beacon/handler/events.go
#	cl/beacon/handler/handler.go
#	cl/beacon/handler/utils_test.go
#	cl/beacon/handler/validators.go
#	cl/cltypes/beacon_block_blinded.go
#	cl/cltypes/solid/hash_list.go
#	cl/cltypes/solid/uint64_vector.go
#	cl/cltypes/solid/uint64slice_byte.go
#	cl/phase1/core/checkpoint.go
#	cl/phase1/core/rawdb/config.go
#	cl/phase1/core/state/raw/hashing.go
#	cl/phase1/forkchoice/fork_graph/fork_graph_disk.go
#	cl/phase1/forkchoice/utils.go
#	cl/phase1/network/beacon_downloader.go
#	cl/phase1/network/services/attestation_service.go
#	cl/phase1/network/services/attestation_service_test.go
#	cl/phase1/network/services/blob_sidecar_service.go
#	cl/phase1/network/services/blob_sidecar_service_test.go
#	cl/phase1/network/services/block_service.go
#	cl/phase1/network/services/block_service_test.go
#	cl/phase1/network/services/proposer_slashing_service.go
#	cl/phase1/network/services/proposer_slashing_service_test.go
#	cl/phase1/stages/clstages.go
#	cmd/capcli/cli.go
#	cmd/caplin/caplin1/run.go
#	cmd/caplin/main.go
#	cmd/diag/main.go
#	cmd/evm/t8n_test.go
#	cmd/hack/hack.go
#	cmd/integration/commands/stages.go
#	cmd/release/go.mod
#	cmd/rpcdaemon/cli/config.go
#	cmd/rpcdaemon/main.go
#	cmd/sentinel/main.go
#	cmd/state/exec3/state_recon.go
#	consensus/misc/eip4844.go
#	core/chain_makers.go
#	core/genesis_write.go
#	core/rawdb/rawdbreset/reset_stages.go
#	core/snaptype/block_types.go
#	core/state/cached_reader.go
#	core/state/state_object.go
#	core/state/txtask.go
#	core/state_transition.go
#	core/system_contract_lookup.go
#	core/systemcontracts/upgrade.go
#	core/types/consolidation_request.go
#	core/types/deposit_request.go
#	core/types/withdrawal_request.go
#	core/vm/evm.go
#	diagnostics/snapshot_sync.go
#	docs/programmers_guide/dupsort.md
#	erigon-lib/chain/snapcfg/util.go
#	erigon-lib/commitment/bin_patricia_hashed.go
#	erigon-lib/commitment/bin_patricia_hashed_test.go
#	erigon-lib/commitment/commitment.go
#	erigon-lib/commitment/commitment_test.go
#	erigon-lib/commitment/hex_patricia_hashed.go
#	erigon-lib/commitment/hex_patricia_hashed_test.go
#	erigon-lib/diagnostics/entities.go
#	erigon-lib/diagnostics/snapshots.go
#	erigon-lib/downloader/downloader.go
#	erigon-lib/downloader/mdbx_piece_completion.go
#	erigon-lib/go.mod
#	erigon-lib/go.sum
#	erigon-lib/kv/helpers.go
#	erigon-lib/seg/decompress.go
#	erigon-lib/state/bps_tree.go
#	erigon-lib/state/domain.go
#	erigon-lib/state/domain_shared.go
#	erigon-lib/state/metrics.go
#	eth/backend.go
#	eth/ethconfig/config.go
#	eth/ethconfig/gen_config.go
#	eth/gasprice/feehistory_test.go
#	eth/gasprice/gasprice_test.go
#	eth/protocols/eth/handlers.go
#	eth/stagedsync/README.md
#	eth/stagedsync/exec3.go
#	eth/stagedsync/stage_bodies_test.go
#	eth/stagedsync/stage_bor_heimdall.go
#	eth/stagedsync/stage_call_traces.go
#	eth/stagedsync/stage_call_traces_test.go
#	eth/stagedsync/stage_headers.go
#	eth/stagedsync/stage_indexes.go
#	eth/stagedsync/stage_indexes_test.go
#	eth/stagedsync/stage_log_index.go
#	eth/stagedsync/stage_polygon_sync.go
#	eth/stagedsync/stage_senders.go
#	eth/stagedsync/sync_test.go
#	go.mod
#	go.sum
#	p2p/sentry/sentry_multi_client/sentry_multi_client.go
#	params/config.go
#	params/protocol_params.go
#	params/version.go
#	polygon/bor/bor.go
#	polygon/bor/fake.go
#	polygon/bor/valset/validator_set.go
#	polygon/bridge/bridge.go
#	polygon/bridge/bridge_test.go
#	polygon/bridge/db.go
#	polygon/bridge/service.go
#	polygon/heimdall/entity_store.go
#	polygon/heimdall/service.go
#	polygon/heimdall/service_store.go
#	polygon/polygoncommon/database.go
#	polygon/sync/block_producers_reader.go
#	polygon/sync/canonical_chain_builder_test.go
#	polygon/sync/difficulty.go
#	polygon/sync/difficulty_test.go
#	polygon/sync/execution_client.go
#	polygon/sync/header_time_validator.go
#	polygon/sync/heimdall_waypoints_fetcher.go
#	polygon/sync/heimdall_waypoints_fetcher_mock.go
#	polygon/sync/service.go
#	polygon/sync/spans_cache.go
#	polygon/sync/sync.go
#	polygon/sync/tip_events.go
#	rpc/server.go
#	tests/state_test_util.go
#	turbo/cli/flags.go
#	turbo/cmdtest/test_cmd.go
#	turbo/engineapi/engine_helpers/fork_validator.go
#	turbo/engineapi/engine_server.go
#	turbo/execution/eth1/block_building.go
#	turbo/execution/eth1/forkchoice.go
#	turbo/jsonrpc/daemon.go
#	turbo/jsonrpc/debug_api.go
#	turbo/jsonrpc/debug_api_test.go
#	turbo/jsonrpc/erigon_receipts.go
#	turbo/jsonrpc/eth_api.go
#	turbo/jsonrpc/eth_api_test.go
#	turbo/jsonrpc/eth_block.go
#	turbo/jsonrpc/eth_block_test.go
#	turbo/jsonrpc/eth_call.go
#	turbo/jsonrpc/eth_callMany_test.go
#	turbo/jsonrpc/eth_call_test.go
#	turbo/jsonrpc/eth_filters_test.go
#	turbo/jsonrpc/eth_mining_test.go
#	turbo/jsonrpc/eth_receipts.go
#	turbo/jsonrpc/gen_traces_test.go
#	turbo/jsonrpc/otterscan_transaction_by_sender_and_nonce_test.go
#	turbo/jsonrpc/parity_api_test.go
#	turbo/jsonrpc/receipts/receipts_generator.go
#	turbo/jsonrpc/send_transaction_test.go
#	turbo/jsonrpc/txpool_api_test.go
#	turbo/rpchelper/helper.go
#	turbo/snapshotsync/freezeblocks/block_snapshots.go
#	turbo/snapshotsync/freezeblocks/bor_snapshots.go
#	turbo/snapshotsync/snap/flags.go
#	turbo/snapshotsync/snapshotsync.go
#	turbo/stages/blockchain_test.go
#	turbo/stages/mock/mock_sentry.go
#	turbo/stages/stageloop.go
#	wmake.ps1
@setunapo setunapo merged commit afa66f1 into node-real:erigon3 Aug 7, 2024
1 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.