-
Notifications
You must be signed in to change notification settings - Fork 118
/
Copy pathlitestorage.go
588 lines (536 loc) · 19.2 KB
/
litestorage.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
package litestorage
import (
"context"
"crypto/ed25519"
"errors"
"fmt"
"math/big"
"sort"
"sync"
"time"
"github.com/avast/retry-go"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"github.com/puzpuzpuz/xsync/v2"
"github.com/sourcegraph/conc/iter"
"github.com/tonkeeper/tongo"
"github.com/tonkeeper/tongo/abi"
"github.com/tonkeeper/tongo/boc"
"github.com/tonkeeper/tongo/liteapi"
"github.com/tonkeeper/tongo/tep64"
"github.com/tonkeeper/tongo/tlb"
"github.com/tonkeeper/tongo/ton"
"go.uber.org/zap"
"github.com/tonkeeper/opentonapi/pkg/blockchain/indexer"
"github.com/tonkeeper/opentonapi/pkg/cache"
"github.com/tonkeeper/opentonapi/pkg/core"
)
var storageTimeHistogramVec = promauto.NewHistogramVec(
prometheus.HistogramOpts{
Name: "litestorage_functions_time",
Help: "LiteStorage functions execution duration distribution in seconds",
Buckets: []float64{0.001, 0.01, 0.05, 0.1, 1, 5, 10},
},
[]string{"method"},
)
// inMsgCreatedLT is used as a key to look up a transaction's hash based on in msg's account and created lt.
type inMsgCreatedLT struct {
account tongo.AccountID
lt uint64
}
func extractInMsgCreatedLT(accountID tongo.AccountID, tx *tlb.Transaction) (inMsgCreatedLT, bool) {
if tx.Msgs.InMsg.Exists && tx.Msgs.InMsg.Value.Value.Info.IntMsgInfo != nil {
return inMsgCreatedLT{account: accountID, lt: tx.Msgs.InMsg.Value.Value.Info.IntMsgInfo.CreatedLt}, true
}
return inMsgCreatedLT{}, false
}
type LiteStorage struct {
logger *zap.Logger
client *liteapi.Client
executor abi.Executor
jettonMetaCache *xsync.MapOf[string, tep64.Metadata]
transactionsIndexByHash *xsync.MapOf[tongo.Bits256, *core.Transaction]
transactionsByInMsgLT *xsync.MapOf[inMsgCreatedLT, tongo.Bits256]
blockCache *xsync.MapOf[tongo.BlockIDExt, *tlb.Block]
accountInterfacesCache *xsync.MapOf[tongo.AccountID, []abi.ContractInterface]
// tvmLibraryCache contains public tvm libraries.
// As a library is immutable, it's ok to cache it.
tvmLibraryCache cache.Cache[string, boc.Cell]
knownAccounts map[string][]tongo.AccountID
// maxGoroutines specifies a number of goroutines used to perform some time-consuming operations.
maxGoroutines int
// trackingAccounts is a list of accounts we track. Defined with ACCOUNTS env variable.
trackingAccounts map[tongo.AccountID]struct{}
pubKeyByAccountID *xsync.MapOf[tongo.AccountID, ed25519.PublicKey]
configCache cache.Cache[int, ton.BlockchainConfig]
stopCh chan struct{}
// mu protects trimmedConfigBase64.
mu sync.RWMutex
// trimmedConfigBase64 is a blockchain config but with a limited set of keys.
// it's performance optimization.
// tmv and txEmulator work much faster with a smaller config.
trimmedConfigBase64 string
}
type Options struct {
preloadAccounts []tongo.AccountID
preloadBlocks []tongo.BlockID
tfPools []tongo.AccountID
jettons []tongo.AccountID
executor abi.Executor
// blockCh is used to receive new blocks in the blockchain, if set.
blockCh <-chan indexer.IDandBlock
}
func WithPreloadAccounts(a []tongo.AccountID) Option {
return func(o *Options) {
o.preloadAccounts = a
}
}
func WithPreloadBlocks(ids []tongo.BlockID) Option {
return func(o *Options) {
o.preloadBlocks = ids
}
}
func WithKnownJettons(a []tongo.AccountID) Option {
return func(o *Options) {
o.jettons = a
}
}
func WithTFPools(pools []tongo.AccountID) Option {
return func(o *Options) {
o.tfPools = pools
}
}
// WithBlockChannel configures a channel to receive notifications about new blocks in the blockchain.
func WithBlockChannel(ch <-chan indexer.IDandBlock) Option {
return func(o *Options) {
o.blockCh = ch
}
}
type Option func(o *Options)
func NewLiteStorage(log *zap.Logger, cli *liteapi.Client, opts ...Option) (*LiteStorage, error) {
o := &Options{}
for i := range opts {
opts[i](o)
}
if o.executor == nil {
o.executor = cli
}
storage := &LiteStorage{
logger: log,
// TODO: introduce an env variable to configure this number
maxGoroutines: 5,
client: cli,
executor: o.executor,
stopCh: make(chan struct{}),
// read-only data
knownAccounts: make(map[string][]tongo.AccountID),
trackingAccounts: map[tongo.AccountID]struct{}{},
// data for concurrent access
// TODO: implement expiration logic for the caches below.
jettonMetaCache: xsync.NewMapOf[tep64.Metadata](),
transactionsIndexByHash: xsync.NewTypedMapOf[tongo.Bits256, *core.Transaction](hashBits256),
transactionsByInMsgLT: xsync.NewTypedMapOf[inMsgCreatedLT, tongo.Bits256](hashInMsgCreatedLT),
blockCache: xsync.NewTypedMapOf[tongo.BlockIDExt, *tlb.Block](hashBlockIDExt),
accountInterfacesCache: xsync.NewTypedMapOf[tongo.AccountID, []abi.ContractInterface](hashAccountID),
pubKeyByAccountID: xsync.NewTypedMapOf[tongo.AccountID, ed25519.PublicKey](hashAccountID),
tvmLibraryCache: cache.NewLRUCache[string, boc.Cell](10000, "tvm_libraries"),
configCache: cache.NewLRUCache[int, ton.BlockchainConfig](4, "config"),
}
storage.knownAccounts["tf_pools"] = o.tfPools
storage.knownAccounts["jettons"] = o.jettons
for _, a := range o.preloadAccounts {
storage.trackingAccounts[a] = struct{}{}
}
blockIterator := iter.Iterator[tongo.BlockID]{MaxGoroutines: storage.maxGoroutines}
blockIterator.ForEach(o.preloadBlocks, func(id *tongo.BlockID) {
if err := storage.preloadBlock(*id); err != nil {
log.Error("failed to preload block",
zap.String("blockID", id.String()),
zap.Error(err))
}
})
iterator := iter.Iterator[tongo.AccountID]{MaxGoroutines: storage.maxGoroutines}
iterator.ForEach(o.preloadAccounts, func(accountID *tongo.AccountID) {
if err := storage.preloadAccount(*accountID); err != nil {
log.Error("failed to preload account",
zap.String("accountID", accountID.String()),
zap.Error(err))
}
})
go storage.run(o.blockCh)
go storage.runBlockchainConfigUpdate(5 * time.Second)
return storage, nil
}
func (s *LiteStorage) SetExecutor(e abi.Executor) {
s.executor = e
}
// Shutdown stops all background goroutines.
func (s *LiteStorage) Shutdown() {
s.stopCh <- struct{}{}
}
func (s *LiteStorage) run(ch <-chan indexer.IDandBlock) {
if ch == nil {
return
}
for block := range ch {
for _, tx := range block.Block.AllTransactions() {
accountID := *ton.NewAccountID(block.ID.Workchain, tx.AccountAddr)
if _, ok := s.trackingAccounts[accountID]; ok {
hash := tongo.Bits256(tx.Hash())
transaction, err := core.ConvertTransaction(accountID.Workchain, tongo.Transaction{Transaction: *tx, BlockID: block.ID}, nil)
if err != nil {
s.logger.Error("failed to process tx",
zap.String("tx-hash", hash.Hex()),
zap.Error(err))
continue
}
s.transactionsIndexByHash.Store(hash, transaction)
if createLT, ok := extractInMsgCreatedLT(accountID, tx); ok {
s.transactionsByInMsgLT.Store(createLT, hash)
}
}
}
}
}
func (s *LiteStorage) GetContract(ctx context.Context, id tongo.AccountID) (*core.Contract, error) {
account, err := s.GetRawAccount(ctx, id)
if err != nil {
return nil, err
}
return &core.Contract{
Balance: account.TonBalance,
Status: account.Status,
Code: account.Code,
Data: account.Data,
Libraries: account.Libraries,
LastTransactionLt: account.LastTransactionLt,
}, nil
}
// GetRawAccount returns low-level information about an account taken directly from the blockchain.
func (s *LiteStorage) GetRawAccount(ctx context.Context, address tongo.AccountID) (*core.Account, error) {
timer := prometheus.NewTimer(prometheus.ObserverFunc(func(v float64) {
storageTimeHistogramVec.WithLabelValues("get_raw_account").Observe(v)
}))
defer timer.ObserveDuration()
var account tlb.ShardAccount
err := retry.Do(func() error {
state, err := s.client.GetAccountState(ctx, address)
if err != nil {
return err
}
account = state
return nil
}, retry.Attempts(10), retry.Delay(10*time.Millisecond))
if err != nil {
return nil, err
}
return core.ConvertToAccount(address, account)
}
// GetRawAccounts returns low-level information about several accounts taken directly from the blockchain.
func (s *LiteStorage) GetRawAccounts(ctx context.Context, ids []tongo.AccountID) ([]*core.Account, error) {
timer := prometheus.NewTimer(prometheus.ObserverFunc(func(v float64) {
storageTimeHistogramVec.WithLabelValues("get_raw_accounts").Observe(v)
}))
defer timer.ObserveDuration()
var accounts []*core.Account
for _, address := range ids {
var account tlb.ShardAccount
err := retry.Do(func() error {
state, err := s.client.GetAccountState(ctx, address)
if err != nil {
return err
}
account = state
return nil
}, retry.Attempts(10), retry.Delay(10*time.Millisecond))
if err != nil {
return nil, err
}
acc, err := core.ConvertToAccount(address, account)
if err != nil {
return nil, err
}
accounts = append(accounts, acc)
}
return accounts, nil
}
func (s *LiteStorage) preloadAccount(a tongo.AccountID) error {
ctx := context.Background()
accountTxs, err := s.client.GetLastTransactions(ctx, a, 2000)
if err != nil {
return err
}
for _, tx := range accountTxs {
inspector := abi.NewContractInspector(abi.InspectWithLibraryResolver(s))
account, err := s.GetRawAccount(ctx, a)
if err != nil {
return err
}
cd, err := inspector.InspectContract(ctx, account.Code, s.executor, a)
t, err := core.ConvertTransaction(a.Workchain, tx, cd)
if err != nil {
return err
}
hash := tongo.Bits256(tx.Hash())
s.transactionsIndexByHash.Store(hash, t)
if createLT, ok := extractInMsgCreatedLT(a, &tx.Transaction); ok {
s.transactionsByInMsgLT.Store(createLT, hash)
}
}
return nil
}
func (s *LiteStorage) preloadBlock(id tongo.BlockID) error {
ctx := context.Background()
extID, _, err := s.client.LookupBlock(ctx, id, 1, nil, nil)
if err != nil {
return err
}
block, err := s.client.GetBlock(ctx, extID)
if err != nil {
return err
}
s.blockCache.Store(extID, &block)
for _, tx := range block.AllTransactions() {
accountID := tongo.AccountID{
Workchain: extID.Workchain,
Address: tx.AccountAddr,
}
inspector := abi.NewContractInspector(abi.InspectWithLibraryResolver(s))
account, err := s.GetRawAccount(ctx, accountID)
if err != nil {
return err
}
cd, err := inspector.InspectContract(ctx, account.Code, s.executor, accountID)
t, err := core.ConvertTransaction(extID.Workchain, tongo.Transaction{Transaction: *tx, BlockID: extID}, cd)
if err != nil {
return err
}
hash := tongo.Bits256(tx.Hash())
s.transactionsIndexByHash.Store(hash, t)
if createLT, ok := extractInMsgCreatedLT(accountID, tx); ok {
s.transactionsByInMsgLT.Store(createLT, hash)
}
}
return nil
}
func (s *LiteStorage) GetBlockHeader(ctx context.Context, id tongo.BlockID) (*core.BlockHeader, error) {
timer := prometheus.NewTimer(prometheus.ObserverFunc(func(v float64) {
storageTimeHistogramVec.WithLabelValues("get_block_header").Observe(v)
}))
defer timer.ObserveDuration()
blockID, _, err := s.client.LookupBlock(ctx, id, 1, nil, nil)
if err != nil {
return nil, err
}
block, err := s.client.GetBlock(ctx, blockID)
if err != nil {
return nil, err
}
s.blockCache.Store(blockID, &block)
header, err := core.ConvertToBlockHeader(blockID, &block)
if err != nil {
return nil, err
}
return header, nil
}
func (s *LiteStorage) GetBlockShards(ctx context.Context, id tongo.BlockID) ([]ton.BlockID, error) {
timer := prometheus.NewTimer(prometheus.ObserverFunc(func(v float64) {
storageTimeHistogramVec.WithLabelValues("get_block_shards").Observe(v)
}))
defer timer.ObserveDuration()
blockID, _, err := s.client.LookupBlock(ctx, id, 1, nil, nil)
if err != nil {
return nil, err
}
shards, err := s.client.GetAllShardsInfo(ctx, blockID)
if err != nil {
return nil, err
}
res := make([]ton.BlockID, len(shards))
for i, s := range shards {
res[i] = s.BlockID
}
sort.Slice(shards, func(i, j int) bool {
return shards[i].Shard < shards[j].Shard
})
return res, nil
}
func (s *LiteStorage) LastMasterchainBlockHeader(ctx context.Context) (*core.BlockHeader, error) {
timer := prometheus.NewTimer(prometheus.ObserverFunc(func(v float64) {
storageTimeHistogramVec.WithLabelValues("get_masterchain").Observe(v)
}))
defer timer.ObserveDuration()
info, err := s.client.GetMasterchainInfo(ctx)
if err != nil {
return nil, err
}
return s.GetBlockHeader(ctx, info.Last.ToBlockIdExt().BlockID)
}
func (s *LiteStorage) GetTransaction(ctx context.Context, hash tongo.Bits256) (*core.Transaction, error) {
timer := prometheus.NewTimer(prometheus.ObserverFunc(func(v float64) {
storageTimeHistogramVec.WithLabelValues("get_transaction").Observe(v)
}))
defer timer.ObserveDuration()
tx, prs := s.transactionsIndexByHash.Load(hash)
if prs {
return tx, nil
}
return nil, fmt.Errorf("not found tx %x", hash)
}
func (s *LiteStorage) SearchTransactionByMessageHash(ctx context.Context, hash tongo.Bits256) (*tongo.Bits256, error) {
//var txHash tongo.Bits256
//found := false
//s.transactionsIndexByHash.Range(func(key tongo.Bits256, value *core.Transaction) bool {
// if value.InMsg != nil && value.InMsg.Hash {
// txHash = key
// found =true
// return false
// }
// return true
//})
//if found {
// return &txHash, nil
//}
return nil, core.ErrEntityNotFound
}
func (s *LiteStorage) GetBlockTransactions(ctx context.Context, id tongo.BlockID) ([]*core.Transaction, error) {
timer := prometheus.NewTimer(prometheus.ObserverFunc(func(v float64) {
storageTimeHistogramVec.WithLabelValues("get_block_transactions").Observe(v)
}))
defer timer.ObserveDuration()
blockID, _, err := s.client.LookupBlock(ctx, id, 1, nil, nil)
if err != nil {
return nil, err
}
block, err := s.client.GetBlock(ctx, blockID)
if err != nil {
return nil, err
}
return core.ExtractTransactions(blockID, &block)
}
func (s *LiteStorage) searchTxInCache(a tongo.AccountID, lt uint64) *core.Transaction {
hash, ok := s.transactionsByInMsgLT.Load(inMsgCreatedLT{account: a, lt: lt})
if !ok {
return nil
}
tx, ok := s.transactionsIndexByHash.Load(hash)
if !ok {
return nil
}
return tx
}
func (s *LiteStorage) GetStorageProviders(ctx context.Context) ([]core.StorageProvider, error) {
timer := prometheus.NewTimer(prometheus.ObserverFunc(func(v float64) {
storageTimeHistogramVec.WithLabelValues("get_storage_providers").Observe(v)
}))
defer timer.ObserveDuration()
return nil, errors.New("not implemented")
}
func (s *LiteStorage) RunSmcMethod(ctx context.Context, id tongo.AccountID, method string, stack tlb.VmStack) (uint32, tlb.VmStack, error) {
timer := prometheus.NewTimer(prometheus.ObserverFunc(func(v float64) {
storageTimeHistogramVec.WithLabelValues("run_smc_method").Observe(v)
}))
defer timer.ObserveDuration()
return s.client.RunSmcMethod(ctx, id, method, stack)
}
func (s *LiteStorage) RunSmcMethodByID(ctx context.Context, id tongo.AccountID, method int, stack tlb.VmStack) (uint32, tlb.VmStack, error) {
timer := prometheus.NewTimer(prometheus.ObserverFunc(func(v float64) {
storageTimeHistogramVec.WithLabelValues("run_smc_method_by_id").Observe(v)
}))
defer timer.ObserveDuration()
return s.client.RunSmcMethodByID(ctx, id, method, stack)
}
func (s *LiteStorage) GetAccountTransactions(ctx context.Context, id tongo.AccountID, limit int, beforeLt, afterLt uint64, descendingOrder bool) ([]*core.Transaction, error) {
timer := prometheus.NewTimer(prometheus.ObserverFunc(func(v float64) {
storageTimeHistogramVec.WithLabelValues("get_account_transactions").Observe(v)
}))
defer timer.ObserveDuration()
txs, err := s.client.GetLastTransactions(ctx, id, limit) //todo: custom with beforeLt, afterLt and descendingOrder
if err != nil {
return nil, err
}
result := make([]*core.Transaction, len(txs))
for i := range txs {
tx, err := core.ConvertTransaction(id.Workchain, txs[i], nil)
if err != nil {
return nil, err
}
result[i] = tx
}
return result, nil
}
func (s *LiteStorage) FindAllDomainsResolvedToAddress(ctx context.Context, a tongo.AccountID, collections map[tongo.AccountID]string) ([]string, error) {
timer := prometheus.NewTimer(prometheus.ObserverFunc(func(v float64) {
storageTimeHistogramVec.WithLabelValues("find_all_domains_resolved_to_address").Observe(v)
}))
defer timer.ObserveDuration()
return nil, nil
}
func (s *LiteStorage) GetWalletPubKey(ctx context.Context, address tongo.AccountID) (ed25519.PublicKey, error) {
timer := prometheus.NewTimer(prometheus.ObserverFunc(func(v float64) {
storageTimeHistogramVec.WithLabelValues("get_wallet_by_pubkey").Observe(v)
}))
defer timer.ObserveDuration()
_, result, err := abi.GetPublicKey(ctx, s.executor, address)
if err == nil {
if r, ok := result.(abi.GetPublicKeyResult); ok {
i := big.Int(r.PublicKey)
b := i.Bytes()
if len(b) < 24 || len(b) > 32 {
return nil, fmt.Errorf("invalid public key")
}
return append(make([]byte, 32-len(b)), b...), nil
}
}
pubKey, ok := s.pubKeyByAccountID.Load(address)
if ok {
return pubKey, nil
}
return nil, fmt.Errorf("can't get public key")
}
func (s *LiteStorage) ReindexAccount(ctx context.Context, accountID tongo.AccountID) error {
timer := prometheus.NewTimer(prometheus.ObserverFunc(func(v float64) {
storageTimeHistogramVec.WithLabelValues("reindex_account").Observe(v)
}))
defer timer.ObserveDuration()
return nil
}
func (s *LiteStorage) GetDnsExpiring(ctx context.Context, id tongo.AccountID, period *int) ([]core.DnsExpiring, error) {
timer := prometheus.NewTimer(prometheus.ObserverFunc(func(v float64) {
storageTimeHistogramVec.WithLabelValues("get_dns_expiring").Observe(v)
}))
defer timer.ObserveDuration()
return nil, nil
}
func (c *LiteStorage) GetInscriptionBalancesByAccount(ctx context.Context, a ton.AccountID) ([]core.InscriptionBalance, error) {
return nil, fmt.Errorf("not implemented") //and cannot be without full blockckchain index
}
func (c *LiteStorage) GetInscriptionsHistoryByAccount(ctx context.Context, a ton.AccountID, ticker *string, beforeLt int64, limit int) ([]core.InscriptionMessage, error) {
return nil, fmt.Errorf("not implemented") //and cannot be without full blockckchain index
}
func (s *LiteStorage) GetReducedBlocks(ctx context.Context, from, to int64) ([]core.ReducedBlock, error) {
return nil, fmt.Errorf("not implemented")
}
func (s *LiteStorage) GetAccountMultisigs(ctx context.Context, accountID ton.AccountID) ([]core.Multisig, error) {
return nil, fmt.Errorf("not implemented")
}
func (s *LiteStorage) GetMultisigByID(ctx context.Context, accountID ton.AccountID) (*core.Multisig, error) {
return nil, fmt.Errorf("not implemented")
}
func (s *LiteStorage) SaveTraceWithState(ctx context.Context, msgHash string, trace *core.Trace, version int, getMethods []abi.MethodInvocation, ttl time.Duration) error {
return fmt.Errorf("not implemented")
}
func (s *LiteStorage) GetTraceWithState(ctx context.Context, msgHash string) (*core.Trace, int, []abi.MethodInvocation, error) {
return nil, 0, nil, fmt.Errorf("not implemented")
}
func (s *LiteStorage) GetBlockchainBlock(ctx context.Context, id ton.BlockID) ([]byte, error) {
idExt, _, err := s.client.LookupBlock(ctx, id, 1, nil, nil)
if err != nil {
return nil, err
}
block, err := s.client.GetBlockRaw(ctx, idExt)
if err != nil {
return nil, err
}
return block.Data, nil
}