-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Copy pathgetters.go
755 lines (650 loc) · 18.5 KB
/
getters.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
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
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
package state
import (
"errors"
"fmt"
"time"
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
"github.com/prysmaticlabs/go-bitfield"
pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/params"
)
// EffectiveBalance returns the effective balance of the
// read only validator.
func (v *ReadOnlyValidator) EffectiveBalance() uint64 {
if v == nil || v.validator == nil {
return 0
}
return v.validator.EffectiveBalance
}
// ActivationEligibilityEpoch returns the activation eligibility epoch of the
// read only validator.
func (v *ReadOnlyValidator) ActivationEligibilityEpoch() uint64 {
return v.validator.ActivationEligibilityEpoch
}
// ActivationEpoch returns the activation epoch of the
// read only validator.
func (v *ReadOnlyValidator) ActivationEpoch() uint64 {
if v == nil || v.validator == nil {
return 0
}
return v.validator.ActivationEpoch
}
// WithdrawableEpoch returns the withdrawable epoch of the
// read only validator.
func (v *ReadOnlyValidator) WithdrawableEpoch() uint64 {
if v == nil || v.validator == nil {
return 0
}
return v.validator.WithdrawableEpoch
}
// ExitEpoch returns the exit epoch of the
// read only validator.
func (v *ReadOnlyValidator) ExitEpoch() uint64 {
if v == nil || v.validator == nil {
return 0
}
return v.validator.ExitEpoch
}
// PublicKey returns the public key of the
// read only validator.
func (v *ReadOnlyValidator) PublicKey() [48]byte {
if v == nil || v.validator == nil {
return [48]byte{}
}
var pubkey [48]byte
copy(pubkey[:], v.validator.PublicKey)
return pubkey
}
// WithdrawalCredentials returns the withdrawal credentials of the
// read only validator.
func (v *ReadOnlyValidator) WithdrawalCredentials() []byte {
creds := make([]byte, len(v.validator.WithdrawalCredentials))
copy(creds[:], v.validator.WithdrawalCredentials)
return creds
}
// Slashed returns the read only validator is slashed.
func (v *ReadOnlyValidator) Slashed() bool {
return v.validator.Slashed
}
// CopyValidator returns the copy of the read only validator.
func (v *ReadOnlyValidator) CopyValidator() *ethpb.Validator {
return CopyValidator(v.validator)
}
// InnerStateUnsafe returns the pointer value of the underlying
// beacon state proto object, bypassing immutability. Use with care.
func (b *BeaconState) InnerStateUnsafe() *pbp2p.BeaconState {
if b == nil {
return nil
}
return b.state
}
// CloneInnerState the beacon state into a protobuf for usage.
func (b *BeaconState) CloneInnerState() *pbp2p.BeaconState {
if b == nil || b.state == nil {
return nil
}
return &pbp2p.BeaconState{
GenesisTime: b.GenesisTime(),
GenesisValidatorsRoot: b.GenesisValidatorRoot(),
Slot: b.Slot(),
Fork: b.Fork(),
LatestBlockHeader: b.LatestBlockHeader(),
BlockRoots: b.BlockRoots(),
StateRoots: b.StateRoots(),
HistoricalRoots: b.HistoricalRoots(),
Eth1Data: b.Eth1Data(),
Eth1DataVotes: b.Eth1DataVotes(),
Eth1DepositIndex: b.Eth1DepositIndex(),
Validators: b.Validators(),
Balances: b.Balances(),
RandaoMixes: b.RandaoMixes(),
Slashings: b.Slashings(),
PreviousEpochAttestations: b.PreviousEpochAttestations(),
CurrentEpochAttestations: b.CurrentEpochAttestations(),
JustificationBits: b.JustificationBits(),
PreviousJustifiedCheckpoint: b.PreviousJustifiedCheckpoint(),
CurrentJustifiedCheckpoint: b.CurrentJustifiedCheckpoint(),
FinalizedCheckpoint: b.FinalizedCheckpoint(),
}
}
// HasInnerState detects if the internal reference to the state data structure
// is populated correctly. Returns false if nil.
func (b *BeaconState) HasInnerState() bool {
return b != nil && b.state != nil
}
// GenesisTime of the beacon state as a uint64.
func (b *BeaconState) GenesisTime() uint64 {
if !b.HasInnerState() {
return 0
}
return b.state.GenesisTime
}
// GenesisValidatorRoot of the beacon state.
func (b *BeaconState) GenesisValidatorRoot() []byte {
if !b.HasInnerState() {
return nil
}
if b.state.GenesisValidatorsRoot == nil {
return params.BeaconConfig().ZeroHash[:]
}
root := make([]byte, 32)
copy(root, b.state.GenesisValidatorsRoot)
return root
}
// GenesisUnixTime returns the genesis time as time.Time.
func (b *BeaconState) GenesisUnixTime() time.Time {
if !b.HasInnerState() {
return time.Unix(0, 0)
}
return time.Unix(int64(b.state.GenesisTime), 0)
}
// Slot of the current beacon chain state.
func (b *BeaconState) Slot() uint64 {
if !b.HasInnerState() {
return 0
}
b.lock.RLock()
defer b.lock.RUnlock()
return b.state.Slot
}
// Fork version of the beacon chain.
func (b *BeaconState) Fork() *pbp2p.Fork {
if !b.HasInnerState() {
return nil
}
if b.state.Fork == nil {
return nil
}
b.lock.RLock()
defer b.lock.RUnlock()
prevVersion := make([]byte, len(b.state.Fork.PreviousVersion))
copy(prevVersion, b.state.Fork.PreviousVersion)
currVersion := make([]byte, len(b.state.Fork.CurrentVersion))
copy(currVersion, b.state.Fork.CurrentVersion)
return &pbp2p.Fork{
PreviousVersion: prevVersion,
CurrentVersion: currVersion,
Epoch: b.state.Fork.Epoch,
}
}
// LatestBlockHeader stored within the beacon state.
func (b *BeaconState) LatestBlockHeader() *ethpb.BeaconBlockHeader {
if !b.HasInnerState() {
return nil
}
if b.state.LatestBlockHeader == nil {
return nil
}
b.lock.RLock()
defer b.lock.RUnlock()
hdr := ðpb.BeaconBlockHeader{
Slot: b.state.LatestBlockHeader.Slot,
ProposerIndex: b.state.LatestBlockHeader.ProposerIndex,
}
parentRoot := make([]byte, len(b.state.LatestBlockHeader.ParentRoot))
bodyRoot := make([]byte, len(b.state.LatestBlockHeader.BodyRoot))
stateRoot := make([]byte, len(b.state.LatestBlockHeader.StateRoot))
copy(parentRoot, b.state.LatestBlockHeader.ParentRoot)
copy(bodyRoot, b.state.LatestBlockHeader.BodyRoot)
copy(stateRoot, b.state.LatestBlockHeader.StateRoot)
hdr.ParentRoot = parentRoot
hdr.BodyRoot = bodyRoot
hdr.StateRoot = stateRoot
return hdr
}
// ParentRoot is a convenience method to access state.LatestBlockRoot.ParentRoot.
func (b *BeaconState) ParentRoot() [32]byte {
if !b.HasInnerState() {
return [32]byte{}
}
parentRoot := [32]byte{}
copy(parentRoot[:], b.state.LatestBlockHeader.ParentRoot)
return parentRoot
}
// BlockRoots kept track of in the beacon state.
func (b *BeaconState) BlockRoots() [][]byte {
if !b.HasInnerState() {
return nil
}
b.lock.RLock()
defer b.lock.RUnlock()
if b.state.BlockRoots == nil {
return nil
}
roots := make([][]byte, len(b.state.BlockRoots))
for i, r := range b.state.BlockRoots {
tmpRt := make([]byte, len(r))
copy(tmpRt, r)
roots[i] = tmpRt
}
return roots
}
// BlockRootAtIndex retrieves a specific block root based on an
// input index value.
func (b *BeaconState) BlockRootAtIndex(idx uint64) ([]byte, error) {
if !b.HasInnerState() {
return nil, ErrNilInnerState
}
if b.state.BlockRoots == nil {
return nil, nil
}
b.lock.RLock()
defer b.lock.RUnlock()
if len(b.state.BlockRoots) <= int(idx) {
return nil, fmt.Errorf("index %d out of range", idx)
}
root := make([]byte, 32)
copy(root, b.state.BlockRoots[idx])
return root, nil
}
// StateRoots kept track of in the beacon state.
func (b *BeaconState) StateRoots() [][]byte {
if !b.HasInnerState() {
return nil
}
if b.state.StateRoots == nil {
return nil
}
b.lock.RLock()
defer b.lock.RUnlock()
roots := make([][]byte, len(b.state.StateRoots))
for i, r := range b.state.StateRoots {
tmpRt := make([]byte, len(r))
copy(tmpRt, r)
roots[i] = tmpRt
}
return roots
}
// HistoricalRoots based on epochs stored in the beacon state.
func (b *BeaconState) HistoricalRoots() [][]byte {
if !b.HasInnerState() {
return nil
}
if b.state.HistoricalRoots == nil {
return nil
}
b.lock.RLock()
defer b.lock.RUnlock()
roots := make([][]byte, len(b.state.HistoricalRoots))
for i, r := range b.state.HistoricalRoots {
tmpRt := make([]byte, len(r))
copy(tmpRt, r)
roots[i] = tmpRt
}
return roots
}
// Eth1Data corresponding to the proof-of-work chain information stored in the beacon state.
func (b *BeaconState) Eth1Data() *ethpb.Eth1Data {
if !b.HasInnerState() {
return nil
}
if b.state.Eth1Data == nil {
return nil
}
return CopyETH1Data(b.state.Eth1Data)
}
// Eth1DataVotes corresponds to votes from eth2 on the canonical proof-of-work chain
// data retrieved from eth1.
func (b *BeaconState) Eth1DataVotes() []*ethpb.Eth1Data {
if !b.HasInnerState() {
return nil
}
if b.state.Eth1DataVotes == nil {
return nil
}
res := make([]*ethpb.Eth1Data, len(b.state.Eth1DataVotes))
for i := 0; i < len(res); i++ {
res[i] = CopyETH1Data(b.state.Eth1DataVotes[i])
}
return res
}
// Eth1DepositIndex corresponds to the index of the deposit made to the
// validator deposit contract at the time of this state's eth1 data.
func (b *BeaconState) Eth1DepositIndex() uint64 {
if !b.HasInnerState() {
return 0
}
return b.state.Eth1DepositIndex
}
// Validators participating in consensus on the beacon chain.
func (b *BeaconState) Validators() []*ethpb.Validator {
if !b.HasInnerState() {
return nil
}
if b.state.Validators == nil {
return nil
}
b.lock.RLock()
defer b.lock.RUnlock()
res := make([]*ethpb.Validator, len(b.state.Validators))
for i := 0; i < len(res); i++ {
val := b.state.Validators[i]
if val == nil {
continue
}
res[i] = CopyValidator(val)
}
return res
}
// ValidatorsReadOnly returns validators participating in consensus on the beacon chain. This
// method doesn't clone the respective validators and returns read only references to the validators.
func (b *BeaconState) ValidatorsReadOnly() []*ReadOnlyValidator {
if !b.HasInnerState() {
return nil
}
if b.state.Validators == nil {
return nil
}
b.lock.RLock()
defer b.lock.RUnlock()
res := make([]*ReadOnlyValidator, len(b.state.Validators))
for i := 0; i < len(res); i++ {
val := b.state.Validators[i]
res[i] = &ReadOnlyValidator{validator: val}
}
return res
}
// ValidatorAtIndex is the validator at the provided index.
func (b *BeaconState) ValidatorAtIndex(idx uint64) (*ethpb.Validator, error) {
if !b.HasInnerState() {
return nil, ErrNilInnerState
}
if b.state.Validators == nil {
return ðpb.Validator{}, nil
}
if uint64(len(b.state.Validators)) <= idx {
return nil, fmt.Errorf("index %d out of range", idx)
}
b.lock.RLock()
defer b.lock.RUnlock()
val := b.state.Validators[idx]
pubKey := make([]byte, len(val.PublicKey))
copy(pubKey, val.PublicKey)
withdrawalCreds := make([]byte, len(val.WithdrawalCredentials))
copy(withdrawalCreds, val.WithdrawalCredentials)
return ðpb.Validator{
PublicKey: pubKey,
WithdrawalCredentials: withdrawalCreds,
EffectiveBalance: val.EffectiveBalance,
Slashed: val.Slashed,
ActivationEligibilityEpoch: val.ActivationEligibilityEpoch,
ActivationEpoch: val.ActivationEpoch,
ExitEpoch: val.ExitEpoch,
WithdrawableEpoch: val.WithdrawableEpoch,
}, nil
}
// ValidatorAtIndexReadOnly is the validator at the provided index. This method
// doesn't clone the validator.
func (b *BeaconState) ValidatorAtIndexReadOnly(idx uint64) (*ReadOnlyValidator, error) {
if !b.HasInnerState() {
return nil, ErrNilInnerState
}
if b.state.Validators == nil {
return &ReadOnlyValidator{}, nil
}
if uint64(len(b.state.Validators)) <= idx {
return nil, fmt.Errorf("index %d out of range", idx)
}
b.lock.RLock()
defer b.lock.RUnlock()
return &ReadOnlyValidator{b.state.Validators[idx]}, nil
}
// ValidatorIndexByPubkey returns a given validator by its 48-byte public key.
func (b *BeaconState) ValidatorIndexByPubkey(key [48]byte) (uint64, bool) {
if b == nil || b.valIdxMap == nil {
return 0, false
}
b.lock.RLock()
defer b.lock.RUnlock()
idx, ok := b.valIdxMap[key]
return idx, ok
}
func (b *BeaconState) validatorIndexMap() map[[48]byte]uint64 {
if b == nil || b.valIdxMap == nil {
return map[[48]byte]uint64{}
}
b.lock.RLock()
defer b.lock.RUnlock()
m := make(map[[48]byte]uint64, len(b.valIdxMap))
for k, v := range b.valIdxMap {
m[k] = v
}
return m
}
// PubkeyAtIndex returns the pubkey at the given
// validator index.
func (b *BeaconState) PubkeyAtIndex(idx uint64) [48]byte {
if !b.HasInnerState() {
return [48]byte{}
}
if idx >= uint64(len(b.state.Validators)) {
return [48]byte{}
}
b.lock.RLock()
defer b.lock.RUnlock()
return bytesutil.ToBytes48(b.state.Validators[idx].PublicKey)
}
// NumValidators returns the size of the validator registry.
func (b *BeaconState) NumValidators() int {
if !b.HasInnerState() {
return 0
}
return len(b.state.Validators)
}
// ReadFromEveryValidator reads values from every validator and applies it to the provided function.
// Warning: This method is potentially unsafe, as it exposes the actual validator registry.
func (b *BeaconState) ReadFromEveryValidator(f func(idx int, val *ReadOnlyValidator) error) error {
if !b.HasInnerState() {
return ErrNilInnerState
}
if b.state.Validators == nil {
return errors.New("nil validators in state")
}
b.lock.RLock()
defer b.lock.RUnlock()
for i, v := range b.state.Validators {
err := f(i, &ReadOnlyValidator{validator: v})
if err != nil {
return err
}
}
return nil
}
// Balances of validators participating in consensus on the beacon chain.
func (b *BeaconState) Balances() []uint64 {
if !b.HasInnerState() {
return nil
}
if b.state.Balances == nil {
return nil
}
b.lock.RLock()
defer b.lock.RUnlock()
res := make([]uint64, len(b.state.Balances))
copy(res, b.state.Balances)
return res
}
// BalanceAtIndex of validator with the provided index.
func (b *BeaconState) BalanceAtIndex(idx uint64) (uint64, error) {
if !b.HasInnerState() {
return 0, ErrNilInnerState
}
if b.state.Balances == nil {
return 0, nil
}
b.lock.RLock()
defer b.lock.RUnlock()
if len(b.state.Balances) <= int(idx) {
return 0, fmt.Errorf("index of %d does not exist", idx)
}
return b.state.Balances[idx], nil
}
// BalancesLength returns the length of the balances slice.
func (b *BeaconState) BalancesLength() int {
if !b.HasInnerState() {
return 0
}
if b.state.Balances == nil {
return 0
}
b.lock.RLock()
defer b.lock.RUnlock()
return len(b.state.Balances)
}
// RandaoMixes of block proposers on the beacon chain.
func (b *BeaconState) RandaoMixes() [][]byte {
if !b.HasInnerState() {
return nil
}
if b.state.RandaoMixes == nil {
return nil
}
b.lock.RLock()
defer b.lock.RUnlock()
mixes := make([][]byte, len(b.state.RandaoMixes))
for i, r := range b.state.RandaoMixes {
tmpRt := make([]byte, len(r))
copy(tmpRt, r)
mixes[i] = tmpRt
}
return mixes
}
// RandaoMixAtIndex retrieves a specific block root based on an
// input index value.
func (b *BeaconState) RandaoMixAtIndex(idx uint64) ([]byte, error) {
if !b.HasInnerState() {
return nil, ErrNilInnerState
}
if b.state.RandaoMixes == nil {
return nil, nil
}
b.lock.RLock()
defer b.lock.RUnlock()
if len(b.state.RandaoMixes) <= int(idx) {
return nil, fmt.Errorf("index %d out of range", idx)
}
root := make([]byte, 32)
copy(root, b.state.RandaoMixes[idx])
return root, nil
}
// RandaoMixesLength returns the length of the randao mixes slice.
func (b *BeaconState) RandaoMixesLength() int {
if !b.HasInnerState() {
return 0
}
if b.state.RandaoMixes == nil {
return 0
}
b.lock.RLock()
defer b.lock.RUnlock()
return len(b.state.RandaoMixes)
}
// Slashings of validators on the beacon chain.
func (b *BeaconState) Slashings() []uint64 {
if !b.HasInnerState() {
return nil
}
if b.state.Slashings == nil {
return nil
}
b.lock.RLock()
defer b.lock.RUnlock()
res := make([]uint64, len(b.state.Slashings))
copy(res, b.state.Slashings)
return res
}
// PreviousEpochAttestations corresponding to blocks on the beacon chain.
func (b *BeaconState) PreviousEpochAttestations() []*pbp2p.PendingAttestation {
if !b.HasInnerState() {
return nil
}
if b.state.PreviousEpochAttestations == nil {
return nil
}
b.lock.RLock()
defer b.lock.RUnlock()
res := make([]*pbp2p.PendingAttestation, len(b.state.PreviousEpochAttestations))
for i := 0; i < len(res); i++ {
res[i] = CopyPendingAttestation(b.state.PreviousEpochAttestations[i])
}
return res
}
// CurrentEpochAttestations corresponding to blocks on the beacon chain.
func (b *BeaconState) CurrentEpochAttestations() []*pbp2p.PendingAttestation {
if !b.HasInnerState() {
return nil
}
if b.state.CurrentEpochAttestations == nil {
return nil
}
b.lock.RLock()
defer b.lock.RUnlock()
res := make([]*pbp2p.PendingAttestation, len(b.state.CurrentEpochAttestations))
for i := 0; i < len(res); i++ {
res[i] = CopyPendingAttestation(b.state.CurrentEpochAttestations[i])
}
return res
}
// JustificationBits marking which epochs have been justified in the beacon chain.
func (b *BeaconState) JustificationBits() bitfield.Bitvector4 {
if !b.HasInnerState() {
return nil
}
if b.state.JustificationBits == nil {
return nil
}
b.lock.RLock()
defer b.lock.RUnlock()
res := make([]byte, len(b.state.JustificationBits.Bytes()))
copy(res, b.state.JustificationBits.Bytes())
return res
}
// PreviousJustifiedCheckpoint denoting an epoch and block root.
func (b *BeaconState) PreviousJustifiedCheckpoint() *ethpb.Checkpoint {
if !b.HasInnerState() {
return nil
}
if b.state.PreviousJustifiedCheckpoint == nil {
return nil
}
b.lock.RLock()
defer b.lock.RUnlock()
return CopyCheckpoint(b.state.PreviousJustifiedCheckpoint)
}
// CurrentJustifiedCheckpoint denoting an epoch and block root.
func (b *BeaconState) CurrentJustifiedCheckpoint() *ethpb.Checkpoint {
if !b.HasInnerState() {
return nil
}
if b.state.CurrentJustifiedCheckpoint == nil {
return nil
}
b.lock.RLock()
defer b.lock.RUnlock()
return CopyCheckpoint(b.state.CurrentJustifiedCheckpoint)
}
// FinalizedCheckpoint denoting an epoch and block root.
func (b *BeaconState) FinalizedCheckpoint() *ethpb.Checkpoint {
if !b.HasInnerState() {
return nil
}
if b.state.FinalizedCheckpoint == nil {
return nil
}
b.lock.RLock()
defer b.lock.RUnlock()
return CopyCheckpoint(b.state.FinalizedCheckpoint)
}
// FinalizedCheckpointEpoch returns the epoch value of the finalized checkpoint.
func (b *BeaconState) FinalizedCheckpointEpoch() uint64 {
if !b.HasInnerState() {
return 0
}
if b.state.FinalizedCheckpoint == nil {
return 0
}
b.lock.RLock()
defer b.lock.RUnlock()
return b.state.FinalizedCheckpoint.Epoch
}