Skip to content

Commit

Permalink
manifest-verify: parallel etag fetch (#12421)
Browse files Browse the repository at this point in the history
  • Loading branch information
AskAlexSharov authored Oct 23, 2024
1 parent 082bf7e commit cc28d26
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 32 deletions.
18 changes: 1 addition & 17 deletions .github/workflows/manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,15 @@ on:
workflow_dispatch:

jobs:
# check-snap-modifications:
# runs-on: ubuntu-24.04
# outputs:
# modified: ${{ steps.check-modified.outputs.modified }}
#
# steps:
# - uses: actions/checkout@v4
# with:
# fetch-depth: 2 # Ensures we fetch enough history to compare
#
# - name: Is erigontech/erigon-snapshot updated in go.mod # if not, pipeline should exit because grep exit code >0 when no match
# run: |
# git diff HEAD~1 HEAD -- go.mod | grep 'github.com/erigontech/erigon-snapshot'

ManifestCheck:
# needs: check-snap-modifications
if: github.event.pull_request.draft == false
runs-on: ubuntu-24.04

steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.22'
- run: sudo apt update && sudo apt install build-essential
go-version: '1.23'
- run: make downloader
- run: echo $ModModified
- run: ./build/bin/downloader manifest-verify --chain mainnet
Expand Down
2 changes: 1 addition & 1 deletion erigon-lib/downloader/snaptype/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ func AllV3Extensions() []string {
}

func IsSeedableExtension(name string) bool {
for _, ext := range append(SeedableV2Extensions(), SeedableV3Extensions()...) {
for _, ext := range append(AllV2Extensions(), AllV3Extensions()...) {
if strings.HasSuffix(name, ext) {
return true
}
Expand Down
42 changes: 28 additions & 14 deletions erigon-lib/downloader/webseed.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,29 +164,43 @@ func (d *WebSeeds) checkHasTorrents(manifestResponse snaptype.WebSeedsFromProvid
}

func (d *WebSeeds) fetchFileEtags(ctx context.Context, manifestResponse snaptype.WebSeedsFromProvider) (tags map[string]string, invalidTags, etagFetchFailed []string, err error) {
lock := sync.Mutex{}
etagFetchFailed = make([]string, 0)
tags = make(map[string]string)
invalidTagsMap := make(map[string]string)

eg := errgroup.Group{}
eg.SetLimit(100)
for name, wurl := range manifestResponse {
name, wurl := name, wurl
u, err := url.Parse(wurl)
if err != nil {
return nil, nil, nil, fmt.Errorf("webseed.fetchFileEtags: %w", err)
}
md5Tag, err := d.retrieveFileEtag(ctx, u)
if err != nil {
if errors.Is(err, ErrInvalidEtag) {
invalidTagsMap[name] = md5Tag
continue
}
if errors.Is(err, ErrEtagNotFound) {
etagFetchFailed = append(etagFetchFailed, name)
continue
eg.Go(func() error {
md5Tag, err := d.retrieveFileEtag(ctx, u)

lock.Lock()
defer lock.Unlock()
if err != nil {
d.logger.Debug("[snapshots.webseed] get file ETag", "err", err, "url", u.String())
if errors.Is(err, ErrInvalidEtag) {
invalidTagsMap[name] = md5Tag
return nil
}
if errors.Is(err, ErrEtagNotFound) {
etagFetchFailed = append(etagFetchFailed, name)
return nil
}
return fmt.Errorf("webseed.fetchFileEtags: %w", err)
}
d.logger.Debug("[snapshots.webseed] get file ETag", "err", err, "url", u.String())
return nil, nil, nil, fmt.Errorf("webseed.fetchFileEtags: %w", err)
}
tags[name] = md5Tag
tags[name] = md5Tag
return nil
})

}
if err := eg.Wait(); err != nil {
return nil, nil, nil, err
}

invalidTags = make([]string, 0)
Expand Down Expand Up @@ -522,7 +536,7 @@ func (d *WebSeeds) retrieveManifest(ctx context.Context, webSeedProviderUrl *url
d.logger.Debug("[snapshots.webseed] empty line in manifest.txt", "webseed", webSeedProviderUrl.String(), "lineNum", fi)
}
continue
case "manifest.txt":
case "manifest.txt", "node.txt":
continue
default:
response[trimmed] = webSeedProviderUrl.JoinPath(trimmed).String()
Expand Down

0 comments on commit cc28d26

Please sign in to comment.