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] - malfeasance2: update GRPC API #6557

Closed
wants to merge 9 commits into from

Conversation

fasmat
Copy link
Member

@fasmat fasmat commented Dec 19, 2024

Motivation

This updates the malfeasance v2alpha1 endpoints to be able to return both legacy and v2 malfeasance proofs.

Description

I changed the malfeasance events to not include the encoded proof any more instead they only report which identity was detected to be malicious and expect the receiver of the event to fetch a proof from the state DB if needed (or call Info on one of the two malfeasance handlers to get information about the malicious behavior of the given identity)

GRPC tests have been updated to check if both v1 and v2 malfeasance proofs are handled correctly.

The malfeasance2.Handler in this PR always returns sql.ErrNotFound to keep the PR size manageable. The full implementation of the malfeasance2.Handler can be found in #6307

Test Plan

existing tests have been updated and new tests were added for changed / added functionality

TODO

  • Explain motivation or link existing issue(s)
  • Test changes and document test plan
  • Update documentation as needed
  • Update changelog as needed

@fasmat fasmat self-assigned this Dec 19, 2024
Copy link

codecov bot commented Dec 19, 2024

Codecov Report

Attention: Patch coverage is 66.31944% with 97 lines in your changes missing coverage. Please review.

Project coverage is 79.7%. Comparing base (febfe27) to head (0cb2cfa).
Report is 1 commits behind head on develop.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
api/grpcserver/v2alpha1/malfeasance.go 56.4% 48 Missing and 16 partials ⚠️
api/grpcserver/activation_service.go 75.0% 6 Missing and 1 partial ⚠️
api/grpcserver/mesh_service.go 46.1% 6 Missing and 1 partial ⚠️
events/events.go 14.2% 6 Missing ⚠️
events/reporter.go 57.1% 2 Missing and 1 partial ⚠️
malfeasance/handler.go 72.7% 2 Missing and 1 partial ⚠️
sql/malfeasance/malfeasance.go 90.0% 2 Missing and 1 partial ⚠️
malfeasance2/handler.go 81.8% 2 Missing ⚠️
api/grpcserver/debug_service.go 0.0% 1 Missing ⚠️
events/malfeasance.go 50.0% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##           develop   #6557     +/-   ##
=========================================
- Coverage     79.8%   79.7%   -0.1%     
=========================================
  Files          354     355      +1     
  Lines        47015   47135    +120     
=========================================
+ Hits         37534   37603     +69     
- Misses        7351    7390     +39     
- Partials      2130    2142     +12     

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

api/grpcserver/v2alpha1/malfeasance.go Outdated Show resolved Hide resolved
@fasmat
Copy link
Member Author

fasmat commented Dec 19, 2024

bors merge

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

This updates the malfeasance v2alpha1 endpoints to be able to return both legacy and v2 malfeasance proofs.
@ivan4th
Copy link
Contributor

ivan4th commented Dec 19, 2024

Possibly overlooked before approving -- are we really using request.Limit?
It does not seem to be included in SQL queries and all of the rows are retrieved

@fasmat
Copy link
Member Author

fasmat commented Dec 19, 2024

Possibly overlooked before approving -- are we really using request.Limit? It does not seem to be included in SQL queries and all of the rows are retrieved

Yes we do - IterateOps uses the sql/builder package to build queries with limit. There are even tests that assert that request.Offset and request.Limit work as expected:

t.Run("limit and offset", func(t *testing.T) {
client := spacemeshv2alpha1.NewMalfeasanceServiceClient(dialGrpc(t, cfg))
list, err := client.List(context.Background(), &spacemeshv2alpha1.MalfeasanceRequest{
Limit: 25,
Offset: 50,
})
require.NoError(t, err)
require.Len(t, list.Proofs, 25)
})

@ivan4th
Copy link
Contributor

ivan4th commented Dec 19, 2024

Ok I see, thanks.
BTW read transaction still makes sense from consistency standpoint.
Imagine an API client making two requests w/o limit specified which yield N malfeasant identities. With new v1 malfeasance being processed between queries, it may so happen that these 2 sets of N identities may have different contents, with one item disappearing and another one taking its place (given that the order of items is by the ID which is effectively random) which may confuse some clients, as it breaks the assumption of the malfeasant identity set being add-only (no items should be removed)

@spacemesh-bors
Copy link

Build failed:

@fasmat
Copy link
Member Author

fasmat commented Dec 19, 2024

Flaky test: #6113

bors merge

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

This updates the malfeasance v2alpha1 endpoints to be able to return both legacy and v2 malfeasance proofs.
@spacemesh-bors
Copy link

Pull request successfully merged into develop.

Build succeeded:

@spacemesh-bors spacemesh-bors bot changed the title malfeasance2: update GRPC API [Merged by Bors] - malfeasance2: update GRPC API Dec 19, 2024
@spacemesh-bors spacemesh-bors bot closed this Dec 19, 2024
@spacemesh-bors spacemesh-bors bot deleted the malfeasance-grpc branch December 19, 2024 20:58
spacemesh-bors bot pushed a commit that referenced this pull request Jan 3, 2025
## Motivation

Followup for #6557. Now malfeasance2 proofs are actually fetched from the DB and metadata for them returned.
spacemesh-bors bot pushed a commit that referenced this pull request Jan 3, 2025
## Motivation

Followup for #6557. Now malfeasance2 proofs are actually fetched from the DB and metadata for them returned.
spacemesh-bors bot pushed a commit that referenced this pull request Jan 3, 2025
## Motivation

Followup for #6557. Now malfeasance2 proofs are actually fetched from the DB and metadata for them returned.
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.

2 participants