Skip to content

Commit

Permalink
near/watcher_fix: improve metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
jumpsiegel committed Sep 14, 2022
1 parent a4e395a commit e0843bf
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 23 deletions.
50 changes: 29 additions & 21 deletions node/pkg/near/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -389,20 +389,6 @@ func (e *Watcher) Run(ctx context.Context) error {
logger.Info("Near watcher connecting to RPC node ", zap.String("url", e.nearRPC))

go func() {
if e.next_round == 0 {
finalBody, err := e.getFinalBlock()
if err != nil {
logger.Error("StatusAfterBlock", zap.Error(err))
p2p.DefaultRegistry.AddErrorCount(vaa.ChainIDNear, 1)
errC <- err
return
}
e.next_round = gjson.ParseBytes(finalBody).Get("result.chunks.0.height_created").Uint()
}

timer := time.NewTicker(time.Second * 1)
defer timer.Stop()

for {
select {
case <-ctx.Done():
Expand All @@ -420,7 +406,29 @@ func (e *Watcher) Run(ctx context.Context) error {
if err != nil {
logger.Error(fmt.Sprintf("near obsvReqC: %s", err.Error()))
}
}
}
}()

go func() {
if e.next_round == 0 {
finalBody, err := e.getFinalBlock()
if err != nil {
logger.Error("StatusAfterBlock", zap.Error(err))
p2p.DefaultRegistry.AddErrorCount(vaa.ChainIDNear, 1)
errC <- err
return
}
e.next_round = gjson.ParseBytes(finalBody).Get("result.chunks.0.height_created").Uint()
}

timer := time.NewTicker(time.Second * 1)
defer timer.Stop()

for {
select {
case <-ctx.Done():
return
case <-timer.C:
finalBody, err := e.getFinalBlock()
if err != nil {
Expand Down Expand Up @@ -456,6 +464,13 @@ func (e *Watcher) Run(ctx context.Context) error {
logger.Info("lastBlock", zap.Uint64("lastBlock", lastBlock), zap.Uint64("next_round", e.next_round))

for ; e.next_round <= lastBlock; e.next_round = e.next_round + 1 {
currentNearHeight.Set(float64(e.next_round))
p2p.DefaultRegistry.SetNetworkStats(vaa.ChainIDNear, &gossipv1.Heartbeat_Network{
Height: int64(e.next_round),
ContractAddress: e.wormholeContract,
})
readiness.SetReady(common.ReadinessNearSyncing)

if e.next_round == lastBlock {
err := e.inspectBody(logger, e.next_round, parsedFinalBody)
if err != nil {
Expand Down Expand Up @@ -487,13 +502,6 @@ func (e *Watcher) Run(ctx context.Context) error {
}
}
}

currentNearHeight.Set(float64(e.next_round - 1))
p2p.DefaultRegistry.SetNetworkStats(vaa.ChainIDNear, &gossipv1.Heartbeat_Network{
Height: int64(e.next_round - 1),
ContractAddress: e.wormholeContract,
})
readiness.SetReady(common.ReadinessNearSyncing)
}
}
}()
Expand Down
4 changes: 2 additions & 2 deletions sdk/js/src/token_bridge/transfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -771,11 +771,11 @@ export async function transferNearFromNear(
args: {
receiver: uint8ArrayToHex(receiver),
chain: chain,
fee: fee.toString(),
fee: fee.toString(10),
payload: payload,
message_fee: message_fee,
},
attachedDeposit: (new BN(qty.toString()).add(new BN(message_fee))),
attachedDeposit: (new BN(qty.toString(10)).add(new BN(message_fee))),
gas: new BN("100000000000000"),
});

Expand Down

0 comments on commit e0843bf

Please sign in to comment.