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

broadcast node's height info into p2p network #3744

Merged
merged 36 commits into from
Feb 6, 2023

Conversation

envestcc
Copy link
Member

@envestcc envestcc commented Dec 29, 2022

Description

Set up a mechanism to pull other delegate nodes info if a delegate node want , in order to have a better understanding of nodes status on the chain.

  • node will broadcast a RequestNodeInfoMessage to notify other nodes if it's configured a valid broadcast interval
  • node will unicast a ResponseNodeInfoMessage with signature to the sender when recieve the request
  • node will verify the ResponseNodeInfoMessage and then update metric

Design: p2p network monitor message design

Fixes #3724

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)

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
  • TestNewDelegateManager
  • TestDelegateManager_HandleNodeInfo
  • TestDelegateManager_RequestNodeInfo
  • TestDelegateManager_TellNodeInfo

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 Dec 29, 2022

Codecov Report

Merging #3744 (37fdaaa) into master (263ff82) will increase coverage by 0.99%.
The diff coverage is 80.52%.

@@            Coverage Diff             @@
##           master    #3744      +/-   ##
==========================================
+ Coverage   74.47%   75.47%   +0.99%     
==========================================
  Files         269      303      +34     
  Lines       23925    25817    +1892     
==========================================
+ Hits        17818    19485    +1667     
- Misses       5174     5315     +141     
- Partials      933     1017      +84     
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

server/itx/server.go Outdated Show resolved Hide resolved
server/cronjob/config.go Outdated Show resolved Hide resolved
dispatcher/dispatcher.go Outdated Show resolved Hide resolved
dispatcher/dispatcher.go Outdated Show resolved Hide resolved
dispatcher/dispatcher.go Outdated Show resolved Hide resolved
dispatcher/dispatcher.go Outdated Show resolved Hide resolved
api/coreservice.go Outdated Show resolved Hide resolved
dispatcher/dispatcher.go Outdated Show resolved Hide resolved
server/itx/server.go Outdated Show resolved Hide resolved
config/config.go Outdated Show resolved Hide resolved
node/node.go Outdated Show resolved Hide resolved
node/node.go Outdated Show resolved Hide resolved
node/node.go Outdated Show resolved Hide resolved
node/node.go Outdated Show resolved Hide resolved
node/node.go Outdated Show resolved Hide resolved
node/node.go Outdated Show resolved Hide resolved
@CoderZhi CoderZhi marked this pull request as ready for review January 4, 2023 19:11
@CoderZhi CoderZhi requested review from Liuhaai, millken and a team as code owners January 4, 2023 19:11
@envestcc envestcc marked this pull request as draft January 5, 2023 15:06
nodeinfo/manager.go Outdated Show resolved Hide resolved
nodeinfo/manager.go Outdated Show resolved Hide resolved
dispatcher/dispatcher.go Outdated Show resolved Hide resolved
dispatcher/dispatcher.go Outdated Show resolved Hide resolved
dispatcher/dispatcher.go Outdated Show resolved Hide resolved
e2etest/nodeinfo_test.go Outdated Show resolved Hide resolved
e2etest/nodeinfo_test.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
go.mod Outdated Show resolved Hide resolved
nodeinfo/manager.go Outdated Show resolved Hide resolved
nodeinfo/manager.go Outdated Show resolved Hide resolved
nodeinfo/config.go Outdated Show resolved Hide resolved
address: privKey.PublicKey().Address().String(),
}

dm.broadcastTask = routine.NewRecurringTask(func() {
Copy link
Member

Choose a reason for hiding this comment

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

broadcastTask could be nil when EnableBroadcastNodeInfo is false

Copy link
Member

Choose a reason for hiding this comment

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

right, i left same comment earlier

Copy link
Member Author

Choose a reason for hiding this comment

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

remain the task has an advantage that a new delegate can enable broadcast automatically without restart

@sonarcloud
Copy link

sonarcloud bot commented Feb 6, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

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

No Coverage information No Coverage information
0.0% 0.0% Duplication

@dustinxie dustinxie merged commit 6fe6a17 into iotexproject:master Feb 6, 2023
@envestcc envestcc deleted the monitor_msg branch April 18, 2023 07:29
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.

broadcast node's height info into p2p network
4 participants