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

[p2p] support network separation #3817

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

envestcc
Copy link
Member

@envestcc envestcc commented Feb 27, 2023

Description

P2P support block, action, consensus three networks, main changes including:

  • add option to choose networks to join
  • add broadcast, unicast, connectedPeers by network method for Agent
  • add AgentProxy to maintain compatibility

Fixes #(issue)

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

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

go.mod Outdated
@@ -204,3 +204,5 @@ require (
replace github.com/ethereum/go-ethereum => github.com/iotexproject/go-ethereum v0.4.2

replace golang.org/x/xerrors => golang.org/x/xerrors v0.0.0-20190212162355-a5947ffaace3

replace github.com/iotexproject/go-p2p => /Users/chenchen/dev/go-p2p
Copy link
Member

Choose a reason for hiding this comment

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

create a PR for go-p2p changes

Copy link
Member Author

Choose a reason for hiding this comment

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

sure, it's here: iotexproject/go-p2p#36

p2p/agent.go Outdated Show resolved Hide resolved
p2p/agent.go Outdated Show resolved Hide resolved
p2p/agent.go Outdated Show resolved Hide resolved
return
}

func (p *agent) broadcastTopicName(network string) string {
Copy link
Member

Choose a reason for hiding this comment

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

topic string

p2p/agent.go Outdated
@@ -390,6 +432,10 @@ func (p *agent) BroadcastOutbound(ctx context.Context, msg proto.Message) (err e
status,
).Inc()
}()
network, err := p.getMessageNetwork(msg)
Copy link
Member

Choose a reason for hiding this comment

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

topic, err := p.getMessageTopic(msg)

p2p/agent.go Outdated Show resolved Hide resolved
p2p/agent.go Outdated Show resolved Hide resolved
p2p/agent_test.go Outdated Show resolved Hide resolved
p2p/agent.go Outdated Show resolved Hide resolved
a.networks[BlockNetwork] = struct{}{}
for _, opt := range opts {
opt(a)
}
Copy link
Member

Choose a reason for hiding this comment

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

if len(a.networks) == 0 { error out }

Copy link
Member Author

Choose a reason for hiding this comment

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

node can not join any subnets in p2p level

p2p/agent.go Outdated
@@ -55,6 +62,8 @@ var (
)
// ErrAgentNotStarted is the error returned when p2p agent has not been started
ErrAgentNotStarted = errors.New("p2p agent has not been started")
// ErrNoConnectedPeers is a broadcast error when have no connected peers
ErrNoConnectedPeers = p2p.ErrNoConnectedPeers
Copy link
Collaborator

Choose a reason for hiding this comment

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

delete

p2p/agent.go Outdated Show resolved Hide resolved
@sonarcloud
Copy link

sonarcloud bot commented Mar 23, 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 4 Code Smells

No Coverage information No Coverage information
1.5% 1.5% Duplication

p2p/agent.go Outdated Show resolved Hide resolved
@sonarcloud
Copy link

sonarcloud bot commented Aug 7, 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 4 Code Smells

No Coverage information No Coverage information
1.4% 1.4% Duplication

@envestcc
Copy link
Member Author

IIP-16 paused

@envestcc envestcc closed this Aug 28, 2023
@envestcc envestcc reopened this Jul 29, 2024
@envestcc envestcc force-pushed the network_separation_v2 branch from da2da0a to a45755e Compare August 2, 2024 00:46
@envestcc envestcc marked this pull request as ready for review August 2, 2024 03:20
@envestcc envestcc requested review from Liuhaai and a team as code owners August 2, 2024 03:20
Copy link

sonarcloud bot commented Aug 2, 2024

status := _successStr
if err != nil {
status = _failureStr
// Skip the broadcast message if it's from the node itself
Copy link
Collaborator

Choose a reason for hiding this comment

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

move to line 291 or delete

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.

4 participants