node: remove remaining "bridge" mentions

Ensure there's no core vs. token bridge ambiguity.

Breaking changes to the CLI:

* "guardiand bridge" CLI is now "guardiand node"
* --solanaBridgeAddress is now --solanaContract
* --bridgeKey is now --guardianKey

The Heartbeat proto message had one of its fields renamed from
BridgeAddress to ContractAddress, but this won't break the wire
format and the only consumer appears to be the CLI.

Change includes a "go mod tidy" - it insisted.

Change-Id: Id8b312827737f07f2d5f3944ebce469d946e7f51
This commit is contained in:
Leo 2021-08-30 16:19:00 +02:00 committed by Leopold Schabel
parent 0b9a2e05ad
commit 4ac19518bd
16 changed files with 323 additions and 182 deletions

View File

@ -73,7 +73,7 @@ local_resource(
env = {"DOCKER_BUILDKIT": "1"}, env = {"DOCKER_BUILDKIT": "1"},
) )
# bridge # node
k8s_yaml_with_ns( k8s_yaml_with_ns(
secret_yaml_generic( secret_yaml_generic(
@ -88,10 +88,10 @@ docker_build(
dockerfile = "node/Dockerfile", dockerfile = "node/Dockerfile",
) )
def build_bridge_yaml(): def build_node_yaml():
bridge_yaml = read_yaml_stream("devnet/bridge.yaml") node_yaml = read_yaml_stream("devnet/node.yaml")
for obj in bridge_yaml: for obj in node_yaml:
if obj["kind"] == "StatefulSet" and obj["metadata"]["name"] == "guardian": if obj["kind"] == "StatefulSet" and obj["metadata"]["name"] == "guardian":
obj["spec"]["replicas"] = num_guardians obj["spec"]["replicas"] = num_guardians
container = obj["spec"]["template"]["spec"]["containers"][0] container = obj["spec"]["template"]["spec"]["containers"][0]
@ -100,9 +100,9 @@ def build_bridge_yaml():
container["command"] += ["--devNumGuardians", str(num_guardians)] container["command"] += ["--devNumGuardians", str(num_guardians)]
container["command"] += ["--bigTableGCPProject", gcpProject] container["command"] += ["--bigTableGCPProject", gcpProject]
return encode_yaml_stream(bridge_yaml) return encode_yaml_stream(node_yaml)
k8s_yaml_with_ns(build_bridge_yaml()) k8s_yaml_with_ns(build_node_yaml())
k8s_resource("guardian", resource_deps = ["proto-gen", "solana-devnet"], port_forwards = [ k8s_resource("guardian", resource_deps = ["proto-gen", "solana-devnet"], port_forwards = [
port_forward(6060, name = "Debug/Status Server [:6060]"), port_forward(6060, name = "Debug/Status Server [:6060]"),

View File

@ -42,11 +42,11 @@ spec:
terminationGracePeriodSeconds: 0 terminationGracePeriodSeconds: 0
volumes: volumes:
# mount shared between containers for runtime state # mount shared between containers for runtime state
- name: bridge-rundir - name: node-rundir
emptyDir: {} emptyDir: {}
- name: bridge-keysdir - name: node-keysdir
secret: secret:
secretName: bridge-bigtable-key secretName: node-bigtable-key
optional: true optional: true
items: items:
- key: bigtable-key.json - key: bigtable-key.json
@ -55,10 +55,10 @@ spec:
- name: guardiand - name: guardiand
image: guardiand-image image: guardiand-image
volumeMounts: volumeMounts:
- mountPath: /run/bridge - mountPath: /run/node
name: bridge-rundir name: node-rundir
- mountPath: /tmp/mounted-keys - mountPath: /tmp/mounted-keys
name: bridge-keysdir name: node-keysdir
env: env:
- name: BIGTABLE_EMULATOR_HOST - name: BIGTABLE_EMULATOR_HOST
value: bigtable-emulator:8086 value: bigtable-emulator:8086
@ -75,7 +75,7 @@ spec:
# - exec # - exec
- /guardiand - /guardiand
# - -- # - --
- bridge - node
- --ethRPC - --ethRPC
- ws://eth-devnet:8545 - ws://eth-devnet:8545
- --bscRPC - --bscRPC
@ -88,14 +88,14 @@ spec:
- localterra - localterra
- --terraContract - --terraContract
- terra18eezxhys9jwku67cm4w84xhnzt4xjj77w2qt62 - terra18eezxhys9jwku67cm4w84xhnzt4xjj77w2qt62
- --solanaBridgeAddress - --solanaContract
- Bridge1p5gheXUvJ6jGWGeCsgPKgnE3YgdGKRVCMY9o - Bridge1p5gheXUvJ6jGWGeCsgPKgnE3YgdGKRVCMY9o
- --solanaWS - --solanaWS
- ws://solana-devnet:8900 - ws://solana-devnet:8900
- --solanaRPC - --solanaRPC
- http://solana-devnet:8899 - http://solana-devnet:8899
- --unsafeDevMode - --unsafeDevMode
- --bridgeKey - --guardianKey
- /tmp/bridge.key - /tmp/bridge.key
- --publicRPC - --publicRPC
- "[::]:7070" - "[::]:7070"

View File

@ -84,8 +84,8 @@ func runListNodes(cmd *cobra.Command, args []string) {
for _, n := range h.RawHeartbeat.Networks { for _, n := range h.RawHeartbeat.Networks {
heights[vaa.ChainID(n.Id)] = n.Height heights[vaa.ChainID(n.Id)] = n.Height
errors[vaa.ChainID(n.Id)] = n.ErrorCount errors[vaa.ChainID(n.Id)] = n.ErrorCount
if len(n.BridgeAddress) >= 16 { if len(n.ContractAddress) >= 16 {
truncAddrs[vaa.ChainID(n.Id)] = n.BridgeAddress[:16] truncAddrs[vaa.ChainID(n.Id)] = n.ContractAddress[:16]
} else { } else {
truncAddrs[vaa.ChainID(n.Id)] = "INVALID" truncAddrs[vaa.ChainID(n.Id)] = "INVALID"
} }

View File

@ -55,8 +55,8 @@ var (
statusAddr *string statusAddr *string
bridgeKeyPath *string guardianKeyPath *string
solanaBridgeAddress *string solanaContract *string
ethRPC *string ethRPC *string
ethContract *string ethContract *string
@ -94,56 +94,56 @@ var (
) )
func init() { func init() {
p2pNetworkID = BridgeCmd.Flags().String("network", "/wormhole/dev", "P2P network identifier") p2pNetworkID = NodeCmd.Flags().String("network", "/wormhole/dev", "P2P network identifier")
p2pPort = BridgeCmd.Flags().Uint("port", 8999, "P2P UDP listener port") p2pPort = NodeCmd.Flags().Uint("port", 8999, "P2P UDP listener port")
p2pBootstrap = BridgeCmd.Flags().String("bootstrap", "", "P2P bootstrap peers (comma-separated)") p2pBootstrap = NodeCmd.Flags().String("bootstrap", "", "P2P bootstrap peers (comma-separated)")
statusAddr = BridgeCmd.Flags().String("statusAddr", "[::]:6060", "Listen address for status server (disabled if blank)") statusAddr = NodeCmd.Flags().String("statusAddr", "[::]:6060", "Listen address for status server (disabled if blank)")
nodeKeyPath = BridgeCmd.Flags().String("nodeKey", "", "Path to node key (will be generated if it doesn't exist)") nodeKeyPath = NodeCmd.Flags().String("nodeKey", "", "Path to node key (will be generated if it doesn't exist)")
adminSocketPath = BridgeCmd.Flags().String("adminSocket", "", "Admin gRPC service UNIX domain socket path") adminSocketPath = NodeCmd.Flags().String("adminSocket", "", "Admin gRPC service UNIX domain socket path")
dataDir = BridgeCmd.Flags().String("dataDir", "", "Data directory") dataDir = NodeCmd.Flags().String("dataDir", "", "Data directory")
bridgeKeyPath = BridgeCmd.Flags().String("bridgeKey", "", "Path to guardian key (required)") guardianKeyPath = NodeCmd.Flags().String("guardianKey", "", "Path to guardian key (required)")
solanaBridgeAddress = BridgeCmd.Flags().String("solanaBridgeAddress", "", "Address of the Solana Bridge Program (required)") solanaContract = NodeCmd.Flags().String("solanaContract", "", "Address of the Solana program (required)")
ethRPC = BridgeCmd.Flags().String("ethRPC", "", "Ethereum RPC URL") ethRPC = NodeCmd.Flags().String("ethRPC", "", "Ethereum RPC URL")
ethContract = BridgeCmd.Flags().String("ethContract", "", "Ethereum bridge contract address") ethContract = NodeCmd.Flags().String("ethContract", "", "Ethereum contract address")
bscRPC = BridgeCmd.Flags().String("bscRPC", "", "Binance Smart Chain RPC URL") bscRPC = NodeCmd.Flags().String("bscRPC", "", "Binance Smart Chain RPC URL")
bscContract = BridgeCmd.Flags().String("bscContract", "", "Binance Smart Chain bridge contract address") bscContract = NodeCmd.Flags().String("bscContract", "", "Binance Smart Chain contract address")
terraWS = BridgeCmd.Flags().String("terraWS", "", "Path to terrad root for websocket connection") terraWS = NodeCmd.Flags().String("terraWS", "", "Path to terrad root for websocket connection")
terraLCD = BridgeCmd.Flags().String("terraLCD", "", "Path to LCD service root for http calls") terraLCD = NodeCmd.Flags().String("terraLCD", "", "Path to LCD service root for http calls")
terraChainID = BridgeCmd.Flags().String("terraChainID", "", "Terra chain ID, used in LCD client initialization") terraChainID = NodeCmd.Flags().String("terraChainID", "", "Terra chain ID, used in LCD client initialization")
terraContract = BridgeCmd.Flags().String("terraContract", "", "Wormhole contract address on Terra blockchain") terraContract = NodeCmd.Flags().String("terraContract", "", "Wormhole contract address on Terra blockchain")
solanaWsRPC = BridgeCmd.Flags().String("solanaWS", "", "Solana Websocket URL (required") solanaWsRPC = NodeCmd.Flags().String("solanaWS", "", "Solana Websocket URL (required")
solanaRPC = BridgeCmd.Flags().String("solanaRPC", "", "Solana RPC URL (required") solanaRPC = NodeCmd.Flags().String("solanaRPC", "", "Solana RPC URL (required")
logLevel = BridgeCmd.Flags().String("logLevel", "info", "Logging level (debug, info, warn, error, dpanic, panic, fatal)") logLevel = NodeCmd.Flags().String("logLevel", "info", "Logging level (debug, info, warn, error, dpanic, panic, fatal)")
unsafeDevMode = BridgeCmd.Flags().Bool("unsafeDevMode", false, "Launch node in unsafe, deterministic devnet mode") unsafeDevMode = NodeCmd.Flags().Bool("unsafeDevMode", false, "Launch node in unsafe, deterministic devnet mode")
devNumGuardians = BridgeCmd.Flags().Uint("devNumGuardians", 5, "Number of devnet guardians to include in guardian set") devNumGuardians = NodeCmd.Flags().Uint("devNumGuardians", 5, "Number of devnet guardians to include in guardian set")
nodeName = BridgeCmd.Flags().String("nodeName", "", "Node name to announce in gossip heartbeats") nodeName = NodeCmd.Flags().String("nodeName", "", "Node name to announce in gossip heartbeats")
publicRPC = BridgeCmd.Flags().String("publicRPC", "", "Listen address for public gRPC interface") publicRPC = NodeCmd.Flags().String("publicRPC", "", "Listen address for public gRPC interface")
publicWeb = BridgeCmd.Flags().String("publicWeb", "", "Listen address for public REST and gRPC Web interface") publicWeb = NodeCmd.Flags().String("publicWeb", "", "Listen address for public REST and gRPC Web interface")
tlsHostname = BridgeCmd.Flags().String("tlsHostname", "", "If set, serve publicWeb as TLS with this hostname using Let's Encrypt") tlsHostname = NodeCmd.Flags().String("tlsHostname", "", "If set, serve publicWeb as TLS with this hostname using Let's Encrypt")
tlsProdEnv = BridgeCmd.Flags().Bool("tlsProdEnv", false, tlsProdEnv = NodeCmd.Flags().Bool("tlsProdEnv", false,
"Use the production Let's Encrypt environment instead of staging") "Use the production Let's Encrypt environment instead of staging")
disableHeartbeatVerify = BridgeCmd.Flags().Bool("disableHeartbeatVerify", false, disableHeartbeatVerify = NodeCmd.Flags().Bool("disableHeartbeatVerify", false,
"Disable heartbeat signature verification (useful during network startup)") "Disable heartbeat signature verification (useful during network startup)")
bigTablePersistenceEnabled = BridgeCmd.Flags().Bool("bigTablePersistenceEnabled", false, "Turn on forwarding events to BigTable") bigTablePersistenceEnabled = NodeCmd.Flags().Bool("bigTablePersistenceEnabled", false, "Turn on forwarding events to BigTable")
bigTableGCPProject = BridgeCmd.Flags().String("bigTableGCPProject", "", "Google Cloud project ID for storing events") bigTableGCPProject = NodeCmd.Flags().String("bigTableGCPProject", "", "Google Cloud project ID for storing events")
bigTableInstanceName = BridgeCmd.Flags().String("bigTableInstanceName", "", "BigTable instance name for storing events") bigTableInstanceName = NodeCmd.Flags().String("bigTableInstanceName", "", "BigTable instance name for storing events")
bigTableTableName = BridgeCmd.Flags().String("bigTableTableName", "", "BigTable table name to store events in") bigTableTableName = NodeCmd.Flags().String("bigTableTableName", "", "BigTable table name to store events in")
bigTableKeyPath = BridgeCmd.Flags().String("bigTableKeyPath", "", "Path to json Service Account key") bigTableKeyPath = NodeCmd.Flags().String("bigTableKeyPath", "", "Path to json Service Account key")
} }
var ( var (
@ -196,14 +196,14 @@ func setRestrictiveUmask() {
syscall.Umask(0077) // cannot fail syscall.Umask(0077) // cannot fail
} }
// BridgeCmd represents the bridge command // NodeCmd represents the node command
var BridgeCmd = &cobra.Command{ var NodeCmd = &cobra.Command{
Use: "bridge", Use: "node",
Short: "Run the bridge server", Short: "Run the guardiand node",
Run: runBridge, Run: runNode,
} }
func runBridge(cmd *cobra.Command, args []string) { func runNode(cmd *cobra.Command, args []string) {
if *unsafeDevMode { if *unsafeDevMode {
fmt.Print(devwarning) fmt.Print(devwarning)
} }
@ -272,8 +272,8 @@ func runBridge(cmd *cobra.Command, args []string) {
*p2pBootstrap = fmt.Sprintf("/dns4/guardian-0.guardian/udp/%d/quic/p2p/%s", *p2pPort, g0key.String()) *p2pBootstrap = fmt.Sprintf("/dns4/guardian-0.guardian/udp/%d/quic/p2p/%s", *p2pPort, g0key.String())
// Deterministic ganache ETH devnet address. // Deterministic ganache ETH devnet address.
*ethContract = devnet.GanacheBridgeContractAddress.Hex() *ethContract = devnet.GanacheWormholeContractAddress.Hex()
*bscContract = devnet.GanacheBridgeContractAddress.Hex() *bscContract = devnet.GanacheWormholeContractAddress.Hex()
// Use the hostname as nodeName. For production, we don't want to do this to // Use the hostname as nodeName. For production, we don't want to do this to
// prevent accidentally leaking sensitive hostnames. // prevent accidentally leaking sensitive hostnames.
@ -289,8 +289,8 @@ func runBridge(cmd *cobra.Command, args []string) {
if *nodeKeyPath == "" && !*unsafeDevMode { // In devnet mode, keys are deterministically generated. if *nodeKeyPath == "" && !*unsafeDevMode { // In devnet mode, keys are deterministically generated.
logger.Fatal("Please specify --nodeKey") logger.Fatal("Please specify --nodeKey")
} }
if *bridgeKeyPath == "" { if *guardianKeyPath == "" {
logger.Fatal("Please specify --bridgeKey") logger.Fatal("Please specify --guardianKey")
} }
if *adminSocketPath == "" { if *adminSocketPath == "" {
logger.Fatal("Please specify --adminSocket") logger.Fatal("Please specify --adminSocket")
@ -314,8 +314,8 @@ func runBridge(cmd *cobra.Command, args []string) {
logger.Fatal("Please specify --nodeName") logger.Fatal("Please specify --nodeName")
} }
if *solanaBridgeAddress == "" { if *solanaContract == "" {
logger.Fatal("Please specify --solanaBridgeAddress") logger.Fatal("Please specify --solanaContract")
} }
if *solanaWsRPC == "" { if *solanaWsRPC == "" {
logger.Fatal("Please specify --solanaWsUrl") logger.Fatal("Please specify --solanaWsUrl")
@ -354,9 +354,9 @@ func runBridge(cmd *cobra.Command, args []string) {
ethContractAddr := eth_common.HexToAddress(*ethContract) ethContractAddr := eth_common.HexToAddress(*ethContract)
bscContractAddr := eth_common.HexToAddress(*bscContract) bscContractAddr := eth_common.HexToAddress(*bscContract)
solBridgeAddress, err := solana_types.PublicKeyFromBase58(*solanaBridgeAddress) solAddress, err := solana_types.PublicKeyFromBase58(*solanaContract)
if err != nil { if err != nil {
logger.Fatal("invalid Solana bridge address", zap.Error(err)) logger.Fatal("invalid Solana contract address", zap.Error(err))
} }
// In devnet mode, we generate a deterministic guardian key and write it to disk. // In devnet mode, we generate a deterministic guardian key and write it to disk.
@ -366,7 +366,7 @@ func runBridge(cmd *cobra.Command, args []string) {
logger.Fatal("failed to generate devnet guardian key", zap.Error(err)) logger.Fatal("failed to generate devnet guardian key", zap.Error(err))
} }
err = writeGuardianKey(gk, "auto-generated deterministic devnet key", *bridgeKeyPath, true) err = writeGuardianKey(gk, "auto-generated deterministic devnet key", *guardianKeyPath, true)
if err != nil { if err != nil {
logger.Fatal("failed to write devnet guardian key", zap.Error(err)) logger.Fatal("failed to write devnet guardian key", zap.Error(err))
} }
@ -384,7 +384,7 @@ func runBridge(cmd *cobra.Command, args []string) {
defer db.Close() defer db.Close()
// Guardian key // Guardian key
gk, err := loadGuardianKey(*bridgeKeyPath) gk, err := loadGuardianKey(*guardianKeyPath)
if err != nil { if err != nil {
logger.Fatal("failed to load guardian key", zap.Error(err)) logger.Fatal("failed to load guardian key", zap.Error(err))
} }
@ -461,29 +461,29 @@ func runBridge(cmd *cobra.Command, args []string) {
} }
if err := supervisor.Run(ctx, "ethwatch", if err := supervisor.Run(ctx, "ethwatch",
ethereum.NewEthBridgeWatcher(*ethRPC, ethContractAddr, "eth", common.ReadinessEthSyncing, vaa.ChainIDEthereum, lockC, setC).Run); err != nil { ethereum.NewEthWatcher(*ethRPC, ethContractAddr, "eth", common.ReadinessEthSyncing, vaa.ChainIDEthereum, lockC, setC).Run); err != nil {
return err return err
} }
if err := supervisor.Run(ctx, "bscwatch", if err := supervisor.Run(ctx, "bscwatch",
ethereum.NewEthBridgeWatcher(*bscRPC, bscContractAddr, "bsc", common.ReadinessBSCSyncing, vaa.ChainIDBSC, lockC, nil).Run); err != nil { ethereum.NewEthWatcher(*bscRPC, bscContractAddr, "bsc", common.ReadinessBSCSyncing, vaa.ChainIDBSC, lockC, nil).Run); err != nil {
return err return err
} }
// Start Terra watcher only if configured // Start Terra watcher only if configured
logger.Info("Starting Terra watcher") logger.Info("Starting Terra watcher")
if err := supervisor.Run(ctx, "terrawatch", if err := supervisor.Run(ctx, "terrawatch",
terra.NewTerraBridgeWatcher(*terraWS, *terraLCD, *terraContract, lockC, setC).Run); err != nil { terra.NewWatcher(*terraWS, *terraLCD, *terraContract, lockC, setC).Run); err != nil {
return err return err
} }
if err := supervisor.Run(ctx, "solwatch-confirmed", if err := supervisor.Run(ctx, "solwatch-confirmed",
solana.NewSolanaWatcher(*solanaWsRPC, *solanaRPC, solBridgeAddress, lockC, rpc.CommitmentConfirmed).Run); err != nil { solana.NewSolanaWatcher(*solanaWsRPC, *solanaRPC, solAddress, lockC, rpc.CommitmentConfirmed).Run); err != nil {
return err return err
} }
if err := supervisor.Run(ctx, "solwatch-finalized", if err := supervisor.Run(ctx, "solwatch-finalized",
solana.NewSolanaWatcher(*solanaWsRPC, *solanaRPC, solBridgeAddress, lockC, rpc.CommitmentFinalized).Run); err != nil { solana.NewSolanaWatcher(*solanaWsRPC, *solanaRPC, solAddress, lockC, rpc.CommitmentFinalized).Run); err != nil {
return err return err
} }

View File

@ -19,7 +19,7 @@ var cfgFile string
// rootCmd represents the base command when called without any subcommands // rootCmd represents the base command when called without any subcommands
var rootCmd = &cobra.Command{ var rootCmd = &cobra.Command{
Use: "guardiand", Use: "guardiand",
Short: "Wormhole bridge server", Short: "Wormhole guardian node",
} }
// Top-level version subcommand // Top-level version subcommand
@ -44,7 +44,7 @@ func init() {
cobra.OnInitialize(initConfig) cobra.OnInitialize(initConfig)
rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.guardiand.yaml)") rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.guardiand.yaml)")
rootCmd.AddCommand(guardiand.BridgeCmd) rootCmd.AddCommand(guardiand.NodeCmd)
rootCmd.AddCommand(guardiand.KeygenCmd) rootCmd.AddCommand(guardiand.KeygenCmd)
rootCmd.AddCommand(guardiand.AdminCmd) rootCmd.AddCommand(guardiand.AdminCmd)
rootCmd.AddCommand(guardiand.TemplateCmd) rootCmd.AddCommand(guardiand.TemplateCmd)

View File

@ -48,6 +48,207 @@ require (
nhooyr.io/websocket v1.8.7 // indirect nhooyr.io/websocket v1.8.7 // indirect
) )
require (
cloud.google.com/go v0.82.0 // indirect
contrib.go.opencensus.io/exporter/stackdriver v0.13.4 // indirect
github.com/99designs/keyring v1.1.3 // indirect
github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d // indirect
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 // indirect
github.com/VictoriaMetrics/fastcache v1.6.0 // indirect
github.com/andres-erbsen/clock v0.0.0-20160526145045-9e14626cd129 // indirect
github.com/benbjohnson/clock v1.0.3 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bgentry/speakeasy v0.1.0 // indirect
github.com/blendle/zapdriver v1.3.1 // indirect
github.com/btcsuite/btcd v0.21.0-beta // indirect
github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce // indirect
github.com/cespare/xxhash v1.1.0 // indirect
github.com/cespare/xxhash/v2 v2.1.1 // indirect
github.com/cheekybits/genny v1.0.0 // indirect
github.com/cosmos/cosmos-sdk v0.39.1 // indirect
github.com/cosmos/go-bip39 v0.0.0-20200817134856-d632e0d11689 // indirect
github.com/cosmos/ledger-cosmos-go v0.11.1 // indirect
github.com/cosmos/ledger-go v0.9.2 // indirect
github.com/danieljoos/wincred v1.0.2 // indirect
github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c // indirect
github.com/deckarep/golang-set v0.0.0-20180603214616-504e848d77ea // indirect
github.com/dfuse-io/binary v0.0.0-20210216024852-4ae6830a495d // indirect
github.com/dfuse-io/logging v0.0.0-20210109005628-b97a57253f70 // indirect
github.com/dgraph-io/ristretto v0.1.0 // indirect
github.com/dustin/go-humanize v1.0.0 // indirect
github.com/dvsekhvalnov/jose2go v0.0.0-20180829124132-7f401d37b68a // indirect
github.com/edsrzf/mmap-go v1.0.0 // indirect
github.com/flynn/noise v1.0.0 // indirect
github.com/francoispqt/gojay v1.2.13 // indirect
github.com/fsnotify/fsnotify v1.4.9 // indirect
github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff // indirect
github.com/go-kit/kit v0.10.0 // indirect
github.com/go-logfmt/logfmt v0.5.0 // indirect
github.com/go-ole/go-ole v1.2.1 // indirect
github.com/go-stack/stack v1.8.0 // indirect
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/glog v0.0.0-20210429001901-424d2337a529 // indirect
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/snappy v0.0.3 // indirect
github.com/google/btree v1.0.1 // indirect
github.com/google/flatbuffers v1.12.0 // indirect
github.com/google/go-cmp v0.5.6 // indirect
github.com/google/gopacket v1.1.19 // indirect
github.com/google/uuid v1.2.0 // indirect
github.com/googleapis/gax-go/v2 v2.0.5 // indirect
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect
github.com/gtank/merlin v0.1.1 // indirect
github.com/gtank/ristretto255 v0.1.2 // indirect
github.com/hashicorp/errwrap v1.0.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/holiman/bloomfilter/v2 v2.0.3 // indirect
github.com/holiman/uint256 v1.2.0 // indirect
github.com/huin/goupnp v1.0.1-0.20210626160114-33cdcbb30dda // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/ipfs/go-cid v0.0.7 // indirect
github.com/ipfs/go-datastore v0.4.5 // indirect
github.com/ipfs/go-ipfs-util v0.0.2 // indirect
github.com/ipfs/go-ipns v0.0.2 // indirect
github.com/ipfs/go-log v1.0.5 // indirect
github.com/jackpal/go-nat-pmp v1.0.2 // indirect
github.com/jbenet/go-temp-err-catcher v0.1.0 // indirect
github.com/jbenet/goprocess v0.1.4 // indirect
github.com/jmhodges/levigo v1.0.0 // indirect
github.com/json-iterator/go v1.1.11 // indirect
github.com/jstemmer/go-junit-report v0.9.1 // indirect
github.com/karalabe/usb v0.0.0-20190919080040-51dc0efba356 // indirect
github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d // indirect
github.com/klauspost/compress v1.13.1 // indirect
github.com/klauspost/cpuid/v2 v2.0.4 // indirect
github.com/koron/go-ssdp v0.0.0-20191105050749-2e1c40ed0b5d // indirect
github.com/libp2p/go-addr-util v0.0.2 // indirect
github.com/libp2p/go-buffer-pool v0.0.2 // indirect
github.com/libp2p/go-cidranger v1.1.0 // indirect
github.com/libp2p/go-conn-security-multistream v0.2.1 // indirect
github.com/libp2p/go-eventbus v0.2.1 // indirect
github.com/libp2p/go-flow-metrics v0.0.3 // indirect
github.com/libp2p/go-libp2p-asn-util v0.0.0-20200825225859-85005c6cf052 // indirect
github.com/libp2p/go-libp2p-autonat v0.4.2 // indirect
github.com/libp2p/go-libp2p-blankhost v0.2.0 // indirect
github.com/libp2p/go-libp2p-circuit v0.4.0 // indirect
github.com/libp2p/go-libp2p-discovery v0.5.0 // indirect
github.com/libp2p/go-libp2p-kbucket v0.4.7 // indirect
github.com/libp2p/go-libp2p-mplex v0.4.1 // indirect
github.com/libp2p/go-libp2p-nat v0.0.6 // indirect
github.com/libp2p/go-libp2p-noise v0.2.0 // indirect
github.com/libp2p/go-libp2p-peerstore v0.2.7 // indirect
github.com/libp2p/go-libp2p-pnet v0.2.0 // indirect
github.com/libp2p/go-libp2p-record v0.1.3 // indirect
github.com/libp2p/go-libp2p-swarm v0.5.0 // indirect
github.com/libp2p/go-libp2p-transport-upgrader v0.4.2 // indirect
github.com/libp2p/go-libp2p-yamux v0.5.4 // indirect
github.com/libp2p/go-maddr-filter v0.1.0 // indirect
github.com/libp2p/go-mplex v0.3.0 // indirect
github.com/libp2p/go-msgio v0.0.6 // indirect
github.com/libp2p/go-nat v0.0.5 // indirect
github.com/libp2p/go-netroute v0.1.6 // indirect
github.com/libp2p/go-openssl v0.0.7 // indirect
github.com/libp2p/go-reuseport v0.0.2 // indirect
github.com/libp2p/go-reuseport-transport v0.0.4 // indirect
github.com/libp2p/go-sockaddr v0.1.1 // indirect
github.com/libp2p/go-stream-muxer-multistream v0.3.0 // indirect
github.com/libp2p/go-tcp-transport v0.2.4 // indirect
github.com/libp2p/go-ws-transport v0.4.0 // indirect
github.com/libp2p/go-yamux/v2 v2.2.0 // indirect
github.com/logrusorgru/aurora v2.0.3+incompatible // indirect
github.com/lucas-clemente/quic-go v0.21.2 // indirect
github.com/magiconair/properties v1.8.1 // indirect
github.com/marten-seemann/qtls-go1-15 v0.1.5 // indirect
github.com/marten-seemann/qtls-go1-16 v0.1.4 // indirect
github.com/marten-seemann/qtls-go1-17 v0.1.0-rc.1 // indirect
github.com/marten-seemann/tcp v0.0.0-20210406111302-dfbc87cc63fd // indirect
github.com/mattn/go-isatty v0.0.13 // indirect
github.com/mattn/go-runewidth v0.0.9 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/miekg/dns v1.1.41 // indirect
github.com/mikioh/tcpinfo v0.0.0-20190314235526-30a79bb1804b // indirect
github.com/mikioh/tcpopt v0.0.0-20190314235656-172688c1accc // indirect
github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643 // indirect
github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1 // indirect
github.com/minio/sha256-simd v1.0.0 // indirect
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
github.com/mitchellh/mapstructure v1.1.2 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/multiformats/go-base32 v0.0.3 // indirect
github.com/multiformats/go-base36 v0.1.0 // indirect
github.com/multiformats/go-multiaddr-dns v0.3.1 // indirect
github.com/multiformats/go-multiaddr-fmt v0.1.0 // indirect
github.com/multiformats/go-multiaddr-net v0.2.0 // indirect
github.com/multiformats/go-multibase v0.0.3 // indirect
github.com/multiformats/go-multihash v0.0.15 // indirect
github.com/multiformats/go-multistream v0.2.2 // indirect
github.com/multiformats/go-varint v0.0.6 // indirect
github.com/nxadm/tail v1.4.8 // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/onsi/ginkgo v1.16.4 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/pelletier/go-toml v1.6.0 // indirect
github.com/peterh/liner v1.1.1-0.20190123174540-a2c9a5303de7 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.18.0 // indirect
github.com/prometheus/procfs v0.6.0 // indirect
github.com/prometheus/tsdb v0.7.1 // indirect
github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0 // indirect
github.com/rjeczalik/notify v0.9.1 // indirect
github.com/rs/cors v1.7.0 // indirect
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect
github.com/spacemonkeygo/spacelog v0.0.0-20180420211403-2296661a0572 // indirect
github.com/spf13/afero v1.2.1 // indirect
github.com/spf13/cast v1.3.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/subosito/gotenv v1.2.0 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20210305035536-64b5b1c73954 // indirect
github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c // indirect
github.com/tendermint/btcd v0.1.1 // indirect
github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 // indirect
github.com/tendermint/go-amino v0.15.1 // indirect
github.com/tendermint/tendermint v0.33.7 // indirect
github.com/tendermint/tm-db v0.5.1 // indirect
github.com/teris-io/shortid v0.0.0-20201117134242-e59966efd125 // indirect
github.com/tidwall/match v1.0.3 // indirect
github.com/tidwall/pretty v1.1.0 // indirect
github.com/tklauser/go-sysconf v0.3.5 // indirect
github.com/tklauser/numcpus v0.2.2 // indirect
github.com/tyler-smith/go-bip39 v1.0.1-0.20181017060643-dbb3b84ba2ef // indirect
github.com/whyrusleeping/go-keyspace v0.0.0-20160322163242-5b898ac5add1 // indirect
github.com/whyrusleeping/multiaddr-filter v0.0.0-20160516205228-e903e4adabd7 // indirect
github.com/whyrusleeping/timecache v0.0.0-20160911033111-cfcb2f1abfee // indirect
github.com/zondax/hid v0.9.0 // indirect
go.etcd.io/bbolt v1.3.3 // indirect
go.opencensus.io v0.23.0 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/ratelimit v0.2.0 // indirect
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 // indirect
golang.org/x/mod v0.4.2 // indirect
golang.org/x/net v0.0.0-20210510120150-4163338589ed // indirect
golang.org/x/oauth2 v0.0.0-20210615190721-d04028783cf1 // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf // indirect
golang.org/x/text v0.3.6 // indirect
golang.org/x/tools v0.1.3 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
google.golang.org/appengine v1.6.7 // indirect
gopkg.in/ini.v1 v1.51.0 // indirect
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
)
// Temporary fork that adds GetConfirmedTransactionWithOpts. Can be removed // Temporary fork that adds GetConfirmedTransactionWithOpts. Can be removed
// once Solana mainnet has upgraded to v1.7.x. // once Solana mainnet has upgraded to v1.7.x.
replace github.com/gagliardetto/solana-go => github.com/certusone/solana-go v0.3.7-0.20210729105530-67b495e4e529 replace github.com/gagliardetto/solana-go => github.com/certusone/solana-go v0.3.7-0.20210729105530-67b495e4e529

View File

@ -1,5 +0,0 @@
package common
type BridgeWatcher interface {
WatchMessages(events chan *MessagePublication) error
}

View File

@ -22,12 +22,7 @@ var (
GanacheClientDefaultAccountAddress = common.HexToAddress("0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1") GanacheClientDefaultAccountAddress = common.HexToAddress("0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1")
// Contracts (deployed by "truffle migrate" on a deterministic devnet) // Contracts (deployed by "truffle migrate" on a deterministic devnet)
GanacheBridgeContractAddress = common.HexToAddress("0xC89Ce4735882C9F0f0FE26686c53074E09B0D550") GanacheWormholeContractAddress = common.HexToAddress("0xC89Ce4735882C9F0f0FE26686c53074E09B0D550")
// ERC20 example tokens.
GanacheExampleERC20Token = common.HexToAddress("0xCfEB869F69431e42cdB54A4F4f105C19C080A601")
GanacheExampleERC20WrappedSOL = common.HexToAddress("0xf5b1d8fab1054b9cf7db274126972f97f9d42a11")
GanacheExampleERC20WrappedTerra = common.HexToAddress("0x62b47a23cd900da982bdbe75aeb891d3ed18cc36")
) )
const ( const (
@ -36,55 +31,6 @@ const (
ganacheDerivationPath = "m/44'/60'/0'/0/%d" ganacheDerivationPath = "m/44'/60'/0'/0/%d"
) )
const (
// id.json account filled by faucet.
SolanaCLIAccount = "6sbzC1eH4FTujJXWj51eQe25cYvr4xfXbJ1vAj7j2k5J"
// Hardcoded contract addresses.
SolanaBridgeContract = "Bridge1p5gheXUvJ6jGWGeCsgPKgnE3YgdGKRVCMY9o"
SolanaTokenContract = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
// Native SPL token
SolanaExampleToken = "6qRhs8oAuZYLd4zzaNnQHqdRyknrQQWDWQhALEN8UA7M"
SolanaExampleTokenOwningAccount = "3C3m4tjTy4nSMkkYdqCDSiCWEgpDa6whvprvABdFGBiW"
// Wrapped ERC20 token
SolanaExampleWrappedERCToken = "85kW19uNvETzH43p3AfpyqPaQS5rWouq4x9rGiKUvihf"
SolanaExampleWrappedERCTokenOwningAccount = "7EFk3VrWeb29SWJPQs5cUyqcY3fQd33S9gELkGybRzeu"
// Wrapped CW20 token
SolanaExampleWrappedCWToken = "9ESkHLgJH4zqbG7fvhpC9u2ZeHMoLJznCHtaRLviEVRh"
SolanaExampleWrappedCWTokenOwningAccount = "EERzaqe8Agm8p1ZkGQFq9zKpP7MDW29FX1pC1vEw9Yfv"
// Lamports per SOL.
SolanaDefaultPrecision = 1e9
// ERC20 default precision.
ERC20DefaultPrecision = 1e18
// CW20 default precision.
TerraDefaultPrecision = 1e8
// Terra LCD url
TerraLCDURL = "http://localhost:1317"
// Terra test chain ID
TerraChainID = "localterra"
// Terra main test address to send/receive tokens
TerraMainTestAddress = "terra1x46rqay4d3cssq8gxxvqz8xt6nwlz4td20k38v"
TerraMainTestAddressHex = "00000000000000000000000035743074956c710800e83198011ccbd4ddf1556d"
// Terra token address
TerraTokenAddress = "terra18vd8fpwxzck93qlwghaj6arh4p7c5n896xzem5"
// Terra bridge contract address
TerraBridgeAddress = "terra18eezxhys9jwku67cm4w84xhnzt4xjj77w2qt62"
// Terra devnet fee payer mnemonic
TerraFeePayerKey = "notice oak worry limit wrap speak medal online prefer cluster roof addict wrist behave treat actual wasp year salad speed social layer crew genius"
)
func DeriveAccount(accountIndex uint) accounts.Account { func DeriveAccount(accountIndex uint) accounts.Account {
path := hdwallet.MustParseDerivationPath(fmt.Sprintf(ganacheDerivationPath, accountIndex)) path := hdwallet.MustParseDerivationPath(fmt.Sprintf(ganacheDerivationPath, accountIndex))
account, err := Wallet().Derive(path, false) account, err := Wallet().Derive(path, false)

View File

@ -55,7 +55,7 @@ func SubmitVAA(ctx context.Context, rpcURL string, vaa *vaa.VAA) (*types.Transac
} }
kt := GetKeyedTransactor(ctx) kt := GetKeyedTransactor(ctx)
bridge, err := abi.NewAbi(GanacheBridgeContractAddress, c) contract, err := abi.NewAbi(GanacheWormholeContractAddress, c)
if err != nil { if err != nil {
panic(err) panic(err)
} }
@ -67,7 +67,7 @@ func SubmitVAA(ctx context.Context, rpcURL string, vaa *vaa.VAA) (*types.Transac
supervisor.Logger(ctx).Info("submitted VAA to Ethereum devnet", zap.Binary("binary", b)) supervisor.Logger(ctx).Info("submitted VAA to Ethereum devnet", zap.Binary("binary", b))
tx, err := bridge.SubmitNewGuardianSet(kt, b) tx, err := contract.SubmitNewGuardianSet(kt, b)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -55,11 +55,11 @@ var (
) )
type ( type (
EthBridgeWatcher struct { Watcher struct {
// Ethereum RPC url // Ethereum RPC url
url string url string
// Address of the Eth bridge contract // Address of the Eth contract contract
bridge eth_common.Address contract eth_common.Address
// Human-readable name of the Eth network, for logging and monitoring. // Human-readable name of the Eth network, for logging and monitoring.
networkName string networkName string
// Readiness component // Readiness component
@ -94,17 +94,17 @@ type (
} }
) )
func NewEthBridgeWatcher( func NewEthWatcher(
url string, url string,
bridge eth_common.Address, contract eth_common.Address,
networkName string, networkName string,
readiness readiness.Component, readiness readiness.Component,
chainID vaa.ChainID, chainID vaa.ChainID,
messageEvents chan *common.MessagePublication, messageEvents chan *common.MessagePublication,
setEvents chan *common.GuardianSet) *EthBridgeWatcher { setEvents chan *common.GuardianSet) *Watcher {
return &EthBridgeWatcher{ return &Watcher{
url: url, url: url,
bridge: bridge, contract: contract,
networkName: networkName, networkName: networkName,
readiness: readiness, readiness: readiness,
chainID: chainID, chainID: chainID,
@ -113,12 +113,12 @@ func NewEthBridgeWatcher(
pending: map[eth_common.Hash]*pendingMessage{}} pending: map[eth_common.Hash]*pendingMessage{}}
} }
func (e *EthBridgeWatcher) Run(ctx context.Context) error { func (e *Watcher) Run(ctx context.Context) error {
logger := supervisor.Logger(ctx) logger := supervisor.Logger(ctx)
// Initialize gossip metrics (we want to broadcast the address even if we're not yet syncing) // Initialize gossip metrics (we want to broadcast the address even if we're not yet syncing)
p2p.DefaultRegistry.SetNetworkStats(e.chainID, &gossipv1.Heartbeat_Network{ p2p.DefaultRegistry.SetNetworkStats(e.chainID, &gossipv1.Heartbeat_Network{
BridgeAddress: e.bridge.Hex(), ContractAddress: e.contract.Hex(),
}) })
timeout, cancel := context.WithTimeout(ctx, 15*time.Second) timeout, cancel := context.WithTimeout(ctx, 15*time.Second)
@ -130,12 +130,12 @@ func (e *EthBridgeWatcher) Run(ctx context.Context) error {
return fmt.Errorf("dialing eth client failed: %w", err) return fmt.Errorf("dialing eth client failed: %w", err)
} }
f, err := abi.NewAbiFilterer(e.bridge, c) f, err := abi.NewAbiFilterer(e.contract, c)
if err != nil { if err != nil {
return fmt.Errorf("could not create wormhole bridge filter: %w", err) return fmt.Errorf("could not create wormhole contract filter: %w", err)
} }
caller, err := abi.NewAbiCaller(e.bridge, c) caller, err := abi.NewAbiCaller(e.contract, c)
if err != nil { if err != nil {
panic(err) panic(err)
} }
@ -254,7 +254,7 @@ func (e *EthBridgeWatcher) Run(ctx context.Context) error {
readiness.SetReady(e.readiness) readiness.SetReady(e.readiness)
p2p.DefaultRegistry.SetNetworkStats(e.chainID, &gossipv1.Heartbeat_Network{ p2p.DefaultRegistry.SetNetworkStats(e.chainID, &gossipv1.Heartbeat_Network{
Height: ev.Number.Int64(), Height: ev.Number.Int64(),
BridgeAddress: e.bridge.Hex(), ContractAddress: e.contract.Hex(),
}) })
e.pendingMu.Lock() e.pendingMu.Lock()
@ -295,7 +295,7 @@ func (e *EthBridgeWatcher) Run(ctx context.Context) error {
} }
} }
func (e *EthBridgeWatcher) fetchAndUpdateGuardianSet( func (e *Watcher) fetchAndUpdateGuardianSet(
logger *zap.Logger, logger *zap.Logger,
ctx context.Context, ctx context.Context,
caller *abi.AbiCaller, caller *abi.AbiCaller,

View File

@ -5,7 +5,7 @@ import (
"crypto/ecdsa" "crypto/ecdsa"
"errors" "errors"
"fmt" "fmt"
bridge_common "github.com/certusone/wormhole/node/pkg/common" node_common "github.com/certusone/wormhole/node/pkg/common"
"github.com/certusone/wormhole/node/pkg/vaa" "github.com/certusone/wormhole/node/pkg/vaa"
"github.com/certusone/wormhole/node/pkg/version" "github.com/certusone/wormhole/node/pkg/version"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
@ -59,7 +59,7 @@ func heartbeatDigest(b []byte) common.Hash {
return ethcrypto.Keccak256Hash(append(heartbeatMessagePrefix, b...)) return ethcrypto.Keccak256Hash(append(heartbeatMessagePrefix, b...))
} }
func Run(obsvC chan *gossipv1.SignedObservation, sendC chan []byte, priv crypto.PrivKey, gk *ecdsa.PrivateKey, gst *bridge_common.GuardianSetState, port uint, networkID string, bootstrapPeers string, nodeName string, disableHeartbeatVerify bool, rootCtxCancel context.CancelFunc) func(ctx context.Context) error { func Run(obsvC chan *gossipv1.SignedObservation, sendC chan []byte, priv crypto.PrivKey, gk *ecdsa.PrivateKey, gst *node_common.GuardianSetState, port uint, networkID string, bootstrapPeers string, nodeName string, disableHeartbeatVerify bool, rootCtxCancel context.CancelFunc) func(ctx context.Context) error {
return func(ctx context.Context) (re error) { return func(ctx context.Context) (re error) {
logger := supervisor.Logger(ctx) logger := supervisor.Logger(ctx)
@ -331,7 +331,7 @@ func Run(obsvC chan *gossipv1.SignedObservation, sendC chan []byte, priv crypto.
} }
} }
func processSignedHeartbeat(from peer.ID, s *gossipv1.SignedHeartbeat, gs *bridge_common.GuardianSet, gst *bridge_common.GuardianSetState, disableVerify bool) (*gossipv1.Heartbeat, error) { func processSignedHeartbeat(from peer.ID, s *gossipv1.SignedHeartbeat, gs *node_common.GuardianSet, gst *node_common.GuardianSetState, disableVerify bool) (*gossipv1.Heartbeat, error) {
envelopeAddr := common.BytesToAddress(s.GuardianAddr) envelopeAddr := common.BytesToAddress(s.GuardianAddr)
idx, ok := gs.KeyIndex(envelopeAddr) idx, ok := gs.KeyIndex(envelopeAddr)
var pk common.Address var pk common.Address

View File

@ -4,7 +4,7 @@ import (
"context" "context"
"encoding/hex" "encoding/hex"
"fmt" "fmt"
bridge_common "github.com/certusone/wormhole/node/pkg/common" node_common "github.com/certusone/wormhole/node/pkg/common"
"github.com/certusone/wormhole/node/pkg/reporter" "github.com/certusone/wormhole/node/pkg/reporter"
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto" "github.com/prometheus/client_golang/prometheus/promauto"
@ -111,7 +111,7 @@ func (p *Processor) handleObservation(ctx context.Context, m *gossipv1.SignedObs
// //
// During an update, vaaState.signatures can contain signatures from *both* guardian sets. // During an update, vaaState.signatures can contain signatures from *both* guardian sets.
// //
var gs *bridge_common.GuardianSet var gs *node_common.GuardianSet
if p.state.vaaSignatures[hash] != nil && p.state.vaaSignatures[hash].gs != nil { if p.state.vaaSignatures[hash] != nil && p.state.vaaSignatures[hash].gs != nil {
gs = p.state.vaaSignatures[hash].gs gs = p.state.vaaSignatures[hash].gs
} else { } else {

View File

@ -21,7 +21,7 @@ import (
) )
type SolanaWatcher struct { type SolanaWatcher struct {
bridge solana.PublicKey contract solana.PublicKey
wsUrl string wsUrl string
rpcUrl string rpcUrl string
commitment rpc.CommitmentType commitment rpc.CommitmentType
@ -94,11 +94,11 @@ type PostMessageData struct {
func NewSolanaWatcher( func NewSolanaWatcher(
wsUrl, rpcUrl string, wsUrl, rpcUrl string,
bridgeAddress solana.PublicKey, contractAddress solana.PublicKey,
messageEvents chan *common.MessagePublication, messageEvents chan *common.MessagePublication,
commitment rpc.CommitmentType) *SolanaWatcher { commitment rpc.CommitmentType) *SolanaWatcher {
return &SolanaWatcher{ return &SolanaWatcher{
bridge: bridgeAddress, contract: contractAddress,
wsUrl: wsUrl, rpcUrl: rpcUrl, wsUrl: wsUrl, rpcUrl: rpcUrl,
messageEvent: messageEvents, messageEvent: messageEvents,
commitment: commitment, commitment: commitment,
@ -108,9 +108,9 @@ func NewSolanaWatcher(
func (s *SolanaWatcher) Run(ctx context.Context) error { func (s *SolanaWatcher) Run(ctx context.Context) error {
// Initialize gossip metrics (we want to broadcast the address even if we're not yet syncing) // Initialize gossip metrics (we want to broadcast the address even if we're not yet syncing)
bridgeAddr := base58.Encode(s.bridge[:]) contractAddr := base58.Encode(s.contract[:])
p2p.DefaultRegistry.SetNetworkStats(vaa.ChainIDSolana, &gossipv1.Heartbeat_Network{ p2p.DefaultRegistry.SetNetworkStats(vaa.ChainIDSolana, &gossipv1.Heartbeat_Network{
BridgeAddress: bridgeAddr, ContractAddress: contractAddr,
}) })
s.logger = supervisor.Logger(ctx) s.logger = supervisor.Logger(ctx)
@ -145,7 +145,7 @@ func (s *SolanaWatcher) Run(ctx context.Context) error {
readiness.SetReady(common.ReadinessSolanaSyncing) readiness.SetReady(common.ReadinessSolanaSyncing)
p2p.DefaultRegistry.SetNetworkStats(vaa.ChainIDSolana, &gossipv1.Heartbeat_Network{ p2p.DefaultRegistry.SetNetworkStats(vaa.ChainIDSolana, &gossipv1.Heartbeat_Network{
Height: int64(slot), Height: int64(slot),
BridgeAddress: bridgeAddr, ContractAddress: contractAddr,
}) })
s.logger.Info("fetched current Solana height", s.logger.Info("fetched current Solana height",
zap.String("commitment", string(s.commitment)), zap.String("commitment", string(s.commitment)),
@ -242,7 +242,7 @@ OUTER:
signature := tx.Transaction.Signatures[0] signature := tx.Transaction.Signatures[0]
var programIndex uint16 var programIndex uint16
for n, key := range tx.Transaction.Message.AccountKeys { for n, key := range tx.Transaction.Message.AccountKeys {
if key.Equals(s.bridge) { if key.Equals(s.contract) {
programIndex = uint16(n) programIndex = uint16(n)
} }
} }
@ -372,7 +372,7 @@ func (s *SolanaWatcher) fetchMessageAccount(ctx context.Context, acc solana.Publ
return return
} }
if !info.Value.Owner.Equals(s.bridge) { if !info.Value.Owner.Equals(s.contract) {
p2p.DefaultRegistry.AddErrorCount(vaa.ChainIDSolana, 1) p2p.DefaultRegistry.AddErrorCount(vaa.ChainIDSolana, 1)
solanaConnectionErrors.WithLabelValues(string(s.commitment), "account_owner_mismatch").Inc() solanaConnectionErrors.WithLabelValues(string(s.commitment), "account_owner_mismatch").Inc()
s.logger.Error("account has invalid owner", s.logger.Error("account has invalid owner",

View File

@ -25,11 +25,11 @@ import (
) )
type ( type (
// BridgeWatcher is responsible for looking over Terra blockchain and reporting new transactions to the bridge // Watcher is responsible for looking over Terra blockchain and reporting new transactions to the contract
BridgeWatcher struct { Watcher struct {
urlWS string urlWS string
urlLCD string urlLCD string
bridge string contract string
msgChan chan *common.MessagePublication msgChan chan *common.MessagePublication
setChan chan *common.GuardianSet setChan chan *common.GuardianSet
@ -70,15 +70,14 @@ type clientRequest struct {
ID uint64 `json:"id"` ID uint64 `json:"id"`
} }
// NewTerraBridgeWatcher creates a new terra bridge watcher // NewWatcher creates a new Terra contract watcher
func NewTerraBridgeWatcher(urlWS string, urlLCD string, bridge string, lockEvents chan *common.MessagePublication, setEvents chan *common.GuardianSet) *BridgeWatcher { func NewWatcher(urlWS string, urlLCD string, contract string, lockEvents chan *common.MessagePublication, setEvents chan *common.GuardianSet) *Watcher {
return &BridgeWatcher{urlWS: urlWS, urlLCD: urlLCD, bridge: bridge, msgChan: lockEvents, setChan: setEvents} return &Watcher{urlWS: urlWS, urlLCD: urlLCD, contract: contract, msgChan: lockEvents, setChan: setEvents}
} }
// Run is the main Terra Bridge run cycle func (e *Watcher) Run(ctx context.Context) error {
func (e *BridgeWatcher) Run(ctx context.Context) error {
p2p.DefaultRegistry.SetNetworkStats(vaa.ChainIDTerra, &gossipv1.Heartbeat_Network{ p2p.DefaultRegistry.SetNetworkStats(vaa.ChainIDTerra, &gossipv1.Heartbeat_Network{
BridgeAddress: e.bridge, ContractAddress: e.contract,
}) })
errC := make(chan error) errC := make(chan error)
@ -95,7 +94,7 @@ func (e *BridgeWatcher) Run(ctx context.Context) error {
defer c.Close() defer c.Close()
// Subscribe to smart contract transactions // Subscribe to smart contract transactions
params := [...]string{fmt.Sprintf("tm.event='Tx' AND execute_contract.contract_address='%s'", e.bridge)} params := [...]string{fmt.Sprintf("tm.event='Tx' AND execute_contract.contract_address='%s'", e.contract)}
command := &clientRequest{ command := &clientRequest{
JSONRPC: "2.0", JSONRPC: "2.0",
Method: "subscribe", Method: "subscribe",
@ -150,7 +149,7 @@ func (e *BridgeWatcher) Run(ctx context.Context) error {
currentTerraHeight.Set(float64(latestBlock.Int())) currentTerraHeight.Set(float64(latestBlock.Int()))
p2p.DefaultRegistry.SetNetworkStats(vaa.ChainIDTerra, &gossipv1.Heartbeat_Network{ p2p.DefaultRegistry.SetNetworkStats(vaa.ChainIDTerra, &gossipv1.Heartbeat_Network{
Height: latestBlock.Int(), Height: latestBlock.Int(),
BridgeAddress: e.bridge, ContractAddress: e.contract,
}) })
} }
}() }()
@ -225,7 +224,7 @@ func (e *BridgeWatcher) Run(ctx context.Context) error {
} }
// Query and report guardian set status // Query and report guardian set status
requestURL := fmt.Sprintf("%s/wasm/contracts/%s/store?query_msg={\"guardian_set_info\":{}}", e.urlLCD, e.bridge) requestURL := fmt.Sprintf("%s/wasm/contracts/%s/store?query_msg={\"guardian_set_info\":{}}", e.urlLCD, e.contract)
req, err := http.NewRequestWithContext(ctx, http.MethodGet, requestURL, nil) req, err := http.NewRequestWithContext(ctx, http.MethodGet, requestURL, nil)
if err != nil { if err != nil {
p2p.DefaultRegistry.AddErrorCount(vaa.ChainIDTerra, 1) p2p.DefaultRegistry.AddErrorCount(vaa.ChainIDTerra, 1)

View File

@ -41,7 +41,7 @@ message Heartbeat {
// Consensus height of the node. // Consensus height of the node.
int64 height = 2; int64 height = 2;
// Chain-specific human-readable representation of the bridge contract address. // Chain-specific human-readable representation of the bridge contract address.
string bridge_address = 3; string contract_address = 3;
// Connection error count // Connection error count
uint64 error_count = 4; uint64 error_count = 4;
} }