-
Notifications
You must be signed in to change notification settings - Fork 4
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
On transaction failure, fetch revert reason with replayed transaction #57
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does look LGTM, but honestly I don't have that good understanding here so I would leave approval to @markspanbroek
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
822dc67
to
28c3c82
Compare
28c3c82
to
6f41cbc
Compare
Ready for another review 👍 |
Note: nim-chronicles was added in this PR (originally was in #55), with some discussion around not including it due to it not being versioned. It does, however appear to be versioned, but I'm not entirely sure if this is enough. The other option, which would suit a future PR, is to add chronicles as an optional dependency. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great @emizzle! This is going to help us a lot in debugging transactions.
ethers.nimble
Outdated
@@ -4,6 +4,7 @@ description = "library for interacting with Ethereum" | |||
license = "MIT" | |||
|
|||
requires "nim >= 1.6.0" | |||
requires "chronicles >= 0.10.3 & < 0.10.4" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would be a little less strict in the patch version; allowing all 0.10.x is probably ok.
requires "chronicles >= 0.10.3 & < 0.10.4" | |
requires "chronicles >= 0.10.3 & < 0.11.0" |
ethers/testing.nim
Outdated
@@ -1,4 +1,5 @@ | |||
import std/strutils | |||
import ./contract |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused import?
testmodule/testContracts.nim
Outdated
@@ -5,6 +5,7 @@ import pkg/questionable | |||
import pkg/stint | |||
import pkg/ethers | |||
import pkg/ethers/erc20 | |||
import pkg/ethers/wallet |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused import?
549a2e7
to
efc8ec0
Compare
…t estimateGas failure
- remove auto-cancellation of failed transaction (failed during estimate gas) to prevent stuck txs - replace it with an async lock during nonce sequencing + gas estimation - simplified cancelTransaction (still exported) such that the new transaction is populated using populateTransaction, so that all gas and fees are reset - moved reverting contract function into its own testing helpers module, and refactored any tests to use it - updated the test helper reverts to check EstimateGasErrors
This would allow applications to use the nonce in case of an error, eg cancel the transaction to prevent stuck txs from occurring
eth_getTransactionByHash responses from geth don't include data, and there was an exception raised, "key not found: data"
…r Transaction object
Add transactionType and chainId to PastTransaction, so they can be sent along with replayed txs
somehow this didn't break the nim-ethers tests?
- remove auto cancellation of failed tx (during estimate gas) - add asynclock to populate transaction, to ensure nonce sequence (signer level) - move checking of receipt status and obtaining revert reason from contract level to provider level
efc8ec0
to
8c363f2
Compare
When calling
.sendTransaction
, the flow is:estimateGas
In step 1, if there is an error during gas estimation, an
EstimateGasError
is raised with the revert reason.In step 2, if the transaction receipt is returned with a status of failed (requires the transaction to be confirmed), the transaction is replayed at the previous block (the full state transitions of the previous block are including, and the state transitions from earlier txs of the same block are not included), and a revert reason is obtained from the replay. A
ProviderError
is raised with the revert reason.The replay flow is:
PastTransaction
typePastTransaction
to aTransaction
eth_sendTransaction
, and providing the transaction object and a block number.NOTE: