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
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
2412217
init monitor message framework
envestcc Dec 29, 2022
0f70388
init broadcast framework
envestcc Dec 30, 2022
5507558
update broadcast framework
envestcc Dec 30, 2022
47e97d5
update broadcast framework
envestcc Dec 30, 2022
935f9cc
add node package to handle node info manager
envestcc Jan 3, 2023
3ecc432
update
envestcc Jan 3, 2023
1090b2a
add node info request and response message
envestcc Jan 6, 2023
6eb404d
remove delegate manager dependency
envestcc Jan 6, 2023
98884a2
add message sign
envestcc Jan 9, 2023
eb56750
add sign for node info message
envestcc Jan 10, 2023
37af551
fix unittest error
envestcc Jan 10, 2023
96d185a
add unittest for node
envestcc Jan 11, 2023
5c0b500
add pubkey in nodeinfo message
envestcc Jan 11, 2023
b15fea7
Merge branch 'master' into monitor_msg
envestcc Jan 11, 2023
6e191c6
fix compile error
envestcc Jan 11, 2023
4660879
update go.mod
envestcc Jan 11, 2023
4284fa8
refactor node unittest
envestcc Jan 12, 2023
fbb6983
refactor unittest
envestcc Jan 12, 2023
19cf088
convert NodeManager.UpdateNode to private
envestcc Jan 13, 2023
b9cd38a
use recovered pubkey from sign to verify
envestcc Jan 13, 2023
fb8f2a9
fix comment
envestcc Jan 13, 2023
5f9bbfd
simplify finding in array
envestcc Jan 13, 2023
1a10a7b
fix lint error
envestcc Jan 13, 2023
8d53cd4
add unicast single request message
envestcc Jan 16, 2023
ebbec69
node push(broadcast) node info message proactively and periodically
envestcc Jan 18, 2023
dc07084
Merge branch 'master' into monitor_msg
envestcc Jan 19, 2023
cbc2a66
fix comment
envestcc Jan 25, 2023
e09792b
chang node to nodeinfo
envestcc Jan 28, 2023
0016e7f
add e2etest for nodeinfo
envestcc Jan 29, 2023
0c6e7ed
fix comment
envestcc Feb 1, 2023
5b4038e
fix comments
envestcc Feb 2, 2023
e9af1cf
Merge branch 'master' into monitor_msg
envestcc Feb 2, 2023
fd70cd1
update mock
envestcc Feb 2, 2023
9947145
move const var _nodeMapSize to config struct
envestcc Feb 6, 2023
63e56ef
Merge branch 'master' into monitor_msg
envestcc Feb 6, 2023
37fdaaa
Update manager.go
dustinxie Feb 6, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ require (
github.com/iotexproject/iotex-address v0.2.8
github.com/iotexproject/iotex-antenna-go/v2 v2.5.1
github.com/iotexproject/iotex-election v0.3.5-0.20210611041425-20ddf674363d
github.com/iotexproject/iotex-proto v0.5.12
github.com/iotexproject/iotex-proto v0.5.13
github.com/libp2p/go-libp2p-core v0.8.5
github.com/mattn/go-sqlite3 v1.14.8 // indirect
github.com/miguelmota/go-ethereum-hdwallet v0.1.1
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,8 @@ github.com/iotexproject/iotex-election v0.3.5-0.20210611041425-20ddf674363d/go.m
github.com/iotexproject/iotex-proto v0.5.0/go.mod h1:Xg6REkv+nTZN+OC22xXIQuqKdTWWHwOAJEXCoMpDwtI=
github.com/iotexproject/iotex-proto v0.5.12 h1:s65DbejTT/c5dBtlQykyPV4V7L6efDuOOGJiqu57LPw=
github.com/iotexproject/iotex-proto v0.5.12/go.mod h1:6Xan740KoIFyw/ZztVpum5jac6Z++o1whMWDIY1SrQk=
github.com/iotexproject/iotex-proto v0.5.13 h1:4NzJWRoeH5z6To/2+t0rTZBzJ4WC+MoLHxAeesiuAnM=
github.com/iotexproject/iotex-proto v0.5.13/go.mod h1:G8u3b4zLUESnfeByVj6oqwnXFXNH4JLOWkwllqx8L80=
github.com/ipfs/go-cid v0.0.1/go.mod h1:GHWU/WuQdMPmIosc4Yn1bcCT7dSeX4lBafM7iqUPQvM=
github.com/ipfs/go-cid v0.0.2/go.mod h1:GHWU/WuQdMPmIosc4Yn1bcCT7dSeX4lBafM7iqUPQvM=
github.com/ipfs/go-cid v0.0.3/go.mod h1:GHWU/WuQdMPmIosc4Yn1bcCT7dSeX4lBafM7iqUPQvM=
Expand Down
2 changes: 2 additions & 0 deletions nodeinfo/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ package nodeinfo

import "time"

const _nodeMapSize = 1000
envestcc marked this conversation as resolved.
Show resolved Hide resolved

// Config node config
type Config struct {
EnableBroadcastNodeInfo bool `yaml:"enableBroadcastNodeInfo"`
Expand Down
17 changes: 7 additions & 10 deletions nodeinfo/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ type (
}
)

const _nodeMapSizeLimit = 1000

var _nodeInfoHeightGauge = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "iotex_node_info_height_gauge",
Expand All @@ -76,7 +74,7 @@ func init() {
// NewInfoManager new info manager
func NewInfoManager(cfg *Config, t transmitter, h chain, privKey crypto.PrivateKey) *InfoManager {
dm := &InfoManager{
nodeMap: lru.New(_nodeMapSizeLimit),
nodeMap: lru.New(_nodeMapSize),
transmitter: t,
chain: h,
privKey: privKey,
Expand All @@ -85,14 +83,13 @@ func NewInfoManager(cfg *Config, t transmitter, h chain, privKey crypto.PrivateK
}

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

// delegates and nodes who are turned on will broadcast
if !cfg.EnableBroadcastNodeInfo && !dm.isDelegate() {
// delegates or nodes who are turned on will broadcast
if cfg.EnableBroadcastNodeInfo || dm.isDelegate() {
if err := dm.BroadcastNodeInfo(context.Background()); err != nil {
log.L().Error("nodeinfo manager broadcast node info failed", zap.Error(err))
}
} else {
log.L().Debug("nodeinfo manager general node disabled node info broadcast")
return
}

if err := dm.BroadcastNodeInfo(context.Background()); err != nil {
log.L().Error("nodeinfo manager broadcast node info failed", zap.Error(err))
}
}, cfg.BroadcastNodeInfoInterval)
return dm
Expand Down