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(TransactionFeedV2): Fix persisted feed storing unmerged transactions #6205

Merged
merged 2 commits into from
Nov 5, 2024

Conversation

sviderock
Copy link
Contributor

@sviderock sviderock commented Nov 1, 2024

Description

While working on a different feed issue, I've noticed there's a bug in storing the first page of the feed to the persisted storage. TLDR, currently it stores "raw" transactions from pagination, which are not merged with the stand by transactions. This still sometimes causes transactions to rearrange on the first load.

This fix moves updating of the feed from to component level. It contradicts the current Redux-driven approach as it moves processing that can be managed on reducer level back to the component level but in order to make it follow that guideline we will need to:

  • move paginatedData to Redux
  • move confirmedTransactions construction to Redux
  • keep paginatedData away from persisted storage with an extra dependency like this or tweak the current persist settings as per their nested persist guide which might cause issues with existing persistence-related tests therefore create more friction to implement this seemingly simple fix.

Initial PR review discussion made sense at the time of working on that PR but back then I overlooked the fact that I've implemented it with this very bug as I was putting the wrong data.transactions data into the feed instead of the right paginatedData[FIRST_PAGE_CURSOR].

Test plan

Existing test to check proper rehydration of the persisted feed passes.

Related issues

Backwards compatibility

Yes

Network scalability

If a new NetworkId and/or Network are added in the future, the changes in this PR will:

  • Continue to work without code changes, OR trigger a compilation error (guaranteeing we find it when a new network is added)

Copy link

codecov bot commented Nov 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.94%. Comparing base (630cf89) to head (5e1a615).
Report is 6 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##             main    #6205    +/-   ##
========================================
  Coverage   88.93%   88.94%            
========================================
  Files         737      737            
  Lines       31370    31386    +16     
  Branches     5800     5497   -303     
========================================
+ Hits        27900    27915    +15     
- Misses       3425     3427     +2     
+ Partials       45       44     -1     
Files with missing lines Coverage Δ
src/transactions/feed/TransactionFeedV2.tsx 90.49% <100.00%> (+0.32%) ⬆️
src/transactions/selectors.ts 100.00% <ø> (ø)
src/transactions/slice.ts 98.63% <100.00%> (-0.02%) ⬇️

... and 4 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 630cf89...5e1a615. Read the comment docs.

Copy link

emerge-tools bot commented Nov 1, 2024

📸 Snapshot Test

Base build not found

No build was found for the base commit 630cf89. This is required to generate a snapshot diff for your pull request.

It's possible that you created a branch off the base commit before all of the CI steps have finished processing, e.g. the one that uploads a build to our system. If that's the case, no problem! Just wait and this will eventually resolve.


🛸 Powered by Emerge Tools

@@ -203,7 +204,8 @@ function mergeStandByTransactionsInRange({
return inRange || newTransaction || veryOldTransaction
})
const deduplicatedTransactions = deduplicateTransactions([...transactions, ...standByInRange])
const transactionsFromAllowedNetworks = deduplicatedTransactions.filter((tx) =>
const sortedTransactions = sortTransactions(deduplicatedTransactions)
Copy link
Contributor Author

@sviderock sviderock Nov 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was also one of the issues as initial persisted feed appeared unsorted therefore also triggering the rearrangement. It does add up an extra sorting loop, but this shouldn't be a major performance issue for now.

@@ -427,6 +429,17 @@ export default function TransactionFeedV2() {
[newlyCompletedCrossChainSwaps]
)

useEffect(
function updatePersistedFeedFirstPage() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if i understand this change correctly, the difference lies in that we want to store firstPageData instead of the received first page data in redux because firstPageData includes the sorted and merged standby transactions? if that is the case, aren't we storing the standby transactions potentially twice?

is it possible instead for the feedFirstPageSelector to return the first page that is merged with the standby transactions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kathaypacific

  1. With the implementation from this PR, duplicates will be present but only for pending and failed transactions. Once pending turn to completed - they will get removed from stand by, therefore duplicates will only exist for failed ones but only for the first page of the feed anyways.
  2. Yes, it is possible!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kathaypacific Argh, it seems like if I move this to the selector - I won't be able to pass isLastPage to the mergeStandByTransactionsInRange function. The rest of un-merged stand by transactions are always pushed to the very bottom of the last page but for that we need to somehow figure out if the page is last which is impossible from the selector level.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hum, okay. i don't have a better suggestion but am slightly concerned that these small details are causing some complexity / workarounds that we will later forget about. i can see us potentially reintroducing these bugs during cleanup initiatives. perhaps @jeanregisser has a suggestion here, or leaving a small comment with a link to your comment explanation above is sufficient for now

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kathaypacific there are a few potential implementation changes that I have in mind but they involve a bit more time to implement as it will most likely require the overall change of managing paginationData on the side of Redux rather than on the component level. In that case, we'll have most of the logic on the reducer level and no duplication.

@@ -427,6 +429,17 @@ export default function TransactionFeedV2() {
[newlyCompletedCrossChainSwaps]
)

useEffect(
function updatePersistedFeedFirstPage() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hum, okay. i don't have a better suggestion but am slightly concerned that these small details are causing some complexity / workarounds that we will later forget about. i can see us potentially reintroducing these bugs during cleanup initiatives. perhaps @jeanregisser has a suggestion here, or leaving a small comment with a link to your comment explanation above is sufficient for now

@sviderock
Copy link
Contributor Author

Merging it acknowledging that we will re-visit this implementation.
For more context, please refer to the discussion above.

@sviderock sviderock added this pull request to the merge queue Nov 5, 2024
Merged via the queue into main with commit 52fb491 Nov 5, 2024
27 checks passed
@sviderock sviderock deleted the slava/feed-v2-fix-persisted-feed branch November 5, 2024 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants