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] - Remove dependency on activation/wire from sql/identities #6330

Closed
wants to merge 2 commits into from

Conversation

fasmat
Copy link
Member

@fasmat fasmat commented Sep 13, 2024

Motivation

The sql/identities package depends on activation/wire. sql packages should not import wire packages, rather should be oblivious to specific encodings of wire types.

This PR removes this dependency.

Description

With an upcoming extension of malfeasance proofs I want to use the sql/identities package as an import in activation/wire. Without this change this won't be possible. Packages needing malfeasance proofs should call the sql/identities package to get the raw bytes and decode the returned bytes themselves if needed.

Test Plan

Existing tests were adjusted and checked to still pass

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 Sep 13, 2024
Comment on lines 190 to 193
var blob sql.Blob
require.NoError(t, identities.LoadMalfeasanceBlob(context.Background(), h.db, nodeID.Bytes(), &blob))
malProof := &wire.MalfeasanceProof{}
codec.MustDecode(blob.Bytes, malProof)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is repeated so often, maybe it deserves a helper in malfeasance package?

func LoadMalfeasanceProof(db sql.Executor, id types.NodeID) (*mwire.MalfeasanceProof, error) { ... }

Copy link
Member Author

Choose a reason for hiding this comment

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

I thought about that as well. The reason I didn't implemented a function that returns a wire.MalfeasanceProof from the DB directly is because on the one hand this function would only used in tests and arguably it the tests instead should assert that an identity has been marked as malfeasant instead of fetching the proof from the DB and asserting that a specific proof was stored (separation of concerns).

Wdyt about simplifying the relevant tests to only check for malfeasance instead of asserting that a specific proof was stored?

Copy link

codecov bot commented Sep 13, 2024

Codecov Report

Attention: Patch coverage is 94.73684% with 1 line in your changes missing coverage. Please review.

Project coverage is 81.8%. Comparing base (a28991f) to head (2d71518).
Report is 1 commits behind head on develop.

Files with missing lines Patch % Lines
sql/identities/identities.go 90.9% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           develop   #6330   +/-   ##
=======================================
  Coverage     81.8%   81.8%           
=======================================
  Files          312     312           
  Lines        34623   34606   -17     
=======================================
- Hits         28334   28328    -6     
+ Misses        4458    4446   -12     
- Partials      1831    1832    +1     

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

@fasmat
Copy link
Member Author

fasmat commented Sep 13, 2024

bors merge

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

The `sql/identities` package depends on `activation/wire`. `sql` packages should not import `wire` packages, rather should be oblivious to specific encodings of wire types.

This PR removes this dependency.
@spacemesh-bors
Copy link

Build failed:

  • ci-status

@fasmat
Copy link
Member Author

fasmat commented Sep 13, 2024

Flaky test: #6262

bors merge

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

The `sql/identities` package depends on `activation/wire`. `sql` packages should not import `wire` packages, rather should be oblivious to specific encodings of wire types.

This PR removes this dependency.
@spacemesh-bors
Copy link

Build failed:

@fasmat
Copy link
Member Author

fasmat commented Sep 13, 2024

grpc errors

bors merge

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

The `sql/identities` package depends on `activation/wire`. `sql` packages should not import `wire` packages, rather should be oblivious to specific encodings of wire types.

This PR removes this dependency.
@spacemesh-bors
Copy link

Pull request successfully merged into develop.

Build succeeded:

@spacemesh-bors spacemesh-bors bot changed the title Remove dependency on activation/wire from sql/identities [Merged by Bors] - Remove dependency on activation/wire from sql/identities Sep 13, 2024
@spacemesh-bors spacemesh-bors bot closed this Sep 13, 2024
@spacemesh-bors spacemesh-bors bot deleted the no-wire-dependency branch September 13, 2024 15:24
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