Skip to content

Commit

Permalink
fix: update Solana last scanned block more frequently (#3314)
Browse files Browse the repository at this point in the history
* update Solana last scanned block more frequently

* add changelog entry

* update slot only if RPC returns nil error

* update slot only if RPC returns nil error

---------

Co-authored-by: Christopher Fuka <[email protected]>
  • Loading branch information
ws4charlie and CryptoFewka authored Dec 18, 2024
1 parent 8d25c74 commit 7d93d5a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 13 additions & 1 deletion zetaclient/chains/solana/observer/inbound.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,26 @@ func (ob *Observer) ObserveInbound(ctx context.Context) error {
ob.WithLastTxScanned(lastSig.String())
}

// query last finalized 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
lastSig := solana.MustSignatureFromBase58(ob.LastTxScanned())
signatures, err := solanarpc.GetSignaturesForAddressUntil(ctx, ob.solClient, ob.gatewayID, lastSig, pageLimit)
if err != nil {
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 {
if errSlot == nil {
ob.WithLastBlockScanned(lastSlot)
}
} else {
ob.Logger().Inbound.Info().Msgf("ObserveInbound: got %d signatures for chain %d", len(signatures), chainID)
}

Expand Down

0 comments on commit 7d93d5a

Please sign in to comment.