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

changes timestampToTransactionHash to one-to-many #3625

Merged
merged 3 commits into from
Mar 10, 2023

Conversation

hughy
Copy link
Contributor

@hughy hughy commented Mar 8, 2023

Summary

it's possible for multiple transactions to have the same timestamp in a wallet.

for example, if an account receives two transactions that are on the same block, but did not sync those transactions until they were on the chain, then both transactions will have the block header timestamp.

this example might occur in practice if a node was offline when the transactions were first created and/or did not receive the transactions in gossip messages before they were added to the chain.

this might also happen for an account that is imported to a wallet after the transactions were added to the chain. when rescanning the chain for the imported account all transactions will use the timestamp of the block header of the block they are found on.

we use the 'timestampToTransactionHash' index to load transactions in order for the 'getAccountTransactions' RPC. the impact of the one-to-one datastore is that the RPC would miss transactions that the account has.

Testing Plan

  • adds unit test for loading multiple transactions from the same block
  • manual testing of migration
  • manual testing of wallet:transactions after migration

Breaking Change

Is this a breaking change? If yes, add notes below on why this is breaking and
what additional work is required, if any.

[ ] Yes

@hughy hughy marked this pull request as ready for review March 8, 2023 17:46
@hughy hughy requested a review from a team as a code owner March 8, 2023 17:46
Copy link
Member

@dguenther dguenther left a comment

Choose a reason for hiding this comment

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

Tested upgrading from a 0.1.71 wallet database with several miners fee transactions, and they still loaded on this branch. Looks like there are some conflicts

it's possible for multiple transactions to have the same timestamp in a wallet.

for example, if an account receives two transactions that are on the same block,
but did not sync those transactions until they were on the chain, then both
transactions will have the block header timestamp.

this example might occur in practice if a node was offline when the transactions
were first created and/or did not receive the transactions in gossip messages
before they were added to the chain.

this might also happen for an account that is imported to a wallet after the
transactions were added to the chain. when rescanning the chain for the imported
account all transactions will use the timestamp of the block header of the block
they are found on.

we use the 'timestampToTransactionHash' index to load transactions in order for
the 'getAccountTransactions' RPC. the impact of the one-to-one datastore is that
the RPC would miss transactions that the account has.
ensure that the right transactions are returned from getTransactionsByTime in
the expected order
do not expect on ordering for accountA transactions - fixture generation sets
        the timestamps for pending transactions to be equal to the time of the
        test run, so we cannot maintain ordering on these timestamps right now
@hughy hughy merged commit 78139ab into staging Mar 10, 2023
@hughy hughy deleted the fix/timestamp-to-many-tx branch March 10, 2023 20:51
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.

None yet

3 participants