Skip to content

Commit

Permalink
fix(cannon): Change duties function signature (#360)
Browse files Browse the repository at this point in the history
* fix(cannon): Change duties function signature

* refactor: Remove commented out code in seeding.yaml
  • Loading branch information
samcm authored Aug 13, 2024
1 parent 79a2ece commit 592b95e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 33 deletions.
60 changes: 30 additions & 30 deletions .github/cannon/seeding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -161,35 +161,6 @@ networks:
AND blob_size = 131072
AND blob_empty_size = 56206"
expected: "1"
- name: BEACON_API_ETH_V1_BEACON_VALIDATORS
finalizedEpoch: 71005
assert:
query: "SELECT COUNT(*) FROM canonical_beacon_validators FINAL
WHERE
epoch = 71006
AND epoch_start_date_time = '2024-08-09 01:58:24'
AND `index` = 0
AND balance = '32005471610'
AND status = 'active_ongoing'
AND effective_balance = '32000000000'
AND slashed = false"
expected: "1"
- name: BEACON_API_ETH_V1_BEACON_VALIDATORS
finalizedEpoch: 71005
assert:
query: "SELECT COUNT(*) FROM canonical_beacon_validators_pubkeys FINAL
WHERE
`index` = 0
AND pubkey = '0x8c87f7a01e54215ac177fb706d78e9edf762f15f34ba81103094da450f1683ced257d4270fc030a9a803aaa060edf16a'"
expected: "1"
- name: BEACON_API_ETH_V1_BEACON_VALIDATORS
finalizedEpoch: 71005
assert:
query: "SELECT COUNT(*) FROM canonical_beacon_validators_withdrawal_credentials FINAL
WHERE
`index` = 0
AND withdrawal_credentials = '0x0100000000000000000000000e5dda855eb1de2a212cd1f62b2a3ee49d20c444'"
expected: "1"
- name: BEACON_API_ETH_V2_BEACON_BLOCK_EXECUTION_TRANSACTION
finalizedEpoch: 71010
assert:
Expand Down Expand Up @@ -248,4 +219,33 @@ networks:
AND epoch_start_date_time = '2024-08-09 03:08:48'
AND has(validators, 1119923)
"
expected: "1"
expected: "1"
# - name: BEACON_API_ETH_V1_BEACON_VALIDATORS
# finalizedEpoch: 71005
# assert:
# query: "SELECT COUNT(*) FROM canonical_beacon_validators FINAL
# WHERE
# epoch = 71006
# AND epoch_start_date_time = '2024-08-09 01:58:24'
# AND `index` = 0
# AND balance = '32005471610'
# AND status = 'active_ongoing'
# AND effective_balance = '32000000000'
# AND slashed = false"
# expected: "1"
# - name: BEACON_API_ETH_V1_BEACON_VALIDATORS
# finalizedEpoch: 71005
# assert:
# query: "SELECT COUNT(*) FROM canonical_beacon_validators_pubkeys FINAL
# WHERE
# `index` = 0
# AND pubkey = '0x8c87f7a01e54215ac177fb706d78e9edf762f15f34ba81103094da450f1683ced257d4270fc030a9a803aaa060edf16a'"
# expected: "1"
# - name: BEACON_API_ETH_V1_BEACON_VALIDATORS
# finalizedEpoch: 71005
# assert:
# query: "SELECT COUNT(*) FROM canonical_beacon_validators_withdrawal_credentials FINAL
# WHERE
# `index` = 0
# AND withdrawal_credentials = '0x0100000000000000000000000e5dda855eb1de2a212cd1f62b2a3ee49d20c444'"
# expected: "1"
6 changes: 3 additions & 3 deletions pkg/cannon/ethereum/services/duties.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func (m *DutiesService) fireOnBeaconCommitteeSubscriptions(epoch phase0.Epoch, c
}
}

func (m *DutiesService) FetchBeaconCommittee(ctx context.Context, stateID string, epoch phase0.Epoch) ([]*v1.BeaconCommittee, error) {
func (m *DutiesService) FetchBeaconCommittee(ctx context.Context, epoch phase0.Epoch) ([]*v1.BeaconCommittee, error) {
if duties := m.beaconCommittees.Get(epoch); duties != nil {
return duties.Value(), nil
}
Expand All @@ -138,7 +138,7 @@ func (m *DutiesService) FetchBeaconCommittee(ctx context.Context, stateID string
}

func (m *DutiesService) GetValidatorIndex(epoch phase0.Epoch, slot phase0.Slot, committeeIndex phase0.CommitteeIndex, position uint64) (phase0.ValidatorIndex, error) {
if _, err := m.FetchBeaconCommittee(context.Background(), "head", epoch); err != nil {
if _, err := m.FetchBeaconCommittee(context.Background(), epoch); err != nil {
return 0, fmt.Errorf("error fetching beacon committee for epoch %d: %w", epoch, err)
}

Expand All @@ -165,7 +165,7 @@ func (m *DutiesService) GetValidatorIndex(epoch phase0.Epoch, slot phase0.Slot,
func (m *DutiesService) GetLastCommitteeIndex(ctx context.Context, slot phase0.Slot) (*phase0.CommitteeIndex, error) {
epoch := m.metadata.Wallclock().Epochs().FromSlot(uint64(slot))

_, err := m.FetchBeaconCommittee(ctx, "head", phase0.Epoch(epoch.Number()))
_, err := m.FetchBeaconCommittee(ctx, phase0.Epoch(epoch.Number()))
if err != nil {
return nil, fmt.Errorf("error fetching beacon committee for epoch %d: %w", epoch.Number(), err)
}
Expand Down

0 comments on commit 592b95e

Please sign in to comment.