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

Allow replacing pending transactions #846

Merged
merged 9 commits into from
Nov 16, 2020
Merged

Conversation

iamdefinitelyahuman
Copy link
Member

What I did

Add the TransactionReceipt.replace method for replacing pending transactions.

Closes #726

How I did it

The logic flow for creating a TransactionReceipt had to be modified slightly. Creating the object is now optionally-blocking via the is_blocking kwarg (this had to be done to avoid making a breaking change). When broadcasting, the object is initially created via a non-blocking call, then added to history, then if required_confs is non-zero it calls wait to block until the necessary confirmations. By using this approach, each tx object is added to history immediately, so that users can CTRL-C and still access the pending the tx.

Replacement happens via TransactionReceipt.replace which accepts either an increment modifier or gas_price absolute and returns a new tx object.

As soon as any one transaction confirms, the other tx's are marked with status -2 (dropped) and removed from history.

How to verify it

This is difficult to write tests for. I've played with it a fair bit on the mainnet and everything seems to work, but unfortunately I think the only real test here is to release and solve bugs are they appear.

Comment on lines +64 to +65
Pending = -1
Reverted = 0
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like these two should be swapped?

Copy link
Member Author

Choose a reason for hiding this comment

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

0 and 1 are standard values to represent reverted and successful in a txreceipt. Brownie has used -1 for pending since forever, modifying it would be a breaking change 😬

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.

Allow manual repricing of pending transactions
2 participants