Skip to content
This repository has been archived by the owner on Nov 10, 2023. It is now read-only.

fix: cache block of pending transaction #3718

Merged
merged 2 commits into from
Mar 28, 2022
Merged

fix: cache block of pending transaction #3718

merged 2 commits into from
Mar 28, 2022

Conversation

iamacook
Copy link
Member

What it solves

Slow clearance of pending transactions

How this PR fixes it

Instead of the pending watcher waiting for the current block + 50 to clear an (unsuccessful) pending transaction upon wallet connection, the block number upon executing a transaction is cached. The watcher now waits for cached block number (if it exists) + 50 instead. It falls back to the current block number if the original block number retrieval failed.

How to test it

  1. Create a queued transaction.
  2. Execute the transaction with a very low gas limit.
  3. Cancel the transaction with a high gas limit and immediately refresh.
  4. The transaction should clear exactly 50 blocks post block stored under the transaction id in the store.

@iamacook iamacook self-assigned this Mar 23, 2022
@github-actions
Copy link

CLA Assistant Lite All Contributors have signed the CLA.

@github-actions
Copy link

github-actions bot commented Mar 23, 2022

ESLint Summary View Full Report

Annotations are provided inline on the Files Changed tab. You can also see all annotations that were generated on the annotations page.

Type Occurrences Fixable
Errors 0 0
Warnings 0 0
Ignored 2 N/A
  • Result: ✅ success
  • Annotations: 0 total

Report generated by eslint-plus-action

@github-actions
Copy link

Deployment links

🟠 Rinkeby Mainnet 🟣 Polygon 🟡 BSC Arbitrum 🟢 Gnosis Chain

@coveralls
Copy link

coveralls commented Mar 23, 2022

Pull Request Test Coverage Report for Build 2028277882

  • 11 of 16 (68.75%) changed or added relevant lines in 4 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.006%) to 35.158%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/logic/safe/store/reducer/pendingTransactions.ts 0 1 0.0%
src/logic/safe/store/actions/pendingTransactions.ts 2 6 33.33%
Totals Coverage Status
Change from base Build 2027159306: 0.006%
Covered Lines: 3409
Relevant Lines: 8770

💛 - Coveralls

Copy link
Member

@DiogoSoaress DiogoSoaress left a comment

Choose a reason for hiding this comment

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

Looks good to me!

Copy link
Member

@usame-algan usame-algan left a comment

Choose a reason for hiding this comment

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

Well done 👍

@francovenica
Copy link
Contributor

Looks good to me

Created a tx with low gas and cancelled it in the MM extension with higher gas. As soon as the cancelation was succesful in the blockexplorer the tx changed from "peding" to "needs execution"
Tried the same by creating a tx that I knew will fail: queue a tx sending .01 Eth and then another one that sends all Eth. Execute the first tx and trying to execute the 2nd one will fail since the safe doesn't have enough funds anymore. The tx switched from "pending" to "need execution" once again as soon the tx failed in the block explorer

@iamacook iamacook merged commit b2e42db into dev Mar 28, 2022
@iamacook iamacook deleted the cache-pending-block branch March 28, 2022 06:23
@github-actions github-actions bot locked and limited conversation to collaborators Mar 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants