Fix VC not properly handled getAggregatedAttestation's 404 error. (#6254)

* Fix VC not properly handled getAggregatedAttestation's 404 error.

* Update AllTests.
This commit is contained in:
Eugene Kabanov 2024-05-01 18:32:28 +03:00 committed by GitHub
parent 1ab6f1654f
commit f3da063510
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 33 additions and 3 deletions

View File

@ -891,6 +891,7 @@ OK: 1/1 Fail: 0/1 Skip: 0/1
+ /eth/v1/validator/sync_committee_selections serialization/deserialization test OK
+ bestSuccess() API timeout test OK
+ firstSuccessParallel() API timeout test OK
+ getAggregatedAttestationDataScore() default test OK
+ getAggregatedAttestationDataScore() test vectors OK
+ getAttestationDataScore() test vectors OK
+ getLiveness() response deserialization test OK
@ -899,7 +900,7 @@ OK: 1/1 Fail: 0/1 Skip: 0/1
+ getUniqueVotes() test vectors OK
+ normalizeUri() test vectors OK
```
OK: 11/11 Fail: 0/11 Skip: 0/11
OK: 12/12 Fail: 0/12 Skip: 0/12
## Validator change pool testing suite
```diff
+ addValidatorChangeMessage/getAttesterSlashingMessage OK
@ -1019,4 +1020,4 @@ OK: 2/2 Fail: 0/2 Skip: 0/2
OK: 9/9 Fail: 0/9 Skip: 0/9
---TOTAL---
OK: 684/689 Fail: 0/689 Skip: 5/689
OK: 685/690 Fail: 0/690 Skip: 5/690

View File

@ -45,6 +45,9 @@ const
const
preferSSZ* = "application/octet-stream,application/json;q=0.9"
LowestScoreAggregatedAttestation* =
phase0.Attestation(
aggregation_bits: CommitteeValidatorsBits(BitSeq.init(1)))
static:
doAssert(ClientMaximumValidatorIds <= ServerMaximumValidatorIds)
@ -615,6 +618,10 @@ type
fork_choice_nodes*: seq[RestNode]
extra_data*: RestExtraData
func isLowestScoreAggregatedAttestation*(a: phase0.Attestation): bool =
(a.data.slot == Slot(0)) and (a.data.index == 0'u64) and
(a.data.source.epoch == Epoch(0)) and (a.data.target.epoch == Epoch(0))
func `==`*(a, b: RestValidatorIndex): bool =
uint64(a) == uint64(b)

View File

@ -1708,6 +1708,13 @@ proc getAggregatedAttestation*(
handle400()
ApiResponse[GetAggregatedAttestationResponse].err(
ResponseInvalidError)
of 404:
# A 404 error must be returned if no attestation is available for the
# requested `attestation_data_root`. To address the issue #6184, we
# use empty GetAggregatedAttestationResponse.
ApiResponse[GetAggregatedAttestationResponse].ok(
GetAggregatedAttestationResponse(
data: LowestScoreAggregatedAttestation))
of 500:
handle500()
ApiResponse[GetAggregatedAttestationResponse].err(

View File

@ -296,6 +296,12 @@ proc produceAndPublishAggregates(service: AttestationServiceRef,
err_name = exc.name, err_msg = exc.msg
return
if isLowestScoreAggregatedAttestation(aggAttestation):
warn "Aggregated attestation with the root was not seen by the " &
"beacon node",
attestation_root = shortLog(attestationRoot)
return
let pendingAggregates =
block:
var res: seq[Future[bool]]

View File

@ -746,6 +746,15 @@ suite "Validator Client test suite":
score = shortScore(getAggregatedAttestationDataScore(adata))
check score == vector[1]
test "getAggregatedAttestationDataScore() default test":
let
adata = GetAggregatedAttestationResponse(
data: LowestScoreAggregatedAttestation)
score = shortScore(getAggregatedAttestationDataScore(adata))
check:
score == "0.0000"
isLowestScoreAggregatedAttestation(adata.data) == true
test "getSyncCommitteeContributionDataScore() test vectors":
for vector in ContributionDataVectors:
let