@@ -372,8 +372,29 @@ func (db *MemDB) storeAttestationUnsafe(pubkey core.PubKey, unsignedData core.Un
372372 }
373373
374374 if value , ok := db .attDuties [aKeyCommIdx0 ]; ok {
375- if value .String () != attData .Data .String () {
376- return errors .New ("clashing attestation data" , z .Any ("key" , aKeyCommIdx0 ))
375+ // When we fetch attestation data with the fetcher, we are doing this in a loop,
376+ // which takes variable amount of time, based on the beacon node's performance.
377+ // If the beacon node is underperforming it might be that in the middle of this loop it receives a new block.
378+ // This will result some attestation datas having the up to date head, while others have an old head.
379+ // In a good scenario of well performing beacon node, the heads will be the same and the `value`` and `attData.Data`
380+ // will be equal. However, in the scenario explained above, their head will missmatch, resulting in inequality.
381+ // That's why we are checking here only if source and target missmatch.
382+ if value .Source .String () != attData .Data .Source .String () {
383+ return errors .New (
384+ "clashing attestation data with hardcoded commidx=0 source" ,
385+ z .Any ("key" , aKeyCommIdx0 ),
386+ z .Str ("existing" , value .Source .String ()),
387+ z .Str ("new" , attData .Data .Source .String ()),
388+ )
389+ }
390+
391+ if value .Target .String () != attData .Data .Target .String () {
392+ return errors .New (
393+ "clashing attestation data with hardcoded commidx=0 target" ,
394+ z .Any ("key" , aKeyCommIdx0 ),
395+ z .Str ("existing" , value .Target .String ()),
396+ z .Str ("new" , attData .Data .Target .String ()),
397+ )
377398 }
378399 } else {
379400 db .attDuties [aKeyCommIdx0 ] = & attData .Data
0 commit comments