Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ go 1.25.5
replace github.com/fbsobreira/gotron-sdk => github.com/smartcontractkit/chainlink-tron/relayer/gotron-sdk v0.0.4

require (
github.com/aptos-labs/aptos-go-sdk v1.7.1-0.20250602153733-bb1facae1d43
github.com/aptos-labs/aptos-go-sdk v1.11.0
github.com/aptos-labs/tree-sitter-move-on-aptos v0.0.0-20250321090037-c820eb4716e1
github.com/block-vision/sui-go-sdk v1.1.3
github.com/ethereum/go-ethereum v1.16.2
Expand All @@ -19,7 +19,7 @@ require (
github.com/pkg/errors v0.9.1
github.com/santhosh-tekuri/jsonschema/v5 v5.3.1
github.com/smacker/go-tree-sitter v0.0.0-20240827094217-dd81d9e9be82
github.com/smartcontractkit/chainlink-aptos v0.0.0-20250905094443-ac02b032b32b
github.com/smartcontractkit/chainlink-aptos v0.0.0-20251024142440-51f2ad2652a2
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250805210128-7f8a0f403c3a
github.com/smartcontractkit/chainlink-common v0.10.1-0.20260217084735-307a5770c4f6
github.com/stretchr/testify v1.11.1
Expand Down Expand Up @@ -47,7 +47,7 @@ require (
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/cloudevents/sdk-go/binding/format/protobuf/v2 v2.16.1 // indirect
github.com/cloudevents/sdk-go/v2 v2.16.1 // indirect
github.com/coder/websocket v1.8.13 // indirect
github.com/coder/websocket v1.8.14 // indirect
github.com/cosmos/go-bip39 v1.0.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0 // indirect
Expand All @@ -71,7 +71,7 @@ require (
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3 // indirect
github.com/hashicorp/go-hclog v1.6.3 // indirect
github.com/hashicorp/yamux v0.1.2 // indirect
github.com/hasura/go-graphql-client v0.13.1 // indirect
github.com/hasura/go-graphql-client v0.14.5 // indirect
github.com/hdevalence/ed25519consensus v0.2.0 // indirect
github.com/holiman/uint256 v1.3.2 // indirect
github.com/invopop/jsonschema v0.13.0 // indirect
Expand Down
16 changes: 8 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ github.com/apache/arrow-go/v18 v18.3.1 h1:oYZT8FqONiK74JhlH3WKVv+2NKYoyZ7C2ioD4D
github.com/apache/arrow-go/v18 v18.3.1/go.mod h1:12QBya5JZT6PnBihi5NJTzbACrDGXYkrgjujz3MRQXU=
github.com/apache/thrift v0.21.0 h1:tdPmh/ptjE1IJnhbhrcl2++TauVjy242rkV/UzJChnE=
github.com/apache/thrift v0.21.0/go.mod h1:W1H8aR/QRtYNvrPeFXBtobyRkd0/YVhTc6i07XIAgDw=
github.com/aptos-labs/aptos-go-sdk v1.7.1-0.20250602153733-bb1facae1d43 h1:Mn2LI+fa8QzVmXQ/30MT76GYTQIxpSB3lzos0hat4qc=
github.com/aptos-labs/aptos-go-sdk v1.7.1-0.20250602153733-bb1facae1d43/go.mod h1:vYm/yHr6cQpoUBMw/Q93SRR1IhP0mPTBrEGjShwUvXc=
github.com/aptos-labs/aptos-go-sdk v1.11.0 h1:vIL1hpjECUiu7zMl9Wz6VV8ttXsrDqKUj0HxoeaIER4=
github.com/aptos-labs/aptos-go-sdk v1.11.0/go.mod h1:8YvYwRg93UcG6pTStCpZdYiscCtKh51sYfeLgIy/41c=
github.com/aptos-labs/tree-sitter-move-on-aptos v0.0.0-20250321090037-c820eb4716e1 h1:KD231JW9jSiu5m0J/w//3qJyGRdvrdabKAF+Fbwvzgo=
github.com/aptos-labs/tree-sitter-move-on-aptos v0.0.0-20250321090037-c820eb4716e1/go.mod h1:+WZUlAOW0a0+7CrPgFVwmflo1LHH61uw4WSJtboIk48=
github.com/bahlo/generic-list-go v0.2.0 h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPnH1Wvgk=
Expand Down Expand Up @@ -51,17 +51,17 @@ github.com/cloudevents/sdk-go/v2 v2.16.1/go.mod h1:v/kVOaWjNfbvc6tkhhlkhvLapj8Aa
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I=
github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ=
github.com/coder/websocket v1.8.13 h1:f3QZdXy7uGVz+4uCJy2nTZyM0yTBj8yANEHhqlXZ9FE=
github.com/coder/websocket v1.8.13/go.mod h1:LNVeNrXQZfe5qhS9ALED3uA+l5pPqvwXg3CKoDBB2gs=
github.com/coder/websocket v1.8.14 h1:9L0p0iKiNOibykf283eHkKUHHrpG7f65OE3BhhO7v9g=
github.com/coder/websocket v1.8.14/go.mod h1:NX3SzP+inril6yawo5CQXx8+fk145lPDC6pumgx0mVg=
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY=
github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw=
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
github.com/cucumber/gherkin/go/v26 v26.2.0 h1:EgIjePLWiPeslwIWmNQ3XHcypPsWAHoMCz/YEBKP4GI=
github.com/cucumber/gherkin/go/v26 v26.2.0/go.mod h1:t2GAPnB8maCT4lkHL99BDCVNzCh1d7dBhCLt150Nr/0=
github.com/cucumber/godog v0.15.0 h1:51AL8lBXF3f0cyA5CV4TnJFCTHpgiy+1x1Hb3TtZUmo=
github.com/cucumber/godog v0.15.0/go.mod h1:FX3rzIDybWABU4kuIXLZ/qtqEe1Ac5RdXmqvACJOces=
github.com/cucumber/godog v0.15.1 h1:rb/6oHDdvVZKS66hrhpjFQFHjthFSrQBCOI1LwshNTI=
github.com/cucumber/godog v0.15.1/go.mod h1:qju+SQDewOljHuq9NSM66s0xEhogx0q30flfxL4WUk8=
github.com/cucumber/messages/go/v21 v21.0.1 h1:wzA0LxwjlWQYZd32VTlAVDTkW6inOFmSM+RuOwHZiMI=
github.com/cucumber/messages/go/v21 v21.0.1/go.mod h1:zheH/2HS9JLVFukdrsPWoPdmUtmYQAQPLk7w5vWsk5s=
github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down Expand Up @@ -169,8 +169,8 @@ github.com/hashicorp/golang-lru v1.0.2 h1:dV3g9Z/unq5DpblPpw+Oqcv4dU/1omnb4Ok8iP
github.com/hashicorp/golang-lru v1.0.2/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
github.com/hashicorp/yamux v0.1.2 h1:XtB8kyFOyHXYVFnwT5C3+Bdo8gArse7j2AQ0DA0Uey8=
github.com/hashicorp/yamux v0.1.2/go.mod h1:C+zze2n6e/7wshOZep2A70/aQU6QBRWJO/G6FT1wIns=
github.com/hasura/go-graphql-client v0.13.1 h1:kKbjhxhpwz58usVl+Xvgah/TDha5K2akNTRQdsEHN6U=
github.com/hasura/go-graphql-client v0.13.1/go.mod h1:k7FF7h53C+hSNFRG3++DdVZWIuHdCaTbI7siTJ//zGQ=
github.com/hasura/go-graphql-client v0.14.5 h1:M9HxxGLCcDZnxJGYyWXAzDYEpommgjW+sUW3V8EaGms=
github.com/hasura/go-graphql-client v0.14.5/go.mod h1:jfSZtBER3or+88Q9vFhWHiFMPppfYILRyl+0zsgPIIw=
github.com/hdevalence/ed25519consensus v0.2.0 h1:37ICyZqdyj0lAZ8P4D1d1id3HqbbG1N3iBb1Tb4rdcU=
github.com/hdevalence/ed25519consensus v0.2.0/go.mod h1:w3BHWjwJbFU29IRHL1Iqkw3sus+7FctEyM4RqDxYNzo=
github.com/holiman/uint256 v1.3.2 h1:a9EgMPSC1AAaj1SZL5zIQD3WbwTuHrMGOerLjGmM/TA=
Expand Down
13 changes: 13 additions & 0 deletions relayer/chainreader/indexer/events_indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ type EventsIndexer struct {
// a map of event handles to the last processed cursor
lastProcessedCursors map[string]*models.EventId
cursorMutex sync.RWMutex

// Optional callback for recording successful sync operations
onSyncSuccess func(ctx context.Context)
}

type EventsIndexerApi interface {
Expand All @@ -44,6 +47,7 @@ type EventsIndexerApi interface {
SyncEvent(ctx context.Context, selector *client.EventSelector) error
AddEventSelector(ctx context.Context, selector *client.EventSelector) error
SetEventOffsetOverrides(ctx context.Context, offsetOverrides map[string]client.EventId) error
SetOnSyncSuccess(callback func(ctx context.Context))
Ready() error
Close() error
}
Expand Down Expand Up @@ -99,6 +103,10 @@ func (eIndexer *EventsIndexer) Start(ctx context.Context) error {
eIndexer.logger.Warnw("EventSync timed out", "duration", elapsed)
} else {
eIndexer.logger.Debugw("Event sync completed successfully", "duration", elapsed)
// Record successful sync for health metrics
if eIndexer.onSyncSuccess != nil {
eIndexer.onSyncSuccess(ctx)
}
}

cancel()
Expand Down Expand Up @@ -447,3 +455,8 @@ func (eIndexer *EventsIndexer) Close() error {
// TODO: implement
return nil
}

// SetOnSyncSuccess sets a callback function that is called after a successful sync operation.
func (eIndexer *EventsIndexer) SetOnSyncSuccess(callback func(ctx context.Context)) {
eIndexer.onSyncSuccess = callback
}
35 changes: 35 additions & 0 deletions relayer/chainreader/indexer/indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (

"github.com/smartcontractkit/chainlink-common/pkg/logger"
"github.com/smartcontractkit/chainlink-common/pkg/services"

"github.com/smartcontractkit/chainlink-sui/relayer/monitor"
)

type Indexer struct {
Expand All @@ -22,6 +24,9 @@ type Indexer struct {
transactionIndexerErr atomic.Value // stores error from transaction indexer goroutine

wg sync.WaitGroup // wait for both indexer goroutines to exit

// Health metrics for monitoring (optional)
healthMetrics *monitor.HealthMetrics
}

type IndexerApi interface {
Expand Down Expand Up @@ -54,6 +59,16 @@ func (i *Indexer) Name() string {

func (i *Indexer) Start(_ context.Context) error {
return i.starter.StartOnce(i.Name(), func() error {
// Set up health metrics callbacks if health metrics are configured
if i.healthMetrics != nil {
i.eventsIndexer.SetOnSyncSuccess(func(ctx context.Context) {
i.RecordEventsIndexerSuccess(ctx)
})
i.transactionIndexer.SetOnSyncSuccess(func(ctx context.Context) {
i.RecordTransactionsIndexerSuccess(ctx)
})
}

// Events indexer
eventsIndexerCtx, eventsIndexerCancel := context.WithCancel(context.Background())
i.eventsIndexerCancel = &eventsIndexerCancel
Expand Down Expand Up @@ -158,3 +173,23 @@ func (i *Indexer) GetTransactionIndexer() TransactionsIndexerApi {
}
return i.transactionIndexer
}

// SetHealthMetrics sets the health metrics instance for the indexer.
// This should be called after creating the indexer to enable health metrics reporting.
func (i *Indexer) SetHealthMetrics(hm *monitor.HealthMetrics) {
i.healthMetrics = hm
}

// RecordEventsIndexerSuccess records a successful events indexer sync operation.
func (i *Indexer) RecordEventsIndexerSuccess(ctx context.Context) {
if i.healthMetrics != nil {
i.healthMetrics.RecordLastSuccess(ctx, monitor.ComponentEventsIndexer)
}
}

// RecordTransactionsIndexerSuccess records a successful transactions indexer sync operation.
func (i *Indexer) RecordTransactionsIndexerSuccess(ctx context.Context) {
if i.healthMetrics != nil {
i.healthMetrics.RecordLastSuccess(ctx, monitor.ComponentTransactionsIndexer)
}
}
13 changes: 13 additions & 0 deletions relayer/chainreader/indexer/transactions_indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,15 @@ type TransactionsIndexer struct {
mu sync.RWMutex
offrampPackageIdReady chan struct{}
offrampPackageOnce sync.Once

// Optional callback for recording successful sync operations
onSyncSuccess func(ctx context.Context)
}

type TransactionsIndexerApi interface {
Start(ctx context.Context) error
SetOffRampPackage(pkg string, latestPkg string)
SetOnSyncSuccess(callback func(ctx context.Context))
Ready() error
Close() error
}
Expand Down Expand Up @@ -115,6 +119,10 @@ func (tIndexer *TransactionsIndexer) Start(ctx context.Context) error {
tIndexer.logger.Warnw("Transaction sync timed out", "duration", elapsed)
} else {
tIndexer.logger.Debugw("Transaction sync completed successfully", "duration", elapsed)
// Record successful sync for health metrics
if tIndexer.onSyncSuccess != nil {
tIndexer.onSyncSuccess(ctx)
}
}

cancel()
Expand Down Expand Up @@ -837,3 +845,8 @@ func (tIndexer *TransactionsIndexer) Close() error {
// TODO: implement
return nil
}

// SetOnSyncSuccess sets a callback function that is called after a successful sync operation.
func (tIndexer *TransactionsIndexer) SetOnSyncSuccess(callback func(ctx context.Context)) {
tIndexer.onSyncSuccess = callback
}
17 changes: 17 additions & 0 deletions relayer/chainreader/reader/chainreader.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"github.com/smartcontractkit/chainlink-sui/relayer/client"
"github.com/smartcontractkit/chainlink-sui/relayer/codec"
"github.com/smartcontractkit/chainlink-sui/relayer/common"
"github.com/smartcontractkit/chainlink-sui/relayer/monitor"

"github.com/smartcontractkit/chainlink-common/pkg/logger"
pkgtypes "github.com/smartcontractkit/chainlink-common/pkg/types"
Expand Down Expand Up @@ -58,6 +59,9 @@ type suiChainReader struct {
// Value: parent object ID
parentObjectIDs map[string]string
parentObjectIDsMutex sync.RWMutex

// Health metrics for monitoring (optional)
healthMetrics *monitor.HealthMetrics
}

var _ pkgtypes.ContractTypeProvider = &suiChainReader{}
Expand Down Expand Up @@ -155,6 +159,19 @@ func (s *suiChainReader) Close() error {
})
}

// SetHealthMetrics sets the health metrics instance for the chain reader.
// This should be called after creating the chain reader to enable health metrics reporting.
func (s *suiChainReader) SetHealthMetrics(hm *monitor.HealthMetrics) {
s.healthMetrics = hm
}

// recordLastSuccess records a successful operation to the health metrics.
func (s *suiChainReader) recordLastSuccess(ctx context.Context) {
if s.healthMetrics != nil {
s.healthMetrics.RecordLastSuccess(ctx, monitor.ComponentChainReader)
}
}

func (s *suiChainReader) Bind(ctx context.Context, bindings []pkgtypes.BoundContract) error {
offrampPackageAddress := ""

Expand Down
19 changes: 19 additions & 0 deletions relayer/chainwriter/chainwriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
cwConfig "github.com/smartcontractkit/chainlink-sui/relayer/chainwriter/config"
"github.com/smartcontractkit/chainlink-sui/relayer/chainwriter/ptb"
"github.com/smartcontractkit/chainlink-sui/relayer/chainwriter/ptb/offramp"
"github.com/smartcontractkit/chainlink-sui/relayer/monitor"
"github.com/smartcontractkit/chainlink-sui/relayer/txm"
)

Expand All @@ -29,6 +30,9 @@ type SuiChainWriter struct {
simulate bool
ptbFactory *ptb.PTBConstructor
services.StateMachine

// Health metrics for monitoring (optional)
healthMetrics *monitor.HealthMetrics
}

func NewSuiChainWriter(lggr logger.Logger, txManager txm.TxManager, config cwConfig.ChainWriterConfig, simulate bool) (*SuiChainWriter, error) {
Expand Down Expand Up @@ -140,6 +144,8 @@ func (s *SuiChainWriter) SubmitTransaction(ctx context.Context, contractName str
}
s.lggr.Infow("Transaction enqueued", "transactionID", tx.TransactionID, "functionName", method)

s.recordLastSuccess(ctx)

return nil
}

Expand Down Expand Up @@ -197,6 +203,19 @@ func (s *SuiChainWriter) Start(ctx context.Context) error {
})
}

// SetHealthMetrics sets the health metrics instance for the chain writer.
// This should be called after creating the chain writer to enable health metrics reporting.
func (s *SuiChainWriter) SetHealthMetrics(hm *monitor.HealthMetrics) {
s.healthMetrics = hm
}

// recordLastSuccess records a successful operation to the health metrics.
func (s *SuiChainWriter) recordLastSuccess(ctx context.Context) {
if s.healthMetrics != nil {
s.healthMetrics.RecordLastSuccess(ctx, monitor.ComponentChainWriter)
}
}

func (s *SuiChainWriter) EstimateGasBudgetFromCCIPExecuteMessage(ctx context.Context, arguments map[string]any, meta *commonTypes.TxMeta) (*big.Int, error) {
offrampArgs, err := offramp.DecodeOffRampExecCallArgs(arguments)
if err != nil {
Expand Down
7 changes: 0 additions & 7 deletions relayer/config/chain_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,6 @@ const (
DefaultTransactionRetentionSecs = uint64(10)
)

type ChainInfo struct {
ChainFamilyName string
ChainID string
NetworkName string
NetworkNameFull string
}

type NodeConfig struct {
Name *string
URL *config.URL
Expand Down
3 changes: 2 additions & 1 deletion relayer/monitor/balance.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/smartcontractkit/chainlink-sui/relayer/client"

aptosBalanceMonitor "github.com/smartcontractkit/chainlink-aptos/relayer/monitor"
aptosTypes "github.com/smartcontractkit/chainlink-aptos/relayer/types"
"github.com/smartcontractkit/chainlink-common/pkg/logger"
"github.com/smartcontractkit/chainlink-common/pkg/services"
"github.com/smartcontractkit/chainlink-common/pkg/types/core"
Expand All @@ -20,7 +21,7 @@ const BalanceCheckTimeout = 30 * time.Second

// BalanceMonitorOpts contains the options for creating a new Sui account balance monitor.
type BalanceMonitorOpts struct {
ChainInfo aptosBalanceMonitor.ChainInfo
ChainInfo aptosTypes.ChainInfo

Config aptosBalanceMonitor.GenericBalanceConfig
Logger logger.Logger
Expand Down
Loading
Loading