@@ -12,12 +12,10 @@ import (
12
12
13
13
"github.com/scroll-tech/go-ethereum/common"
14
14
"github.com/scroll-tech/go-ethereum/crypto/kzg4844"
15
- "github.com/scroll-tech/go-ethereum/rollup/rollup_sync_service"
16
15
)
17
16
18
17
type BeaconNodeClient struct {
19
18
apiEndpoint string
20
- l1Client * rollup_sync_service.L1Client
21
19
genesisTime uint64
22
20
secondsPerSlot uint64
23
21
}
28
26
beaconNodeBlobEndpoint = "/eth/v1/beacon/blob_sidecars"
29
27
)
30
28
31
- func NewBeaconNodeClient (apiEndpoint string , l1Client * rollup_sync_service. L1Client ) (* BeaconNodeClient , error ) {
29
+ func NewBeaconNodeClient (apiEndpoint string ) (* BeaconNodeClient , error ) {
32
30
// get genesis time
33
31
genesisPath , err := url .JoinPath (apiEndpoint , beaconNodeGenesisEndpoint )
34
32
if err != nil {
@@ -94,19 +92,13 @@ func NewBeaconNodeClient(apiEndpoint string, l1Client *rollup_sync_service.L1Cli
94
92
95
93
return & BeaconNodeClient {
96
94
apiEndpoint : apiEndpoint ,
97
- l1Client : l1Client ,
98
95
genesisTime : genesisTime ,
99
96
secondsPerSlot : secondsPerSlot ,
100
97
}, nil
101
98
}
102
99
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
110
102
111
103
// get blob sidecar for slot
112
104
blobSidecarPath , err := url .JoinPath (c .apiEndpoint , beaconNodeBlobEndpoint , fmt .Sprintf ("%d" , slot ))
@@ -156,7 +148,7 @@ func (c *BeaconNodeClient) GetBlobByVersionedHashAndBlockNumber(ctx context.Cont
156
148
}
157
149
}
158
150
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 )
160
152
}
161
153
162
154
type GenesisResp struct {
0 commit comments