feat: decode Solidity revert reasons (CPL-175)#246
Merged
Conversation
Self-hosted runners retain files between workflow runs, causing `gh release download` to fail when deploy-context.json already exists. Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add a generic Solidity revert decoder in lit-core that handles Error(string) and Panic(uint256) without ethers dependency, and a contract-specific wrapper in lit-api-server that decodes AccountConfig custom errors. Wire into send_transaction and add_group simulation call paths so contract reverts surface the actual error reason instead of opaque gas price messages. Closes CPL-175 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves the API/server error surface area for EVM interactions by decoding Solidity revert data into human-readable messages, replacing opaque contract/transaction failures with decoded revert reasons.
Changes:
- Added a generic revert decoder to
lit-corefor standardError(string)andPanic(uint256)encodings. - Added an
lit-api-serverwrapper that decodesAccountConfigcustom errors via ethers bindings with fallback to the generic decoder. - Wired decoded revert messages into
send_transactionandadd_groupsimulation error paths.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
lit-core/lit-core/src/utils/mod.rs |
Exposes the new decode_revert utility module. |
lit-core/lit-core/src/utils/decode_revert.rs |
Implements and tests the core decoder for standard Solidity revert formats. |
lit-api-server/src/accounts/decode_revert.rs |
Adds contract-specific + generic revert decoding for AccountConfig errors. |
lit-api-server/src/accounts/signable_contract.rs |
Uses decoded revert messages when transaction submission fails. |
lit-api-server/src/accounts/mod.rs |
Uses decoded revert messages for add_group simulation failures. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Clippy's empty_line_after_doc_comments lint flagged the module-level doc comment as a regular doc comment (///) with an empty line before the next item. Convert to inner doc comments (//!) to properly document the module. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Validate ABI offset word is 0x20 in Error(string) decoding - Reject non-zero high bytes in length and panic code words - Use checked_add to prevent integer overflow on 64 + len - Reorder decode_contract_revert to try standard Error(string) before AccountConfigErrors, so revert strings are labelled consistently as "Revert: ..." instead of "Contract error: ..." - Truncate unknown revert hex output to 64 bytes max Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a
decode_revertutility that decodes Solidity revert reasons from raw EVM error data, replacing opaque "gas price issue" error messages with the actual contract error.Core decoder (lit-core): Generic Solidity revert decoder handling
Error(string)(0x08c379a0) andPanic(uint256)(0x4e487b71) with no ethers dependency. 10 unit tests covering happy paths, edge cases, and error boundaries.Contract wrapper (lit-api-server): Decodes
AccountConfigErrorscustom errors (AccountDoesNotExist, InsufficientBalance, NoAccountAccess, etc.) using the ethers-generated ABI bindings, with fallback to the generic decoder.Wiring:
send_transactionandadd_groupsimulation call now surface decoded revert reasons instead of raw contract errors.Test Coverage
Pre-Landing Review
No blocking issues. Informational findings acknowledged:
.call().await?sites not yet wired (acceptable for v1, can extend later)TODOS
Related: "Server should return 403 for management permission denials" — this PR enables that work by making contract error types decodable, but does not implement the HTTP status mapping.
Test plan
🤖 Generated with Claude Code