Skip to content

Commit

Permalink
CCQ: Add enable flag and feature flag (#2986)
Browse files Browse the repository at this point in the history
* CCQ: Add enable flag and feature flag

* Fix build error
  • Loading branch information
bruce-riley authored and evan-gray committed May 25, 2023
1 parent 5ff26eb commit 520757a
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 1 deletion.
7 changes: 7 additions & 0 deletions Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand All @@ -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
Expand Down Expand Up @@ -295,6 +297,11 @@ def build_node_yaml():
"--ibcContract",
"wormhole1nc5tatafv6eyq7llkr2gv50ff9e22mnf70qgjlv737ktmt4eswrq0kdhcj"
]

if ccq:
container["command"] += [
"--ccqEnabled=true"
]

return encode_yaml_stream(node_yaml_with_replicas)

Expand Down
1 change: 1 addition & 0 deletions devnet/node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ spec:
- --publicRpcLogDetail
- "full"
# - --chainGovernorEnabled=true
# - --ccqEnabled=true
# - --logLevel=debug
securityContext:
capabilities:
Expand Down
10 changes: 9 additions & 1 deletion node/cmd/guardiand/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ var (
bigTableKeyPath *string

chainGovernorEnabled *bool
ccqEnabled *bool
)

func init() {
Expand Down Expand Up @@ -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 (
Expand Down Expand Up @@ -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(
Expand All @@ -1204,6 +1211,7 @@ func runNode(cmd *cobra.Command, args []string) {
nil,
components,
&ibc.Features,
&ccqFeatures,
signedQueryReqWriteC,
queryResponseReadC)); err != nil {
return err
Expand Down Expand Up @@ -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 {
Expand Down
9 changes: 9 additions & 0 deletions node/cmd/guardiand/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions node/cmd/spy/spy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions node/pkg/p2p/p2p.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions node/pkg/p2p/watermark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
))
Expand Down

0 comments on commit 520757a

Please sign in to comment.