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

Replace snaptype.AllTypes with local definitions #10132

Merged
merged 1 commit into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 8 additions & 1 deletion eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -794,11 +794,18 @@ func New(ctx context.Context, stack *node.Node, config *ethconfig.Config, logger
hook := stages2.NewHook(backend.sentryCtx, backend.chainDB, backend.notifications, backend.stagedSync, backend.blockReader, backend.chainConfig, backend.logger, backend.sentriesClient.SetStatus)

if !config.Sync.UseSnapshots && backend.downloaderClient != nil {
for _, p := range snaptype.AllTypes {
for _, p := range blockReader.AllTypes() {
backend.downloaderClient.ProhibitNewDownloads(ctx, &protodownloader.ProhibitNewDownloadsRequest{
Type: p.String(),
})
}

for _, p := range snaptype.CaplinSnapshotTypes {
backend.downloaderClient.ProhibitNewDownloads(ctx, &protodownloader.ProhibitNewDownloadsRequest{
Type: p.String(),
})
}

}

checkStateRoot := true
Expand Down
15 changes: 13 additions & 2 deletions migrations/prohibit_new_downloads2.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (
"github.com/ledgerwatch/erigon-lib/downloader"
"github.com/ledgerwatch/erigon-lib/downloader/snaptype"
"github.com/ledgerwatch/erigon-lib/kv"
coresnaptype "github.com/ledgerwatch/erigon/core/snaptype"
borsnaptype "github.com/ledgerwatch/erigon/polygon/bor/snaptype"
"github.com/ledgerwatch/log/v3"
)

Expand All @@ -38,12 +40,21 @@ var ProhibitNewDownloadsLock2 = Migration{
}
if len(content) == 0 { // old format, need to change to all snaptypes except blob sidecars
locked := []string{}
ts := snaptype.AllTypes
for _, t := range ts {

for _, t := range coresnaptype.BlockSnapshotTypes {
locked = append(locked, t.String())
}

for _, t := range borsnaptype.BorSnapshotTypes {
locked = append(locked, t.String())
}

for _, t := range snaptype.CaplinSnapshotTypes {
if t.String() != snaptype.BlobSidecars.String() {
locked = append(locked, t.String())
}
}

newContent, err := json.Marshal(locked)
if err != nil {
return err
Expand Down
22 changes: 15 additions & 7 deletions turbo/snapshotsync/snapshotsync.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,20 +207,28 @@ func WaitForDownloader(ctx context.Context, logPrefix string, histV3, blobs bool
//

// prohibits further downloads, except some exceptions
for _, p := range snaptype.AllTypes {
if (p.Enum() == snaptype.BeaconBlocks.Enum() || p.Enum() == snaptype.BlobSidecars.Enum()) && caplin == NoCaplin {
continue
}
if p.Enum() == snaptype.BlobSidecars.Enum() && !blobs {
continue
}
for _, p := range blockReader.AllTypes() {
if _, err := snapshotDownloader.ProhibitNewDownloads(ctx, &proto_downloader.ProhibitNewDownloadsRequest{
Type: p.String(),
}); err != nil {
return err
}
}

if caplin != NoCaplin {
for _, p := range snaptype.CaplinSnapshotTypes {
if p.Enum() == snaptype.BlobSidecars.Enum() && !blobs {
continue
}

if _, err := snapshotDownloader.ProhibitNewDownloads(ctx, &proto_downloader.ProhibitNewDownloadsRequest{
Type: p.String(),
}); err != nil {
return err
}
}
}

if err := rawdb.WriteSnapshots(tx, blockReader.FrozenFiles(), agg.Files()); err != nil {
return err
}
Expand Down
Loading