node: XPLA watcher (#1676)

This commit is contained in:
Paul Noel 2022-10-05 13:05:31 +00:00 committed by GitHub
parent 59882d963d
commit 9657f41561
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 72 additions and 2 deletions

View File

@ -122,6 +122,7 @@ func runListNodes(cmd *cobra.Command, args []string) {
networks = append(networks, network{"Neon", vaa.ChainIDNeon})
networks = append(networks, network{"Injective", vaa.ChainIDInjective})
networks = append(networks, network{"Arbitrum", vaa.ChainIDArbitrum})
networks = append(networks, network{"XPLA", vaa.ChainIDXpla})
}
if len(only) > 0 {

View File

@ -121,6 +121,10 @@ var (
injectiveLCD *string
injectiveContract *string
xplaWS *string
xplaLCD *string
xplaContract *string
algorandIndexerRPC *string
algorandIndexerToken *string
algorandAlgodRPC *string
@ -242,6 +246,10 @@ func init() {
injectiveLCD = NodeCmd.Flags().String("injectiveLCD", "", "Path to LCD service root for Injective http calls")
injectiveContract = NodeCmd.Flags().String("injectiveContract", "", "Wormhole contract address on Injective blockchain")
xplaWS = NodeCmd.Flags().String("xplaWS", "", "Path to root for XPLA websocket connection")
xplaLCD = NodeCmd.Flags().String("xplaLCD", "", "Path to LCD service root for XPLA http calls")
xplaContract = NodeCmd.Flags().String("xplaContract", "", "Wormhole contract address on XPLA blockchain")
algorandIndexerRPC = NodeCmd.Flags().String("algorandIndexerRPC", "", "Algorand Indexer RPC URL")
algorandIndexerToken = NodeCmd.Flags().String("algorandIndexerToken", "", "Algorand Indexer access token")
algorandAlgodRPC = NodeCmd.Flags().String("algorandAlgodRPC", "", "Algorand Algod RPC URL")
@ -420,6 +428,7 @@ func runNode(cmd *cobra.Command, args []string) {
readiness.RegisterComponent(common.ReadinessNeonSyncing)
readiness.RegisterComponent(common.ReadinessInjectiveSyncing)
readiness.RegisterComponent(common.ReadinessArbitrumSyncing)
readiness.RegisterComponent(common.ReadinessXplaSyncing)
}
if *statusAddr != "" {
@ -601,6 +610,15 @@ func runNode(cmd *cobra.Command, args []string) {
if *arbitrumContract == "" {
logger.Fatal("Please specify --arbitrumContract")
}
if *xplaWS == "" {
logger.Fatal("Please specify --xplaWS")
}
if *xplaLCD == "" {
logger.Fatal("Please specify --xplaLCD")
}
if *xplaContract == "" {
logger.Fatal("Please specify --xplaContract")
}
} else {
if *ethRopstenRPC != "" {
logger.Fatal("Please do not specify --ethRopstenRPC in non-testnet mode")
@ -623,6 +641,15 @@ func runNode(cmd *cobra.Command, args []string) {
if *injectiveContract != "" && !*unsafeDevMode {
logger.Fatal("Please do not specify --injectiveContract")
}
if *xplaWS != "" && !*unsafeDevMode {
logger.Fatal("Please do not specify --xplaWS")
}
if *xplaLCD != "" && !*unsafeDevMode {
logger.Fatal("Please do not specify --xplaLCD")
}
if *xplaContract != "" && !*unsafeDevMode {
logger.Fatal("Please do not specify --xplaContract")
}
if *arbitrumRPC != "" && !*unsafeDevMode {
logger.Fatal("Please do not specify --arbitrumRPC")
}
@ -848,6 +875,7 @@ func runNode(cmd *cobra.Command, args []string) {
chainObsvReqC[vaa.ChainIDEthereumRopsten] = make(chan *gossipv1.ObservationRequest, observationRequestBufferSize)
chainObsvReqC[vaa.ChainIDInjective] = make(chan *gossipv1.ObservationRequest, observationRequestBufferSize)
chainObsvReqC[vaa.ChainIDArbitrum] = make(chan *gossipv1.ObservationRequest, observationRequestBufferSize)
chainObsvReqC[vaa.ChainIDXpla] = make(chan *gossipv1.ObservationRequest, observationRequestBufferSize)
}
go handleReobservationRequests(rootCtx, clock.New(), logger, obsvReqC, chainObsvReqC)
@ -1054,6 +1082,13 @@ func runNode(cmd *cobra.Command, args []string) {
return err
}
}
if *testnetMode {
logger.Info("Starting XPLA watcher")
if err := supervisor.Run(ctx, "xplawatch",
cosmwasm.NewWatcher(*xplaWS, *xplaLCD, *xplaContract, lockC, chainObsvReqC[vaa.ChainIDXpla], common.ReadinessXplaSyncing, vaa.ChainIDXpla).Run); err != nil {
return err
}
}
if *algorandIndexerRPC != "" {
if err := supervisor.Run(ctx, "algorandwatch",

View File

@ -23,6 +23,7 @@ const (
ReadinessNeonSyncing readiness.Component = "neonSyncing"
ReadinessTerra2Syncing readiness.Component = "terra2Syncing"
ReadinessInjectiveSyncing readiness.Component = "injectiveSyncing"
ReadinessXplaSyncing readiness.Component = "xplaSyncing"
ReadinessPythNetSyncing readiness.Component = "pythnetSyncing"
ReadinessArbitrumSyncing readiness.Component = "arbitrumSyncing"
ReadinessWormchainSyncing readiness.Component = "wormchainSyncing"

View File

@ -28,6 +28,7 @@ import {
isEVMChain,
isTerraChain,
CHAIN_ID_PYTHNET,
CHAIN_ID_XPLA,
} from "./consts";
import { hashLookup } from "./near";
@ -99,6 +100,8 @@ export const tryUint8ArrayToNative = (
return humanAddress("wormhole", a.slice(-20));
} else if (chainId === CHAIN_ID_NEAR) {
throw Error("uint8ArrayToNative: Use tryHexToNativeStringNear instead.");
} else if (chainId === CHAIN_ID_XPLA) {
throw Error("uint8ArrayToNative: XPLA not supported yet.");
} else if (chainId === CHAIN_ID_OSMOSIS) {
throw Error("uint8ArrayToNative: Osmosis not supported yet.");
} else if (chainId === CHAIN_ID_SUI) {
@ -231,6 +234,8 @@ export const tryNativeToHexString = (
return uint8ArrayToHex(arrayify(sha256(Buffer.from(address))));
} else if (chainId === CHAIN_ID_OSMOSIS) {
throw Error("hexToNativeString: Osmosis not supported yet.");
} else if (chainId === CHAIN_ID_XPLA) {
throw Error("hexToNativeString: XPLA not supported yet.");
} else if (chainId === CHAIN_ID_SUI) {
throw Error("hexToNativeString: Sui not supported yet.");
} else if (chainId === CHAIN_ID_APTOS) {

View File

@ -26,6 +26,7 @@ export const CHAINS = {
optimism: 24,
gnosis: 25,
pythnet: 26,
xpla: 28,
ropsten: 10001,
wormholechain: 3104,
} as const;
@ -61,7 +62,7 @@ export type EVMChainName =
*/
export type SolanaChainName = "solana" | "pythnet";
export type CosmWasmChainName = "terra" | "terra2" | "injective";
export type CosmWasmChainName = "terra" | "terra2" | "injective" | "xpla";
export type TerraChainName = "terra" | "terra2";
export type Contracts = {
@ -211,6 +212,11 @@ const MAINNET = {
token_bridge: undefined,
nft_bridge: undefined,
},
xpla: {
core: undefined,
token_bridge: undefined,
nft_bridge: undefined,
},
ropsten: {
core: undefined,
token_bridge: undefined,
@ -360,6 +366,12 @@ const TESTNET = {
token_bridge: undefined,
nft_bridge: undefined,
},
xpla: {
core: "xpla1upkjn4mthr0047kahvn0llqx4qpqfn75lnph4jpxfn8walmm8mqsanyy35",
token_bridge:
"xpla1alpgm9geq76dzhk5xvt6qqc2lza0vtzzpskgys5rkmjzph8cs69sl09fq9",
nft_bridge: undefined,
},
ropsten: {
core: "0x210c5F5e2AF958B4defFe715Dc621b7a3BA888c5",
token_bridge: "0xF174F9A837536C449321df1Ca093Bb96948D5386",
@ -509,6 +521,11 @@ const DEVNET = {
token_bridge: undefined,
nft_bridge: undefined,
},
xpla: {
core: undefined,
token_bridge: undefined,
nft_bridge: undefined,
},
ropsten: {
core: undefined,
token_bridge: undefined,
@ -586,6 +603,7 @@ export const CHAIN_ID_ARBITRUM = CHAINS["arbitrum"];
export const CHAIN_ID_OPTIMISM = CHAINS["optimism"];
export const CHAIN_ID_GNOSIS = CHAINS["gnosis"];
export const CHAIN_ID_PYTHNET = CHAINS["pythnet"];
export const CHAIN_ID_XPLA = CHAINS["xpla"];
export const CHAIN_ID_ETHEREUM_ROPSTEN = CHAINS["ropsten"];
export const CHAIN_ID_WORMHOLE_CHAIN = CHAINS["wormholechain"];
@ -733,7 +751,8 @@ export function isCosmWasmChain(
return (
chainId === CHAIN_ID_TERRA ||
chainId === CHAIN_ID_TERRA2 ||
chainId === CHAIN_ID_INJECTIVE
chainId === CHAIN_ID_INJECTIVE ||
chainId === CHAIN_ID_XPLA
);
}

View File

@ -144,6 +144,8 @@ func (c ChainID) String() string {
return "pythnet"
case ChainIDWormchain:
return "wormholechain"
case ChainIDXpla:
return "xpla"
default:
return fmt.Sprintf("unknown chain ID: %d", c)
}
@ -199,6 +201,8 @@ func ChainIDFromString(s string) (ChainID, error) {
return ChainIDPythNet, nil
case "wormholechain":
return ChainIDWormchain, nil
case "xpla":
return ChainIDXpla, nil
default:
return ChainIDUnset, fmt.Errorf("unknown chain ID: %s", s)
}
@ -248,6 +252,8 @@ const (
ChainIDArbitrum ChainID = 23
// ChainIDPythNet is the ChainID of PythNet
ChainIDPythNet ChainID = 26
// ChainIDXpla is the ChainID of Xpla
ChainIDXpla ChainID = 28
//ChainIDWormchain is the ChainID of Wormholechain
ChainIDWormchain ChainID = 3104

View File

@ -44,6 +44,7 @@ func TestChainIDFromString(t *testing.T) {
{input: "terra2", output: ChainIDTerra2},
{input: "injective", output: ChainIDInjective},
{input: "arbitrum", output: ChainIDArbitrum},
{input: "xpla", output: ChainIDXpla},
{input: "ethereum-ropsten", output: ChainIDEthereumRopsten},
{input: "Solana", output: ChainIDSolana},
@ -66,6 +67,7 @@ func TestChainIDFromString(t *testing.T) {
{input: "Terra2", output: ChainIDTerra2},
{input: "Injective", output: ChainIDInjective},
{input: "Arbitrum", output: ChainIDArbitrum},
{input: "XPLA", output: ChainIDXpla},
{input: "Ethereum-ropsten", output: ChainIDEthereumRopsten},
{input: "Wormholechain", output: ChainIDWormchain},
{input: "wormholechain", output: ChainIDWormchain},
@ -160,6 +162,7 @@ func TestChainId_String(t *testing.T) {
{input: 18, output: "terra2"},
{input: 19, output: "injective"},
{input: 23, output: "arbitrum"},
{input: 28, output: "xpla"},
{input: 10001, output: "ethereum-ropsten"},
{input: 3104, output: "wormholechain"},
}