From 9a9584d613e54e6f9414b2e5241555744f39db01 Mon Sep 17 00:00:00 2001 From: Charlie Chen Date: Tue, 17 Dec 2024 13:34:21 -0600 Subject: [PATCH 1/4] update Solana last scanned block more frequently --- zetaclient/chains/solana/observer/inbound.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/zetaclient/chains/solana/observer/inbound.go b/zetaclient/chains/solana/observer/inbound.go index 6eab1242ac..cfa81c57b6 100644 --- a/zetaclient/chains/solana/observer/inbound.go +++ b/zetaclient/chains/solana/observer/inbound.go @@ -81,6 +81,12 @@ func (ob *Observer) ObserveInbound(ctx context.Context) error { ob.WithLastTxScanned(lastSig.String()) } + // query last finalized slot + lastSlot, err := ob.solClient.GetSlot(ctx, rpc.CommitmentFinalized) + if err != nil { + ob.Logger().Inbound.Err(err).Msg("unable to get last slot") + } + // get all signatures for the gateway address since last scanned signature lastSig := solana.MustSignatureFromBase58(ob.LastTxScanned()) signatures, err := solanarpc.GetSignaturesForAddressUntil(ctx, ob.solClient, ob.gatewayID, lastSig, pageLimit) @@ -88,7 +94,11 @@ func (ob *Observer) ObserveInbound(ctx context.Context) error { ob.Logger().Inbound.Err(err).Msg("error GetSignaturesForAddressUntil") return err } - if len(signatures) > 0 { + + // update metrics if no new signatures found + if len(signatures) == 0 { + ob.WithLastBlockScanned(lastSlot) + } else { ob.Logger().Inbound.Info().Msgf("ObserveInbound: got %d signatures for chain %d", len(signatures), chainID) } From 68d9eae3b21d3e413118879c8a4963a845e2226e Mon Sep 17 00:00:00 2001 From: Charlie Chen Date: Tue, 17 Dec 2024 13:42:29 -0600 Subject: [PATCH 2/4] add changelog entry --- changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/changelog.md b/changelog.md index 66136741a3..434d69161e 100644 --- a/changelog.md +++ b/changelog.md @@ -28,6 +28,7 @@ * [3253](https://github.com/zeta-chain/node/pull/3253) - fix solana inbound version 0 queries and move tss keysign prior to relayer key checking * [3278](https://github.com/zeta-chain/node/pull/3278) - enforce checksum format for asset address in ZRC20 * [3289](https://github.com/zeta-chain/node/pull/3289) - remove all dynamic peer discovery (zetaclient) +* [3314](https://github.com/zeta-chain/node/pull/3314) - update `last_scanned_block_number` metrics more frequently for Solana chain ## v23.0.0 From 02b173239940ee9ee016a53eceddd00665ac60fb Mon Sep 17 00:00:00 2001 From: Charlie Chen Date: Tue, 17 Dec 2024 13:49:59 -0600 Subject: [PATCH 3/4] update slot only if RPC returns nil error --- zetaclient/chains/solana/observer/inbound.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/zetaclient/chains/solana/observer/inbound.go b/zetaclient/chains/solana/observer/inbound.go index cfa81c57b6..fff144c67e 100644 --- a/zetaclient/chains/solana/observer/inbound.go +++ b/zetaclient/chains/solana/observer/inbound.go @@ -82,9 +82,9 @@ func (ob *Observer) ObserveInbound(ctx context.Context) error { } // query last finalized slot - lastSlot, err := ob.solClient.GetSlot(ctx, rpc.CommitmentFinalized) - if err != nil { - ob.Logger().Inbound.Err(err).Msg("unable to get last slot") + lastSlot, errSlot := ob.solClient.GetSlot(ctx, rpc.CommitmentFinalized) + if errSlot != nil { + ob.Logger().Inbound.Err(errSlot).Msg("unable to get last slot") } // get all signatures for the gateway address since last scanned signature @@ -96,7 +96,7 @@ func (ob *Observer) ObserveInbound(ctx context.Context) error { } // update metrics if no new signatures found - if len(signatures) == 0 { + if len(signatures) == 0 && errSlot == nil { ob.WithLastBlockScanned(lastSlot) } else { ob.Logger().Inbound.Info().Msgf("ObserveInbound: got %d signatures for chain %d", len(signatures), chainID) From 912a24345fe7f761a329542114f8ef4911622bea Mon Sep 17 00:00:00 2001 From: Charlie Chen Date: Tue, 17 Dec 2024 13:53:40 -0600 Subject: [PATCH 4/4] update slot only if RPC returns nil error --- zetaclient/chains/solana/observer/inbound.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/zetaclient/chains/solana/observer/inbound.go b/zetaclient/chains/solana/observer/inbound.go index fff144c67e..6cc1c8d84c 100644 --- a/zetaclient/chains/solana/observer/inbound.go +++ b/zetaclient/chains/solana/observer/inbound.go @@ -96,8 +96,10 @@ func (ob *Observer) ObserveInbound(ctx context.Context) error { } // update metrics if no new signatures found - if len(signatures) == 0 && errSlot == nil { - ob.WithLastBlockScanned(lastSlot) + if len(signatures) == 0 { + if errSlot == nil { + ob.WithLastBlockScanned(lastSlot) + } } else { ob.Logger().Inbound.Info().Msgf("ObserveInbound: got %d signatures for chain %d", len(signatures), chainID) }