Skip to content

Conversation

@ecPablo
Copy link
Contributor

@ecPablo ecPablo commented Nov 26, 2025

Adds execution error decode command. This command takes a JSON for an mcms-tools results json and attempts to decode the error revert reason using the ABI registries injected by the proposal context.

TODO: Remove local replace once mcmslib is released with smartcontractkit/mcms#547

.

AI Summary

This pull request introduces significant improvements to error decoding for EVM transaction failures, adds a new CLI command for error decoding, and includes dependency updates. The most notable changes are the addition of robust helpers for decoding EVM execution errors, comprehensive tests for these helpers, and a new CLI command to decode errors from JSON files using the ABI registry. Several dependencies in go.mod have also been updated.

EVM Error Decoding Enhancements

  • Added DecodedExecutionError struct and tryDecodeExecutionError function in err_decode_helpers.go to extract and decode revert reasons and underlying reasons from EVM execution errors, handling both custom and standard errors, and supporting decoding with or without an ABI registry.
  • Introduced decodeRevertData and decodeRevertDataFromBytes helpers to convert hex or byte revert data into human-readable error messages, falling back to custom error selectors if no decoder is available.

CLI Improvements

  • Added a new CLI command error-decode-evm in mcms_v2.go that reads a JSON file containing transaction error data, loads the ABI registry from the specified environment, decodes the error using the new helpers, and prints the decoded revert and underlying reasons. [1] [2]

Testing

  • Added a comprehensive test Test_tryDecodeExecutionError in err_decode_helpers_test.go that covers decoding custom errors, standard errors, selectors, underlying reasons, and nil/empty cases for the new error decoding logic.

Dependency Updates

  • Updated several dependencies in go.mod, including github.com/smartcontractkit/chain-selectors, github.com/smartcontractkit/chainlink-testing-framework/framework, golang.org/x/oauth2, and others. Also, replaced the github.com/smartcontractkit/mcms dependency to use a local path. [1] [2] [3] [4] [5] [6] [7]

Minor Improvements

  • Improved error logging and error joining in the MultiClient.retryWithBackups method for more informative logs when retryable errors occur.
  • Cleaned up unnecessary comments in maybeDataErr for code clarity.

These changes collectively improve the developer experience when diagnosing and understanding EVM transaction failures, both programmatically and via the CLI.

@changeset-bot
Copy link

changeset-bot bot commented Nov 26, 2025

🦋 Changeset detected

Latest commit: 42702ae

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
chainlink-deployments-framework Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@ecPablo ecPablo marked this pull request as ready for review November 28, 2025 14:40
@ecPablo ecPablo requested a review from a team as a code owner November 28, 2025 14:40
Copilot AI review requested due to automatic review settings November 28, 2025 14:40
Copy link
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 adds functionality to decode EVM execution errors using ABI registries, including a new CLI command, comprehensive error decoding helpers, and dependency updates. The implementation enables users to decode transaction error data from JSON files by leveraging the domain's ABI registry for human-readable error messages.

Key changes:

  • Added tryDecodeExecutionError and supporting functions to decode execution errors with or without an ABI registry
  • Introduced error-decode-evm CLI command that reads JSON files containing transaction errors and decodes them using the environment's ABI registry
  • Updated several dependencies including mcms, chain-selectors, and testing framework packages

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
go.mod Updated dependency versions for mcms, chain-selectors, chainlink-testing-framework, and other packages
engine/cld/legacy/cli/mcmsv2/mcms_v2.go Added new CLI command error-decode-evm to decode transaction errors from JSON files
engine/cld/legacy/cli/mcmsv2/err_decode_helpers_test.go Added comprehensive test coverage for the new error decoding functionality
engine/cld/legacy/cli/mcmsv2/err_decode_helpers.go Implemented error decoding helpers including tryDecodeExecutionError and supporting functions
chain/evm/provider/rpcclient/multiclient.go Enhanced error logging by joining original error with decoded error data

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@gustavogama-cll gustavogama-cll left a comment

Choose a reason for hiding this comment

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

looks good overall, but we should apply the fixes suggested by Copilot before merging.

As a future enhancement, I'd suggest making the error-file optional and accepting the encoded error from stdin by default.

Oh, and we're also missing a changeset.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings November 28, 2025 19:04
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
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

Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings November 28, 2025 19:10
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
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

Copilot reviewed 5 out of 6 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings November 28, 2025 19:12
Copy link
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

Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings November 28, 2025 19:17
Copy link
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

Copilot reviewed 6 out of 7 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings November 28, 2025 19:47
Copy link
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

Copilot reviewed 6 out of 7 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

// Create ProposalContext to get EVM registry
proposalCtx, err := analyzer.NewDefaultProposalContext(env)
if err != nil {
lggr.Warnf("Failed to create default proposal context: %v. Proceeding without ABI registry.", err)
Copy link

Copilot AI Nov 28, 2025

Choose a reason for hiding this comment

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

After warning about the failed proposal context, the code proceeds but doesn't set proposalCtx to nil or handle the case where it might be in a partially initialized state. Consider explicitly setting proposalCtx = nil after this warning to ensure consistent behavior in the checks below.

Suggested change
lggr.Warnf("Failed to create default proposal context: %v. Proceeding without ABI registry.", err)
lggr.Warnf("Failed to create default proposal context: %v. Proceeding without ABI registry.", err)
proposalCtx = nil

Copilot uses AI. Check for mistakes.
}
}

if hasSelector && !hasData {
Copy link

Copilot AI Nov 28, 2025

Choose a reason for hiding this comment

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

The logic checks hasSelector && !hasData on line 673, but when hasData is true and decoding fails (lines 668-670), it doesn't try the selector. Consider attempting selector-based decoding as a fallback when data-based decoding fails, by changing line 673 to just if hasSelector to cover both cases where data decoding failed and where there's no data.

Suggested change
if hasSelector && !hasData {
if hasSelector {

Copilot uses AI. Check for mistakes.
@cl-sonarqube-production
Copy link

@ecPablo ecPablo added this pull request to the merge queue Nov 28, 2025
Merged via the queue into main with commit c0b7401 Nov 28, 2025
16 checks passed
@ecPablo ecPablo deleted the ecpablo/add-err-decode-command branch November 28, 2025 21:38
github-merge-queue bot pushed a commit that referenced this pull request Dec 2, 2025
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## chainlink-deployments-framework@0.71.0

### Minor Changes

-
[#604](#604)
[`c0b7401`](c0b7401)
Thanks [@ecPablo](https://github.com/ecPablo)! - add error decode
command

---------

Co-authored-by: app-token-issuer-engops[bot] <144731339+app-token-issuer-engops[bot]@users.noreply.github.com>
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