mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 14:16:44 +00:00
fix: configure default timeout for blob clients (#1191)
* feat: configure default timeout for blob clients * fix typo
This commit is contained in:
parent
141a8df143
commit
d8f4932bf2
4 changed files with 27 additions and 6 deletions
|
|
@ -24,7 +24,7 @@ import (
|
||||||
const (
|
const (
|
||||||
VersionMajor = 5 // Major version component of the current release
|
VersionMajor = 5 // Major version component of the current release
|
||||||
VersionMinor = 8 // Minor version component of the current release
|
VersionMinor = 8 // Minor version component of the current release
|
||||||
VersionPatch = 49 // Patch version component of the current release
|
VersionPatch = 50 // Patch version component of the current release
|
||||||
VersionMeta = "mainnet" // Version metadata to append to the version string
|
VersionMeta = "mainnet" // Version metadata to append to the version string
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,12 +9,18 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/scroll-tech/go-ethereum/common"
|
"github.com/scroll-tech/go-ethereum/common"
|
||||||
"github.com/scroll-tech/go-ethereum/crypto/kzg4844"
|
"github.com/scroll-tech/go-ethereum/crypto/kzg4844"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
BeaconNodeDefaultTimeout = 15 * time.Second
|
||||||
|
)
|
||||||
|
|
||||||
type BeaconNodeClient struct {
|
type BeaconNodeClient struct {
|
||||||
|
client *http.Client
|
||||||
apiEndpoint string
|
apiEndpoint string
|
||||||
genesisTime uint64
|
genesisTime uint64
|
||||||
secondsPerSlot uint64
|
secondsPerSlot uint64
|
||||||
|
|
@ -27,12 +33,14 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewBeaconNodeClient(apiEndpoint string) (*BeaconNodeClient, error) {
|
func NewBeaconNodeClient(apiEndpoint string) (*BeaconNodeClient, error) {
|
||||||
|
client := &http.Client{Timeout: BeaconNodeDefaultTimeout}
|
||||||
|
|
||||||
// get genesis time
|
// get genesis time
|
||||||
genesisPath, err := url.JoinPath(apiEndpoint, beaconNodeGenesisEndpoint)
|
genesisPath, err := url.JoinPath(apiEndpoint, beaconNodeGenesisEndpoint)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to join path, err: %w", err)
|
return nil, fmt.Errorf("failed to join path, err: %w", err)
|
||||||
}
|
}
|
||||||
resp, err := http.Get(genesisPath)
|
resp, err := client.Get(genesisPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("cannot do request, err: %w", err)
|
return nil, fmt.Errorf("cannot do request, err: %w", err)
|
||||||
}
|
}
|
||||||
|
|
@ -62,7 +70,7 @@ func NewBeaconNodeClient(apiEndpoint string) (*BeaconNodeClient, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to join path, err: %w", err)
|
return nil, fmt.Errorf("failed to join path, err: %w", err)
|
||||||
}
|
}
|
||||||
resp, err = http.Get(specPath)
|
resp, err = client.Get(specPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("cannot do request, err: %w", err)
|
return nil, fmt.Errorf("cannot do request, err: %w", err)
|
||||||
}
|
}
|
||||||
|
|
@ -91,6 +99,7 @@ func NewBeaconNodeClient(apiEndpoint string) (*BeaconNodeClient, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return &BeaconNodeClient{
|
return &BeaconNodeClient{
|
||||||
|
client: client,
|
||||||
apiEndpoint: apiEndpoint,
|
apiEndpoint: apiEndpoint,
|
||||||
genesisTime: genesisTime,
|
genesisTime: genesisTime,
|
||||||
secondsPerSlot: secondsPerSlot,
|
secondsPerSlot: secondsPerSlot,
|
||||||
|
|
@ -105,7 +114,7 @@ func (c *BeaconNodeClient) GetBlobByVersionedHashAndBlockTime(ctx context.Contex
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to join path, err: %w", err)
|
return nil, fmt.Errorf("failed to join path, err: %w", err)
|
||||||
}
|
}
|
||||||
resp, err := http.Get(blobSidecarPath)
|
resp, err := c.client.Get(blobSidecarPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("cannot do request, err: %w", err)
|
return nil, fmt.Errorf("cannot do request, err: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,12 +8,17 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/scroll-tech/go-ethereum/common"
|
"github.com/scroll-tech/go-ethereum/common"
|
||||||
"github.com/scroll-tech/go-ethereum/common/hexutil"
|
"github.com/scroll-tech/go-ethereum/common/hexutil"
|
||||||
"github.com/scroll-tech/go-ethereum/crypto/kzg4844"
|
"github.com/scroll-tech/go-ethereum/crypto/kzg4844"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
BlobScanDefaultTimeout = 15 * time.Second
|
||||||
|
)
|
||||||
|
|
||||||
type BlobScanClient struct {
|
type BlobScanClient struct {
|
||||||
client *http.Client
|
client *http.Client
|
||||||
apiEndpoint string
|
apiEndpoint string
|
||||||
|
|
@ -21,7 +26,7 @@ type BlobScanClient struct {
|
||||||
|
|
||||||
func NewBlobScanClient(apiEndpoint string) *BlobScanClient {
|
func NewBlobScanClient(apiEndpoint string) *BlobScanClient {
|
||||||
return &BlobScanClient{
|
return &BlobScanClient{
|
||||||
client: http.DefaultClient,
|
client: &http.Client{Timeout: BlobScanDefaultTimeout},
|
||||||
apiEndpoint: apiEndpoint,
|
apiEndpoint: apiEndpoint,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,18 +8,25 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/scroll-tech/go-ethereum/common"
|
"github.com/scroll-tech/go-ethereum/common"
|
||||||
"github.com/scroll-tech/go-ethereum/common/hexutil"
|
"github.com/scroll-tech/go-ethereum/common/hexutil"
|
||||||
"github.com/scroll-tech/go-ethereum/crypto/kzg4844"
|
"github.com/scroll-tech/go-ethereum/crypto/kzg4844"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
BlockNativeDefaultTimeout = 15 * time.Second
|
||||||
|
)
|
||||||
|
|
||||||
type BlockNativeClient struct {
|
type BlockNativeClient struct {
|
||||||
|
client *http.Client
|
||||||
apiEndpoint string
|
apiEndpoint string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewBlockNativeClient(apiEndpoint string) *BlockNativeClient {
|
func NewBlockNativeClient(apiEndpoint string) *BlockNativeClient {
|
||||||
return &BlockNativeClient{
|
return &BlockNativeClient{
|
||||||
|
client: &http.Client{Timeout: BlockNativeDefaultTimeout},
|
||||||
apiEndpoint: apiEndpoint,
|
apiEndpoint: apiEndpoint,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -34,7 +41,7 @@ func (c *BlockNativeClient) GetBlobByVersionedHashAndBlockTime(ctx context.Conte
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("cannot create request, err: %w", err)
|
return nil, fmt.Errorf("cannot create request, err: %w", err)
|
||||||
}
|
}
|
||||||
resp, err := http.DefaultClient.Do(req)
|
resp, err := c.client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("cannot do request, err: %w", err)
|
return nil, fmt.Errorf("cannot do request, err: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue