-
Notifications
You must be signed in to change notification settings - Fork 20.3k
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
eth/downloader: implement beacon sync #23982
Merged
Merged
Changes from 21 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
0f78c4f
eth/downloader: implement beacon sync
karalabe 0d22561
eth/downloader: fix a crash if the beacon chain is reduced in length
karalabe 786308d
eth/downloader: fix beacon sync start/stop thrashing data race
karalabe 49b7771
eth/downloader: use a non-nil pivot even in degenerate sync requests
karalabe 3f16180
eth/downloader: don't touch internal state on beacon Head retrieval
karalabe 1c5a698
eth/downloader: fix spelling mistakes
karalabe 344d81a
eth/downloader: fix some typos
karalabe 944e050
eth: integrate legacy/beacon sync switchover and UX
karalabe 0a50767
eth: handle UX wise being stuck on post-merge TTD
karalabe f6a427d
core, eth: integrate the beacon client with the beacon sync
karalabe ba9e91f
eth/catalyst: make some warning messages nicer
karalabe ef4d465
eth/downloader: remove Ethereum 1&2 notions in favor of merge
karalabe 92020c9
core/beacon, eth: clean up engine API returns a bit
karalabe 46c0e3f
eth/downloader: add skeleton extension tests
karalabe 336b5df
eth/catalyst: keep non-kiln spec, handle mining on ttd
karalabe 38114ad
eth/downloader: add beacon header retrieval tests
karalabe 71861e7
eth: fixed spelling, commented failing tests out
MariusVanDerWijden 7ac324b
eth/downloader: review fixes
karalabe 4f2c4e9
eth/downloader: drop peers failing to deliver beacon headers
karalabe 2cb92eb
core/rawdb: track beacon sync data in db inspect
karalabe bec4fd6
eth: fix review concerns
karalabe 7c12053
internal/web3ext: nit
karalabe 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 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 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 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 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 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,80 @@ | ||
// Copyright 2021 The go-ethereum Authors | ||
// This file is part of the go-ethereum library. | ||
// | ||
// The go-ethereum library is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Lesser General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// The go-ethereum library is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public License | ||
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
package rawdb | ||
|
||
import ( | ||
"bytes" | ||
|
||
"github.com/ethereum/go-ethereum/core/types" | ||
"github.com/ethereum/go-ethereum/ethdb" | ||
"github.com/ethereum/go-ethereum/log" | ||
"github.com/ethereum/go-ethereum/rlp" | ||
) | ||
|
||
// ReadSkeletonSyncStatus retrieves the serialized sync status saved at shutdown. | ||
func ReadSkeletonSyncStatus(db ethdb.KeyValueReader) []byte { | ||
data, _ := db.Get(skeletonSyncStatusKey) | ||
return data | ||
} | ||
|
||
// WriteSkeletonSyncStatus stores the serialized sync status to save at shutdown. | ||
func WriteSkeletonSyncStatus(db ethdb.KeyValueWriter, status []byte) { | ||
if err := db.Put(skeletonSyncStatusKey, status); err != nil { | ||
log.Crit("Failed to store skeleton sync status", "err", err) | ||
} | ||
} | ||
|
||
// DeleteSkeletonSyncStatus deletes the serialized sync status saved at the last | ||
// shutdown | ||
func DeleteSkeletonSyncStatus(db ethdb.KeyValueWriter) { | ||
if err := db.Delete(skeletonSyncStatusKey); err != nil { | ||
log.Crit("Failed to remove skeleton sync status", "err", err) | ||
} | ||
} | ||
|
||
// ReadSkeletonHeader retrieves a block header from the skeleton sync store, | ||
func ReadSkeletonHeader(db ethdb.KeyValueReader, number uint64) *types.Header { | ||
data, _ := db.Get(skeletonHeaderKey(number)) | ||
if len(data) == 0 { | ||
return nil | ||
} | ||
header := new(types.Header) | ||
if err := rlp.Decode(bytes.NewReader(data), header); err != nil { | ||
log.Error("Invalid skeleton header RLP", "number", number, "err", err) | ||
return nil | ||
} | ||
return header | ||
} | ||
|
||
// WriteSkeletonHeader stores a block header into the skeleton sync store. | ||
func WriteSkeletonHeader(db ethdb.KeyValueWriter, header *types.Header) { | ||
data, err := rlp.EncodeToBytes(header) | ||
if err != nil { | ||
log.Crit("Failed to RLP encode header", "err", err) | ||
} | ||
key := skeletonHeaderKey(header.Number.Uint64()) | ||
if err := db.Put(key, data); err != nil { | ||
log.Crit("Failed to store skeleton header", "err", err) | ||
} | ||
} | ||
|
||
// DeleteSkeletonHeader removes all block header data associated with a hash. | ||
func DeleteSkeletonHeader(db ethdb.KeyValueWriter, number uint64) { | ||
if err := db.Delete(skeletonHeaderKey(number)); err != nil { | ||
log.Crit("Failed to delete skeleton header", "err", err) | ||
} | ||
} |
This file contains 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 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
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.
This comment was marked as spam.
Sorry, something went wrong.