Skip to content

Commit

Permalink
Merge pull request #5 from wormhole-foundation/main
Browse files Browse the repository at this point in the history
[pull] main from wormhole-foundation:main
  • Loading branch information
djb15 authored Dec 11, 2023
2 parents bf9660f + 2a3d4c8 commit a9da355
Show file tree
Hide file tree
Showing 17 changed files with 235 additions and 113 deletions.
2 changes: 1 addition & 1 deletion aptos/wormhole/sources/state.move
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ module wormhole::state {
move_to(admin, create_guardian_set_changed_handle(account::new_event_handle<GuardianSetChanged>(admin)));
}

public(friend) entry fun publish_event(
public(friend) fun publish_event(
sender: u64,
sequence: u64,
nonce: u64,
Expand Down
14 changes: 5 additions & 9 deletions cosmwasm/deployment/terra2/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,17 @@ deploy/token_bridge: token_bridge-code-id-$(NETWORK).txt
tools/node_modules: tools/package-lock.json
cd tools && npm ci

LocalTerra:
git clone --depth 1 https://www.github.com/terra-money/LocalTerra

test/node_modules: test/package-lock.json
cd test && npm ci


.PHONY: test
## Run unit and integration tests
test: artifacts test/node_modules LocalTerra
test: artifacts test/node_modules
@if pgrep terrad; then echo "Error: terrad already running. Stop it before running tests"; exit 1; fi
cd LocalTerra && DOCKER_BUILDKIT=1 docker-compose up --detach
sleep 5
cd test && npm run test || (cd ../LocalTerra && docker-compose down && exit 1)
cd LocalTerra && docker-compose down
cd devnet && DOCKER_BUILDKIT=1 docker-compose up --detach
sleep 10
cd test && npm run test || (cd ../devnet && docker-compose down && exit 1)
cd devnet && docker-compose down

.PHONY: clean
clean:
Expand Down
10 changes: 10 additions & 0 deletions cosmwasm/deployment/terra2/devnet/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: "3.8"

services:
terrad:
image: ghcr.io/terra-money/localterra:2.0.1@sha256:be788330d9af64ad2dc645e41e543a8df335531a84572f1a0350c3e548977a3d
ports:
- "1317:1317"
- "9090:9090"
- "9091:9091"
- "26657:26657"
2 changes: 2 additions & 0 deletions devnet/node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ spec:
- ws://eth-devnet:8545
- --scrollRPC
- ws://eth-devnet:8545
- --mantleRPC
- ws://eth-devnet:8545
# - --wormchainURL
# - wormchain:9090
# - --accountantKeyPath
Expand Down
16 changes: 16 additions & 0 deletions ethereum/.env.mantle.testnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Mantle testnet env
# Rename to .env to use with truffle migrations

# Wormhole Core Migrations
INIT_SIGNERS=["0x13947Bd48b18E53fdAeEe77F3473391aC727C638"]
INIT_CHAIN_ID=35
INIT_GOV_CHAIN_ID=0x1
INIT_GOV_CONTRACT=0x0000000000000000000000000000000000000000000000000000000000000004
INIT_EVM_CHAIN_ID=5001

# Bridge Migrations
BRIDGE_INIT_CHAIN_ID=35
BRIDGE_INIT_GOV_CHAIN_ID=0x1
BRIDGE_INIT_GOV_CONTRACT=0x0000000000000000000000000000000000000000000000000000000000000004
BRIDGE_INIT_WETH=0xEa12Be2389c2254bAaD383c6eD1fa1e15202b52A
BRIDGE_INIT_FINALITY=1
9 changes: 9 additions & 0 deletions ethereum/truffle-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,15 @@ module.exports = {
},
network_id: 534351,
},
mantle_testnet: {
provider: () => {
return new HDWalletProvider(
process.env.MNEMONIC,
"https://rpc.testnet.mantle.xyz"
);
},
network_id: 5001,
},
rootstock: {
provider: () => {
return new HDWalletProvider(
Expand Down
11 changes: 10 additions & 1 deletion node/cmd/ccq/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,14 @@ func (s *httpServer) handleQuery(w http.ResponseWriter, r *http.Request) {
invalidQueryRequestReceived.WithLabelValues("invalid_api_key").Inc()
return
}
totalRequestsByUser.WithLabelValues(permEntry.userName).Inc()

queryRequestBytes, err := hex.DecodeString(q.Bytes)
if err != nil {
s.logger.Error("failed to decode request bytes", zap.String("userId", permEntry.userName), zap.Error(err))
http.Error(w, err.Error(), http.StatusBadRequest)
invalidQueryRequestReceived.WithLabelValues("failed_to_decode_request").Inc()
invalidRequestsByUser.WithLabelValues(permEntry.userName).Inc()
return
}

Expand All @@ -100,6 +102,7 @@ func (s *httpServer) handleQuery(w http.ResponseWriter, r *http.Request) {
s.logger.Error("failed to decode signature bytes", zap.String("userId", permEntry.userName), zap.Error(err))
http.Error(w, err.Error(), http.StatusBadRequest)
invalidQueryRequestReceived.WithLabelValues("failed_to_decode_signature").Inc()
invalidRequestsByUser.WithLabelValues(permEntry.userName).Inc()
return
}

Expand All @@ -114,7 +117,8 @@ func (s *httpServer) handleQuery(w http.ResponseWriter, r *http.Request) {
if status, err := validateRequest(s.logger, s.env, s.permissions, s.signerKey, apiKey, signedQueryRequest); err != nil {
s.logger.Error("failed to validate request", zap.String("userId", permEntry.userName), zap.String("requestId", requestId), zap.Int("status", status), zap.Error(err))
http.Error(w, err.Error(), status)
// Metric has already been pegged.
// Error specific metric has already been pegged.
invalidRequestsByUser.WithLabelValues(permEntry.userName).Inc()
return
}

Expand All @@ -129,6 +133,7 @@ func (s *httpServer) handleQuery(w http.ResponseWriter, r *http.Request) {
s.logger.Error("failed to marshal gossip message", zap.String("userId", permEntry.userName), zap.String("requestId", requestId), zap.Error(err))
http.Error(w, err.Error(), http.StatusInternalServerError)
invalidQueryRequestReceived.WithLabelValues("failed_to_marshal_gossip_msg").Inc()
invalidRequestsByUser.WithLabelValues(permEntry.userName).Inc()
return
}

Expand All @@ -138,6 +143,7 @@ func (s *httpServer) handleQuery(w http.ResponseWriter, r *http.Request) {
s.logger.Info("duplicate request", zap.String("userId", permEntry.userName), zap.String("requestId", requestId))
http.Error(w, "Duplicate request", http.StatusBadRequest)
invalidQueryRequestReceived.WithLabelValues("duplicate_request").Inc()
invalidRequestsByUser.WithLabelValues(permEntry.userName).Inc()
return
}

Expand All @@ -147,6 +153,7 @@ func (s *httpServer) handleQuery(w http.ResponseWriter, r *http.Request) {
s.logger.Error("failed to publish gossip message", zap.String("userId", permEntry.userName), zap.String("requestId", requestId), zap.Error(err))
http.Error(w, err.Error(), http.StatusInternalServerError)
invalidQueryRequestReceived.WithLabelValues("failed_to_publish_gossip_msg").Inc()
invalidRequestsByUser.WithLabelValues(permEntry.userName).Inc()
s.pendingResponses.Remove(pendingResponse)
return
}
Expand All @@ -163,6 +170,7 @@ func (s *httpServer) handleQuery(w http.ResponseWriter, r *http.Request) {
s.logger.Error("failed to marshal response", zap.String("userId", permEntry.userName), zap.String("requestId", requestId), zap.Error(err))
http.Error(w, err.Error(), http.StatusInternalServerError)
invalidQueryRequestReceived.WithLabelValues("failed_to_marshal_response").Inc()
invalidRequestsByUser.WithLabelValues(permEntry.userName).Inc()
break
}
// Signature indices must be ascending for on-chain verification
Expand All @@ -184,6 +192,7 @@ func (s *httpServer) handleQuery(w http.ResponseWriter, r *http.Request) {
s.logger.Error("failed to encode response", zap.String("userId", permEntry.userName), zap.String("requestId", requestId), zap.Error(err))
http.Error(w, err.Error(), http.StatusInternalServerError)
invalidQueryRequestReceived.WithLabelValues("failed_to_encode_response").Inc()
invalidRequestsByUser.WithLabelValues(permEntry.userName).Inc()
break
}
}
Expand Down
12 changes: 12 additions & 0 deletions node/cmd/ccq/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ var (
Help: "Total number of requested calls by chain",
}, []string{"chain_name"})

totalRequestsByUser = promauto.NewCounterVec(
prometheus.CounterOpts{
Name: "ccq_server_total_requests_by_user",
Help: "Total number of requests by user name",
}, []string{"user_name"})

invalidRequestsByUser = promauto.NewCounterVec(
prometheus.CounterOpts{
Name: "ccq_server_invalid_requests_by_user",
Help: "Total number of invalid requests by user name",
}, []string{"user_name"})

queryResponsesReceived = promauto.NewCounterVec(
prometheus.CounterOpts{
Name: "ccq_server_total_query_responses_received_by_peer_id",
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 @@ -115,6 +115,7 @@ func runListNodes(cmd *cobra.Command, args []string) {
{"Base", vaa.ChainIDBase},
{"Sei", vaa.ChainIDSei},
{"Scroll", vaa.ChainIDScroll},
{"Mantle", vaa.ChainIDMantle},
{"Wormchain", vaa.ChainIDWormchain},
{"Sepolia", vaa.ChainIDSepolia},
}
Expand Down
29 changes: 29 additions & 0 deletions node/cmd/guardiand/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@ var (
scrollRPC *string
scrollContract *string

mantleRPC *string
mantleContract *string

sepoliaRPC *string
sepoliaContract *string

Expand Down Expand Up @@ -343,6 +346,9 @@ func init() {
scrollRPC = NodeCmd.Flags().String("scrollRPC", "", "Scroll RPC URL")
scrollContract = NodeCmd.Flags().String("scrollContract", "", "Scroll contract address")

mantleRPC = NodeCmd.Flags().String("mantleRPC", "", "Mantle RPC URL")
mantleContract = NodeCmd.Flags().String("mantleContract", "", "Mantle contract address")

baseRPC = NodeCmd.Flags().String("baseRPC", "", "Base RPC URL")
baseContract = NodeCmd.Flags().String("baseContract", "", "Base contract address")

Expand Down Expand Up @@ -498,6 +504,7 @@ func runNode(cmd *cobra.Command, args []string) {
*baseContract = unsafeDevModeEvmContractAddress(*baseContract)
*sepoliaContract = unsafeDevModeEvmContractAddress(*sepoliaContract)
*scrollContract = unsafeDevModeEvmContractAddress(*scrollContract)
*mantleContract = unsafeDevModeEvmContractAddress(*mantleContract)
}

// Verify flags
Expand Down Expand Up @@ -640,6 +647,16 @@ func runNode(cmd *cobra.Command, args []string) {
logger.Fatal("Both --scrollContract and --scrollRPC must be set together or both unset")
}

// Mantle should not be allowed in mainnet until its finality policy is understood and implemented in the watcher.
// Note that as of 11/9/2023 Mantle does not support querying for `finalized` or `safe`, just `latest`, so we will need to implement a finalizer.
if *mantleRPC != "" && !*testnetMode && !*unsafeDevMode {
logger.Fatal("mantle is currently only supported in devnet and testnet")
}

if (*mantleRPC == "") != (*mantleContract == "") {
logger.Fatal("Both --mantleContract and --mantleRPC must be set together or both unset")
}

if *gatewayWS != "" {
if *gatewayLCD == "" || *gatewayContract == "" {
logger.Fatal("If --gatewayWS is specified, then --gatewayLCD and --gatewayContract must be specified")
Expand Down Expand Up @@ -865,6 +882,7 @@ func runNode(cmd *cobra.Command, args []string) {
rpcMap["ibcWS"] = *ibcWS
rpcMap["karuraRPC"] = *karuraRPC
rpcMap["klaytnRPC"] = *klaytnRPC
rpcMap["mantleRPC"] = *mantleRPC
rpcMap["moonbeamRPC"] = *moonbeamRPC
rpcMap["nearRPC"] = *nearRPC
rpcMap["neonRPC"] = *neonRPC
Expand Down Expand Up @@ -1253,6 +1271,17 @@ func runNode(cmd *cobra.Command, args []string) {
watcherConfigs = append(watcherConfigs, wc)
}

if shouldStart(mantleRPC) {
wc := &evm.WatcherConfig{
NetworkID: "mantle",
ChainID: vaa.ChainIDMantle,
Rpc: *mantleRPC,
Contract: *mantleContract,
}

watcherConfigs = append(watcherConfigs, wc)
}

if shouldStart(terraWS) {
wc := &cosmwasm.WatcherConfig{
NetworkID: "terra",
Expand Down
Loading

0 comments on commit a9da355

Please sign in to comment.