Giter Site home page Giter Site logo

allchain / plunger Goto Github PK

View Code? Open in Web Editor NEW

This project forked from makerdao/plunger

0.0 1.0 0.0 75 KB

Tool for overriding Ethereum transactions stuck in the pool

License: GNU Affero General Public License v3.0

Shell 0.08% Python 13.83% HTML 86.09%

plunger's Introduction

Plunger

Tool helping to deal with Ethereum transactions stuck in the pool.

Build Status codecov Code Climate Issue Count

https://chat.makerdao.com/channel/keeper

Rationale

Due to periodic Ethereum network congestion, transactions can easily get stuck in the transaction pool for many hours if not days. plunger is a tool that helps to deal with such situations by either overriding them with zero-valued transactions with higher gas price, or just waiting for them to clear themselves. It also allows you to list pending transactions for manual inspection.

plunger has been created during development of the Maker Keeper Framework. It is essential to run each keeper from an individual address that does not have any pending transactions. That is why before starting each keeper, doing a plunger --source parity_txqueue --wait 0x..... is recommended.

If you want to discuss this tool, the best place is the #keeper channel in the Maker RocketChat, linked above.

Installation

This project uses Python 3.6.2.

In order to clone the project and install required third-party packages please execute:

git clone https://github.com/makerdao/plunger.git
cd plunger
pip3 install -r requirements.txt

Known macOS issues

In order for the requirements to install correctly on macOS, please install openssl, libtool and pkg-config using Homebrew:

brew install openssl libtool pkg-config

and set the LDFLAGS environment variable before you run pip3 install -r requirements.txt:

export LDFLAGS="-L$(brew --prefix openssl)/lib" CFLAGS="-I$(brew --prefix openssl)/include" 

Usage

usage: plunger [-h] [--rpc-host RPC_HOST] [--rpc-port RPC_PORT]
               [--gas-price GAS_PRICE] --source SOURCE
               (--list | --wait | --override-with-zero-txs)
               address

positional arguments:
  address               Ethereum address to check for pending transactions

optional arguments:
  -h, --help            show this help message and exit
  --rpc-host RPC_HOST   JSON-RPC host (default: `localhost')
  --rpc-port RPC_PORT   JSON-RPC port (default: `8545')
  --gas-price GAS_PRICE
                        Gas price (in Wei) for overriding transactions
  --source SOURCE       Comma-separated list of sources to use for pending
                        transaction discovery (available: etherscan,
                        parity_txqueue)
  --list                List pending transactions
  --wait                Wait for the pending transactions to clear
  --override-with-zero-txs
                        Override the pending transactions with zero-value txs

Listing pending transactions

If you want plunger to only list pending transactions originating from the specified address, call it with the --list argument:

bin/plunger --source etherscan,parity_txqueue --list 0x0101010101010101010101010101010101010101

Waiting for pending transactions to clear

If you want plunger to just wait for the pending transactions from the specified address to get processed by the network (i.e. to get mined), run it with the --wait argument:

bin/plunger --source etherscan,parity_txqueue --wait 0x0101010101010101010101010101010101010101

This is a completely passive mode i.e. no Ethereum transactions get sent by plunger if called with --wait.

Plunger will not terminate until all pending transactions get mined. If it for some exceptional reason (the Ethereum node going down or some other network connectivity issues) terminates earlier than that, it will return a non-zero exit code.

Overriding pending transactions

If you want plunger to try to override all pending transactions with a zero Wei ether transfer but with gas cost higher than the original, run it with the --override-with-zero-txs argument:

bin/plunger --source etherscan,parity_txqueue --override-with-zero-txs 0x0101010101010101010101010101010101010101

Plunger will send replacement transactions immediately, then it will start monitoring the network and will not terminate until all pending transactions or their replacements get mined. Due to the nature of the Ethereum network, there is no guarantee which transactions will actually get executed. It is possible that some of the original stuck ones will actually get through. You can also get a mix of old and new ones being mined when there is more than one transaction pending.

If for some exceptional reason (the Ethereum node going down or some other network connectivity issues) plunger terminates before all pending transactions from the specified address get mined, it will return a non-zero exit code.

The account specified has to be unlocked for plunger to be able to sign and send replacement transactions.

Gas price

Gas price for overriding transactions can be specified using the --gas-price argument. If this argument is not present, plunger will use the default gas price suggested by the Ethereum node it is connected to.

Bear in mind that the new gas price has to be at least 10% higher than the original one, otherwise Parity will not even accept such a replacement transaction. If it happens, plunger will display an error message but will still wait for the pending transactions to get mined as it is still possible the original one will go through.

Pending transactions discovery

The --source argument has to be used to specify how plunger should discover pending transactions. Currently it can either query etherscan.io (--source etherscan) or look for them in the Parity transaction queue (--source parity_txqueue). Bear in mind that it is a custom Parity RPC endpoint and so this latter method will not work with geth.

Both discovery methods can be used at the same time (--source etherscan,parity_txqueue).

The etherscan.io integration works by scraping their website as the API exposed by them does not give access to pending transactions.

Testing

Automated testing

A unit-test harness is present for testing almost all plunger features. It can be run with the ./test.sh script, preceded by installing necessary dependencies with pip3 install -r requirements-dev.txt.

Manual testing

The following commands can be used to manually test plunger. The first two commands send 1 Wei transfers with a pretty low gas price of 0.5 GWei, so they won't instantly get mined and will very likely get stuck. The third command runs plunger using the same account, so if everything works correctly we can see these two transactions being plunged.

export ETH_FROM=0x001.......

seth send --async --gas-price=500000000 --value=1 -F $ETH_FROM $ETH_FROM
seth send --async --gas-price=500000000 --value=1 -F $ETH_FROM $ETH_FROM

bin/plunger --source parity_txqueue --override-with-zero-txs $ETH_FROM

The above snippet uses seth (see https://github.com/dapphub/dapptools/tree/master/src/seth) for sending transactions.

License

See COPYING file.

plunger's People

Contributors

blinkystitt avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.