Skip to content

Commit

Permalink
[p2p]Add p2p MaxMessageSize config (#4071)
Browse files Browse the repository at this point in the history
  • Loading branch information
millken authored Jan 30, 2024
1 parent 83db41b commit fef8141
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ require (
github.com/hashicorp/vault/api v1.1.0
github.com/holiman/uint256 v1.2.0
github.com/iotexproject/go-fsm v1.0.0
github.com/iotexproject/go-p2p v0.3.5
github.com/iotexproject/go-p2p v0.3.6
github.com/iotexproject/go-pkgs v0.1.13
github.com/iotexproject/iotex-address v0.2.8
github.com/iotexproject/iotex-antenna-go/v2 v2.5.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -649,8 +649,8 @@ github.com/iotexproject/go-ethereum v1.7.4-0.20230806203205-6819e8158a5f h1:9+i3
github.com/iotexproject/go-ethereum v1.7.4-0.20230806203205-6819e8158a5f/go.mod h1:it7x0DWnTDMfVFdXcU6Ti4KEFQynLHVRarcSlPr0HBo=
github.com/iotexproject/go-fsm v1.0.0 h1:Zrg9JnNDUZg4Anpj6oa0Tk4+sXbHTpJzI0v5/Cj5N6A=
github.com/iotexproject/go-fsm v1.0.0/go.mod h1:t3aYXtCCcQxyS7oduQZyuUpPnVI4ddFTwbAagHN7fT0=
github.com/iotexproject/go-p2p v0.3.5 h1:F71XxYQtR25youD+dCXnMgtfiCKGUFh8KDIqU7u5xOk=
github.com/iotexproject/go-p2p v0.3.5/go.mod h1:P32N/mwLUWMQ/okMcNLlfBO7iD5ITyBOvN41roKdPdg=
github.com/iotexproject/go-p2p v0.3.6 h1:AhCq0d6ytoNlcT+tOcqZV0W0Slolsf1FoMbyxxgsAhM=
github.com/iotexproject/go-p2p v0.3.6/go.mod h1:P32N/mwLUWMQ/okMcNLlfBO7iD5ITyBOvN41roKdPdg=
github.com/iotexproject/go-pkgs v0.1.5-0.20210604060651-be5ee19f2575/go.mod h1:ttXhcwrtODyh7JozpJlCml09CjP0pcKqTe2B0MbTGc8=
github.com/iotexproject/go-pkgs v0.1.12/go.mod h1:t5X9kQ1VL5H+L+DC5GmohXnFKlcxaTcRnIBBuydcsTQ=
github.com/iotexproject/go-pkgs v0.1.13 h1:bK48DVenkfYkC4TRoqL77RLFRBE1MUfscCW495kzcC8=
Expand Down
3 changes: 3 additions & 0 deletions p2p/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ type (
EnableRateLimit bool `yaml:"enableRateLimit"`
PrivateNetworkPSK string `yaml:"privateNetworkPSK"`
MaxPeers int `yaml:"maxPeers"`
MaxMessageSize int `yaml:"maxMessageSize"`
}

// Agent is the agent to help the blockchain node connect into the P2P networks and send/receive messages
Expand Down Expand Up @@ -143,6 +144,7 @@ var DefaultConfig = Config{
EnableRateLimit: true,
PrivateNetworkPSK: "",
MaxPeers: 30,
MaxMessageSize: p2p.DefaultConfig.MaxMessageSize,
}

// NewDummyAgent creates a dummy p2p agent
Expand Down Expand Up @@ -214,6 +216,7 @@ func (p *agent) Start(ctx context.Context) error {
p2p.DHTProtocolID(p.chainID),
p2p.DHTGroupID(p.chainID),
p2p.WithMaxPeer(uint32(p.cfg.MaxPeers)),
p2p.WithMaxMessageSize(p.cfg.MaxMessageSize),
}
if p.cfg.EnableRateLimit {
opts = append(opts, p2p.WithRateLimit(p.cfg.RateLimit))
Expand Down
1 change: 1 addition & 0 deletions p2p/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ func TestBroadcast(t *testing.T) {
Port: port,
BootstrapNodes: []string{bootnodeAddr[0].String()},
ReconnectInterval: 150 * time.Second,
MaxMessageSize: p2p.DefaultConfig.MaxMessageSize,
}, 1, hash.ZeroHash256, b, u)
agent.Start(ctx)
agents = append(agents, agent)
Expand Down

0 comments on commit fef8141

Please sign in to comment.