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

implement isDelegate() in nodeinfo #3804

Merged
merged 7 commits into from
Feb 14, 2023

Conversation

envestcc
Copy link
Member

@envestcc envestcc commented Feb 8, 2023

Description

  • Implement the isDelegate logic in nodeinfo package
  • Add feature enable switch for nodeinfo

Type of change

Please delete options that are not relevant.

  • Code refactor or improvement

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • make test

Test Configuration:

  • Firmware version:
  • Hardware:
  • Toolchain:
  • SDK:

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@codecov
Copy link

codecov bot commented Feb 8, 2023

Codecov Report

Merging #3804 (7bed04e) into master (263ff82) will increase coverage by 0.91%.
The diff coverage is 80.54%.

❗ Current head 7bed04e differs from pull request most recent head edb947a. Consider uploading reports for the commit edb947a to get more accurate results

@@            Coverage Diff             @@
##           master    #3804      +/-   ##
==========================================
+ Coverage   74.47%   75.39%   +0.91%     
==========================================
  Files         269      303      +34     
  Lines       23925    25854    +1929     
==========================================
+ Hits        17818    19492    +1674     
- Misses       5174     5342     +168     
- Partials      933     1020      +87     
Impacted Files Coverage Δ
action/actctx.go 90.62% <ø> (+6.25%) ⬆️
action/action.go 82.35% <ø> (ø)
action/action_deserializer.go 57.14% <ø> (ø)
action/candidate_update.go 88.88% <0.00%> (-4.14%) ⬇️
action/consignment_transfer.go 90.41% <ø> (ø)
action/const.go 100.00% <ø> (ø)
action/execution.go 83.78% <ø> (ø)
action/grantreward.go 68.57% <ø> (ø)
action/protocol/account/protocol.go 86.90% <ø> (ø)
action/protocol/dock.go 100.00% <ø> (ø)
... and 282 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

chainservice/builder.go Outdated Show resolved Hide resolved
chainservice/builder.go Outdated Show resolved Hide resolved
chainservice/builder.go Outdated Show resolved Hide resolved
nodeinfo/manager.go Outdated Show resolved Hide resolved
chainservice/builder.go Outdated Show resolved Hide resolved
@envestcc envestcc marked this pull request as ready for review February 13, 2023 02:11
@envestcc envestcc requested review from CoderZhi and a team as code owners February 13, 2023 02:11
nodeinfo/manager.go Outdated Show resolved Hide resolved
nodeinfo/manager.go Outdated Show resolved Hide resolved
nodeinfo/manager.go Outdated Show resolved Hide resolved
nodeinfo/manager.go Outdated Show resolved Hide resolved
nodeinfo/manager.go Outdated Show resolved Hide resolved
nodeinfo/manager.go Outdated Show resolved Hide resolved
@sonarcloud
Copy link

sonarcloud bot commented Feb 14, 2023

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
15.1% 15.1% Duplication

@Liuhaai Liuhaai merged commit 897703b into iotexproject:master Feb 14, 2023
@envestcc envestcc deleted the monitor_msg_v3 branch February 15, 2023 01:21
dustinxie pushed a commit that referenced this pull request Feb 18, 2023
* implement nodinfo.isDelegate
Copy link
Collaborator

@CoderZhi CoderZhi left a comment

Choose a reason for hiding this comment

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

  • bad namings like GetNodeByAddr.
  • as discussed, subscribe block may be a better solution

Comment on lines +235 to +240
if !dm.delegateCache {
if err := dm.updateDelegateCache(); err != nil {
log.L().Error("nodeinfo manager update delegate cache failed", zap.Error(err))
}
}
return dm.delegateCache
Copy link
Collaborator

Choose a reason for hiding this comment

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

after setting delegateCache, a node will always be a delegate, which is not true.

Copy link
Member

Choose a reason for hiding this comment

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

same thought here. Read from block is a good solution

Comment on lines +102 to +105
if !protocol.MustGetFeatureCtx(ctx).EnableNodeInfo {
log.L().Debug("nodeinfo manager feature is disabled")
return
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

not a height dependent feature & should not be checked in the recurring task

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.

5 participants