Skip to content

Commit a8e45a2

Browse files
wlmyngclaude
andauthored
[gql] Remove legacy JsonCursor format support for Transactions connection (#27336)
## Description After one release, fully deprecate the legacy format by removing MultiCursor from the Transaction cursor format. To land before #26871 ## Test plan How did you test the new or updated feature? --- ## Release notes Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required. For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates. - [ ] Protocol: - [ ] Nodes (Validators and Full nodes): - [ ] gRPC: - [ ] JSON-RPC: - [ ] GraphQL: - [ ] CLI: - [ ] Rust SDK: - [ ] Indexing Framework: --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
1 parent bf7b60b commit a8e45a2

2 files changed

Lines changed: 11 additions & 56 deletions

File tree

crates/sui-indexer-alt-e2e-tests/tests/graphql_transactions_query_tests.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -175,17 +175,4 @@ async fn test_transactions_query_cursor_pagination() {
175175
.unwrap();
176176
assert!(page.edges.is_empty());
177177
assert!(!page.page_info.has_next_page);
178-
179-
// Legacy cursor support -- the service accepts the old Base64-encoded JSON transaction
180-
// sequence number format, but outputs the new format only.
181-
let after = Base64::encode(serde_json::to_vec(&0u64).unwrap());
182-
let before = Base64::encode(serde_json::to_vec(&6u64).unwrap());
183-
184-
let page = transactions(&cluster, None, Some(2), Some(after), Some(before))
185-
.await
186-
.unwrap();
187-
188-
assert_eq!(window(&page.edges), window(&all.edges[4..=5]));
189-
assert!(page.page_info.has_previous_page);
190-
assert!(page.page_info.has_next_page);
191178
}

crates/sui-indexer-alt-graphql/src/api/types/transaction/mod.rs

Lines changed: 11 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ use sui_types::transaction::TransactionExpiration;
3232

3333
use crate::api::scalars::base64::Base64;
3434
use crate::api::scalars::cursor::ByteCursor;
35-
use crate::api::scalars::cursor::JsonCursor;
36-
use crate::api::scalars::cursor::MultiCursor;
3735
use crate::api::scalars::cursor::OpaqueCursor;
3836
use crate::api::scalars::digest::Digest;
3937
use crate::api::scalars::fq_name_filter::FqNameFilter;
@@ -75,17 +73,16 @@ pub(crate) struct TransactionContents {
7573
}
7674

7775
/// Validated transaction cursor coordinates.
78-
#[derive(Clone, Debug, PartialEq, Eq)]
76+
#[derive(Clone, Debug, Copy)]
7977
pub struct TransactionToken {
8078
/// Tracks the originating `CursorToken`'s kind, so it can be reproduced on re-encode.
8179
kind: CursorKind,
8280
checkpoint: u64,
8381
tx_seq: u64,
8482
}
8583

86-
/// Compatibility dispatch over the on-wire cursor formats: `CursorToken` (primary) or the
87-
/// legacy JSON cursor (secondary).
88-
pub type CTransaction = MultiCursor<OpaqueCursor<TransactionToken>, JsonCursor<u64>>;
84+
/// Compatibility dispatch over the on-wire cursor format.
85+
pub type CTransaction = OpaqueCursor<TransactionToken>;
8986

9087
/// Custom `Connection` for transactions to support partially-filled pages.
9188
pub(crate) struct TransactionConnection {
@@ -474,20 +471,17 @@ impl TransactionConnection {
474471
impl TransactionToken {
475472
/// Mint the edge cursor for the transaction at the given coordinates.
476473
pub(crate) fn cursor(checkpoint: u64, tx_seq: u64) -> CTransaction {
477-
CTransaction::new(OpaqueCursor::new(Self {
474+
OpaqueCursor::new(Self {
478475
kind: CursorKind::Item,
479476
checkpoint,
480477
tx_seq,
481-
}))
478+
})
482479
}
483480
}
484481

485482
impl TxBoundsCursor for CTransaction {
486483
fn tx_sequence_number(&self) -> u64 {
487-
match self {
488-
CTransaction::Primary(c) => c.tx_seq,
489-
CTransaction::Secondary(c) => **c,
490-
}
484+
self.tx_seq
491485
}
492486
}
493487

@@ -528,10 +522,10 @@ impl TryFrom<CursorToken> for TransactionToken {
528522
}
529523
}
530524

531-
impl Eq for CTransaction {}
532-
impl PartialEq for CTransaction {
525+
impl Eq for TransactionToken {}
526+
impl PartialEq for TransactionToken {
533527
fn eq(&self, other: &Self) -> bool {
534-
self.tx_sequence_number() == other.tx_sequence_number()
528+
self.tx_seq == other.tx_seq
535529
}
536530
}
537531

@@ -872,17 +866,10 @@ mod tests {
872866
TransactionToken::cursor(checkpoint, position)
873867
}
874868

875-
/// Legacy pg-style cursor: a bare JSON-encoded `tx_sequence_number`.
876-
fn legacy_cursor(position: u64) -> CTransaction {
877-
CTransaction::Secondary(JsonCursor::new(position))
878-
}
879-
880869
/// Decode an edge cursor back into its `CursorToken`.
881870
fn edge_token(cursor: &str) -> CursorToken {
882-
match CTransaction::decode_cursor(cursor).expect("decodable edge cursor") {
883-
CTransaction::Primary(c) => CursorToken::from(&*c),
884-
CTransaction::Secondary(_) => panic!("expected grpc cursor, got legacy"),
885-
}
871+
let decoded = CTransaction::decode_cursor(cursor).expect("decodable edge cursor");
872+
CursorToken::from(&*decoded)
886873
}
887874

888875
fn edge_positions(conn: &TransactionConnection) -> Vec<u64> {
@@ -949,25 +936,6 @@ mod tests {
949936
assert!(conn.page_info.has_next_page);
950937
}
951938

952-
/// A legacy pg-style cursor (bare JSON `tx_sequence_number`) resumes the same way as a grpc
953-
/// cursor with the same position.
954-
#[test]
955-
fn paginate_preloaded_resumes_after_legacy_cursor() {
956-
let txs = preloaded_txs(10..15);
957-
let conn = Transaction::paginate_preloaded_transactions(
958-
Scope::for_tests(),
959-
STREAMED_CP,
960-
&txs,
961-
&page_params_for_testing(Some(2), Some(legacy_cursor(11)), None, None),
962-
TransactionFilter::default(),
963-
)
964-
.expect("paginated");
965-
966-
assert_eq!(edge_positions(&conn), [12, 13]);
967-
assert!(conn.page_info.has_previous_page);
968-
assert!(conn.page_info.has_next_page);
969-
}
970-
971939
/// `last: n` must return the tail of the matching set.
972940
#[test]
973941
fn paginate_preloaded_backward_page_returns_tail() {

0 commit comments

Comments
 (0)