@@ -23,6 +23,7 @@ import (
23
23
"golang.org/x/crypto/sha3"
24
24
25
25
"github.com/certusone/wormhole/node/pkg/guardiansigner"
26
+ "github.com/certusone/wormhole/node/pkg/node"
26
27
gossipv1 "github.com/certusone/wormhole/node/pkg/proto/gossip/v1"
27
28
publicrpcv1 "github.com/certusone/wormhole/node/pkg/proto/publicrpc/v1"
28
29
"github.com/wormhole-foundation/wormhole/sdk"
@@ -62,6 +63,7 @@ func init() {
62
63
DumpVAAByMessageID .Flags ().AddFlagSet (pf )
63
64
DumpRPCs .Flags ().AddFlagSet (pf )
64
65
SendObservationRequest .Flags ().AddFlagSet (pf )
66
+ ReobserveWithEndpoint .Flags ().AddFlagSet (pf )
65
67
ClientChainGovernorStatusCmd .Flags ().AddFlagSet (pf )
66
68
ClientChainGovernorReloadCmd .Flags ().AddFlagSet (pf )
67
69
ClientChainGovernorDropPendingVAACmd .Flags ().AddFlagSet (pf )
@@ -84,6 +86,7 @@ func init() {
84
86
AdminCmd .AddCommand (DumpVAAByMessageID )
85
87
AdminCmd .AddCommand (DumpRPCs )
86
88
AdminCmd .AddCommand (SendObservationRequest )
89
+ AdminCmd .AddCommand (ReobserveWithEndpoint )
87
90
AdminCmd .AddCommand (ClientChainGovernorStatusCmd )
88
91
AdminCmd .AddCommand (ClientChainGovernorReloadCmd )
89
92
AdminCmd .AddCommand (ClientChainGovernorDropPendingVAACmd )
@@ -136,6 +139,13 @@ var SendObservationRequest = &cobra.Command{
136
139
Args : cobra .ExactArgs (2 ),
137
140
}
138
141
142
+ var ReobserveWithEndpoint = & cobra.Command {
143
+ Use : "reobserve-with-endpoint [CHAIN_ID|CHAIN_NAME] [TX_HASH_HEX] [CUSTOM_URL]" ,
144
+ Short : "Performs a local reobservation for the given chain ID and chain-specific tx_hash using the specified endpoint" ,
145
+ Run : runReobserveWithEndpoint ,
146
+ Args : cobra .ExactArgs (3 ),
147
+ }
148
+
139
149
var ClientChainGovernorStatusCmd = & cobra.Command {
140
150
Use : "governor-status" ,
141
151
Short : "Displays the status of the chain governor" ,
@@ -415,6 +425,51 @@ func runSendObservationRequest(cmd *cobra.Command, args []string) {
415
425
}
416
426
}
417
427
428
+ func runReobserveWithEndpoint (cmd * cobra.Command , args []string ) {
429
+ chainID , err := parseChainID (args [0 ])
430
+ if err != nil {
431
+ log .Fatalf ("invalid chain ID: %v" , err )
432
+ }
433
+
434
+ // Support tx with or without leading 0x.
435
+ txHash , err := hex .DecodeString (strings .TrimPrefix (args [1 ], "0x" ))
436
+ if err != nil {
437
+ txHash , err = base58 .Decode (args [1 ])
438
+ if err != nil {
439
+ log .Fatalf ("invalid transaction hash (neither hex nor base58): %v" , err )
440
+ }
441
+ }
442
+
443
+ url := args [2 ]
444
+ if valid := node .ValidateURL (url , []string {"http" , "https" }); ! valid {
445
+ log .Fatalf (`invalid url, must be "http" or "https"` )
446
+ }
447
+
448
+ // Allow extra time since the watcher can block on the reobservation.
449
+ ctx , cancel := context .WithTimeout (context .Background (), 30 * time .Second )
450
+ defer cancel ()
451
+
452
+ conn , c , err := getAdminClient (ctx , * clientSocketPath )
453
+ if err != nil {
454
+ log .Fatalf ("failed to get admin client: %v" , err )
455
+ }
456
+ defer conn .Close ()
457
+
458
+ resp , err := c .ReobserveWithEndpoint (ctx , & nodev1.ReobserveWithEndpointRequest {
459
+ ChainId : uint32 (chainID ),
460
+ TxHash : txHash ,
461
+ Url : url ,
462
+ })
463
+ if err != nil {
464
+ log .Fatalf ("failed to send observation request with endpoint: %v" , err )
465
+ }
466
+ if resp .NumObservations == 0 {
467
+ fmt .Println ("Did not reobserve anything" )
468
+ } else {
469
+ fmt .Println ("Reobserved" , resp .NumObservations , "messages" )
470
+ }
471
+ }
472
+
418
473
func runDumpRPCs (cmd * cobra.Command , args []string ) {
419
474
ctx , cancel := context .WithTimeout (context .Background (), 5 * time .Second )
420
475
defer cancel ()
0 commit comments