From 520757ada412a4ea682c3b40ba8e5d52b7ed5f2b Mon Sep 17 00:00:00 2001 From: bruce-riley <96066700+bruce-riley@users.noreply.github.com> Date: Wed, 24 May 2023 17:38:49 -0500 Subject: [PATCH] CCQ: Add enable flag and feature flag (#2986) * CCQ: Add enable flag and feature flag * Fix build error --- Tiltfile | 7 +++++++ devnet/node.yaml | 1 + node/cmd/guardiand/node.go | 10 +++++++++- node/cmd/guardiand/query.go | 9 +++++++++ node/cmd/spy/spy.go | 1 + node/pkg/p2p/p2p.go | 4 ++++ node/pkg/p2p/watermark_test.go | 1 + 7 files changed, 32 insertions(+), 1 deletion(-) diff --git a/Tiltfile b/Tiltfile index 959e1c69a2..721329273c 100644 --- a/Tiltfile +++ b/Tiltfile @@ -62,6 +62,7 @@ config.define_bool("node_metrics", False, "Enable Prometheus & Grafana for Guard config.define_bool("guardiand_governor", False, "Enable chain governor in guardiand") config.define_bool("wormchain", False, "Enable a wormchain node") config.define_bool("ibc_relayer", False, "Enable IBC relayer between cosmos chains") +config.define_bool("ccq", False, "Enable cross chain queries in guardiand") cfg = config.parse() num_guardians = int(cfg.get("num", "1")) @@ -87,6 +88,7 @@ node_metrics = cfg.get("node_metrics", False) guardiand_governor = cfg.get("guardiand_governor", False) ibc_relayer = cfg.get("ibc_relayer", ci) btc = cfg.get("btc", False) +ccq = cfg.get("ccq", False) if cfg.get("manual", False): trigger_mode = TRIGGER_MODE_MANUAL @@ -295,6 +297,11 @@ def build_node_yaml(): "--ibcContract", "wormhole1nc5tatafv6eyq7llkr2gv50ff9e22mnf70qgjlv737ktmt4eswrq0kdhcj" ] + + if ccq: + container["command"] += [ + "--ccqEnabled=true" + ] return encode_yaml_stream(node_yaml_with_replicas) diff --git a/devnet/node.yaml b/devnet/node.yaml index d19e7cb7f6..552beef143 100644 --- a/devnet/node.yaml +++ b/devnet/node.yaml @@ -170,6 +170,7 @@ spec: - --publicRpcLogDetail - "full" # - --chainGovernorEnabled=true + # - --ccqEnabled=true # - --logLevel=debug securityContext: capabilities: diff --git a/node/cmd/guardiand/node.go b/node/cmd/guardiand/node.go index 8c0c0e2cdd..58374e9c01 100644 --- a/node/cmd/guardiand/node.go +++ b/node/cmd/guardiand/node.go @@ -216,6 +216,7 @@ var ( bigTableKeyPath *string chainGovernorEnabled *bool + ccqEnabled *bool ) func init() { @@ -378,6 +379,7 @@ func init() { bigTableKeyPath = NodeCmd.Flags().String("bigTableKeyPath", "", "Path to json Service Account key") chainGovernorEnabled = NodeCmd.Flags().Bool("chainGovernorEnabled", false, "Run the chain governor") + ccqEnabled = NodeCmd.Flags().Bool("ccqEnabled", false, "Enable cross chain query support") } var ( @@ -1182,6 +1184,11 @@ func runNode(cmd *cobra.Command, args []string) { components := p2p.DefaultComponents() components.Port = *p2pPort + ccqFeatures := "" + if *ccqEnabled { + ccqFeatures = "ccq" + } + // Run supervisor. supervisor.New(rootCtx, logger, func(ctx context.Context) error { if err := supervisor.Run(ctx, "p2p", p2p.Run( @@ -1204,6 +1211,7 @@ func runNode(cmd *cobra.Command, args []string) { nil, components, &ibc.Features, + &ccqFeatures, signedQueryReqWriteC, queryResponseReadC)); err != nil { return err @@ -1584,7 +1592,7 @@ func runNode(cmd *cobra.Command, args []string) { } go handleReobservationRequests(rootCtx, clock.New(), logger, obsvReqReadC, chainObsvReqC) - go handleQueryRequests(rootCtx, logger, signedQueryReqReadC, chainQueryReqC) + go handleQueryRequests(rootCtx, logger, signedQueryReqReadC, chainQueryReqC, *ccqEnabled) if acct != nil { if err := acct.Start(ctx); err != nil { diff --git a/node/cmd/guardiand/query.go b/node/cmd/guardiand/query.go index 68acbda63a..ae41469529 100644 --- a/node/cmd/guardiand/query.go +++ b/node/cmd/guardiand/query.go @@ -26,13 +26,22 @@ func handleQueryRequests( logger *zap.Logger, signedQueryReqC <-chan *gossipv1.SignedQueryRequest, chainQueryReqC map[vaa.ChainID]chan *gossipv1.SignedQueryRequest, + enableFlag bool, ) { qLogger := logger.With(zap.String("component", "queryHandler")) + if enableFlag { + qLogger.Info("cross chain queries are enabled") + } + for { select { case <-ctx.Done(): return case signedQueryRequest := <-signedQueryReqC: + if !enableFlag { + qLogger.Debug("dropping query request, feature is not enabled") + continue + } // requestor validation happens here // request type validation is currently handled by the watcher // in the future, it may be worthwhile to catch certain types of diff --git a/node/cmd/spy/spy.go b/node/cmd/spy/spy.go index 0c6a6a2fdd..a084512d22 100644 --- a/node/cmd/spy/spy.go +++ b/node/cmd/spy/spy.go @@ -553,6 +553,7 @@ func runSpy(cmd *cobra.Command, args []string) { nil, components, nil, // ibc feature string + nil, // cross chain query feature string nil, // query requests nil, // query responses diff --git a/node/pkg/p2p/p2p.go b/node/pkg/p2p/p2p.go index 85b2c31d11..3e3affb4d2 100644 --- a/node/pkg/p2p/p2p.go +++ b/node/pkg/p2p/p2p.go @@ -155,6 +155,7 @@ func Run( signedGovSt chan *gossipv1.SignedChainGovernorStatus, components *Components, ibcFeatures *string, + ccqFeatures *string, signedQueryReqC chan<- *gossipv1.SignedQueryRequest, queryResponseReadC <-chan *node_common.QueryResponsePublication, ) func(ctx context.Context) error { @@ -312,6 +313,9 @@ func Run( if ibcFeatures != nil && *ibcFeatures != "" { features = append(features, *ibcFeatures) } + if ccqFeatures != nil && *ccqFeatures != "" { + features = append(features, *ccqFeatures) + } heartbeat := &gossipv1.Heartbeat{ NodeName: nodeName, diff --git a/node/pkg/p2p/watermark_test.go b/node/pkg/p2p/watermark_test.go index 24717d980f..921faf4f95 100644 --- a/node/pkg/p2p/watermark_test.go +++ b/node/pkg/p2p/watermark_test.go @@ -182,6 +182,7 @@ func startGuardian(t *testing.T, ctx context.Context, g *G) { g.signedGovSt, g.components, nil, // ibc feature string + nil, // cross chain query feature string nil, // signed query request channel nil, // query response channel ))