|
78 | 78 | ParticipationFlags* = uint8 |
79 | 79 |
|
80 | 80 | EpochParticipationFlags* = |
81 | | - distinct HashList[ParticipationFlags, Limit VALIDATOR_REGISTRY_LIMIT] |
| 81 | + distinct List[ParticipationFlags, Limit VALIDATOR_REGISTRY_LIMIT] |
82 | 82 |
|
83 | 83 | # https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.2/specs/altair/beacon-chain.md#syncaggregate |
84 | 84 | SyncAggregate* = object |
@@ -558,10 +558,8 @@ type |
558 | 558 | # Represent in full; for the next epoch, current_epoch_participation in |
559 | 559 | # epoch n is previous_epoch_participation in epoch n+1 but this doesn't |
560 | 560 | # generalize. |
561 | | - previous_epoch_participation*: |
562 | | - List[ParticipationFlags, Limit VALIDATOR_REGISTRY_LIMIT] |
563 | | - current_epoch_participation*: |
564 | | - List[ParticipationFlags, Limit VALIDATOR_REGISTRY_LIMIT] |
| 561 | + previous_epoch_participation*: EpochParticipationFlags |
| 562 | + current_epoch_participation*: EpochParticipationFlags |
565 | 563 |
|
566 | 564 | justification_bits*: JustificationBits |
567 | 565 | previous_justified_checkpoint*: Checkpoint |
@@ -589,26 +587,44 @@ template `[]`*(arr: array[SYNC_COMMITTEE_SIZE, auto] | seq; |
589 | 587 | makeLimitedU8(SyncSubcommitteeIndex, SYNC_COMMITTEE_SUBNET_COUNT) |
590 | 588 | makeLimitedU16(IndexInSyncCommittee, SYNC_COMMITTEE_SIZE) |
591 | 589 |
|
592 | | -template asHashList*(epochFlags: EpochParticipationFlags): untyped = |
593 | | - HashList[ParticipationFlags, Limit VALIDATOR_REGISTRY_LIMIT] epochFlags |
| 590 | +template asList*(epochFlags: EpochParticipationFlags): untyped = |
| 591 | + List[ParticipationFlags, Limit VALIDATOR_REGISTRY_LIMIT] epochFlags |
| 592 | +template asList*(epochFlags: var EpochParticipationFlags): untyped = |
| 593 | + let tmp = cast[ptr List[ParticipationFlags, Limit VALIDATOR_REGISTRY_LIMIT]](addr epochFlags) |
| 594 | + tmp[] |
| 595 | + |
| 596 | +template asSeq*(epochFlags: EpochParticipationFlags): untyped = |
| 597 | + seq[ParticipationFlags] asList(epochFlags) |
| 598 | + |
| 599 | +template asSeq*(epochFlags: var EpochParticipationFlags): untyped = |
| 600 | + let tmp = cast[ptr seq[ParticipationFlags]](addr epochFlags) |
| 601 | + tmp[] |
594 | 602 |
|
595 | 603 | template item*(epochFlags: EpochParticipationFlags, idx: ValidatorIndex): ParticipationFlags = |
596 | | - asHashList(epochFlags).item(idx) |
| 604 | + asList(epochFlags)[idx] |
597 | 605 |
|
598 | | -template `[]`*(epochFlags: EpochParticipationFlags, idx: ValidatorIndex|uint64): ParticipationFlags = |
599 | | - asHashList(epochFlags)[idx] |
| 606 | +template `[]`*(epochFlags: EpochParticipationFlags, idx: ValidatorIndex|uint64|int): ParticipationFlags = |
| 607 | + asList(epochFlags)[idx] |
600 | 608 |
|
601 | 609 | template `[]=`*(epochFlags: EpochParticipationFlags, idx: ValidatorIndex, flags: ParticipationFlags) = |
602 | | - asHashList(epochFlags)[idx] = flags |
| 610 | + asList(epochFlags)[idx] = flags |
603 | 611 |
|
604 | 612 | template add*(epochFlags: var EpochParticipationFlags, flags: ParticipationFlags): bool = |
605 | | - asHashList(epochFlags).add flags |
| 613 | + asList(epochFlags).add flags |
606 | 614 |
|
607 | 615 | template len*(epochFlags: EpochParticipationFlags): int = |
608 | | - asHashList(epochFlags).len |
609 | | - |
610 | | -template data*(epochFlags: EpochParticipationFlags): untyped = |
611 | | - asHashList(epochFlags).data |
| 616 | + asList(epochFlags).len |
| 617 | + |
| 618 | +template low*(epochFlags: EpochParticipationFlags): int = |
| 619 | + asSeq(epochFlags).low |
| 620 | +template high*(epochFlags: EpochParticipationFlags): int = |
| 621 | + asSeq(epochFlags).high |
| 622 | + |
| 623 | +template assign*(v: var EpochParticipationFlags, src: EpochParticipationFlags) = |
| 624 | + # TODO https://github.com/nim-lang/Nim/issues/21123 |
| 625 | + mixin assign |
| 626 | + var tmp = cast[ptr seq[ParticipationFlags]](addr v) |
| 627 | + assign(tmp[], distinctBase src) |
612 | 628 |
|
613 | 629 | func shortLog*(v: SomeBeaconBlock): auto = |
614 | 630 | ( |
|
0 commit comments