From f998e18219a146ba7766cf28aa423561e80fb19c Mon Sep 17 00:00:00 2001 From: Alex Sharov Date: Thu, 19 Oct 2023 08:17:49 +0700 Subject: [PATCH] downloader: default webseed token for e2 (#8512) --- erigon-lib/downloader/webseed.go | 17 +++-------------- erigon-lib/go.mod | 2 +- erigon-lib/go.sum | 4 ++-- go.mod | 2 +- go.sum | 4 ++-- 5 files changed, 9 insertions(+), 20 deletions(-) diff --git a/erigon-lib/downloader/webseed.go b/erigon-lib/downloader/webseed.go index 90f5ad9d1..e1112499f 100644 --- a/erigon-lib/downloader/webseed.go +++ b/erigon-lib/downloader/webseed.go @@ -3,7 +3,6 @@ package downloader import ( "bytes" "context" - "encoding/base64" "fmt" "io" "net/http" @@ -201,25 +200,15 @@ func (d *WebSeeds) callHttpProvider(ctx context.Context, webSeedProviderUrl *url return response, nil } func (d *WebSeeds) callS3Provider(ctx context.Context, token string) (snaptype.WebSeedsFromProvider, error) { - var bucketName = "erigon-v3-snapshots-" + d.chainName + "-webseed" - //v1:base64(accID:accessKeyID:accessKeySecret) + //v1:bucketName:accID:accessKeyID:accessKeySecret l := strings.Split(token, ":") - if len(l) != 2 { + if len(l) != 5 { return nil, fmt.Errorf("token has invalid format, exepcing 'v1:tokenInBase64'") } - version, tokenInBase64 := strings.TrimSpace(l[0]), strings.TrimSpace(l[1]) + version, bucketName, accountId, accessKeyId, accessKeySecret := strings.TrimSpace(l[0]), strings.TrimSpace(l[1]), strings.TrimSpace(l[2]), strings.TrimSpace(l[3]), strings.TrimSpace(l[4]) if version != "v1" { return nil, fmt.Errorf("not supported version: %s", version) } - rawDecodedText, err := base64.StdEncoding.DecodeString(tokenInBase64) - if err != nil { - return nil, err - } - l = strings.Split(string(rawDecodedText), ":") - accountId, accessKeyId, accessKeySecret := strings.TrimSpace(l[0]), strings.TrimSpace(l[1]), strings.TrimSpace(l[2]) - if len(l) != 3 { - return nil, fmt.Errorf("token has invalid format, exepcing 'accountId:accessKeyId:accessKeySecret'") - } var fileName = "webseeds.toml" r2Resolver := aws.EndpointResolverWithOptionsFunc(func(service, region string, options ...interface{}) (aws.Endpoint, error) { diff --git a/erigon-lib/go.mod b/erigon-lib/go.mod index e419bc240..abcc31ba5 100644 --- a/erigon-lib/go.mod +++ b/erigon-lib/go.mod @@ -4,7 +4,7 @@ go 1.20 require ( github.com/erigontech/mdbx-go v0.27.19 - github.com/ledgerwatch/erigon-snapshot v1.3.1-0.20231018041646-a68ea6e20084 + github.com/ledgerwatch/erigon-snapshot v1.3.1-0.20231018092740-2cf0f5394484 github.com/ledgerwatch/interfaces v0.0.0-20231011121315-f58b806039f0 github.com/ledgerwatch/log/v3 v3.9.0 github.com/ledgerwatch/secp256k1 v1.0.0 diff --git a/erigon-lib/go.sum b/erigon-lib/go.sum index a087d5ba2..563d6416e 100644 --- a/erigon-lib/go.sum +++ b/erigon-lib/go.sum @@ -280,8 +280,8 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c= -github.com/ledgerwatch/erigon-snapshot v1.3.1-0.20231018041646-a68ea6e20084 h1:5FFMJ67en/bG3w335e3KW4fcqX65k6Xel6DsoAH7Mho= -github.com/ledgerwatch/erigon-snapshot v1.3.1-0.20231018041646-a68ea6e20084/go.mod h1:3AuPxZc85jkehh/HA9h8gabv5MSi3kb/ddtzBsTVJFo= +github.com/ledgerwatch/erigon-snapshot v1.3.1-0.20231018092740-2cf0f5394484 h1:dig1Uxshg/uDpvtpEicP5bLpvhCwIJMdHLMISrgfxuI= +github.com/ledgerwatch/erigon-snapshot v1.3.1-0.20231018092740-2cf0f5394484/go.mod h1:3AuPxZc85jkehh/HA9h8gabv5MSi3kb/ddtzBsTVJFo= github.com/ledgerwatch/interfaces v0.0.0-20231011121315-f58b806039f0 h1:7z6cyoCKP6qxtKSO74eAY6XiHWKaOi+melvPeMCXLl8= github.com/ledgerwatch/interfaces v0.0.0-20231011121315-f58b806039f0/go.mod h1:ugQv1QllJzBny3cKZKxUrSnykkjkBgm27eQM6dnGAcc= github.com/ledgerwatch/log/v3 v3.9.0 h1:iDwrXe0PVwBC68Dd94YSsHbMgQ3ufsgjzXtFNFVZFRk= diff --git a/go.mod b/go.mod index eda7b70c9..93fec6ef9 100644 --- a/go.mod +++ b/go.mod @@ -189,7 +189,7 @@ require ( github.com/koron/go-ssdp v0.0.4 // indirect github.com/kr/pretty v0.3.1 // indirect github.com/kr/text v0.2.0 // indirect - github.com/ledgerwatch/erigon-snapshot v1.3.1-0.20231018041646-a68ea6e20084 // indirect + github.com/ledgerwatch/erigon-snapshot v1.3.1-0.20231018092740-2cf0f5394484 // indirect github.com/libp2p/go-buffer-pool v0.1.0 // indirect github.com/libp2p/go-cidranger v1.1.0 // indirect github.com/libp2p/go-flow-metrics v0.1.0 // indirect diff --git a/go.sum b/go.sum index c9d73f742..8925ac311 100644 --- a/go.sum +++ b/go.sum @@ -539,8 +539,8 @@ github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v0.0.0-20170224010052-a616ab194758 h1:0D5M2HQSGD3PYPwICLl+/9oulQauOuETfgFvhBDffs0= github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c= github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8= -github.com/ledgerwatch/erigon-snapshot v1.3.1-0.20231018041646-a68ea6e20084 h1:5FFMJ67en/bG3w335e3KW4fcqX65k6Xel6DsoAH7Mho= -github.com/ledgerwatch/erigon-snapshot v1.3.1-0.20231018041646-a68ea6e20084/go.mod h1:3AuPxZc85jkehh/HA9h8gabv5MSi3kb/ddtzBsTVJFo= +github.com/ledgerwatch/erigon-snapshot v1.3.1-0.20231018092740-2cf0f5394484 h1:dig1Uxshg/uDpvtpEicP5bLpvhCwIJMdHLMISrgfxuI= +github.com/ledgerwatch/erigon-snapshot v1.3.1-0.20231018092740-2cf0f5394484/go.mod h1:3AuPxZc85jkehh/HA9h8gabv5MSi3kb/ddtzBsTVJFo= github.com/ledgerwatch/log/v3 v3.9.0 h1:iDwrXe0PVwBC68Dd94YSsHbMgQ3ufsgjzXtFNFVZFRk= github.com/ledgerwatch/log/v3 v3.9.0/go.mod h1:EiAY6upmI/6LkNhOVxb4eVsmsP11HZCnZ3PlJMjYiqE= github.com/ledgerwatch/secp256k1 v1.0.0 h1:Usvz87YoTG0uePIV8woOof5cQnLXGYa162rFf3YnwaQ=