Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix non-deterministic sorting in transactions REST API #2454

Merged
merged 2 commits into from
Aug 26, 2021
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@
],
"token_transfers": [
{
"account": "0.0.300",
"amount": -1200,
"account": "0.0.200",
"amount": 200,
"token_id": "0.0.90000"
},
{
"account": "0.0.200",
"amount": 200,
"account": "0.0.300",
"amount": -1200,
"token_id": "0.0.90000"
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@
],
"token_transfers": [
{
"account": "0.0.8",
"amount": -1200,
"account": "0.0.3",
"amount": 200,
"token_id": "0.0.90000"
},
{
"account": "0.0.3",
"amount": 200,
"account": "0.0.8",
"amount": -1200,
"token_id": "0.0.90000"
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,13 @@
],
"token_transfers": [
{
"account": "0.0.8",
"amount": -1200,
"account": "0.0.3",
"amount": 200,
"token_id": "0.0.90000"
},
{
"account": "0.0.3",
"amount": 200,
"account": "0.0.8",
"amount": -1200,
"token_id": "0.0.90000"
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,6 @@
}
],
"token_transfers": [
{
"account": "0.0.9",
"amount": -1200,
"token_id": "0.0.90000"
},
{
"account": "0.0.3",
"amount": 200,
Expand All @@ -126,6 +121,11 @@
"account": "0.0.8",
"amount": 1000,
"token_id": "0.0.90000"
},
{
"account": "0.0.9",
"amount": -1200,
"token_id": "0.0.90000"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,13 @@
],
"token_transfers": [
{
"account": "0.0.8",
"amount": -1200,
"account": "0.0.3",
"amount": 200,
"token_id": "0.0.90000"
},
{
"account": "0.0.3",
"amount": 200,
"account": "0.0.8",
"amount": -1200,
"token_id": "0.0.90000"
},
{
Expand Down Expand Up @@ -227,13 +227,13 @@
],
"token_transfers": [
{
"account": "0.0.8",
"amount": -1200,
"account": "0.0.3",
"amount": 200,
"token_id": "0.0.90000"
},
{
"account": "0.0.3",
"amount": 200,
"account": "0.0.8",
"amount": -1200,
"token_id": "0.0.90000"
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,6 @@
}
],
"token_transfers": [
{
"account": "0.0.9",
"amount": -1200,
"token_id": "0.0.90000"
},
{
"account": "0.0.3",
"amount": 200,
Expand All @@ -163,6 +158,11 @@
"account": "0.0.8",
"amount": 1000,
"token_id": "0.0.90000"
},
{
"account": "0.0.9",
"amount": -1200,
"token_id": "0.0.90000"
}
]
},
Expand Down Expand Up @@ -226,11 +226,6 @@
}
],
"token_transfers": [
{
"account": "0.0.9",
"amount": -1200,
"token_id": "0.0.90000"
},
{
"account": "0.0.3",
"amount": 200,
Expand All @@ -240,6 +235,11 @@
"account": "0.0.8",
"amount": 1000,
"token_id": "0.0.90000"
},
{
"account": "0.0.9",
"amount": -1200,
"token_id": "0.0.90000"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,18 +99,6 @@
}
],
"nft_transfers": [
{
"receiver_account_id": "0.0.9",
"sender_account_id": null,
"serial_number": 1,
"token_id": "0.0.100000"
},
{
"receiver_account_id": "0.0.98",
"sender_account_id": "0.0.9",
"serial_number": 2,
"token_id": "0.0.100000"
},
{
"receiver_account_id": "0.0.8",
"sender_account_id": "0.0.3",
Expand All @@ -128,6 +116,18 @@
"sender_account_id": null,
"serial_number": 3,
"token_id": "0.0.90000"
},
{
"receiver_account_id": "0.0.9",
"sender_account_id": null,
"serial_number": 1,
"token_id": "0.0.100000"
},
{
"receiver_account_id": "0.0.98",
"sender_account_id": "0.0.9",
"serial_number": 2,
"token_id": "0.0.100000"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,13 @@
],
"token_transfers": [
{
"account": "0.0.300",
"amount": -1200,
"account": "0.0.200",
"amount": 200,
"token_id": "0.0.90000"
},
{
"account": "0.0.200",
"amount": 200,
"account": "0.0.300",
"amount": -1200,
"token_id": "0.0.90000"
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,13 @@
],
"token_transfers": [
{
"account": "0.0.300",
"amount": -1200,
"account": "0.0.200",
"amount": 200,
"token_id": "0.0.90000"
},
{
"account": "0.0.200",
"amount": 200,
"account": "0.0.300",
"amount": -1200,
"token_id": "0.0.90000"
},
{
Expand Down
9 changes: 6 additions & 3 deletions hedera-mirror-rest/transactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ const getSelectClauseWithTransfers = (includeExtraInfo) => {
'account_id', account_id,
'amount', amount,
'token_id', token_id
))
) order by token_id, account_id
)
from token_transfer
where token_transfer.consensus_timestamp = t.consensus_ns
`;
Expand All @@ -60,7 +61,8 @@ const getSelectClauseWithTransfers = (includeExtraInfo) => {
'sender_account_id', ${NftTransfer.SENDER_ACCOUNT_ID},
'serial_number', ${NftTransfer.SERIAL_NUMBER},
'token_id', ${NftTransfer.TOKEN_ID}
))
) order by ${NftTransfer.TOKEN_ID}, ${NftTransfer.SERIAL_NUMBER}
)
from ${NftTransfer.tableName} ${NftTransfer.tableAlias}
where ${NftTransfer.CONSENSUS_TIMESTAMP_FULL_NAME} = ${Transaction.CONSENSUS_NS_FULL_NAME}
`;
Expand All @@ -70,7 +72,8 @@ const getSelectClauseWithTransfers = (includeExtraInfo) => {
'collector_account_id', ${AssessedCustomFee.COLLECTOR_ACCOUNT_ID},
'effective_payer_account_ids', ${AssessedCustomFee.EFFECTIVE_PAYER_ACCOUNT_IDS},
'token_id', ${AssessedCustomFee.TOKEN_ID}
))
) order by ${AssessedCustomFee.COLLECTOR_ACCOUNT_ID}, ${AssessedCustomFee.AMOUNT}
)
from ${AssessedCustomFee.tableName} ${AssessedCustomFee.tableAlias}
where ${AssessedCustomFee.CONSENSUS_TIMESTAMP_FULL_NAME} = ${Transaction.CONSENSUS_NS_FULL_NAME}
`;
Expand Down