Skip to content

Commit

Permalink
Clean up tool so it can be merged
Browse files Browse the repository at this point in the history
  • Loading branch information
bruce-riley committed Mar 13, 2024
1 parent ebf877b commit ecc61f3
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ ARG GO_BUILD_ARGS=-race

RUN --mount=type=cache,target=/root/.cache --mount=type=cache,target=/go \
export CGO_ENABLED=1 && \
cd node/hack/query/mainnet_test && \
go build ${GO_BUILD_ARGS} -gcflags="all=-N -l" --ldflags '-extldflags "-Wl,--allow-multiple-definition" -X "github.com/certusone/wormhole/node/cmd/guardiand.Build=dev"' -mod=readonly -o /mainnet_test mainnet.go && \
cd node/hack/query/ccqlistener && \
go build ${GO_BUILD_ARGS} -gcflags="all=-N -l" --ldflags '-extldflags "-Wl,--allow-multiple-definition" -X "github.com/certusone/wormhole/node/cmd/guardiand.Build=dev"' -mod=readonly -o /ccqlistener mainnet.go && \
go get github.com/CosmWasm/[email protected] && \
cp /go/pkg/mod/github.com/!cosm!wasm/[email protected]/internal/api/libwasmvm.x86_64.so /usr/lib/

Expand All @@ -43,6 +43,6 @@ COPY --from=build /usr/lib/libwasmvm.x86_64.so /usr/lib/
COPY --from=build /bin/bash /bin/dash /bin/sh /bin/

# finally copy the guardian executable
COPY --from=build /mainnet_test .
COPY --from=build /ccqlistener .

CMD ["/mainnet_test", "--configDir /app/cfg"]
CMD ["/ccqlistener", "--configDir /app/cfg"]
Original file line number Diff line number Diff line change
@@ -1,16 +1,28 @@
// This tool can be used to send a simple CCQ query request in mainnet.
// This tool can be used to verify that a guardian is properly receiving CCQ queries and publishing responses.

// This tool can be used to passively listen for query responses from any guardian:
// go run ccqlistener.go --listenOnly
//
// Or it can be used to passively listen for query responses from a particular guardian:
// go run ccqlistener.go --listenOnly --targetPeerId <yourGuardianP2pPeerId>
//
// This should work both in mainnet and testnet because there are routine monitoring queries running every few minutes.
// Note that you may need to wait 15 minutes or more to see something. Look for message saying "query response received".

// This tool can also be used to generate a simple query request, send it and wait for the response. Note that this takes
// considerable more set up, as the P2P ID and signing key of this tool must be defined here and configured on the guardian.
//
// It requires the following two files:
// ./mainnet_test.nodeKey - This file contains the P2P peer ID to be used. If the file does not exist, it will be created.
// ./mainnet_test.signerKey - This file contains the key used to sign the request. It must exist.
// To use this tool to generate a query, you need two local files:
// ./ccqlistener.nodeKey - This file contains the P2P peer ID to be used. If the file does not exist, it will be created.
// ./ccqlistener.signerKey - This file contains the key used to sign the request. It must exist.
//
// If the nodeKey file does not exist, it will be generated. The log output will print the peerID in the "Test started" line.
// That peerID must be included in the `ccqAllowedPeers` parameter on the guardian.
//
// The signerKey file can be generated by doing: guardiand keygen --block-type "CCQ SERVER SIGNING KEY" /path/to/key/file
// The generated key (which is listed as the `PublicKey` in the file) must be included in the `ccqAllowedRequesters` parameter on the guardian.
//
// To run this tool, do `go run mainnet.go`
// To run this tool, do `go run ccqlistener.go`
//
// - Look for the line saying "Signing key loaded" and confirm the public key matches what is configured on the guardian.
// - Look for the "Test started" and confirm that the peer ID matches what is configured on the guardian.
Expand All @@ -19,11 +31,11 @@
// - After this, the test runs, and you should eventually see "Success! Test passed"
//
// To run the tool as a docker image, you can do something like this:
// - wormhole$ docker build --target build -f node/hack/query/mainnet_test/Dockerfile -t mainnet-test .
// - wormhole$ docker run -v /mainnet_test/cfg:/app/cfg mainnet-test /mainnet_test --configDir /app/cfg
// Where /mainnet_test is a directory containing these files:
// - mainnet_test.nodeKey
// - mainnet_test.signerKey
// - wormhole$ docker build --target build -f node/hack/query/ccqlistener/Dockerfile -t ccqlistener .
// - wormhole$ docker run -v /ccqlistener/cfg:/app/cfg ccqlistener /ccqlistener --configDir /app/cfg
// Where /ccqlistener is a directory containing these files:
// - ccqlistener.nodeKey
// - ccqlistener.signerKey

package main

Expand Down Expand Up @@ -61,8 +73,8 @@ var (
p2pBootstrap = flag.String("bootstrap",
"/dns4/wormhole-mainnet-v2-bootstrap.certus.one/udp/8996/quic/p2p/12D3KooWQp644DK27fd3d4Km3jr7gHiuJJ5ZGmy8hH4py7fP4FP7,/dns4/wormhole-v2-mainnet-bootstrap.xlabs.xyz/udp/8996/quic/p2p/12D3KooWNQ9tVrcb64tw6bNs2CaNrUGPM7yRrKvBBheQ5yCyPHKC,/dns4/wormhole.mcf.rocks/udp/8996/quic/p2p/12D3KooWDZVv7BhZ8yFLkarNdaSWaB43D6UbQwExJ8nnGAEmfHcU,/dns4/wormhole-v2-mainnet-bootstrap.staking.fund/udp/8996/quic/p2p/12D3KooWG8obDX9DNi1KUwZNu9xkGwfKqTp2GFwuuHpWZ3nQruS1",
"P2P bootstrap peers (comma-separated)")
nodeKeyPath = flag.String("nodeKey", "mainnet_test.nodeKey", "Path to node key (will be generated if it doesn't exist)")
signerKeyPath = flag.String("signerKey", "mainnet_test.signerKey", "Path to key used to sign unsigned queries")
nodeKeyPath = flag.String("nodeKey", "ccqlistener.nodeKey", "Path to node key (will be generated if it doesn't exist)")
signerKeyPath = flag.String("signerKey", "ccqlistener.signerKey", "Path to key used to sign unsigned queries")
configDir = flag.String("configDir", ".", "Directory where nodeKey and signerKey are loaded from (default is .)")
listenOnly = flag.Bool("listenOnly", false, "Only listen for responses, don't publish anything (default is false)")
targetPeerId = flag.String("targetPeerId", "", "Only process responses from this peer ID (default is everything)")
Expand Down

0 comments on commit ecc61f3

Please sign in to comment.