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

feat: introduces verbose actionable error messaging #592

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

dutterbutter
Copy link
Collaborator

Closed #571 in favour of this PR given all the changes since then.

The following etc/errors/anvil.json json file outlines the errors that could be hit based on the errors defined here. To make it easier to review and have discussion please refer to this Notion page where the json schema and display are also present for easier dialogue. Feedback would be appreciated, especially as many error cases I am unfamiliar with so assistance in properly defining cause / fixes would be helpful.

cc: @sayon @itegulov @popzxc

What 💻

Why ✋

  • Provide the user with informative and actionable error messaging

Evidence 📷

Include screenshots, screen recordings, or console output here demonstrating that your changes work as intended

Previous errors shown

03:11:55  INFO Unable to estimate gas for the request with our suggested gas limit of 104010000. The transaction is most likely unexecutable. Breakdown of estimation:
03:11:55  INFO 	Estimated transaction body gas cost: 80000000
03:11:55  INFO 	Gas for pubdata: 0
03:11:55  INFO 	Overhead: 10000
03:11:55  INFO execution reverted: Account validation error: Error function_selector = 0x03eb8b54, data = 0x03eb8b540000000000000000000000000000000000000000000000008ad7db82e7522d000000000000000000000000000000000000000000000000000010b87e5d6a2d00

Note: We print gas estimation details implying its a gas issue even though this error is the account having insufficient funds.

Defined structured errors shown

error: [anvil-halt-1] Account validation error: InsufficientFunds(uint256,uint256): 03eb8b540000000000000000000000000000000000000000000000008ad7db82e7522d000000000000000000000000000000000000000000000000000010b87e5d6a2d00
    |
    = error: Account validation failed during execution.
    | 
    | Transaction details:
    |   Transaction Type: EIP1559Transaction
    |   Nonce: 0
    |   To: 0x36615cf349d7f6344891b1e7ca7c72883f5dc049
    |   From: 0xfac041bcf2c4b43319c2c0a39aba53f4cbe44fe5
    |   Gas Limit: 0
    |   Gas Price: 0.04525000 gwei
    |   Gas Per Pubdata Limit: 50000
    | 
    | Likely causes:
    |   - Insufficient funds to cover transaction costs.
    |   - Invalid account state or credentials.
    | 
    | Possible fixes:
    |   - Add enough balance to the account to pay for gas and the transaction amount.
    |   - Verify that the account used has a valid signature and nonce.
    |
note: This error occurs when the account validation step fails during the verification and execution of a transaction.
error: transaction execution halted due to the above error

Note: same error.

Comment on lines 475 to +491
if let ExecutionResult::Halt { reason } = result.result {
// Halt means that something went really bad with the transaction execution (in most cases invalid signature,
// but it could also be bootloader panic etc).
// In such case, we should not persist the VM data, and we should pretend that transaction never existed.
anyhow::bail!("Transaction HALT: {reason}");
let reason_clone = reason.clone();

let halt_error = tokio::runtime::Handle::current().block_on(async {
tokio::task::spawn_blocking(move || {
// Create a new multi-threaded runtime explicitly.
let rt = tokio::runtime::Builder::new_multi_thread()
.enable_all()
.build()
.expect("Failed to create multi-threaded runtime");
rt.block_on(reason_clone.to_halt_error())
})
.await
.expect("spawn_blocking failed")
});

print_execution_error(&halt_error, Some(&l2_tx));
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Could use some guidance here, this fails the unit tests due to runtime error. It would be ideal if we can still handle halt reasons and provide users with an informative error message here rather than just bailing with halt reason.

Any insight on how I can handle the threading issue? I suppose I can make the unit tests multi-threaded (e.g. #[tokio::test(flavor = "multi_thread")]) but that seems like a workaround.

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.

1 participant