Skip to content

Commit

Permalink
graphql: Remove TransactionBlockFilter.recvAddress and AddressTransac…
Browse files Browse the repository at this point in the history
…tionBlockRelation.RECV (#19805)

## Description

These fields were flagged for deprecation in 1.34 and have been replaced
in 1.35 by

- `TransactionBlockFilter.affectedAddress` and
- `AddressTransactionBlockRelation.AFFECTED`

Which offer a similar (but not exactly the same) semantics, but without
confusion around the sender address which was often also an implicit
recipient of a transaction.

## Test plan

```
sui$ cargo nextest run -p sui-graphql-rpc
sui$ cargo nextest run -p sui-graphql-rpc --features staging
sui$ cargo nextest run -p sui-graphql-e2e-tests
```

## Stack

- #19708 
- #19802 
- #19803 
- #19804 

---

## 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): 
- [ ] Indexer: 
- [ ] JSON-RPC: 
- [x] GraphQL: `TransactionBlockFilter.recvAddress` and
`AddressTransactionBlockRelation.RECV` have been replace by
`TransactionBlockFilter.affectedAddress` and
`AddressTransactionBlockRelation.AFFECTED` which offer similar
semantics, but without confusion around the sender address which was
also often (but not always) an implicit recipient. Now we don't
distinguish between senders and recipients -- we only have senders and
"affected" addresses which were touched by the transaction in some way.
- [ ] CLI: 
- [ ] Rust SDK:
- [ ] REST API:
  • Loading branch information
amnn authored Oct 11, 2024
1 parent ec535cf commit 2cddd9d
Show file tree
Hide file tree
Showing 26 changed files with 91 additions and 337 deletions.
5 changes: 5 additions & 0 deletions .changeset/pretty-hounds-breathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@mysten/graphql-transport': patch
---

Update the GraphQL transport to account for the removal of recvAddress and the introduction of affectedAddress.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ task 7, line 48:
//# create-checkpoint
Checkpoint created: 1

task 8, lines 50-97:
task 8, lines 50-92:
//# run-graphql
Response: {
"data": {
Expand Down Expand Up @@ -563,146 +563,6 @@ Response: {
}
]
},
"receivedByA": {
"nodes": [
{
"effects": {
"objectChanges": {
"nodes": [
{
"inputState": null,
"outputState": {
"asMoveObject": {
"asCoin": {
"coinBalance": "1000000"
}
}
}
},
{
"inputState": {
"asMoveObject": {
"asCoin": {
"coinBalance": "300000000000000"
}
}
},
"outputState": {
"asMoveObject": {
"asCoin": {
"coinBalance": "299999996024000"
}
}
}
}
]
}
}
},
{
"effects": {
"objectChanges": {
"nodes": [
{
"inputState": {
"asMoveObject": {
"asCoin": {
"coinBalance": "299999996024000"
}
}
},
"outputState": {
"asMoveObject": {
"asCoin": {
"coinBalance": "299999992026120"
}
}
}
},
{
"inputState": null,
"outputState": {
"asMoveObject": {
"asCoin": {
"coinBalance": "2000000"
}
}
}
}
]
}
}
},
{
"effects": {
"objectChanges": {
"nodes": [
{
"inputState": {
"asMoveObject": {
"asCoin": {
"coinBalance": "299999992026120"
}
}
},
"outputState": {
"asMoveObject": {
"asCoin": {
"coinBalance": "299999987028240"
}
}
}
},
{
"inputState": null,
"outputState": {
"asMoveObject": {
"asCoin": {
"coinBalance": "3000000"
}
}
}
}
]
}
}
},
{
"effects": {
"objectChanges": {
"nodes": [
{
"inputState": {
"asMoveObject": {
"asCoin": {
"coinBalance": "299999987028240"
}
}
},
"outputState": {
"asMoveObject": {
"asCoin": {
"coinBalance": "299999981030360"
}
}
}
},
{
"inputState": null,
"outputState": {
"asMoveObject": {
"asCoin": {
"coinBalance": "4000000"
}
}
}
}
]
}
}
}
]
},
"affectsB": {
"nodes": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,6 @@
nodes { ...CoinBalances }
}

# ...and the transactions that A was a recipient for
receivedByA: transactionBlocks(filter: { kind: PROGRAMMABLE_TX, recvAddress: "@{A}" }, scanLimit: 1000) {
nodes { ...CoinBalances }
}

# B was not affected by all the transactions
affectsB: transactionBlocks(filter: { kind: PROGRAMMABLE_TX, affectedAddress: "@{B}" }, scanLimit: 1000) {
nodes { ...CoinBalances }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ module Test::M1 {

//# run-graphql
{
transactionBlocks(filter: {recvAddress: "@{A}" transactionIds: []}) {
transactionBlocks(filter: {affectedAddress: "@{A}" transactionIds: []}) {
pageInfo {
hasNextPage
hasPreviousPage
Expand All @@ -86,7 +86,7 @@ module Test::M1 {

//# run-graphql
{
transactionBlocks(scanLimit: 10 filter: {recvAddress: "@{A}" transactionIds: []}) {
transactionBlocks(scanLimit: 10 filter: {affectedAddress: "@{A}" transactionIds: []}) {
pageInfo {
hasNextPage
hasPreviousPage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ module Test::M1 {

//# run-graphql
{
transactionBlocks(first: 2 scanLimit: 2 filter: {recvAddress: "@{A}" afterCheckpoint: 1 beforeCheckpoint: 4}) {
transactionBlocks(first: 2 scanLimit: 2 filter: {affectedAddress: "@{A}" afterCheckpoint: 1 beforeCheckpoint: 4}) {
pageInfo {
hasPreviousPage
hasNextPage
Expand All @@ -82,7 +82,7 @@ module Test::M1 {
# so tx 4 and 6. the boundary cursors should wrap the response set,
# and both should have isScanLimited set to false
{
transactionBlocks(first: 2 after: "@{cursor_0}" filter: {recvAddress: "@{A}" afterCheckpoint: 1 beforeCheckpoint: 4}) {
transactionBlocks(first: 2 after: "@{cursor_0}" filter: {affectedAddress: "@{A}" afterCheckpoint: 1 beforeCheckpoint: 4}) {
pageInfo {
hasPreviousPage
hasNextPage
Expand All @@ -107,7 +107,7 @@ module Test::M1 {
# Meanwhile, because of the scanLimit of 2, the boundary cursors are
# startCursor: 4, endCursor: 5, and both are scan limited
{
transactionBlocks(first: 2 after: "@{cursor_0}" scanLimit: 2 filter: {recvAddress: "@{A}" afterCheckpoint: 1 beforeCheckpoint: 4}) {
transactionBlocks(first: 2 after: "@{cursor_0}" scanLimit: 2 filter: {affectedAddress: "@{A}" afterCheckpoint: 1 beforeCheckpoint: 4}) {
pageInfo {
hasPreviousPage
hasNextPage
Expand All @@ -133,7 +133,7 @@ module Test::M1 {
# startCursor: 7, endCursor: 8, both scan limited
# response set consists of single tx 8
{
transactionBlocks(first: 2 after: "@{cursor_0}" scanLimit: 2 filter: {recvAddress: "@{A}" afterCheckpoint: 1 beforeCheckpoint: 4}) {
transactionBlocks(first: 2 after: "@{cursor_0}" scanLimit: 2 filter: {affectedAddress: "@{A}" afterCheckpoint: 1 beforeCheckpoint: 4}) {
pageInfo {
hasPreviousPage
hasNextPage
Expand Down Expand Up @@ -162,7 +162,7 @@ module Test::M1 {
# consequently, the endCursor wraps the result set
# startCursor: 6, endCursor: 8, endCursor is not scan limited
{
transactionBlocks(first: 2 after: "@{cursor_0}" scanLimit: 6 filter: {recvAddress: "@{A}" afterCheckpoint: 1 beforeCheckpoint: 4}) {
transactionBlocks(first: 2 after: "@{cursor_0}" scanLimit: 6 filter: {affectedAddress: "@{A}" afterCheckpoint: 1 beforeCheckpoint: 4}) {
pageInfo {
hasPreviousPage
hasNextPage
Expand All @@ -187,7 +187,7 @@ module Test::M1 {
# fetch the last tx without scan limit
# startCursor = endCursor = 10, wrapping the response set
{
transactionBlocks(first: 2 after: "@{cursor_0}" filter: {recvAddress: "@{A}" afterCheckpoint: 1 beforeCheckpoint: 4}) {
transactionBlocks(first: 2 after: "@{cursor_0}" filter: {affectedAddress: "@{A}" afterCheckpoint: 1 beforeCheckpoint: 4}) {
pageInfo {
hasPreviousPage
hasNextPage
Expand All @@ -213,7 +213,7 @@ module Test::M1 {
# unlike the not-scan-limited query, the start and end cursors
# are expanded out to the scanned window, instead of wrapping the response set
{
transactionBlocks(first: 2 after: "@{cursor_0}" scanLimit: 6 filter: {recvAddress: "@{A}" afterCheckpoint: 1 beforeCheckpoint: 4}) {
transactionBlocks(first: 2 after: "@{cursor_0}" scanLimit: 6 filter: {affectedAddress: "@{A}" afterCheckpoint: 1 beforeCheckpoint: 4}) {
pageInfo {
hasPreviousPage
hasNextPage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ module Test::M1 {
# startCursor is at 3 + scanLimited, endCursor at 4 + not scanLimited
# this is because between (2, 7), txs 4 and 6 match, and thus endCursor snaps to last of result
{
transactionBlocks(first: 1 scanLimit: 4 after: "@{cursor_0}" before: "@{cursor_1}" filter: {recvAddress: "@{B}" afterCheckpoint: 1 beforeCheckpoint: 4}) {
transactionBlocks(first: 1 scanLimit: 4 after: "@{cursor_0}" before: "@{cursor_1}" filter: {affectedAddress: "@{B}" afterCheckpoint: 1 beforeCheckpoint: 4}) {
pageInfo {
hasPreviousPage
hasNextPage
Expand All @@ -86,7 +86,7 @@ module Test::M1 {
# and scan-limit logic will override this as there are still more txs to scan
# note that we're scanning txs [3, 6]
{
transactionBlocks(first: 3 scanLimit: 4 after: "@{cursor_0}" before: "@{cursor_1}" filter: {recvAddress: "@{B}" afterCheckpoint: 1 beforeCheckpoint: 4}) {
transactionBlocks(first: 3 scanLimit: 4 after: "@{cursor_0}" before: "@{cursor_1}" filter: {affectedAddress: "@{B}" afterCheckpoint: 1 beforeCheckpoint: 4}) {
pageInfo {
hasPreviousPage
hasNextPage
Expand All @@ -111,7 +111,7 @@ module Test::M1 {
# txs 5 and 7 match, but due to page size of `first: 1`, we only return tx 5
# startCursor is 5 + scan limited, endCursor is also 5 + scan limited
{
transactionBlocks(first: 1 scanLimit: 3 after: "@{cursor_0}" before: "@{cursor_1}" filter: {recvAddress: "@{A}" afterCheckpoint: 1 beforeCheckpoint: 4}) {
transactionBlocks(first: 1 scanLimit: 3 after: "@{cursor_0}" before: "@{cursor_1}" filter: {affectedAddress: "@{A}" afterCheckpoint: 1 beforeCheckpoint: 4}) {
pageInfo {
hasPreviousPage
hasNextPage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ module Test::M1 {
# [2, 3, 4, 5, 6, 7, 8, 9, 10, 11] <- tx_sequence_number
# [B, A, B, A, B, A, A, A, B, B]
{
transactionBlocks(first: 50 filter: {recvAddress: "@{B}" afterCheckpoint: 1 beforeCheckpoint: 4}) {
transactionBlocks(first: 50 filter: {affectedAddress: "@{B}" afterCheckpoint: 1 beforeCheckpoint: 4}) {
pageInfo {
hasPreviousPage
hasNextPage
Expand Down Expand Up @@ -89,7 +89,7 @@ module Test::M1 {
# The cursor for the node will have `is_scan_limited` flag set to false, because we know for sure there is
# a corresponding element for the cursor in the result set.
{
transactionBlocks(first: 2 scanLimit: 2 filter: {recvAddress: "@{B}" afterCheckpoint: 1 beforeCheckpoint: 4}) {
transactionBlocks(first: 2 scanLimit: 2 filter: {affectedAddress: "@{B}" afterCheckpoint: 1 beforeCheckpoint: 4}) {
pageInfo {
hasPreviousPage
hasNextPage
Expand All @@ -115,7 +115,7 @@ module Test::M1 {
# Still paginating with `scanLimit`, both the start and end cursors should have `is_scan_limited` flag to true
# because of the scanLimit of 4, startCursor = endCursor = 4
{
transactionBlocks(first: 1 scanLimit: 1 after: "@{cursor_0}" filter: {recvAddress: "@{B}" afterCheckpoint: 1 beforeCheckpoint: 4}) {
transactionBlocks(first: 1 scanLimit: 1 after: "@{cursor_0}" filter: {affectedAddress: "@{B}" afterCheckpoint: 1 beforeCheckpoint: 4}) {
pageInfo {
hasPreviousPage
hasNextPage
Expand Down Expand Up @@ -143,7 +143,7 @@ module Test::M1 {
# instead of wrapping around the result set, the boundary cursors are pushed out
# to the first and last transaction scanned in this query
{
transactionBlocks(first: 3 scanLimit: 3 after: "@{cursor_0}" filter: {recvAddress: "@{B}" afterCheckpoint: 1 beforeCheckpoint: 4}) {
transactionBlocks(first: 3 scanLimit: 3 after: "@{cursor_0}" filter: {affectedAddress: "@{B}" afterCheckpoint: 1 beforeCheckpoint: 4}) {
pageInfo {
hasPreviousPage
hasNextPage
Expand Down Expand Up @@ -171,7 +171,7 @@ module Test::M1 {
# instead of returninng None, we set the boundary cursors
# to the first and last transaction scanned in this query
{
transactionBlocks(first: 2 scanLimit: 2 after: "@{cursor_0}" filter: {recvAddress: "@{B}" afterCheckpoint: 1 beforeCheckpoint: 4}) {
transactionBlocks(first: 2 scanLimit: 2 after: "@{cursor_0}" filter: {affectedAddress: "@{B}" afterCheckpoint: 1 beforeCheckpoint: 4}) {
pageInfo {
hasPreviousPage
hasNextPage
Expand All @@ -198,7 +198,7 @@ module Test::M1 {
# startCursor at 10, endCursor at 11
# correctly detects we've reached the end of the upper bound
{
transactionBlocks(first: 2 scanLimit: 2 after: "@{cursor_0}" filter: {recvAddress: "@{B}" afterCheckpoint: 1 beforeCheckpoint: 4}) {
transactionBlocks(first: 2 scanLimit: 2 after: "@{cursor_0}" filter: {affectedAddress: "@{B}" afterCheckpoint: 1 beforeCheckpoint: 4}) {
pageInfo {
hasPreviousPage
hasNextPage
Expand Down Expand Up @@ -230,7 +230,7 @@ module Test::M1 {
# regardless of the specified scanLimit
# correctly detects we've reached the end of the upper bound
{
transactionBlocks(first: 2 scanLimit: 2 after: "@{cursor_0}" filter: {recvAddress: "@{B}" afterCheckpoint: 1 beforeCheckpoint: 5}) {
transactionBlocks(first: 2 scanLimit: 2 after: "@{cursor_0}" filter: {affectedAddress: "@{B}" afterCheckpoint: 1 beforeCheckpoint: 5}) {
pageInfo {
hasPreviousPage
hasNextPage
Expand Down Expand Up @@ -259,7 +259,7 @@ module Test::M1 {
# there is a next page, which is the 12th tx, which should yield an empty set
# per the filtering criteria
{
transactionBlocks(last: 2 scanLimit: 2 before: "@{cursor_0}" filter: {recvAddress: "@{B}" afterCheckpoint: 1 beforeCheckpoint: 5}) {
transactionBlocks(last: 2 scanLimit: 2 before: "@{cursor_0}" filter: {affectedAddress: "@{B}" afterCheckpoint: 1 beforeCheckpoint: 5}) {
pageInfo {
hasPreviousPage
hasNextPage
Expand Down
Loading

0 comments on commit 2cddd9d

Please sign in to comment.