node: add Polygon support
Change-Id: Ia919861879eb6c831d4dd9ccbe1748e7123502e5
This commit is contained in:
parent
d4ea78d2ca
commit
c64576cc0b
|
@ -80,6 +80,8 @@ spec:
|
|||
- ws://eth-devnet:8545
|
||||
- --bscRPC
|
||||
- ws://eth-devnet2:8545
|
||||
- --polygonRPC
|
||||
- ws://eth-devnet:8545
|
||||
- --terraWS
|
||||
- ws://terra-terrad:26657/websocket
|
||||
- --terraLCD
|
||||
|
|
|
@ -100,6 +100,7 @@ func ReadRow(w http.ResponseWriter, r *http.Request) {
|
|||
"ethereum": "2",
|
||||
"terra": "3",
|
||||
"bsc": "4",
|
||||
"polygon": "5",
|
||||
}
|
||||
lowercaseChain := strings.ToLower(emitterChain)
|
||||
if _, ok := chainNameMap[lowercaseChain]; ok {
|
||||
|
|
|
@ -65,9 +65,9 @@ func runListNodes(cmd *cobra.Command, args []string) {
|
|||
w := tabwriter.NewWriter(os.Stdout, 0, 8, 2, ' ', 0)
|
||||
|
||||
if showDetails {
|
||||
_, _ = w.Write([]byte("Node key\tGuardian key\tNode name\tVersion\tLast seen\tUptime\tSolana\tEthereum\tTerra\tBSC\n"))
|
||||
_, _ = w.Write([]byte("Node key\tGuardian key\tNode name\tVersion\tLast seen\tUptime\tSolana\tEthereum\tTerra\tBSC\nPolygon\n"))
|
||||
} else {
|
||||
_, _ = w.Write([]byte("Node key\tGuardian key\tNode name\tVersion\tLast seen\tSolana\tEthereum\tTerra\tBSC\n"))
|
||||
_, _ = w.Write([]byte("Node key\tGuardian key\tNode name\tVersion\tLast seen\tSolana\tEthereum\tTerra\tBSC\nPolygon\n"))
|
||||
}
|
||||
|
||||
for _, h := range nodes {
|
||||
|
@ -93,7 +93,7 @@ func runListNodes(cmd *cobra.Command, args []string) {
|
|||
|
||||
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)\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)\n",
|
||||
h.P2PNodeAddr,
|
||||
h.RawHeartbeat.GuardianAddr,
|
||||
h.RawHeartbeat.NodeName,
|
||||
|
@ -112,10 +112,13 @@ func runListNodes(cmd *cobra.Command, args []string) {
|
|||
truncAddrs[vaa.ChainIDBSC],
|
||||
heights[vaa.ChainIDBSC],
|
||||
errors[vaa.ChainIDBSC],
|
||||
truncAddrs[vaa.ChainIDPolygon],
|
||||
heights[vaa.ChainIDPolygon],
|
||||
errors[vaa.ChainIDPolygon],
|
||||
)
|
||||
} else {
|
||||
fmt.Fprintf(w,
|
||||
"%s\t%s\t%s\t%s\t%s\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\n",
|
||||
h.P2PNodeAddr,
|
||||
h.RawHeartbeat.GuardianAddr,
|
||||
h.RawHeartbeat.NodeName,
|
||||
|
@ -125,6 +128,7 @@ func runListNodes(cmd *cobra.Command, args []string) {
|
|||
heights[vaa.ChainIDEthereum],
|
||||
heights[vaa.ChainIDTerra],
|
||||
heights[vaa.ChainIDBSC],
|
||||
heights[vaa.ChainIDPolygon],
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,6 +66,9 @@ var (
|
|||
bscRPC *string
|
||||
bscContract *string
|
||||
|
||||
polygonRPC *string
|
||||
polygonContract *string
|
||||
|
||||
terraWS *string
|
||||
terraLCD *string
|
||||
terraContract *string
|
||||
|
@ -119,6 +122,9 @@ func init() {
|
|||
bscRPC = NodeCmd.Flags().String("bscRPC", "", "Binance Smart Chain RPC URL")
|
||||
bscContract = NodeCmd.Flags().String("bscContract", "", "Binance Smart Chain contract address")
|
||||
|
||||
polygonRPC = NodeCmd.Flags().String("polygonRPC", "", "Polygon RPC URL")
|
||||
polygonContract = NodeCmd.Flags().String("polygonContract", "", "Polygon 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")
|
||||
|
@ -280,6 +286,7 @@ func runNode(cmd *cobra.Command, args []string) {
|
|||
// Deterministic ganache ETH devnet address.
|
||||
*ethContract = devnet.GanacheWormholeContractAddress.Hex()
|
||||
*bscContract = devnet.GanacheWormholeContractAddress.Hex()
|
||||
*polygonContract = devnet.GanacheWormholeContractAddress.Hex()
|
||||
|
||||
// Use the hostname as nodeName. For production, we don't want to do this to
|
||||
// prevent accidentally leaking sensitive hostnames.
|
||||
|
@ -316,6 +323,12 @@ func runNode(cmd *cobra.Command, args []string) {
|
|||
if *bscContract == "" {
|
||||
logger.Fatal("Please specify --bscContract")
|
||||
}
|
||||
if *polygonRPC == "" {
|
||||
logger.Fatal("Please specify --polygonRPC")
|
||||
}
|
||||
if *polygonContract == "" {
|
||||
logger.Fatal("Please specify --polygonContract")
|
||||
}
|
||||
if *nodeName == "" {
|
||||
logger.Fatal("Please specify --nodeName")
|
||||
}
|
||||
|
@ -373,12 +386,14 @@ func runNode(cmd *cobra.Command, args []string) {
|
|||
//
|
||||
// Insert "I'm a sign, not a cop" meme.
|
||||
//
|
||||
if strings.HasSuffix(*ethRPC, "mainnet.infura.io") {
|
||||
if strings.HasSuffix(*ethRPC, "mainnet.infura.io") ||
|
||||
strings.HasSuffix(*polygonRPC, "polygon-mainnet.infura.io") {
|
||||
logger.Fatal("Infura is known to send incorrect blocks - please use your own nodes")
|
||||
}
|
||||
|
||||
ethContractAddr := eth_common.HexToAddress(*ethContract)
|
||||
bscContractAddr := eth_common.HexToAddress(*bscContract)
|
||||
polygonContractAddr := eth_common.HexToAddress(*polygonContract)
|
||||
solAddress, err := solana_types.PublicKeyFromBase58(*solanaContract)
|
||||
if err != nil {
|
||||
logger.Fatal("invalid Solana contract address", zap.Error(err))
|
||||
|
@ -506,6 +521,11 @@ func runNode(cmd *cobra.Command, args []string) {
|
|||
return err
|
||||
}
|
||||
|
||||
if err := supervisor.Run(ctx, "polygonwatch",
|
||||
ethereum.NewEthWatcher(*polygonRPC, polygonContractAddr, "polygon", common.ReadinessPolygonSyncing, vaa.ChainIDPolygon, lockC, nil).Run); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Start Terra watcher only if configured
|
||||
logger.Info("Starting Terra watcher")
|
||||
if err := supervisor.Run(ctx, "terrawatch",
|
||||
|
|
|
@ -3,8 +3,9 @@ package common
|
|||
import "github.com/certusone/wormhole/node/pkg/readiness"
|
||||
|
||||
const (
|
||||
ReadinessEthSyncing readiness.Component = "ethSyncing"
|
||||
ReadinessSolanaSyncing readiness.Component = "solanaSyncing"
|
||||
ReadinessTerraSyncing readiness.Component = "terraSyncing"
|
||||
ReadinessBSCSyncing readiness.Component = "bscSyncing"
|
||||
ReadinessEthSyncing readiness.Component = "ethSyncing"
|
||||
ReadinessSolanaSyncing readiness.Component = "solanaSyncing"
|
||||
ReadinessTerraSyncing readiness.Component = "terraSyncing"
|
||||
ReadinessBSCSyncing readiness.Component = "bscSyncing"
|
||||
ReadinessPolygonSyncing readiness.Component = "polygonSyncing"
|
||||
)
|
||||
|
|
|
@ -91,6 +91,8 @@ func (c ChainID) String() string {
|
|||
return "terra"
|
||||
case ChainIDBSC:
|
||||
return "bsc"
|
||||
case ChainIDPolygon:
|
||||
return "polygon"
|
||||
default:
|
||||
return fmt.Sprintf("unknown chain ID: %d", c)
|
||||
}
|
||||
|
@ -106,6 +108,8 @@ const (
|
|||
ChainIDTerra ChainID = 3
|
||||
// ChainIDBSC is the ChainID of Binance Smart Chain
|
||||
ChainIDBSC ChainID = 4
|
||||
// ChainIDPolygon is the ChainID of Polygon
|
||||
ChainIDPolygon ChainID = 5
|
||||
|
||||
minVAALength = 1 + 4 + 52 + 4 + 1 + 1
|
||||
SupportedVAAVersion = 0x01
|
||||
|
|
|
@ -13,6 +13,7 @@ enum ChainID {
|
|||
CHAIN_ID_ETHEREUM = 2;
|
||||
CHAIN_ID_TERRA = 3;
|
||||
CHAIN_ID_BSC = 4;
|
||||
CHAIN_ID_POLYGON = 5;
|
||||
}
|
||||
|
||||
// MessageID is a VAA's globally unique identifier (see data availability design document).
|
||||
|
|
Loading…
Reference in New Issue