|
|
@@ -38,7 +38,7 @@ type GuardianOption struct {
|
|
|
}
|
|
|
|
|
|
// GuardianOptionP2P configures p2p networking.
|
|
|
-// Dependencies: Accountant, Governor
|
|
|
+// Dependencies: See below.
|
|
|
func GuardianOptionP2P(
|
|
|
p2pKey libp2p_crypto.PrivKey,
|
|
|
networkId string,
|
|
|
@@ -51,14 +51,14 @@ func GuardianOptionP2P(
|
|
|
ccqPort uint,
|
|
|
ccqAllowedPeers string,
|
|
|
gossipAdvertiseAddress string,
|
|
|
- ibcFeaturesFunc func() string,
|
|
|
+ ibcEnabled bool,
|
|
|
protectedPeers []string,
|
|
|
ccqProtectedPeers []string,
|
|
|
featureFlags []string,
|
|
|
) *GuardianOption {
|
|
|
return &GuardianOption{
|
|
|
name: "p2p",
|
|
|
- dependencies: []string{"accountant", "governor", "gateway-relayer"},
|
|
|
+ dependencies: []string{"accountant", "alternate-publisher", "gateway-relayer", "governor", "query"},
|
|
|
f: func(ctx context.Context, logger *zap.Logger, g *G) error {
|
|
|
components := p2p.DefaultComponents()
|
|
|
components.Port = port
|
|
|
@@ -77,9 +77,14 @@ func GuardianOptionP2P(
|
|
|
// Add the gossip advertisement address
|
|
|
components.GossipAdvertiseAddress = gossipAdvertiseAddress
|
|
|
|
|
|
- var alternatePublisherFeaturesFunc func() string
|
|
|
- if g.alternatePublisher != nil {
|
|
|
- alternatePublisherFeaturesFunc = g.alternatePublisher.GetFeatures
|
|
|
+ // Get the static feature flags and add them to what was passed in.
|
|
|
+ featureFlags = getStaticFeatureFlags(g, featureFlags)
|
|
|
+
|
|
|
+ // Create the list of dynamic feature flag functions.
|
|
|
+ featureFlagFuncs := []func() string{}
|
|
|
+ if ibcEnabled {
|
|
|
+ // IBC has a dynamic feature flag because it reports the Wormchain version.
|
|
|
+ featureFlagFuncs = append(featureFlagFuncs, ibc.GetFeatures)
|
|
|
}
|
|
|
|
|
|
params, err := p2p.NewRunParams(
|
|
|
@@ -102,9 +107,7 @@ func GuardianOptionP2P(
|
|
|
g.gov,
|
|
|
disableHeartbeatVerify,
|
|
|
components,
|
|
|
- ibcFeaturesFunc,
|
|
|
- (g.gatewayRelayer != nil), // gatewayRelayerEnabled,
|
|
|
- (g.queryHandler != nil), // ccqEnabled,
|
|
|
+ (g.queryHandler != nil), // ccqEnabled,
|
|
|
g.signedQueryReqC.writeC,
|
|
|
g.queryResponsePublicationC.readC,
|
|
|
ccqBootstrapPeers,
|
|
|
@@ -113,9 +116,8 @@ func GuardianOptionP2P(
|
|
|
protectedPeers,
|
|
|
ccqProtectedPeers,
|
|
|
featureFlags,
|
|
|
+ featureFlagFuncs,
|
|
|
),
|
|
|
- p2p.WithProcessorFeaturesFunc(processor.GetFeatures),
|
|
|
- p2p.WithAlternatePublisherFeaturesFunc(alternatePublisherFeaturesFunc),
|
|
|
)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
@@ -619,12 +621,12 @@ func GuardianOptionAlternatePublisher(guardianAddr []byte, configs []string) *Gu
|
|
|
}
|
|
|
|
|
|
// GuardianOptionProcessor enables the default processor, which is required to make consensus on messages.
|
|
|
-// Dependencies: db, governor, accountant
|
|
|
+// Dependencies: See below.
|
|
|
func GuardianOptionProcessor(networkId string) *GuardianOption {
|
|
|
return &GuardianOption{
|
|
|
name: "processor",
|
|
|
// governor and accountant may be set to nil, but that choice needs to be made before the processor is configured
|
|
|
- dependencies: []string{"db", "governor", "accountant", "gateway-relayer", "alternate-publisher"},
|
|
|
+ dependencies: []string{"accountant", "alternate-publisher", "db", "gateway-relayer", "governor"},
|
|
|
|
|
|
f: func(ctx context.Context, logger *zap.Logger, g *G) error {
|
|
|
|
|
|
@@ -650,3 +652,33 @@ func GuardianOptionProcessor(networkId string) *GuardianOption {
|
|
|
return nil
|
|
|
}}
|
|
|
}
|
|
|
+
|
|
|
+// getStaticFeatureFlags creates the list of feature flags that do not change after initialization and adds them to the ones passed in.
|
|
|
+// Note: Any objects referenced here should be listed as dependencies in `GuardianOptionP2P`.
|
|
|
+func getStaticFeatureFlags(g *G, featureFlags []string) []string {
|
|
|
+ if g.gov != nil {
|
|
|
+ flag := "gov"
|
|
|
+ if g.gov.IsFlowCancelEnabled() {
|
|
|
+ flag = "gov:fc"
|
|
|
+ }
|
|
|
+ featureFlags = append(featureFlags, flag)
|
|
|
+ }
|
|
|
+
|
|
|
+ if g.acct != nil {
|
|
|
+ featureFlags = append(featureFlags, g.acct.FeatureString())
|
|
|
+ }
|
|
|
+
|
|
|
+ if g.queryHandler != nil {
|
|
|
+ featureFlags = append(featureFlags, "ccq")
|
|
|
+ }
|
|
|
+
|
|
|
+ if g.gatewayRelayer != nil {
|
|
|
+ featureFlags = append(featureFlags, "gwrelayer")
|
|
|
+ }
|
|
|
+
|
|
|
+ if g.alternatePublisher != nil {
|
|
|
+ featureFlags = append(featureFlags, g.alternatePublisher.GetFeatures())
|
|
|
+ }
|
|
|
+
|
|
|
+ return featureFlags
|
|
|
+}
|