From 034dc15cfaa5b433ba4529e417ad29fc644962b0 Mon Sep 17 00:00:00 2001 From: Reisen Date: Mon, 12 Jun 2023 11:27:16 +0200 Subject: [PATCH] feat: add go profiling --- hermes/src/network/p2p.go | 8 ++++++++ hermes/src/store/proof/wormhole_merkle.rs | 6 +++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/hermes/src/network/p2p.go b/hermes/src/network/p2p.go index e9e00cae..a02c8b4b 100644 --- a/hermes/src/network/p2p.go +++ b/hermes/src/network/p2p.go @@ -32,6 +32,9 @@ import ( "strings" "time" + "net/http" + _ "net/http/pprof" + "github.com/libp2p/go-libp2p" "github.com/libp2p/go-libp2p/core/crypto" "github.com/libp2p/go-libp2p/core/host" @@ -55,6 +58,11 @@ func RegisterObservationCallback(f C.callback_t, network_id, bootstrap_addrs, li bootstrapAddrs := strings.Split(C.GoString(bootstrap_addrs), ",") listenAddrs := strings.Split(C.GoString(listen_addrs), ",") + // Bind pprof to 6060 for debugging Go code. + go func() { + http.ListenAndServe("127.0.0.1:6060", nil) + }() + var startTime int64 var recoverRerun func() diff --git a/hermes/src/store/proof/wormhole_merkle.rs b/hermes/src/store/proof/wormhole_merkle.rs index f16b5a90..25d7c0d0 100644 --- a/hermes/src/store/proof/wormhole_merkle.rs +++ b/hermes/src/store/proof/wormhole_merkle.rs @@ -14,8 +14,8 @@ use { pythnet_sdk::{ accumulators::{ merkle::{ - MerkleAccumulator, MerklePath, + MerkleTree, }, Accumulator, }, @@ -84,12 +84,12 @@ pub fn construct_message_states_proofs( // Check whether the state is valid let merkle_acc = - match MerkleAccumulator::::from_set(raw_messages.iter().map(|m| m.as_ref())) { + match MerkleTree::::from_set(raw_messages.iter().map(|m| m.as_ref())) { Some(merkle_acc) => merkle_acc, None => return Ok(vec![]), // It only happens when the message set is empty }; - if merkle_acc.root != wormhole_merkle_state.root.root { + if merkle_acc.root.as_bytes() != wormhole_merkle_state.root.root { return Err(anyhow!("Invalid merkle root")); }