Skip to content

Commit e3b2c4c

Browse files
committed
fix
1 parent cbd5efc commit e3b2c4c

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

rollup/da_syncer/blob_client/beacon_node_client.go

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,31 @@ func NewBeaconNodeClient(apiEndpoint string) (*BeaconNodeClient, error) {
105105
}, nil
106106
}
107107

108+
func (c *BeaconNodeClient) getBlobsPath(slot uint64, versionedHash common.Hash) (string, error) {
109+
basePath, err := url.JoinPath(c.apiEndpoint, beaconNodeBlobEndpoint, fmt.Sprintf("%d", slot))
110+
if err != nil {
111+
return "", fmt.Errorf("failed to join path, err: %w", err)
112+
}
113+
u, err := url.Parse(basePath)
114+
if err != nil {
115+
return "", fmt.Errorf("failed to parse path, err: %w", err)
116+
}
117+
q := u.Query()
118+
q.Set("versioned_hashes", fmt.Sprintf("[%s]", versionedHash.Hex()))
119+
u.RawQuery = q.Encode()
120+
queryPath := u.String()
121+
return queryPath, nil
122+
}
123+
108124
func (c *BeaconNodeClient) GetBlobByVersionedHashAndBlockTime(ctx context.Context, versionedHash common.Hash, blockTime uint64) (*kzg4844.Blob, error) {
109125
slot := (blockTime - c.genesisTime) / c.secondsPerSlot
110126

111-
// get blob sidecar for slot
112-
blobSidecarPath, err := url.JoinPath(c.apiEndpoint, beaconNodeBlobEndpoint, fmt.Sprintf("%d?versioned_hashes=[%s]", slot, versionedHash))
127+
// get blob by slot and versioned hash
128+
getBlobsPath, err := c.getBlobsPath(slot, versionedHash)
113129
if err != nil {
114-
return nil, fmt.Errorf("failed to join path, err: %w", err)
130+
return nil, fmt.Errorf("failed to create getBlobs path, err: %w", err)
115131
}
116-
req, err := http.NewRequestWithContext(ctx, "GET", blobSidecarPath, nil)
132+
req, err := http.NewRequestWithContext(ctx, "GET", getBlobsPath, nil)
117133
if err != nil {
118134
return nil, fmt.Errorf("failed to create request, err: %w", err)
119135
}

rollup/da_syncer/blob_client/blob_client.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ import (
1212
)
1313

1414
const (
15-
lenBlobBytes int = 131072
16-
lenKZGCommitment int = 48
15+
lenBlobBytes int = 131072
1716
)
1817

1918
type BlobClient interface {

0 commit comments

Comments
 (0)