Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - Do not try to publish proofs for malicious ATXs during sync #5586

Closed
wants to merge 5 commits into from

Conversation

ivan4th
Copy link
Contributor

@ivan4th ivan4th commented Feb 19, 2024

Motivation

Publishing is blocked during sync because Syncer::ListenToATXGossip() returns false, and thus every malicious ATX being synced is causing an error resulting in an interruption of sync.

Description

Do not try to publish ATX malfeasance proofs during sync.

Test Plan

Sync a test node, look for sync interruptions / errors

Publishing is blocked during sync because Syncer::ListenToATXGossip()
returns false, and thus every malicious ATX being synced was causing
an error resulting in an interruption of sync.
Copy link

codecov bot commented Feb 19, 2024

Codecov Report

Attention: 14 lines in your changes are missing coverage. Please review.

Comparison is base (0c4c55d) 79.6% compared to head (6c98cf4) 79.7%.
Report is 4 commits behind head on develop.

Files Patch % Lines
activation/handler.go 78.1% 12 Missing and 2 partials ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           develop   #5586   +/-   ##
=======================================
  Coverage     79.6%   79.7%           
=======================================
  Files          270     270           
  Lines        27186   27199   +13     
=======================================
+ Hits         21667   21688   +21     
+ Misses        3973    3967    -6     
+ Partials      1546    1544    -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ivan4th
Copy link
Contributor Author

ivan4th commented Feb 19, 2024

bors try

spacemesh-bors bot added a commit that referenced this pull request Feb 19, 2024
@spacemesh-bors
Copy link

try

Build succeeded:

CHANGELOG.md Show resolved Hide resolved
}
encodedProof, err := codec.Encode(&gossip)
if err != nil {
h.log.With().Fatal("failed to encode malfeasance gossip", log.Err(err))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe MustEncode, since the code was changed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

}
if err = h.publisher.Publish(ctx, pubsub.MalfeasanceProof, encodedProof); err != nil {
h.log.With().Error("failed to broadcast malfeasance proof", log.Err(err))
return fmt.Errorf("broadcast atx malfeasance proof: %w", err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the log 1 line above necessary if we return same error up the stack?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message from the handlers was being ignored in pubsub code:

err := handler(log.WithNewRequestID(ctx), pid, msg.Data)
metrics.ProcessedMessagesDuration.WithLabelValues(topic, castResult(err)).
Observe(float64(time.Since(start)))
switch {
case errors.Is(err, ErrValidationReject):
return pubsub.ValidationReject
case err != nil:
return pubsub.ValidationIgnore
default:
return pubsub.ValidationAccept
}

I've added debug logging there, but IIUC failing to be able to broadcast the malfeasance proof should be more than a silent validation error by default, so I kept logging there, too.

h.inProgressMu.Lock()
defer h.inProgressMu.Unlock()
for _, ch := range h.inProgress[atx.ID()] {
ch <- err
close(ch)
}
delete(h.inProgress, atx.ID())
return err
return proof, err
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

proof, nil ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

h.processATX() call above that may return an error, and that error needs to be sent over an "inProgress" channel, but it also needs to be returned so that HandleSyncedAtx() and HandleGossipAtx() don't swallow errors

activation/handler_test.go Outdated Show resolved Hide resolved
@dshulyak
Copy link
Contributor

@ivan4th should we merge the change?

@ivan4th
Copy link
Contributor Author

ivan4th commented Feb 26, 2024

Yes, let's merge

@ivan4th
Copy link
Contributor Author

ivan4th commented Feb 26, 2024

bors merge

spacemesh-bors bot pushed a commit that referenced this pull request Feb 26, 2024
## Motivation

Publishing is blocked during sync because `Syncer::ListenToATXGossip()` returns false, and thus every malicious ATX being synced is causing an error resulting in an interruption of sync.
@spacemesh-bors
Copy link

Pull request successfully merged into develop.

Build succeeded:

@spacemesh-bors spacemesh-bors bot changed the title Do not try to publish proofs for malicious ATXs during sync [Merged by Bors] - Do not try to publish proofs for malicious ATXs during sync Feb 26, 2024
@spacemesh-bors spacemesh-bors bot closed this Feb 26, 2024
@spacemesh-bors spacemesh-bors bot deleted the fix/sync-publish branch February 26, 2024 16:34
ivan4th added a commit that referenced this pull request Feb 28, 2024
Publishing is blocked during sync because `Syncer::ListenToATXGossip()` returns false, and thus every malicious ATX being synced is causing an error resulting in an interruption of sync.
ivan4th added a commit that referenced this pull request Feb 29, 2024
Publishing is blocked during sync because `Syncer::ListenToATXGossip()` returns false, and thus every malicious ATX being synced is causing an error resulting in an interruption of sync.
ivan4th added a commit that referenced this pull request Feb 29, 2024
Publishing is blocked during sync because `Syncer::ListenToATXGossip()` returns false, and thus every malicious ATX being synced is causing an error resulting in an interruption of sync.
ivan4th added a commit that referenced this pull request Feb 29, 2024
Backport #5586: Do not try to publish proofs for malicious ATXs during sync
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants