-
Notifications
You must be signed in to change notification settings - Fork 136
Expand file tree
/
Copy pathunsigneddata.go
More file actions
704 lines (588 loc) · 19.2 KB
/
unsigneddata.go
File metadata and controls
704 lines (588 loc) · 19.2 KB
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
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
// Copyright © 2022-2026 Obol Labs Inc. Licensed under the terms of a Business Source License 1.1
package core
import (
"encoding/json"
eth2api "github.com/attestantio/go-eth2-client/api"
eth2v1 "github.com/attestantio/go-eth2-client/api/v1"
eth2bellatrix "github.com/attestantio/go-eth2-client/api/v1/bellatrix"
eth2capella "github.com/attestantio/go-eth2-client/api/v1/capella"
eth2deneb "github.com/attestantio/go-eth2-client/api/v1/deneb"
eth2electra "github.com/attestantio/go-eth2-client/api/v1/electra"
eth2fulu "github.com/attestantio/go-eth2-client/api/v1/fulu"
eth2spec "github.com/attestantio/go-eth2-client/spec"
"github.com/attestantio/go-eth2-client/spec/altair"
"github.com/attestantio/go-eth2-client/spec/bellatrix"
"github.com/attestantio/go-eth2-client/spec/capella"
eth2e "github.com/attestantio/go-eth2-client/spec/electra"
eth2p0 "github.com/attestantio/go-eth2-client/spec/phase0"
ssz "github.com/ferranbt/fastssz"
"github.com/obolnetwork/charon/app/errors"
"github.com/obolnetwork/charon/app/z"
"github.com/obolnetwork/charon/eth2util"
)
var (
_ UnsignedData = AttestationData{}
_ UnsignedData = AggregatedAttestation{}
_ UnsignedData = VersionedAggregatedAttestation{}
_ UnsignedData = VersionedProposal{}
_ UnsignedData = SyncContribution{}
// Some types also support SSZ marshalling and unmarshalling.
_ ssz.Marshaler = AttestationData{}
_ ssz.Marshaler = AggregatedAttestation{}
_ ssz.Marshaler = VersionedAggregatedAttestation{}
_ ssz.Marshaler = VersionedProposal{}
_ ssz.Marshaler = SyncContribution{}
_ ssz.Unmarshaler = new(AttestationData)
_ ssz.Unmarshaler = new(AggregatedAttestation)
_ ssz.Unmarshaler = new(VersionedAggregatedAttestation)
_ ssz.Unmarshaler = new(VersionedProposal)
_ ssz.Unmarshaler = new(SyncContribution)
)
// AttestationData wraps the eth2 attestation data and adds the original duty.
// The original duty allows mapping the partial signed response from the VC
// back to the validator pubkey via the aggregation bits field.
type AttestationData struct {
Data eth2p0.AttestationData
Duty eth2v1.AttesterDuty
}
func (a AttestationData) Clone() (UnsignedData, error) {
var resp AttestationData
err := cloneSSZMarshaler(a, &resp)
if err != nil {
return nil, errors.Wrap(err, "clone attestation")
}
return resp, nil
}
func (a AttestationData) MarshalJSON() ([]byte, error) {
resp, err := json.Marshal(attestationDataJSON{
Data: &a.Data,
Duty: &a.Duty,
})
if err != nil {
return nil, errors.Wrap(err, "marshal attestation")
}
return resp, nil
}
func (a *AttestationData) UnmarshalJSON(data []byte) error {
var att attestationDataJSON
if err := json.Unmarshal(data, &att); err != nil {
return errors.Wrap(err, "unmarshal attestation")
}
a.Data = *att.Data
a.Duty = *att.Duty
return nil
}
type attestationDataJSON struct {
Data *eth2p0.AttestationData `json:"attestation_data"`
Duty *eth2v1.AttesterDuty `json:"attestation_duty"`
}
// NewAggregatedAttestation returns a new aggregated attestation.
func NewAggregatedAttestation(att *eth2p0.Attestation) AggregatedAttestation {
return AggregatedAttestation{Attestation: *att}
}
// AggregatedAttestation wraps un unsigned aggregated attestation and implements the UnsignedData interface.
type AggregatedAttestation struct {
eth2p0.Attestation
}
func (a AggregatedAttestation) Clone() (UnsignedData, error) {
var resp AggregatedAttestation
err := cloneSSZMarshaler(a, &resp)
if err != nil {
return nil, errors.Wrap(err, "clone aggregated attestation")
}
return resp, nil
}
func (a AggregatedAttestation) MarshalJSON() ([]byte, error) {
return a.Attestation.MarshalJSON()
}
func (a *AggregatedAttestation) UnmarshalJSON(input []byte) error {
var att eth2p0.Attestation
if err := json.Unmarshal(input, &att); err != nil {
return errors.Wrap(err, "unmarshal aggregated attestation")
}
*a = AggregatedAttestation{Attestation: att}
return nil
}
func (a AggregatedAttestation) MarshalSSZ() ([]byte, error) {
return a.Attestation.MarshalSSZ()
}
func (a AggregatedAttestation) MarshalSSZTo(dst []byte) ([]byte, error) {
return a.Attestation.MarshalSSZTo(dst)
}
func (a AggregatedAttestation) SizeSSZ() int {
return a.Attestation.SizeSSZ()
}
func (a *AggregatedAttestation) UnmarshalSSZ(b []byte) error {
return a.Attestation.UnmarshalSSZ(b)
}
// NewVersionedAggregatedAttestation returns a new aggregated attestation.
func NewVersionedAggregatedAttestation(att *eth2spec.VersionedAttestation) (VersionedAggregatedAttestation, error) {
switch att.Version {
case eth2spec.DataVersionPhase0:
if att.Phase0 == nil {
return VersionedAggregatedAttestation{}, errors.New("no phase0 attestation")
}
case eth2spec.DataVersionAltair:
if att.Altair == nil {
return VersionedAggregatedAttestation{}, errors.New("no altair attestation")
}
case eth2spec.DataVersionBellatrix:
if att.Bellatrix == nil {
return VersionedAggregatedAttestation{}, errors.New("no bellatrix attestation")
}
case eth2spec.DataVersionCapella:
if att.Capella == nil {
return VersionedAggregatedAttestation{}, errors.New("no capella attestation")
}
case eth2spec.DataVersionDeneb:
if att.Deneb == nil {
return VersionedAggregatedAttestation{}, errors.New("no deneb attestation")
}
case eth2spec.DataVersionElectra:
if att.Electra == nil {
return VersionedAggregatedAttestation{}, errors.New("no electra attestation")
}
case eth2spec.DataVersionFulu:
if att.Fulu == nil {
return VersionedAggregatedAttestation{}, errors.New("no fulu attestation")
}
default:
return VersionedAggregatedAttestation{}, errors.New("unknown version")
}
return VersionedAggregatedAttestation{VersionedAttestation: *att}, nil
}
// VersionedAggregatedAttestation wraps un unsigned aggregated attestation and implements the UnsignedData interface.
type VersionedAggregatedAttestation struct {
eth2spec.VersionedAttestation
}
func (a VersionedAggregatedAttestation) Clone() (UnsignedData, error) {
var resp VersionedAggregatedAttestation
err := cloneSSZMarshaler(a, &resp)
if err != nil {
return nil, errors.Wrap(err, "clone aggregated attestation")
}
return resp, nil
}
func (a VersionedAggregatedAttestation) MarshalJSON() ([]byte, error) {
var marshaller json.Marshaler
switch a.Version {
// No aggregatedAttestation nil checks since `NewVersionedProposal` assumed.
case eth2spec.DataVersionPhase0:
marshaller = a.Phase0
case eth2spec.DataVersionAltair:
marshaller = a.Altair
case eth2spec.DataVersionBellatrix:
marshaller = a.Bellatrix
case eth2spec.DataVersionCapella:
marshaller = a.Capella
case eth2spec.DataVersionDeneb:
marshaller = a.Deneb
case eth2spec.DataVersionElectra:
marshaller = a.Electra
case eth2spec.DataVersionFulu:
marshaller = a.Fulu
default:
return nil, errors.New("unknown version")
}
aggregatedAttestation, err := marshaller.MarshalJSON()
if err != nil {
return nil, errors.Wrap(err, "marshal aggregatedAttestation")
}
version, err := eth2util.DataVersionFromETH2(a.Version)
if err != nil {
return nil, errors.Wrap(err, "convert version")
}
resp, err := json.Marshal(versionedRawAttestationJSON{
Version: version,
ValidatorIndex: a.ValidatorIndex,
Attestation: aggregatedAttestation,
})
if err != nil {
return nil, errors.Wrap(err, "marshal wrapper")
}
return resp, nil
}
func (a VersionedAggregatedAttestation) HashTreeRoot() ([32]byte, error) {
switch a.Version {
// No aggregatedAttestation nil checks since `NewVersionedProposal` assumed.
case eth2spec.DataVersionPhase0:
return a.Phase0.HashTreeRoot()
case eth2spec.DataVersionAltair:
return a.Altair.HashTreeRoot()
case eth2spec.DataVersionBellatrix:
return a.Bellatrix.HashTreeRoot()
case eth2spec.DataVersionCapella:
return a.Capella.HashTreeRoot()
case eth2spec.DataVersionDeneb:
return a.Deneb.HashTreeRoot()
case eth2spec.DataVersionElectra:
return a.Electra.HashTreeRoot()
case eth2spec.DataVersionFulu:
return a.Fulu.HashTreeRoot()
default:
return [32]byte{}, errors.New("unknown version")
}
}
func (a *VersionedAggregatedAttestation) UnmarshalJSON(input []byte) error {
var raw versionedRawAttestationJSON
if err := json.Unmarshal(input, &raw); err != nil {
return errors.Wrap(err, "unmarshal attestation")
}
resp := eth2spec.VersionedAttestation{Version: raw.Version.ToETH2()}
switch resp.Version {
case eth2spec.DataVersionPhase0:
att := new(eth2p0.Attestation)
err := json.Unmarshal(raw.Attestation, &att)
if err != nil {
return errors.Wrap(err, "unmarshal phase0")
}
resp.Phase0 = att
case eth2spec.DataVersionAltair:
att := new(eth2p0.Attestation)
err := json.Unmarshal(raw.Attestation, &att)
if err != nil {
return errors.Wrap(err, "unmarshal altair")
}
resp.Altair = att
case eth2spec.DataVersionBellatrix:
att := new(eth2p0.Attestation)
err := json.Unmarshal(raw.Attestation, &att)
if err != nil {
return errors.Wrap(err, "unmarshal bellatrix")
}
resp.Bellatrix = att
case eth2spec.DataVersionCapella:
att := new(eth2p0.Attestation)
err := json.Unmarshal(raw.Attestation, &att)
if err != nil {
return errors.Wrap(err, "unmarshal capella")
}
resp.Capella = att
case eth2spec.DataVersionDeneb:
att := new(eth2p0.Attestation)
err := json.Unmarshal(raw.Attestation, &att)
if err != nil {
return errors.Wrap(err, "unmarshal deneb")
}
resp.Deneb = att
case eth2spec.DataVersionElectra:
att := new(eth2e.Attestation)
err := json.Unmarshal(raw.Attestation, &att)
if err != nil {
return errors.Wrap(err, "unmarshal electra")
}
resp.Electra = att
case eth2spec.DataVersionFulu:
att := new(eth2e.Attestation)
err := json.Unmarshal(raw.Attestation, &att)
if err != nil {
return errors.Wrap(err, "unmarshal fulu")
}
resp.Fulu = att
default:
return errors.New("unknown attestation version", z.Str("version", a.Version.String()))
}
resp.ValidatorIndex = raw.ValidatorIndex
a.VersionedAttestation = resp
return nil
}
// NewVersionedProposal validates and returns a new wrapped VersionedProposal.
func NewVersionedProposal(proposal *eth2api.VersionedProposal) (VersionedProposal, error) {
switch proposal.Version {
case eth2spec.DataVersionPhase0:
if proposal.Blinded {
return VersionedProposal{}, errors.New("phase0 blocks do not support blinding")
}
if proposal.Phase0 == nil {
return VersionedProposal{}, errors.New("no phase0 block")
}
case eth2spec.DataVersionAltair:
if proposal.Blinded {
return VersionedProposal{}, errors.New("altair blocks do not support blinding")
}
if proposal.Altair == nil {
return VersionedProposal{}, errors.New("no altair block")
}
case eth2spec.DataVersionBellatrix:
if proposal.Bellatrix == nil && !proposal.Blinded {
return VersionedProposal{}, errors.New("no bellatrix block")
}
if proposal.BellatrixBlinded == nil && proposal.Blinded {
return VersionedProposal{}, errors.New("no bellatrix blinded block")
}
case eth2spec.DataVersionCapella:
if proposal.Capella == nil && !proposal.Blinded {
return VersionedProposal{}, errors.New("no capella block")
}
if proposal.CapellaBlinded == nil && proposal.Blinded {
return VersionedProposal{}, errors.New("no capella blinded block")
}
case eth2spec.DataVersionDeneb:
if proposal.Deneb == nil && !proposal.Blinded {
return VersionedProposal{}, errors.New("no deneb block")
}
if proposal.DenebBlinded == nil && proposal.Blinded {
return VersionedProposal{}, errors.New("no deneb blinded block")
}
case eth2spec.DataVersionElectra:
if proposal.Electra == nil && !proposal.Blinded {
return VersionedProposal{}, errors.New("no electra block")
}
if proposal.ElectraBlinded == nil && proposal.Blinded {
return VersionedProposal{}, errors.New("no electra blinded block")
}
case eth2spec.DataVersionFulu:
if proposal.Fulu == nil && !proposal.Blinded {
return VersionedProposal{}, errors.New("no fulu block")
}
if proposal.FuluBlinded == nil && proposal.Blinded {
return VersionedProposal{}, errors.New("no fulu blinded block")
}
default:
return VersionedProposal{}, errors.New("unknown version")
}
return VersionedProposal{VersionedProposal: *proposal}, nil
}
// VersionedProposal wraps the eth2 versioned proposal and implements UnsignedData.
type VersionedProposal struct {
eth2api.VersionedProposal
}
func (p VersionedProposal) Clone() (UnsignedData, error) {
var resp VersionedProposal
err := cloneSSZMarshaler(p, &resp)
if err != nil {
return nil, errors.Wrap(err, "clone block")
}
return resp, nil
}
func (p VersionedProposal) MarshalJSON() ([]byte, error) {
var marshaller json.Marshaler
switch p.Version {
// No block nil checks since `NewVersionedProposal` assumed.
case eth2spec.DataVersionPhase0:
marshaller = p.Phase0
case eth2spec.DataVersionAltair:
marshaller = p.Altair
case eth2spec.DataVersionBellatrix:
if p.Blinded {
marshaller = p.BellatrixBlinded
} else {
marshaller = p.Bellatrix
}
case eth2spec.DataVersionCapella:
if p.Blinded {
marshaller = p.CapellaBlinded
} else {
marshaller = p.Capella
}
case eth2spec.DataVersionDeneb:
if p.Blinded {
marshaller = p.DenebBlinded
} else {
marshaller = p.Deneb
}
case eth2spec.DataVersionElectra:
if p.Blinded {
marshaller = p.ElectraBlinded
} else {
marshaller = p.Electra
}
case eth2spec.DataVersionFulu:
if p.Blinded {
marshaller = p.FuluBlinded
} else {
marshaller = p.Fulu
}
default:
return nil, errors.New("unknown version")
}
block, err := marshaller.MarshalJSON()
if err != nil {
return nil, errors.Wrap(err, "marshal block")
}
version, err := eth2util.DataVersionFromETH2(p.Version)
if err != nil {
return nil, errors.Wrap(err, "convert version")
}
resp, err := json.Marshal(versionedRawBlockJSON{
Version: version,
Block: block,
Blinded: p.Blinded,
})
if err != nil {
return nil, errors.Wrap(err, "marshal wrapper")
}
return resp, nil
}
func (p *VersionedProposal) UnmarshalJSON(input []byte) error {
var raw versionedRawBlockJSON
if err := json.Unmarshal(input, &raw); err != nil {
return errors.Wrap(err, "unmarshal block")
}
resp := eth2api.VersionedProposal{
Version: raw.Version.ToETH2(),
Blinded: raw.Blinded,
}
switch resp.Version {
case eth2spec.DataVersionPhase0:
if raw.Blinded {
return errors.New("phase0 blocks do not support blinding")
}
block := new(eth2p0.BeaconBlock)
if err := json.Unmarshal(raw.Block, &block); err != nil {
return errors.Wrap(err, "unmarshal phase0")
}
resp.Phase0 = block
case eth2spec.DataVersionAltair:
if raw.Blinded {
return errors.New("altair blocks do not support blinding")
}
block := new(altair.BeaconBlock)
if err := json.Unmarshal(raw.Block, &block); err != nil {
return errors.Wrap(err, "unmarshal altair")
}
resp.Altair = block
case eth2spec.DataVersionBellatrix:
if raw.Blinded {
block := new(eth2bellatrix.BlindedBeaconBlock)
if err := json.Unmarshal(raw.Block, &block); err != nil {
return errors.Wrap(err, "unmarshal bellatrix blinded")
}
resp.BellatrixBlinded = block
} else {
block := new(bellatrix.BeaconBlock)
if err := json.Unmarshal(raw.Block, &block); err != nil {
return errors.Wrap(err, "unmarshal bellatrix")
}
resp.Bellatrix = block
}
case eth2spec.DataVersionCapella:
if raw.Blinded {
block := new(eth2capella.BlindedBeaconBlock)
if err := json.Unmarshal(raw.Block, &block); err != nil {
return errors.Wrap(err, "unmarshal capella blinded")
}
resp.CapellaBlinded = block
} else {
block := new(capella.BeaconBlock)
if err := json.Unmarshal(raw.Block, &block); err != nil {
return errors.Wrap(err, "unmarshal capella")
}
resp.Capella = block
}
case eth2spec.DataVersionDeneb:
if raw.Blinded {
block := new(eth2deneb.BlindedBeaconBlock)
if err := json.Unmarshal(raw.Block, &block); err != nil {
return errors.Wrap(err, "unmarshal deneb blinded")
}
resp.DenebBlinded = block
} else {
block := new(eth2deneb.BlockContents)
if err := json.Unmarshal(raw.Block, &block); err != nil {
return errors.Wrap(err, "unmarshal deneb")
}
resp.Deneb = block
}
case eth2spec.DataVersionElectra:
if raw.Blinded {
block := new(eth2electra.BlindedBeaconBlock)
if err := json.Unmarshal(raw.Block, &block); err != nil {
return errors.Wrap(err, "unmarshal electra blinded")
}
resp.ElectraBlinded = block
} else {
block := new(eth2electra.BlockContents)
if err := json.Unmarshal(raw.Block, &block); err != nil {
return errors.Wrap(err, "unmarshal electra")
}
resp.Electra = block
}
case eth2spec.DataVersionFulu:
if raw.Blinded {
block := new(eth2electra.BlindedBeaconBlock) // Fulu blinded blocks have the same structure as electra blinded blocks.
if err := json.Unmarshal(raw.Block, &block); err != nil {
return errors.Wrap(err, "unmarshal fulu blinded")
}
resp.FuluBlinded = block
} else {
block := new(eth2fulu.BlockContents)
if err := json.Unmarshal(raw.Block, &block); err != nil {
return errors.Wrap(err, "unmarshal fulu")
}
resp.Fulu = block
}
default:
return errors.New("unknown version")
}
*p = VersionedProposal{VersionedProposal: resp}
return nil
}
// NewSyncContribution returns a new SyncContribution.
func NewSyncContribution(c *altair.SyncCommitteeContribution) SyncContribution {
return SyncContribution{SyncCommitteeContribution: *c}
}
type SyncContribution struct {
altair.SyncCommitteeContribution
}
func (s SyncContribution) Clone() (UnsignedData, error) {
var resp SyncContribution
err := cloneSSZMarshaler(s, &resp)
if err != nil {
return nil, errors.Wrap(err, "clone sync contribution")
}
return resp, nil
}
func (s SyncContribution) MarshalJSON() ([]byte, error) {
return s.SyncCommitteeContribution.MarshalJSON()
}
func (s *SyncContribution) UnmarshalJSON(input []byte) error {
return s.SyncCommitteeContribution.UnmarshalJSON(input)
}
func (s SyncContribution) MarshalSSZ() ([]byte, error) {
return s.SyncCommitteeContribution.MarshalSSZ()
}
func (s SyncContribution) MarshalSSZTo(dst []byte) ([]byte, error) {
return s.SyncCommitteeContribution.MarshalSSZTo(dst)
}
func (s SyncContribution) SizeSSZ() int {
return s.SyncCommitteeContribution.SizeSSZ()
}
func (s *SyncContribution) UnmarshalSSZ(b []byte) error {
return s.SyncCommitteeContribution.UnmarshalSSZ(b)
}
// unmarshalUnsignedData returns an instantiated unsigned data based on the duty type.
func unmarshalUnsignedData(typ DutyType, data []byte) (UnsignedData, error) {
switch typ {
case DutyAttester:
var resp AttestationData
if err := unmarshal(data, &resp); err != nil {
return nil, errors.Wrap(err, "unmarshal attestation data")
}
return resp, nil
case DutyProposer:
var resp VersionedProposal
if err := unmarshal(data, &resp); err != nil {
return nil, errors.Wrap(err, "unmarshal proposal")
}
return resp, nil
case DutyAggregator:
var respVersioned VersionedAggregatedAttestation
if err := unmarshal(data, &respVersioned); err != nil {
var resp AggregatedAttestation
if err := unmarshal(data, &resp); err != nil {
return nil, errors.Wrap(err, "unmarshal aggregated attestation")
}
return resp, nil
}
return respVersioned, nil
case DutySyncContribution:
var resp SyncContribution
if err := unmarshal(data, &resp); err != nil {
return nil, errors.Wrap(err, "unmarshal sync contribution")
}
return resp, nil
default:
return nil, errors.New("unsupported unsigned data duty type")
}
}