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

node/meta: Use neo-go's new notification API #3164

Merged
merged 3 commits into from
Feb 21, 2025

Conversation

carpawell
Copy link
Member

Receive object notifications by block and process them in sync, not independently. This is important for a consistent MPT state. Strictly speaking, it was a bug before but it was a bug that was impossible to fix without neo-go's new getblocknotifications API available with 0.108.0 release. Closes #3142.

@carpawell carpawell self-assigned this Feb 20, 2025
@carpawell carpawell force-pushed the fix/meta/get-notifications-from-block branch from 6792706 to 67929c2 Compare February 20, 2025 21:01
Copy link

codecov bot commented Feb 20, 2025

Codecov Report

Attention: Patch coverage is 57.44681% with 40 lines in your changes missing coverage. Please review.

Project coverage is 23.03%. Comparing base (d9c3652) to head (f85af2f).
Report is 8 commits behind head on master.

Files with missing lines Patch % Lines
pkg/services/meta/blocks.go 66.66% 16 Missing and 7 partials ⚠️
pkg/services/meta/meta.go 22.22% 14 Missing ⚠️
pkg/services/meta/notifications.go 57.14% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3164      +/-   ##
==========================================
+ Coverage   23.01%   23.03%   +0.01%     
==========================================
  Files         756      757       +1     
  Lines       60210    60210              
==========================================
+ Hits        13860    13868       +8     
+ Misses      45357    45349       -8     
  Partials      993      993              

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

"go.uber.org/zap"
)

func (m *Meta) blockFetcher(ctx context.Context, buff <-chan *block.Header) {
Copy link
Contributor

Choose a reason for hiding this comment

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

could u pls move these methods to a separate source file in a separate patch? this would easify the review

Copy link
Member Author

Choose a reason for hiding this comment

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

done

Copy link
Member Author

Choose a reason for hiding this comment

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

btw, i cost me additional 30+ mins for rebasing, conflicting, fixing, and rechecking additional threads below. this PR changes logic in general so old functions become separate things (it is by blocks now), but still PR is 200- lines, imo it was not worth it but it is already done

Copy link
Contributor

Choose a reason for hiding this comment

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

ive no idea how u could face any conflicts with this change, but thx anyway

Copy link
Member Author

Choose a reason for hiding this comment

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

because i was moving parts that should be changed to fix other threads. change it once in the original code, and change it second time in the moving commit. moving commit cannot be first because there was no "block" logic before and imo it was a good change as a single commit that changed everything

@@ -32,6 +33,17 @@ type ContainerLister interface {
List() (map[cid.ID]struct{}, error)
}

// wsClient is for test purposes only.
type wsClient interface {
GetBlockNotifications(blockHash util.Uint256, filters ...*neorpc.NotificationFilter) (*result.BlockNotifications, error)
Copy link
Contributor

Choose a reason for hiding this comment

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

suggest to write docs incl. what behavior Meta expects for blocks w/o notifications - error of both nil?

Copy link
Member Author

Choose a reason for hiding this comment

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

what docs? this is literally simplification for tests. if there is either a test http server that can be mocked or we do not use tests at all, this interface does not exist. this is literally rpcclient.WSClient. docs will not save us if neo-go decides to change behavior. i do not plan to have any self written implementation here ever

Copy link
Contributor

@cthulhu-rider cthulhu-rider Feb 21, 2025

Choose a reason for hiding this comment

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

ik why it's needed, idk how GetBlockNotifications interface behaves in mentioned case and wanna highlight this

neo-go decides to change behavior

it definitely wont change the behavior intentionally

Copy link
Member Author

Choose a reason for hiding this comment

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

will some reference to rpcclient.WSClient be enough in the comment? cause i do not understand you. nothing should implement it and it declares nothing for no one, it is literally rpcclient.WSClient but it is hard to mock it for tests. and i prefer this interface not to exist, but it would decrease coverage. i believe we will come to httptest package usage but not now

Copy link
Contributor

@cthulhu-rider cthulhu-rider Feb 21, 2025

Choose a reason for hiding this comment

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

yeah, u may state that this is a part of WSClient interface consumed by Meta

but 1st of all i wanna realize what is returned - 404 error, both nil or non-nil with empty fields?

It has already been implemented via deleted container notifications.

Signed-off-by: Pavel Karpy <[email protected]>
@carpawell carpawell force-pushed the fix/meta/get-notifications-from-block branch from 67929c2 to 80389fa Compare February 21, 2025 10:22
Receive object notifications by block and process them in sync, not
independently. This is important for a consistent MPT state. Strictly speaking,
it was a bug before but it was a bug that was impossible to fix without neo-go's
new `getblocknotifications` API available with 0.108.0 release. Closes #3142.

Signed-off-by: Pavel Karpy <[email protected]>
Also rename `container.go` to `containers.go` since we already have `blocks.go`
and `notifications.go` with the same meaning.

Signed-off-by: Pavel Karpy <[email protected]>
@carpawell carpawell force-pushed the fix/meta/get-notifications-from-block branch from 80389fa to f85af2f Compare February 21, 2025 10:29
@carpawell
Copy link
Member Author

Also fixed races.

@roman-khimov roman-khimov merged commit 8934873 into master Feb 21, 2025
21 of 22 checks passed
@roman-khimov roman-khimov deleted the fix/meta/get-notifications-from-block branch February 21, 2025 15:58
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.

Use getblocknotifications API for meta handling
3 participants