@@ -12,12 +12,10 @@ import (
1212
1313 "github.com/scroll-tech/go-ethereum/common"
1414 "github.com/scroll-tech/go-ethereum/crypto/kzg4844"
15- "github.com/scroll-tech/go-ethereum/rollup/rollup_sync_service"
1615)
1716
1817type BeaconNodeClient struct {
1918 apiEndpoint string
20- l1Client * rollup_sync_service.L1Client
2119 genesisTime uint64
2220 secondsPerSlot uint64
2321}
2826 beaconNodeBlobEndpoint = "/eth/v1/beacon/blob_sidecars"
2927)
3028
31- func NewBeaconNodeClient (apiEndpoint string , l1Client * rollup_sync_service. L1Client ) (* BeaconNodeClient , error ) {
29+ func NewBeaconNodeClient (apiEndpoint string ) (* BeaconNodeClient , error ) {
3230 // get genesis time
3331 genesisPath , err := url .JoinPath (apiEndpoint , beaconNodeGenesisEndpoint )
3432 if err != nil {
@@ -94,19 +92,13 @@ func NewBeaconNodeClient(apiEndpoint string, l1Client *rollup_sync_service.L1Cli
9492
9593 return & BeaconNodeClient {
9694 apiEndpoint : apiEndpoint ,
97- l1Client : l1Client ,
9895 genesisTime : genesisTime ,
9996 secondsPerSlot : secondsPerSlot ,
10097 }, nil
10198}
10299
103- func (c * BeaconNodeClient ) GetBlobByVersionedHashAndBlockNumber (ctx context.Context , versionedHash common.Hash , blockNumber uint64 ) (* kzg4844.Blob , error ) {
104- // get block timestamp to calculate slot
105- header , err := c .l1Client .GetHeaderByNumber (blockNumber )
106- if err != nil {
107- return nil , fmt .Errorf ("failed to get header by number, err: %w" , err )
108- }
109- slot := (header .Time - c .genesisTime ) / c .secondsPerSlot
100+ func (c * BeaconNodeClient ) GetBlobByVersionedHashAndBlockTime (ctx context.Context , versionedHash common.Hash , blockTime uint64 ) (* kzg4844.Blob , error ) {
101+ slot := (blockTime - c .genesisTime ) / c .secondsPerSlot
110102
111103 // get blob sidecar for slot
112104 blobSidecarPath , err := url .JoinPath (c .apiEndpoint , beaconNodeBlobEndpoint , fmt .Sprintf ("%d" , slot ))
@@ -156,7 +148,7 @@ func (c *BeaconNodeClient) GetBlobByVersionedHashAndBlockNumber(ctx context.Cont
156148 }
157149 }
158150
159- return nil , fmt .Errorf ("missing blob %v in slot %d, block number %d " , versionedHash , slot , blockNumber )
151+ return nil , fmt .Errorf ("missing blob %v in slot %d" , versionedHash , slot )
160152}
161153
162154type GenesisResp struct {
0 commit comments