diff --git a/blockchain/blockchain.go b/blockchain/blockchain.go index efc32b84b9..b203ea9296 100644 --- a/blockchain/blockchain.go +++ b/blockchain/blockchain.go @@ -38,6 +38,12 @@ const ( SigP256sm2 = "p256sm2" ) +// Message networks definition +const ( + // CompatiableNetwork is the network for connecting to the nodes without message network feature + CompatibleNetwork = "" +) + var ( _blockMtc = prometheus.NewGaugeVec( prometheus.GaugeOpts{ diff --git a/chainservice/builder.go b/chainservice/builder.go index c3a13c4584..c75c075b85 100644 --- a/chainservice/builder.go +++ b/chainservice/builder.go @@ -520,7 +520,7 @@ func (builder *Builder) buildNodeInfoManager() error { return errors.New("cannot find staking protocol") } chain := builder.cs.chain - dm := nodeinfo.NewInfoManager(&builder.cfg.NodeInfo, cs.p2pAgent.Subnet(CompatibleNetwork), cs.chain, builder.cfg.Chain.ProducerPrivateKey(), func() []string { + dm := nodeinfo.NewInfoManager(&builder.cfg.NodeInfo, cs.p2pAgent.Subnet(blockchain.CompatibleNetwork), cs.chain, builder.cfg.Chain.ProducerPrivateKey(), func() []string { ctx := protocol.WithFeatureCtx( protocol.WithBlockCtx( genesis.WithGenesisContext(context.Background(), chain.Genesis()), @@ -552,7 +552,7 @@ func (builder *Builder) buildBlockSyncer() error { return nil } - p2pAgent := builder.cs.p2pAgent.Subnet(CompatibleNetwork) + p2pAgent := builder.cs.p2pAgent.Subnet(blockchain.CompatibleNetwork) chain := builder.cs.chain consens := builder.cs.consensus dao := builder.cs.blockdao @@ -647,7 +647,7 @@ func (builder *Builder) buildActionSyncer() error { p2pAgent := builder.cs.p2pAgent actionsync := actsync.NewActionSync(builder.cfg.ActionSync, &actsync.Helper{ P2PNeighbor: p2pAgent.ConnectedPeers, - UnicastOutbound: p2pAgent.Subnet(CompatibleNetwork).UnicastOutbound, + UnicastOutbound: p2pAgent.Subnet(blockchain.CompatibleNetwork).UnicastOutbound, }) builder.cs.actionsync = actionsync builder.cs.lifecycle.Add(actionsync) @@ -787,7 +787,7 @@ func (builder *Builder) buildBlockTimeCalculator() (err error) { } func (builder *Builder) buildConsensusComponent() error { - p2pAgent := builder.cs.p2pAgent.Subnet(CompatibleNetwork) + p2pAgent := builder.cs.p2pAgent.Subnet(blockchain.CompatibleNetwork) copts := []consensus.Option{ consensus.WithBroadcast(func(msg proto.Message) error { return p2pAgent.BroadcastOutbound(context.Background(), msg) diff --git a/chainservice/chainservice.go b/chainservice/chainservice.go index 9bf982d0b3..d355b145f5 100644 --- a/chainservice/chainservice.go +++ b/chainservice/chainservice.go @@ -42,12 +42,6 @@ import ( "github.com/iotexproject/iotex-core/v2/systemcontractindex/stakingindex" ) -// Message networks definition -const ( - // CompatiableNetwork is the network for connecting to the nodes without message network feature - CompatibleNetwork = "" -) - var ( _blockchainFullnessMtc = prometheus.NewGaugeVec( prometheus.GaugeOpts{ @@ -143,7 +137,7 @@ func (cs *ChainService) HandleActionRequest(ctx context.Context, peer peer.AddrI } return err } - return cs.p2pAgent.Subnet(CompatibleNetwork).UnicastOutbound(ctx, peer, act.Proto()) + return cs.p2pAgent.Subnet(blockchain.CompatibleNetwork).UnicastOutbound(ctx, peer, act.Proto()) } // HandleBlock handles incoming block request. @@ -226,7 +220,7 @@ func (cs *ChainService) NewAPIServer(cfg api.Config, plugins map[int]interface{} if cfg.GRPCPort == 0 && cfg.HTTPPort == 0 { return nil, nil } - p2pAgent := cs.p2pAgent.Subnet(CompatibleNetwork) + p2pAgent := cs.p2pAgent.Subnet(blockchain.CompatibleNetwork) apiServerOptions := []api.Option{ api.WithBroadcastOutbound(func(ctx context.Context, chainID uint32, msg proto.Message) error { return p2pAgent.BroadcastOutbound(ctx, msg) diff --git a/e2etest/local_actpool_test.go b/e2etest/local_actpool_test.go index 15bcc0f3d4..92d2e0580e 100644 --- a/e2etest/local_actpool_test.go +++ b/e2etest/local_actpool_test.go @@ -19,7 +19,7 @@ import ( "github.com/iotexproject/go-pkgs/crypto" "github.com/iotexproject/iotex-core/v2/action" - "github.com/iotexproject/iotex-core/v2/chainservice" + "github.com/iotexproject/iotex-core/v2/blockchain" "github.com/iotexproject/iotex-core/v2/config" "github.com/iotexproject/iotex-core/v2/p2p" "github.com/iotexproject/iotex-core/v2/server/itx" @@ -60,8 +60,8 @@ func TestLocalActPool(t *testing.T) { func(_ context.Context, _ uint32, _ peer.AddrInfo, _ proto.Message) { }, - p2p.JoinSubnet(chainservice.CompatibleNetwork), - ).Subnet(chainservice.CompatibleNetwork) + p2p.JoinSubnet(blockchain.CompatibleNetwork), + ).Subnet(blockchain.CompatibleNetwork) require.NotNil(cli) require.NoError(cli.Start(ctx)) fmt.Println("p2p agent started") @@ -139,8 +139,8 @@ func TestPressureActPool(t *testing.T) { func(_ context.Context, _ uint32, _ peer.AddrInfo, _ proto.Message) { }, - p2p.JoinSubnet(chainservice.CompatibleNetwork), - ).Subnet(chainservice.CompatibleNetwork) + p2p.JoinSubnet(blockchain.CompatibleNetwork), + ).Subnet(blockchain.CompatibleNetwork) require.NotNil(cli) require.NoError(cli.Start(ctx)) diff --git a/e2etest/local_test.go b/e2etest/local_test.go index b9b10379ad..2e9b73f36f 100644 --- a/e2etest/local_test.go +++ b/e2etest/local_test.go @@ -33,7 +33,6 @@ import ( "github.com/iotexproject/iotex-core/v2/blockchain/blockdao" "github.com/iotexproject/iotex-core/v2/blockchain/filedao" "github.com/iotexproject/iotex-core/v2/blockchain/genesis" - "github.com/iotexproject/iotex-core/v2/chainservice" "github.com/iotexproject/iotex-core/v2/config" "github.com/iotexproject/iotex-core/v2/db" "github.com/iotexproject/iotex-core/v2/p2p" @@ -126,8 +125,8 @@ func TestLocalCommit(t *testing.T) { }, func(_ context.Context, _ uint32, _ peer.AddrInfo, _ proto.Message) { }, - p2p.JoinSubnet(chainservice.CompatibleNetwork), - ).Subnet(chainservice.CompatibleNetwork) + p2p.JoinSubnet(blockchain.CompatibleNetwork), + ).Subnet(blockchain.CompatibleNetwork) require.NotNil(p) require.NoError(p.Start(ctx)) defer func() { @@ -332,7 +331,7 @@ func TestLocalSync(t *testing.T) { hash.ZeroHash256, func(_ context.Context, _ uint32, _ string, msg proto.Message) {}, func(_ context.Context, _ uint32, _ peer.AddrInfo, _ proto.Message) {}, - p2p.JoinSubnet(chainservice.CompatibleNetwork), + p2p.JoinSubnet(blockchain.CompatibleNetwork), ) require.NoError(bootnode.Start(ctx)) addrs, err := bootnode.Self() @@ -408,7 +407,7 @@ func TestLocalSync(t *testing.T) { }() err = testutil.WaitUntil(time.Millisecond*100, time.Second*60, func() (bool, error) { - peers, err := svr.P2PAgent().Subnet(chainservice.CompatibleNetwork).ConnectedPeers() + peers, err := svr.P2PAgent().Subnet(blockchain.CompatibleNetwork).ConnectedPeers() return len(peers) >= 1, err }) require.NoError(err) diff --git a/server/itx/server.go b/server/itx/server.go index ed0f240ce7..a8d2b85516 100644 --- a/server/itx/server.go +++ b/server/itx/server.go @@ -17,6 +17,7 @@ import ( "go.uber.org/zap" "github.com/iotexproject/iotex-core/v2/api" + "github.com/iotexproject/iotex-core/v2/blockchain" "github.com/iotexproject/iotex-core/v2/chainservice" "github.com/iotexproject/iotex-core/v2/config" "github.com/iotexproject/iotex-core/v2/dispatcher" @@ -65,7 +66,7 @@ func newServer(cfg config.Config, testing bool) (*Server, error) { case config.StandaloneScheme: p2pAgent = p2p.NewDummyAgent() default: - p2pAgent = p2p.NewAgent(cfg.Network, cfg.Chain.ID, cfg.Genesis.Hash(), dispatcher.HandleBroadcast, dispatcher.HandleTell, p2p.JoinSubnet(chainservice.CompatibleNetwork)) + p2pAgent = p2p.NewAgent(cfg.Network, cfg.Chain.ID, cfg.Genesis.Hash(), dispatcher.HandleBroadcast, dispatcher.HandleTell, p2p.JoinSubnet(blockchain.CompatibleNetwork)) } chains := make(map[uint32]*chainservice.ChainService) apiServers := make(map[uint32]*api.ServerV2)