Skip to content

feat: decode Solidity revert reasons (CPL-175)#246

Merged
GTC6244 merged 5 commits intomainfrom
feature/cpl-175-decode-opcodes
Mar 31, 2026
Merged

feat: decode Solidity revert reasons (CPL-175)#246
GTC6244 merged 5 commits intomainfrom
feature/cpl-175-decode-opcodes

Conversation

@GTC6244
Copy link
Copy Markdown
Contributor

@GTC6244 GTC6244 commented Mar 31, 2026

Summary

Adds a decode_revert utility 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) and Panic(uint256) (0x4e487b71) with no ethers dependency. 10 unit tests covering happy paths, edge cases, and error boundaries.

Contract wrapper (lit-api-server): Decodes AccountConfigErrors custom errors (AccountDoesNotExist, InsufficientBalance, NoAccountAccess, etc.) using the ethers-generated ABI bindings, with fallback to the generic decoder.

Wiring: send_transaction and add_group simulation call now surface decoded revert reasons instead of raw contract errors.

Test Coverage

Tests: 10 passed, 0 failed
Coverage: 10/13 code paths tested (77%)
  lit-core decoder: 9/9 paths tested
  lit-api-server wrapper: requires ethers mocking (integration-level)

Pre-Landing Review

No blocking issues. Informational findings acknowledged:

  • Read-only .call().await? sites not yet wired (acceptable for v1, can extend later)
  • Error chain flattened to string (design choice for human-readable messages)

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

  • All lit-core decode_revert tests pass (10 tests)
  • lit-api-server compiles cleanly

🤖 Generated with Claude Code

Garandor and others added 2 commits March 30, 2026 22:06
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>
Comment thread lit-core/lit-core/src/utils/decode_revert.rs Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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-core for standard Error(string) and Panic(uint256) encodings.
  • Added an lit-api-server wrapper that decodes AccountConfig custom errors via ethers bindings with fallback to the generic decoder.
  • Wired decoded revert messages into send_transaction and add_group simulation 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.

Comment thread lit-core/lit-core/src/utils/decode_revert.rs
Comment thread lit-core/lit-core/src/utils/decode_revert.rs Outdated
Comment thread lit-core/lit-core/src/utils/decode_revert.rs Outdated
Comment thread lit-api-server/src/accounts/decode_revert.rs Outdated
Comment thread lit-api-server/src/accounts/decode_revert.rs Outdated
GTC6244 and others added 3 commits March 31, 2026 11:28
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>
@GTC6244 GTC6244 changed the base branch from next to main March 31, 2026 15:48
@GTC6244 GTC6244 merged commit 216808b into main Mar 31, 2026
21 checks passed
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.

3 participants