Skip to content

Commit b4b7ee4

Browse files
authored
update sui and fix tests (#21867)
* update sui and fix tests * update tests * re-arrange tests * fix tests * update * update * update * update * upgrade sui * fix * update
1 parent 3f47960 commit b4b7ee4

19 files changed

Lines changed: 818 additions & 773 deletions

File tree

.github/integration-in-memory-tests.yml

Lines changed: 171 additions & 133 deletions
Large diffs are not rendered by default.

core/scripts/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ require (
511511
github.com/smartcontractkit/chainlink-protos/workflows/go v0.0.0-20260323124644-faea187e6997 // indirect
512512
github.com/smartcontractkit/chainlink-solana v1.1.2-0.20260407162454-407b2a207dcc // indirect
513513
github.com/smartcontractkit/chainlink-solana/contracts v0.0.0-20260217175957-8f1af02c5075 // indirect
514-
github.com/smartcontractkit/chainlink-sui v0.0.0-20260403160819-db38ee3fbcde // indirect
514+
github.com/smartcontractkit/chainlink-sui v0.0.0-20260408023220-974ac248027c // indirect
515515
github.com/smartcontractkit/chainlink-sui/deployment v0.0.0-20260304150206-c64e48eb0cb0 // indirect
516516
github.com/smartcontractkit/chainlink-testing-framework/framework/components/fake v0.10.0 // indirect
517517
github.com/smartcontractkit/chainlink-testing-framework/parrot v0.6.2 // indirect

core/scripts/go.sum

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

deployment/ccip/changeset/testhelpers/test_adapter_sui.go

Lines changed: 23 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,10 @@ import (
1313
"github.com/block-vision/sui-go-sdk/models"
1414
"github.com/block-vision/sui-go-sdk/sui"
1515

16-
module_offramp "github.com/smartcontractkit/chainlink-aptos/bindings/ccip_offramp/offramp"
17-
"github.com/smartcontractkit/chainlink-aptos/relayer/codec"
1816
"github.com/smartcontractkit/chainlink-common/pkg/types/ccipocr3"
1917
sui_module_offramp "github.com/smartcontractkit/chainlink-sui/bindings/generated/ccip/ccip_offramp/offramp"
2018
sui_ccip_offramp "github.com/smartcontractkit/chainlink-sui/bindings/packages/offramp"
19+
"github.com/smartcontractkit/chainlink-sui/relayer/codec"
2120

2221
"github.com/smartcontractkit/chainlink-common/pkg/utils/tests"
2322

@@ -32,6 +31,13 @@ type SuiAdapter struct {
3231
cldf_sui.Chain
3332
}
3433

34+
// offRampOriginalPkgID returns the original (V1) package ID, which must be used
35+
// for event queries. In Sui, struct types (including events) always carry the
36+
// original defining package's ID regardless of which upgraded version emitted them.
37+
func (a *SuiAdapter) offRampOriginalPkgID() string {
38+
return a.state.OffRampAddress
39+
}
40+
3541
func NewSuiAdapter(chain cldf.BlockChain, env deployment.Environment) Adapter {
3642
c, ok := chain.(cldf_sui.Chain)
3743
if !ok {
@@ -76,7 +82,7 @@ func (a *SuiAdapter) ValidateCommit(t *testing.T, sourceSelector uint64, startBl
7682
t,
7783
sourceSelector,
7884
a.Chain,
79-
a.state.OffRampAddress,
85+
a.offRampOriginalPkgID(),
8086
startBlock,
8187
seqNumRange,
8288
true,
@@ -89,7 +95,7 @@ func (a *SuiAdapter) ValidateExec(t *testing.T, sourceSelector uint64, startBloc
8995
t,
9096
sourceSelector,
9197
a.Chain,
92-
a.state.OffRampAddress,
98+
a.offRampOriginalPkgID(),
9399
startBlock,
94100
seqNrs,
95101
)
@@ -113,8 +119,7 @@ func SuiEventEmitter[T any](
113119
Version string
114120
}, 200)
115121
errChan := make(chan error)
116-
limit := uint64(50) // Use uint64 directly to avoid conversion
117-
seenEvents := make(map[string]bool) // Track all seen event IDs to prevent duplicates
122+
limit := uint64(50)
118123

119124
go func() {
120125
defer close(ch)
@@ -123,9 +128,11 @@ func SuiEventEmitter[T any](
123128
ticker := time.NewTicker(time.Second * 2)
124129
defer ticker.Stop()
125130

131+
var cursor interface{}
132+
126133
for {
134+
// Drain all available pages from the current cursor position before waiting.
127135
for {
128-
// As this can take a few iterations if there are many events, check for done before each request
129136
select {
130137
case <-done:
131138
t.Logf("[DEBUG] SuiEventEmitter: Stopping due to done signal")
@@ -139,6 +146,7 @@ func SuiEventEmitter[T any](
139146

140147
events, err := client.SuiXQueryEvents(t.Context(), models.SuiXQueryEventsRequest{
141148
SuiEventFilter: eventFilter,
149+
Cursor: cursor,
142150
Limit: limit,
143151
DescendingOrder: false,
144152
})
@@ -153,37 +161,21 @@ func SuiEventEmitter[T any](
153161
}
154162

155163
if len(events.Data) == 0 {
156-
// No new events found
157164
t.Logf("[DEBUG] SuiEventEmitter: No new events found")
158165
break
159166
}
160167

161168
t.Logf("[DEBUG] SuiEventEmitter: Processing %d events", len(events.Data))
162-
newEventsCount := 0
163169

164170
for _, ev := range events.Data {
165-
// Create unique event ID combining transaction digest and event sequence
166171
eventID := fmt.Sprintf("%s:%s", ev.Id.TxDigest, ev.Id.EventSeq)
167172

168-
if seenEvents[eventID] {
169-
t.Logf("[DEBUG] SuiEventEmitter: Skipping duplicate event %s with type %s and transaction module %s at timestamp %s", eventID, ev.Type, ev.TransactionModule, ev.TimestampMs)
170-
continue // skip duplicates
171-
}
172-
seenEvents[eventID] = true
173-
174173
var out T
175-
// TODO: Use proper SUI JSON decoder instead of Aptos decoder
176-
if err := codec.DecodeAptosJsonValue(ev.ParsedJson, &out); err != nil {
177-
t.Logf("[DEBUG] SuiEventEmitter: Decode error for event %s with type %s and transaction module %s at timestamp %s: %v", eventID, ev.Type, ev.TransactionModule, ev.TimestampMs, err)
178-
select {
179-
case errChan <- fmt.Errorf("failed to decode event %s with type %s and transaction module %s at timestamp %s: %w", eventID, ev.Type, ev.TransactionModule, ev.TimestampMs, err):
180-
case <-done:
181-
return
182-
}
174+
if err := codec.DecodeSuiJsonValue(ev.ParsedJson, &out); err != nil {
175+
t.Logf("[DEBUG] SuiEventEmitter: Decode error for event %s: %v (skipping)", eventID, err)
183176
continue
184177
}
185178

186-
newEventsCount++
187179
eventData := struct {
188180
Event T
189181
Version string
@@ -192,26 +184,21 @@ func SuiEventEmitter[T any](
192184
Version: ev.Id.EventSeq,
193185
}
194186

195-
// Non-blocking send to prevent goroutine deadlock
196187
select {
197188
case ch <- eventData:
198-
t.Logf("[DEBUG] SuiEventEmitter: Sent event %s with type %s and transaction module %s at timestamp %s", eventID, ev.Type, ev.TransactionModule, ev.TimestampMs)
189+
t.Logf("[DEBUG] SuiEventEmitter: Sent event %s with type %s at timestamp %s", eventID, ev.Type, ev.TimestampMs)
199190
case <-done:
200191
t.Logf("[DEBUG] SuiEventEmitter: Stopping due to done signal during send")
201192
return
202193
default:
203-
t.Logf("[WARNING] SuiEventEmitter: Channel full, dropping event %s with type %s and transaction module %s at timestamp %s", eventID, ev.Type, ev.TransactionModule, ev.TimestampMs)
204-
// Channel is full, log warning but continue processing
205-
// This prevents blocking the entire event loop
194+
t.Logf("[WARNING] SuiEventEmitter: Channel full, dropping event %s", eventID)
206195
}
207196
}
208197

209-
t.Logf("[DEBUG] SuiEventEmitter: Processed %d new events out of %d total", newEventsCount, len(events.Data))
198+
// Advance the cursor so the next query picks up where we left off.
199+
cursor = events.NextCursor
210200

211-
// For now, break after processing to avoid infinite loops
212-
// TODO: Implement proper cursor-based pagination when SUI SDK supports it
213-
if uint64(len(events.Data)) < limit {
214-
// Received fewer events than limit, likely no more events available
201+
if !events.HasNextPage {
215202
break
216203
}
217204
}
@@ -220,7 +207,6 @@ func SuiEventEmitter[T any](
220207
t.Logf("[DEBUG] SuiEventEmitter: Stopping due to done signal in ticker loop")
221208
return
222209
case <-ticker.C:
223-
t.Logf("[DEBUG] SuiEventEmitter: Ticker fired, checking for new events")
224210
continue
225211
}
226212
}
@@ -318,7 +304,7 @@ func confirmExecWithExpectedSeqNrsSui(
318304
defer close(done)
319305

320306
t.Log("[DEBUG] Subscribing to Sui events...", offRampAddress)
321-
sink, errChan := SuiEventEmitter[module_offramp.ExecutionStateChanged](t, dest.Client, offRampAddress, "offramp", "ExecutionStateChanged", done)
307+
sink, errChan := SuiEventEmitter[sui_module_offramp.ExecutionStateChanged](t, dest.Client, offRampAddress, "offramp", "ExecutionStateChanged", done)
322308

323309
t.Log("[DEBUG] Event subscription established")
324310

deployment/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ require (
5656
github.com/smartcontractkit/chainlink-protos/orchestrator v0.10.0
5757
github.com/smartcontractkit/chainlink-solana v1.1.2-0.20260407162454-407b2a207dcc
5858
github.com/smartcontractkit/chainlink-solana/contracts v0.0.0-20260217175957-8f1af02c5075
59-
github.com/smartcontractkit/chainlink-sui v0.0.0-20260403160819-db38ee3fbcde
59+
github.com/smartcontractkit/chainlink-sui v0.0.0-20260408023220-974ac248027c
6060
github.com/smartcontractkit/chainlink-sui/deployment v0.0.0-20260304150206-c64e48eb0cb0
6161
github.com/smartcontractkit/chainlink-testing-framework/framework v0.15.3
6262
github.com/smartcontractkit/chainlink-testing-framework/lib v1.54.5

deployment/go.sum

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ require (
105105
github.com/smartcontractkit/chainlink-protos/storage-service v0.3.0
106106
github.com/smartcontractkit/chainlink-protos/workflows/go v0.0.0-20260323124644-faea187e6997
107107
github.com/smartcontractkit/chainlink-solana v1.1.2-0.20260407162454-407b2a207dcc
108-
github.com/smartcontractkit/chainlink-sui v0.0.0-20260403160819-db38ee3fbcde
108+
github.com/smartcontractkit/chainlink-sui v0.0.0-20260408023220-974ac248027c
109109
github.com/smartcontractkit/chainlink-ton v0.0.0-20260331005855-7b5a4b3384f8
110110
github.com/smartcontractkit/cre-sdk-go v1.5.0
111111
github.com/smartcontractkit/cre-sdk-go/capabilities/networking/http v1.3.0

go.sum

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

integration-tests/go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ require (
4444
github.com/smartcontractkit/chainlink-evm v0.3.4-0.20260330133421-5151ea0c3b05
4545
github.com/smartcontractkit/chainlink-evm/gethwrappers v0.0.0-20260119171452-39c98c3b33cd
4646
github.com/smartcontractkit/chainlink-protos/job-distributor v0.18.0
47-
github.com/smartcontractkit/chainlink-sui v0.0.0-20260403160819-db38ee3fbcde
48-
github.com/smartcontractkit/chainlink-sui/deployment v0.0.0-20260403160819-db38ee3fbcde
47+
github.com/smartcontractkit/chainlink-sui v0.0.0-20260408023220-974ac248027c
48+
github.com/smartcontractkit/chainlink-sui/deployment v0.0.0-20260408023220-974ac248027c
4949
github.com/smartcontractkit/chainlink-testing-framework/lib v1.54.7
5050
github.com/smartcontractkit/chainlink-testing-framework/parrot v0.6.2
5151
github.com/smartcontractkit/chainlink-testing-framework/sentinel v0.1.2

integration-tests/go.sum

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)