Skip to content

Commit

Permalink
node: add fantom support
Browse files Browse the repository at this point in the history
Only run in testnet until the contracts are deployed to mainnet.
  • Loading branch information
SEJeff authored and evan-gray committed Feb 15, 2022
1 parent fce0708 commit b54b7e1
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 1 deletion.
2 changes: 2 additions & 0 deletions devnet/node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ spec:
- ws://eth-devnet:8545
- --avalancheRPC
- ws://eth-devnet:8545
- --fantomRPC
- ws://eth-devnet:8545
- --oasisRPC
- ws://eth-devnet:8545
- --terraWS
Expand Down
1 change: 1 addition & 0 deletions node/cmd/guardiand/adminnodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ func runListNodes(cmd *cobra.Command, args []string) {

if isTestnet {
networks = append(networks, network{"Ropsten", vaa.ChainIDEthereumRopsten})
networks = append(networks, network{"Fantom", vaa.ChainIDFantom})
}

if len(only) > 0 {
Expand Down
27 changes: 26 additions & 1 deletion node/cmd/guardiand/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ var (
ethRopstenRPC *string
ethRopstenContract *string

fantomRPC *string
fantomContract *string

avalancheRPC *string
avalancheContract *string

Expand Down Expand Up @@ -155,6 +158,9 @@ func init() {
oasisRPC = NodeCmd.Flags().String("oasisRPC", "", "Oasis RPC URL")
oasisContract = NodeCmd.Flags().String("oasisContract", "", "Oasis contract address")

fantomRPC = NodeCmd.Flags().String("fantomRPC", "", "Fantom Websocket RPC URL")
fantomContract = NodeCmd.Flags().String("fantomContract", "", "Fantom 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")
Expand Down Expand Up @@ -281,6 +287,7 @@ func runNode(cmd *cobra.Command, args []string) {
readiness.RegisterComponent(common.ReadinessOasisSyncing)
if *testnetMode {
readiness.RegisterComponent(common.ReadinessEthRopstenSyncing)
readiness.RegisterComponent(common.ReadinessFantomSyncing)
}

if *statusAddr != "" {
Expand Down Expand Up @@ -324,6 +331,7 @@ func runNode(cmd *cobra.Command, args []string) {
*polygonContract = devnet.GanacheWormholeContractAddress.Hex()
*avalancheContract = devnet.GanacheWormholeContractAddress.Hex()
*oasisContract = devnet.GanacheWormholeContractAddress.Hex()
*fantomContract = devnet.GanacheWormholeContractAddress.Hex()
}

// Verify flags
Expand Down Expand Up @@ -371,13 +379,25 @@ func runNode(cmd *cobra.Command, args []string) {
if *ethRopstenContract == "" {
logger.Fatal("Please specify --ethRopstenContract")
}
if *fantomRPC == "" {
logger.Fatal("Please specify --fantomRPC")
}
if *fantomContract == "" {
logger.Fatal("Please specify --fantomContract")
}
} else {
if *ethRopstenRPC != "" {
logger.Fatal("Please do not specify --ethRopstenRPC in non-testnet mode")
}
if *ethRopstenContract != "" {
logger.Fatal("Please do not specify --ethRopstenContract in non-testnet mode")
}
if *fantomRPC == "" {
logger.Fatal("Please do not specify --fantomRPC in non-testnet mode")
}
if *fantomContract == "" {
logger.Fatal("Please do not specify --fantomContract in non-testnet mode")
}
}
if *nodeName == "" {
logger.Fatal("Please specify --nodeName")
Expand Down Expand Up @@ -462,6 +482,7 @@ func runNode(cmd *cobra.Command, args []string) {
ethRopstenContractAddr := eth_common.HexToAddress(*ethRopstenContract)
avalancheContractAddr := eth_common.HexToAddress(*avalancheContract)
oasisContractAddr := eth_common.HexToAddress(*oasisContract)
fantomContractAddr := eth_common.HexToAddress(*fantomContract)
solAddress, err := solana_types.PublicKeyFromBase58(*solanaContract)
if err != nil {
logger.Fatal("invalid Solana contract address", zap.Error(err))
Expand Down Expand Up @@ -546,6 +567,7 @@ func runNode(cmd *cobra.Command, args []string) {
chainObsvReqC[vaa.ChainIDAvalanche] = make(chan *gossipv1.ObservationRequest)
chainObsvReqC[vaa.ChainIDOasis] = make(chan *gossipv1.ObservationRequest)
if *testnetMode {
chainObsvReqC[vaa.ChainIDFantom] = make(chan *gossipv1.ObservationRequest)
chainObsvReqC[vaa.ChainIDEthereumRopsten] = make(chan *gossipv1.ObservationRequest)
}

Expand Down Expand Up @@ -684,12 +706,15 @@ func runNode(cmd *cobra.Command, args []string) {
ethereum.NewEthWatcher(*oasisRPC, oasisContractAddr, "oasis", common.ReadinessOasisSyncing, vaa.ChainIDOasis, lockC, nil, 1, chainObsvReqC[vaa.ChainIDOasis]).Run); err != nil {
return err
}

if *testnetMode {
if err := supervisor.Run(ctx, "ethropstenwatch",
ethereum.NewEthWatcher(*ethRopstenRPC, ethRopstenContractAddr, "ethropsten", common.ReadinessEthRopstenSyncing, vaa.ChainIDEthereumRopsten, lockC, setC, 1, chainObsvReqC[vaa.ChainIDEthereumRopsten]).Run); err != nil {
return err
}
if err := supervisor.Run(ctx, "fantomwatch",
ethereum.NewEthWatcher(*fantomRPC, fantomContractAddr, "fantom", common.ReadinessFantomSyncing, vaa.ChainIDFantom, lockC, nil, 1, chainObsvReqC[vaa.ChainIDFantom]).Run); err != nil {
return err
}
}

// Start Terra watcher only if configured
Expand Down
1 change: 1 addition & 0 deletions node/pkg/common/readiness.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ const (
ReadinessEthRopstenSyncing readiness.Component = "ethRopstenSyncing"
ReadinessAvalancheSyncing readiness.Component = "avalancheSyncing"
ReadinessOasisSyncing readiness.Component = "oasisSyncing"
ReadinessFantomSyncing readiness.Component = "fantomSyncing"
)
6 changes: 6 additions & 0 deletions node/pkg/vaa/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ func (c ChainID) String() string {
return "avalanche"
case ChainIDOasis:
return "oasis"
case ChainIDFantom:
return "fantom"
case ChainIDAlgorand:
return "algorand"
case ChainIDEthereumRopsten:
Expand Down Expand Up @@ -125,6 +127,8 @@ func ChainIDFromString(s string) (ChainID, error) {
return ChainIDAvalanche, nil
case "oasis":
return ChainIDOasis, nil
case "fantom":
return ChainIDFantom, nil
case "algorand":
return ChainIDAlgorand, nil
case "ethereum-ropsten":
Expand Down Expand Up @@ -152,6 +156,8 @@ const (
ChainIDOasis ChainID = 7
// ChainIDAlgorand is the ChainID of Algorand
ChainIDAlgorand ChainID = 8
// ChainIDFantom is the ChainID of Fantom
ChainIDFantom ChainID = 10

// ChainIDEthereumRopsten is the ChainID of Ethereum Ropsten
ChainIDEthereumRopsten ChainID = 10001
Expand Down
1 change: 1 addition & 0 deletions proto/publicrpc/v1/publicrpc.proto
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ enum ChainID {
CHAIN_ID_AVALANCHE = 6;
CHAIN_ID_OASIS = 7;
CHAIN_ID_ALGORAND = 8;
CHAIN_ID_FANTOM = 10;
// 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;
Expand Down

0 comments on commit b54b7e1

Please sign in to comment.