forked from ethereum/go-ethereum
-
Notifications
You must be signed in to change notification settings - Fork 281
feat: follower node sync from DA #631
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
Closed
Closed
Changes from 65 commits
Commits
Show all changes
73 commits
Select commit
Hold shift + click to select a range
4fe6c3a
implement l1rpcfetcher and prepare for implementing da_syncer
NazariiDenha 25bc860
finish da_syncer, add db access, small fixes
NazariiDenha deed82a
Merge branch 'develop' of github.com:scroll-tech/go-ethereum into fea…
NazariiDenha 635f744
fix lint
NazariiDenha 69d6c39
address comments
NazariiDenha 8bc5a6b
Merge branch 'develop' of github.com:scroll-tech/go-ethereum into fea…
NazariiDenha 2bef690
poc
NazariiDenha b6fc6dd
update poc, preprocess blocks before inserting to generate missing he…
NazariiDenha 794c251
Merge branch 'develop' of github.com:scroll-tech/go-ethereum into fea…
NazariiDenha 5f11287
refactor code to new design with pipeline
NazariiDenha 885bd3e
Merge branch 'develop' of github.com:scroll-tech/go-ethereum into fea…
NazariiDenha 6b9e837
adapt for codecv0 types
NazariiDenha c6201c3
prepare for blob dta asource
NazariiDenha 27a4e51
implement blob fethcer
NazariiDenha 6991da0
implement blob fethcer
NazariiDenha e483219
fixes after testing and add synced l1 height to db
NazariiDenha 48dd5d8
Merge branch 'feat/sync-directly-from-da' of github.com:scroll-tech/g…
NazariiDenha eb377fe
fixes and improvements after testing
NazariiDenha 5a48000
fixes and improvements after testing
NazariiDenha 01e5f9c
Merge branch 'feat/sync-directly-from-da' of github.com:scroll-tech/g…
NazariiDenha 1a84506
Merge branch 'develop' of github.com:scroll-tech/go-ethereum into fea…
NazariiDenha fd6d899
update codec version
NazariiDenha 9b929ff
lint
NazariiDenha 9b13959
update codec dependency
NazariiDenha 20ca22d
Merge branch 'develop' of github.com:scroll-tech/go-ethereum into fea…
NazariiDenha bf1d02e
goimports
NazariiDenha bc9b360
small fixes
NazariiDenha e55416e
fix lint, turn off handler, worker, miner during da syncing
NazariiDenha 1ff0973
remove comments
NazariiDenha b3726ff
support blocknative
NazariiDenha 6e0ccdb
fix
NazariiDenha cc65d00
Merge branch 'develop' of github.com:scroll-tech/go-ethereum into fea…
NazariiDenha 49c3c15
fix lint
NazariiDenha e825a42
fix bug with decoding [parentbatch
NazariiDenha 750c615
support codec v3
NazariiDenha e3ced13
Merge branch 'develop' of github.com:scroll-tech/go-ethereum into fea…
NazariiDenha cda4058
address comments
NazariiDenha f3a1c5d
fix: nil pointer when enabling --da.sync=true
jonastheis 2931099
fix: block not being inserted due to Clique verification
jonastheis 1c36c2c
refactor: compose DA types for more cohesion, maintainability and cod…
jonastheis e587c98
feat: execute blocks only once
jonastheis 9dc17cb
refactor: introduce partial header and partial block for data from DA…
jonastheis dbdbc88
minor cleanup
jonastheis 26dbf42
feat: fix issue with not specifying difficulty
jonastheis 0f8e35c
refactor: compose DA types for more cohesion, maintainability and cod…
jonastheis 912af16
feat: implement generic min heap
jonastheis bdb575d
feat: use generic min heap instead of map in BatchQueue
jonastheis 362d160
fix compile errors after rebase
jonastheis 329dd54
disable all p2p networking
NazariiDenha 15ec7c4
Merge branch 'develop' of github.com:scroll-tech/go-ethereum into fea…
NazariiDenha d958069
chore: auto version bump [bot]
NazariiDenha 69e1a9e
v3 finalization
NazariiDenha 0fd2a08
feat: add shrinking map that shrinks itself after a certain number of…
jonastheis 3f68f2c
feat: use shrinking map in batch queue to delete specific elements fr…
jonastheis 53bdb18
feat: execute blocks only once
jonastheis 5243d59
refactor: introduce partial header and partial block for data from DA…
jonastheis 7018b5b
minor cleanup
jonastheis fe33d83
feat: fix issue with not specifying difficulty
jonastheis d279e83
Merge remote-tracking branch 'origin/feat/sync-directly-from-da' into…
jonastheis d3ca47e
feat: implement simple pipeline reset (#941)
jonastheis 19ed11d
feat: remove changes to Clique as we're not verifying signatures when…
jonastheis a6461d5
feat: only request finalized block number when necessary
jonastheis 85bbc98
minor cleanup and comments
jonastheis 485c229
cycle over list of blob clients (#960)
NazariiDenha f8eadfe
Merge branch 'develop' into feat/sync-directly-from-da
0xmountaintop 399dcfc
feat: introduce custom errors and mark RPC related errors as temporar…
jonastheis 9e1769f
fix blob_client_list
NazariiDenha 0649954
chore: auto version bump [bot]
NazariiDenha 0b2fe3b
feat: enable prefetching in BuildAndWriteBlock
jonastheis 9e3c838
(follower_node)support beacon node client as blob provider (#988)
NazariiDenha 787c955
update codec version
NazariiDenha dcd9c5c
Merge branch 'develop' of github.com:scroll-tech/go-ethereum into fea…
NazariiDenha 4a66bf3
support codec v4
NazariiDenha File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package backoff | ||
|
||
import ( | ||
"math" | ||
"math/rand" | ||
"time" | ||
) | ||
|
||
// Exponential is a backoff strategy that increases the delay between retries exponentially. | ||
type Exponential struct { | ||
attempt int | ||
|
||
maxJitter time.Duration | ||
|
||
min time.Duration | ||
max time.Duration | ||
} | ||
|
||
func NewExponential(minimum, maximum, maxJitter time.Duration) *Exponential { | ||
return &Exponential{ | ||
min: minimum, | ||
max: maximum, | ||
maxJitter: maxJitter, | ||
} | ||
} | ||
|
||
func (e *Exponential) NextDuration() time.Duration { | ||
var jitter time.Duration | ||
if e.maxJitter > 0 { | ||
jitter = time.Duration(rand.Int63n(e.maxJitter.Nanoseconds())) | ||
} | ||
|
||
minFloat := float64(e.min) | ||
duration := math.Pow(2, float64(e.attempt)) * minFloat | ||
|
||
// limit at configured maximum | ||
if duration > float64(e.max) { | ||
duration = float64(e.max) | ||
} | ||
|
||
e.attempt++ | ||
return time.Duration(duration) + jitter | ||
} | ||
|
||
func (e *Exponential) Reset() { | ||
e.attempt = 0 | ||
} | ||
|
||
func (e *Exponential) Attempt() int { | ||
return e.attempt | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package backoff | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestExponentialBackoff(t *testing.T) { | ||
t.Run("Multiple attempts", func(t *testing.T) { | ||
e := NewExponential(100*time.Millisecond, 10*time.Second, 0) | ||
expectedDurations := []time.Duration{ | ||
100 * time.Millisecond, | ||
200 * time.Millisecond, | ||
400 * time.Millisecond, | ||
800 * time.Millisecond, | ||
1600 * time.Millisecond, | ||
3200 * time.Millisecond, | ||
6400 * time.Millisecond, | ||
10 * time.Second, // capped at max | ||
} | ||
for i, expected := range expectedDurations { | ||
require.Equal(t, expected, e.NextDuration(), "attempt %d", i) | ||
} | ||
}) | ||
|
||
t.Run("Jitter added", func(t *testing.T) { | ||
e := NewExponential(1*time.Second, 10*time.Second, 1*time.Second) | ||
duration := e.NextDuration() | ||
require.GreaterOrEqual(t, duration, 1*time.Second) | ||
require.Less(t, duration, 2*time.Second) | ||
}) | ||
|
||
t.Run("Edge case: min > max", func(t *testing.T) { | ||
e := NewExponential(10*time.Second, 5*time.Second, 0) | ||
require.Equal(t, 5*time.Second, e.NextDuration()) | ||
}) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
package common | ||
|
||
import ( | ||
"container/heap" | ||
) | ||
|
||
// Heap is a generic min-heap (or max-heap, depending on Comparable behavior) implementation. | ||
type Heap[T Comparable[T]] struct { | ||
heap innerHeap[T] | ||
} | ||
|
||
func NewHeap[T Comparable[T]]() *Heap[T] { | ||
return &Heap[T]{ | ||
heap: make(innerHeap[T], 0), | ||
} | ||
} | ||
|
||
func (h *Heap[T]) Len() int { | ||
return len(h.heap) | ||
} | ||
|
||
func (h *Heap[T]) Push(element T) *HeapElement[T] { | ||
heapElement := NewHeapElement(element) | ||
heap.Push(&h.heap, heapElement) | ||
|
||
return heapElement | ||
} | ||
|
||
func (h *Heap[T]) Pop() *HeapElement[T] { | ||
return heap.Pop(&h.heap).(*HeapElement[T]) | ||
} | ||
|
||
func (h *Heap[T]) Peek() *HeapElement[T] { | ||
if h.Len() == 0 { | ||
return nil | ||
} | ||
|
||
return h.heap[0] | ||
} | ||
|
||
func (h *Heap[T]) Remove(element *HeapElement[T]) { | ||
heap.Remove(&h.heap, element.index) | ||
} | ||
|
||
func (h *Heap[T]) Clear() { | ||
h.heap = make(innerHeap[T], 0) | ||
} | ||
|
||
type innerHeap[T Comparable[T]] []*HeapElement[T] | ||
|
||
func (h innerHeap[T]) Len() int { | ||
return len(h) | ||
} | ||
|
||
func (h innerHeap[T]) Less(i, j int) bool { | ||
return h[i].Value().CompareTo(h[j].Value()) < 0 | ||
} | ||
|
||
func (h innerHeap[T]) Swap(i, j int) { | ||
h[i], h[j] = h[j], h[i] | ||
h[i].index, h[j].index = i, j | ||
} | ||
|
||
func (h *innerHeap[T]) Push(x interface{}) { | ||
data := x.(*HeapElement[T]) | ||
*h = append(*h, data) | ||
data.index = len(*h) - 1 | ||
} | ||
|
||
func (h *innerHeap[T]) Pop() interface{} { | ||
n := len(*h) | ||
element := (*h)[n-1] | ||
(*h)[n-1] = nil // avoid memory leak | ||
*h = (*h)[:n-1] | ||
element.index = -1 | ||
|
||
return element | ||
} | ||
|
||
// Comparable is an interface for types that can be compared. | ||
type Comparable[T any] interface { | ||
// CompareTo compares x with other. | ||
// To create a min heap, return: | ||
// -1 if x < other | ||
// 0 if x == other | ||
// +1 if x > other | ||
// To create a max heap, return the opposite. | ||
CompareTo(other T) int | ||
} | ||
|
||
// HeapElement is a wrapper around the value stored in the heap. | ||
type HeapElement[T Comparable[T]] struct { | ||
value T | ||
index int | ||
} | ||
|
||
func NewHeapElement[T Comparable[T]](value T) *HeapElement[T] { | ||
return &HeapElement[T]{ | ||
value: value, | ||
} | ||
} | ||
|
||
func (h *HeapElement[T]) Value() T { | ||
return h.value | ||
} | ||
|
||
func (h *HeapElement[T]) Index() int { | ||
return h.index | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package common | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
type Int int | ||
|
||
func (i Int) CompareTo(other Int) int { | ||
if i < other { | ||
return -1 | ||
} else if i > other { | ||
return 1 | ||
} else { | ||
return 0 | ||
} | ||
} | ||
|
||
func TestHeap(t *testing.T) { | ||
h := NewHeap[Int]() | ||
|
||
require.Equal(t, 0, h.Len(), "Heap should be empty initially") | ||
|
||
h.Push(Int(3)) | ||
h.Push(Int(1)) | ||
h.Push(Int(2)) | ||
|
||
require.Equal(t, 3, h.Len(), "Heap should have three elements after pushing") | ||
|
||
require.EqualValues(t, 1, h.Pop(), "Pop should return the smallest element") | ||
require.Equal(t, 2, h.Len(), "Heap should have two elements after popping") | ||
|
||
require.EqualValues(t, 2, h.Pop(), "Pop should return the next smallest element") | ||
require.Equal(t, 1, h.Len(), "Heap should have one element after popping") | ||
|
||
require.EqualValues(t, 3, h.Pop(), "Pop should return the last element") | ||
require.Equal(t, 0, h.Len(), "Heap should be empty after popping all elements") | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.