diff --git a/node/cmd/guardiand/adminnodes.go b/node/cmd/guardiand/adminnodes.go index f2df01ee8..a2bf3d741 100644 --- a/node/cmd/guardiand/adminnodes.go +++ b/node/cmd/guardiand/adminnodes.go @@ -67,9 +67,9 @@ func runListNodes(cmd *cobra.Command, args []string) { if *testnetMode { // Include Ropsten in testnet mode if showDetails { - _, _ = w.Write([]byte("Node key\tGuardian key\tNode name\tVersion\tLast seen\tUptime\tSolana\tEthereum\tTerra\tBSC\tPolygon\tRopsten\n")) + _, _ = w.Write([]byte("Node key\tGuardian key\tNode name\tVersion\tLast seen\tUptime\tSolana\tEthereum\tTerra\tBSC\tPolygon\tAvalanche\tRopsten\n")) } else { - _, _ = w.Write([]byte("Node key\tGuardian key\tNode name\tVersion\tLast seen\tSolana\tEthereum\tTerra\tBSC\tPolygon\tRopsten\n")) + _, _ = w.Write([]byte("Node key\tGuardian key\tNode name\tVersion\tLast seen\tSolana\tEthereum\tTerra\tBSC\tPolygon\tAvalanche\tRopsten\n")) } } else { if showDetails { @@ -103,7 +103,7 @@ func runListNodes(cmd *cobra.Command, args []string) { if *testnetMode { if showDetails { fmt.Fprintf(w, - "%s\t%s\t%s\t%s\t%s\t%s\t%s %d (%d)\t%s %d (%d)\t%s %d (%d)\t%s %d (%d)\t%s %d (%d)\t%s %d (%d)\n", + "%s\t%s\t%s\t%s\t%s\t%s\t%s %d (%d)\t%s %d (%d)\t%s %d (%d)\t%s %d (%d)\t%s %d (%d)\t%s %d (%d)\t%s %d (%d)\n", h.P2PNodeAddr, h.RawHeartbeat.GuardianAddr, h.RawHeartbeat.NodeName, @@ -125,13 +125,16 @@ func runListNodes(cmd *cobra.Command, args []string) { truncAddrs[vaa.ChainIDPolygon], heights[vaa.ChainIDPolygon], errors[vaa.ChainIDPolygon], + truncAddrs[vaa.ChainIDAvalanche], + heights[vaa.ChainIDAvalanche], + errors[vaa.ChainIDAvalanche], truncAddrs[vaa.ChainIDEthereumRopsten], heights[vaa.ChainIDEthereumRopsten], errors[vaa.ChainIDEthereumRopsten], ) } else { fmt.Fprintf(w, - "%s\t%s\t%s\t%s\t%s\t%d\t%d\t%d\t%d\t%d\t%d\n", + "%s\t%s\t%s\t%s\t%s\t%d\t%d\t%d\t%d\t%d\t%d\t%d\n", h.P2PNodeAddr, h.RawHeartbeat.GuardianAddr, h.RawHeartbeat.NodeName, @@ -142,6 +145,7 @@ func runListNodes(cmd *cobra.Command, args []string) { heights[vaa.ChainIDTerra], heights[vaa.ChainIDBSC], heights[vaa.ChainIDPolygon], + heights[vaa.ChainIDAvalanche], heights[vaa.ChainIDEthereumRopsten], ) } diff --git a/node/cmd/guardiand/node.go b/node/cmd/guardiand/node.go index 06530cbca..953523d46 100644 --- a/node/cmd/guardiand/node.go +++ b/node/cmd/guardiand/node.go @@ -68,6 +68,9 @@ var ( ethRopstenRPC *string ethRopstenContract *string + avalancheRPC *string + avalancheContract *string + terraWS *string terraLCD *string terraContract *string @@ -128,6 +131,9 @@ func init() { ethRopstenRPC = NodeCmd.Flags().String("ethRopstenRPC", "", "Ethereum Ropsten RPC URL") ethRopstenContract = NodeCmd.Flags().String("ethRopstenContract", "", "Ethereum Ropsten contract address") + avalancheRPC = NodeCmd.Flags().String("avalancheRPC", "", "Avalanche RPC URL") + avalancheContract = NodeCmd.Flags().String("avalancheContract", "", "Avalanche contract address") + terraWS = NodeCmd.Flags().String("terraWS", "", "Path to terrad root for websocket connection") terraLCD = NodeCmd.Flags().String("terraLCD", "", "Path to LCD service root for http calls") terraContract = NodeCmd.Flags().String("terraContract", "", "Wormhole contract address on Terra blockchain") @@ -238,6 +244,7 @@ func runNode(cmd *cobra.Command, args []string) { readiness.RegisterComponent(common.ReadinessPolygonSyncing) if *testnetMode { readiness.RegisterComponent(common.ReadinessEthRopstenSyncing) + readiness.RegisterComponent(common.ReadinessAvalancheSyncing) } if *statusAddr != "" { @@ -328,6 +335,9 @@ func runNode(cmd *cobra.Command, args []string) { if *ethRopstenContract == "" { logger.Fatal("Please specify --ethRopstenContract") } + if *avalancheRPC == "" { + logger.Fatal("Please specify --avalancheRPC") + } } else { if *ethRopstenRPC != "" { logger.Fatal("Please do not specify --ethRopstenRPC in non-testnet mode") @@ -335,6 +345,9 @@ func runNode(cmd *cobra.Command, args []string) { if *ethRopstenContract != "" { logger.Fatal("Please do not specify --ethRopstenContract in non-testnet mode") } + if *avalancheRPC != "" { + logger.Fatal("Please do not specify --avalancheRPC in non-testnet mode") + } } if *nodeName == "" { logger.Fatal("Please specify --nodeName") @@ -402,6 +415,7 @@ func runNode(cmd *cobra.Command, args []string) { bscContractAddr := eth_common.HexToAddress(*bscContract) polygonContractAddr := eth_common.HexToAddress(*polygonContract) ethRopstenContractAddr := eth_common.HexToAddress(*ethRopstenContract) + avalancheContractAddr := eth_common.HexToAddress(*avalancheContract) solAddress, err := solana_types.PublicKeyFromBase58(*solanaContract) if err != nil { logger.Fatal("invalid Solana contract address", zap.Error(err)) @@ -539,6 +553,10 @@ func runNode(cmd *cobra.Command, args []string) { ethereum.NewEthWatcher(*ethRopstenRPC, ethRopstenContractAddr, "ethropsten", common.ReadinessEthRopstenSyncing, vaa.ChainIDEthereumRopsten, lockC, setC).Run); err != nil { return err } + if err := supervisor.Run(ctx, "avalanchewatch", + ethereum.NewEthWatcher(*avalancheRPC, avalancheContractAddr, "avalanche", common.ReadinessAvalancheSyncing, vaa.ChainIDAvalanche, lockC, nil).Run); err != nil { + return err + } } // Start Terra watcher only if configured diff --git a/node/pkg/common/readiness.go b/node/pkg/common/readiness.go index 0a4a64185..5cd542652 100644 --- a/node/pkg/common/readiness.go +++ b/node/pkg/common/readiness.go @@ -9,4 +9,5 @@ const ( ReadinessBSCSyncing readiness.Component = "bscSyncing" ReadinessPolygonSyncing readiness.Component = "polygonSyncing" ReadinessEthRopstenSyncing readiness.Component = "ethRopstenSyncing" + ReadinessAvalancheSyncing readiness.Component = "avalancheSyncing" ) diff --git a/node/pkg/vaa/structs.go b/node/pkg/vaa/structs.go index 3101cb7a8..606752290 100644 --- a/node/pkg/vaa/structs.go +++ b/node/pkg/vaa/structs.go @@ -94,6 +94,8 @@ func (c ChainID) String() string { return "bsc" case ChainIDPolygon: return "polygon" + case ChainIDAvalanche: + return "avalanche" case ChainIDEthereumRopsten: return "ethereum-ropsten" default: @@ -115,6 +117,8 @@ func ChainIDFromString(s string) (ChainID, error) { return ChainIDBSC, nil case "polygon": return ChainIDPolygon, nil + case "avalanche": + return ChainIDAvalanche, nil case "ethereum-ropsten": return ChainIDEthereumRopsten, nil default: @@ -134,6 +138,9 @@ const ( ChainIDBSC ChainID = 4 // ChainIDPolygon is the ChainID of Polygon ChainIDPolygon ChainID = 5 + // ChainIDAvalanche is the ChainID of Avalanche + ChainIDAvalanche ChainID = 6 + // ChainIDEthereumRopsten is the ChainID of Ethereum Ropsten ChainIDEthereumRopsten ChainID = 10001 diff --git a/proto/publicrpc/v1/publicrpc.proto b/proto/publicrpc/v1/publicrpc.proto index 1cc73736a..aeb9f7c63 100644 --- a/proto/publicrpc/v1/publicrpc.proto +++ b/proto/publicrpc/v1/publicrpc.proto @@ -14,6 +14,7 @@ enum ChainID { CHAIN_ID_TERRA = 3; CHAIN_ID_BSC = 4; CHAIN_ID_POLYGON = 5; + CHAIN_ID_AVALANCHE = 6; // Special case - Eth has two testnets. CHAIN_ID_ETHEREUM is Goerli, // but we also want to connect to Ropsten, so we add a separate chain. CHAIN_ID_ETHEREUM_ROPSTEN = 10001;