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

[feature] Resend txn & Handle dropped txns #70

Open
roynalnaruto opened this issue Aug 1, 2019 · 7 comments
Open

[feature] Resend txn & Handle dropped txns #70

roynalnaruto opened this issue Aug 1, 2019 · 7 comments
Labels
bounty This issue has a bounty associated with it

Comments

@roynalnaruto
Copy link
Contributor

roynalnaruto commented Aug 1, 2019

Feature

What is the feature?

This feature is covered by two scenarios.

Scenario 1 (Handling Dropped Txns)

Whenever a signed transaction is sent to the Ethereum blockchain, it is stored in the "Mempool" before getting mined in a future block. There is a limit to the size of the Mempool. In instances where the blockchain is overloaded with a large number of transactions, the Mempool eventually becomes full. This causes some pending transactions to be dropped from the Mempool.

When a transaction is dropped from the Mempool, the user needs to resend the transaction (preferably with a higher gas price). We have faced these scenarios a few times in the last couple of months. Users who are under the assumption that their transaction will be mined after the network settles down, are later surprised to note that their transaction actually cannot be found in the pending transactions as well (because it got dropped out of the Mempool).

Scenario 2 (Re-sending txns with higher gas price)

The second scenario also occurs when the blockchain network is congested. In this scenario, a user who sent a transaction with a gas price of say, 5 gwei, would have to wait for long time before their transaction is mined (if the average gas price during that time is say, 20 gwei). In such cases, some users may prefer and afford re-sending the same transaction with a higher gas price of say, 30 gwei, to force their transaction through.

In order to resend a transaction with updated gas price, this new transaction must have the same nonce as the older one. By modifying just the gas price of the transaction object, the new transaction can be signed again and sent to the Ethereum node. Both those transactions would now have the same nonce, but the latest one with a higher gas price. Whenever one of them is mined, the other is automatically dropped.

How can it be done?

Solution

The solution to both problems is to save the transaction so that it can be resent or reused later.

  • When the user signs a transaction, the UI must send the signed and raw transaction to be monitored via watchTransaction
  • When the user resends a transaction, the UI must send the transaction and send the signed and raw transaction again to update the previous transaction via resendTransaction
    • Also the same nonce must be reused for resending the transaction
    • The user is shown the same "Sign Txn" modal to update the gas price, and re-sign the txn before it can be sent again
  • A 5 minute cron job will check all watched transaction. For each watched transaction, check the status of the transaction by querying the Ethereum Blockchain:
    • If the transaction cannot be fetched, it is considered dropped
    • If the transaction is mined in a past block, delete all transactions with the same group_id to unwatch them
    • If all of the transactions of a group is dropped, resend only the latest raw signed transaction and delete the other transactions in the group.

Schema

In dao-server, create watching_transactions table consisting of the following:

  • id - Primary key for recording transactions. Prefer UUID over auto-generated integer.
  • user_id- Id of the user who signed the transaction
  • group_id - Id of the original transaction to group resent transactions. If this is the original transaction, this is just id. If this refers to a resent transaction, this refers to that transaction's id.
  • transaction_object - JSON.stringify-ied transaction object. This stores the transaction parameters to be reused when it needs to be resent with higher gas. Consult https://github.com/ethereum/wiki/wiki/JavaScript-API#web3ethsendtransaction
  • signed_transaction - Signed transaction object in HEX format. https://github.com/ethereum/wiki/wiki/JavaScript-API#web3ethsendrawtransaction
  • created_at and updated_at - Default timestamp
  • txhash - Field to index or search a transaction

GraphQL

Types:

  • WatchedTransaction
    • id (ID) - UUID of the watched transaction
    • user(User) - Signer of the transaction
    • transactionObject (String) - The JSONified transaction data object

Mutations:

  • watchTransaction
    Given a transaction, save it to the database to be resent.

    © 2019 GitHub, Inc.
    Terms
    Privacy
    Security
    Status
    Help

    Contact GitHub
    Pricing
    API
    Training
    Blog
    About

    * `signedTransaction` (String) - Signed transaction in HEX format
    
    • Output
      • watchedTransaction (WatchedTransaction) - Newly created transaction
  • resendTransaction
    Given an old transaction, resend it with new parameters or gas prices.

    • The nonce must be the same as the previous
    • The new transaction should have the same group id as the one being referred or resent.
    • Input
      • id (ID) - ID of the transaction to be resent
      • transactionObject (String) - The JSONified transaction data object
      • signedTransaction (String) - Signed transaction in HEX format
    • Output
      *watchedTransaction (WatchedTransaction) - Newly resent transaction

Query:

  • watchedTransaction
    Given a transaction txhash, find the last watched transaction in the group with that txhash .

    • Input
      • txhash (ID) - Txhash of the watched transaction
    • Output
      • watchedTransaction (WatchedTransaction) - Found transaction

Other Comments

The scenario #2 has front-end integration as well. The github issue for that is here.

@roynalnaruto roynalnaruto added the bounty This issue has a bounty associated with it label Aug 1, 2019
@gitcoinbot
Copy link

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


This issue now has a funding of 1.017 ETH (199.93 USD @ $196.59/ETH) attached to it.

@gitcoinbot
Copy link

gitcoinbot commented Aug 21, 2019

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


Work has been started.

These users each claimed they can complete the work by 267 years, 2 months from now.
Please review their action plans below:

1) bshevchenko has been approved to start work.

Will do in a most accurate way :)

Learn more on the Gitcoin Issue Details page.

@gitcoinbot
Copy link

@bshevchenko Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

  • reminder (3 days)
  • escalation to mods (6 days)

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

@bshevchenko
Copy link
Contributor

@gitcoinbot yeap

bshevchenko added a commit to bshevchenko/dao-server that referenced this issue Sep 1, 2019
bshevchenko added a commit to bshevchenko/dao-server that referenced this issue Sep 1, 2019
bshevchenko added a commit to bshevchenko/dao-server that referenced this issue Sep 2, 2019
bshevchenko added a commit to bshevchenko/dao-server that referenced this issue Sep 2, 2019
@gitcoinbot
Copy link

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


Work for 1.017 ETH (180.69 USD @ $177.67/ETH) has been submitted by:

  1. @bshevchenko

@tymat please take a look at the submitted work:


bshevchenko added a commit to bshevchenko/dao-server that referenced this issue Sep 4, 2019
bshevchenko added a commit to bshevchenko/dao-server that referenced this issue Sep 4, 2019
bshevchenko added a commit to bshevchenko/dao-server that referenced this issue Sep 4, 2019
bshevchenko added a commit to bshevchenko/dao-server that referenced this issue Sep 4, 2019
bshevchenko added a commit to bshevchenko/dao-server that referenced this issue Sep 5, 2019
bshevchenko added a commit to bshevchenko/dao-server that referenced this issue Sep 5, 2019
bshevchenko added a commit to bshevchenko/dao-server that referenced this issue Sep 9, 2019
bshevchenko added a commit to bshevchenko/dao-server that referenced this issue Sep 9, 2019
bshevchenko added a commit to bshevchenko/dao-server that referenced this issue Sep 9, 2019
bshevchenko added a commit to bshevchenko/dao-server that referenced this issue Sep 9, 2019
bshevchenko added a commit to bshevchenko/dao-server that referenced this issue Sep 9, 2019
bshevchenko added a commit to bshevchenko/dao-server that referenced this issue Sep 9, 2019
bshevchenko added a commit to bshevchenko/dao-server that referenced this issue Sep 9, 2019
bshevchenko added a commit to bshevchenko/dao-server that referenced this issue Sep 9, 2019
bshevchenko added a commit to bshevchenko/dao-server that referenced this issue Sep 10, 2019
bshevchenko added a commit to bshevchenko/dao-server that referenced this issue Sep 10, 2019
bshevchenko added a commit to bshevchenko/dao-server that referenced this issue Sep 10, 2019
bshevchenko added a commit to bshevchenko/dao-server that referenced this issue Sep 11, 2019
bshevchenko added a commit to bshevchenko/dao-server that referenced this issue Sep 11, 2019
bshevchenko added a commit to bshevchenko/dao-server that referenced this issue Sep 11, 2019
bshevchenko added a commit to bshevchenko/dao-server that referenced this issue Sep 11, 2019
bshevchenko added a commit to bshevchenko/dao-server that referenced this issue Sep 11, 2019
bshevchenko added a commit to bshevchenko/dao-server that referenced this issue Sep 11, 2019
bshevchenko added a commit to bshevchenko/dao-server that referenced this issue Sep 12, 2019
bshevchenko added a commit to bshevchenko/dao-server that referenced this issue Sep 12, 2019
@gitcoinbot
Copy link

⚡️ A tip worth 1.01700 ETH (182.63 USD @ $179.58/ETH) has been granted to @bshevchenko for this issue from @tymat. ⚡️

Nice work @bshevchenko! To redeem your tip, login to Gitcoin at https://gitcoin.co/explorer and select 'Claim Tip' from dropdown menu in the top right, or check your email for a link to the tip redemption page.

@gitcoinbot
Copy link

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


The funding of 1.017 ETH (183.94 USD @ $180.87/ETH) attached to this issue has been approved & issued to @bshevchenko.

Additional Tips for this Bounty:

  • tymat tipped 1.0170 ETH worth 183.94 USD to bshevchenko.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bounty This issue has a bounty associated with it
Projects
None yet
Development

No branches or pull requests

3 participants