Handle contract custom errors in redemptions - #782
Open
evgeny-stakewise wants to merge 1 commit into
Open
Conversation
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.
Adds custom error decoding to the redemption transaction paths, following the pattern already used in the harvest task.
Custom error handling
OsTokenRedeemerContractnow mixes inErrorMixin, so reverts can be decoded against its own ABI merged with the sharedErrors.jsonlibrary ABI.Three call sites in
src/redemptions/execution.pygo throughos_token_redeemer_contractdirectly rather than the multicall contract, and none of them decoded reverts:tx_process_exit_queuetx_manager.transacttx_redeem_positiontx_manager.transact%rsimulate_redeem_position.call()%rEach now catches
ContractCustomErrorfirst and logsdecode_custom_error(str(e.data)) or e.data. Verified against the real ABI:0x09bde339decodes toInvalidProof(),0x4ca88867toAccessDenied().tx_update_vaults_stateis left alone — it submits through the multicall contract.Exception handling cleanup
The
except (Web3Exception, RuntimeError, ValueError)tuples were stale.RuntimeErrordated back to when these sites wrapped a helper that raisedRuntimeErroron a failed receipt; that helper is long gone andtx_manager.transactsignals failure by returningNone.ValueErrorpredates web3 v7, where every error subclassesWeb3Exception. Both catches are now plainexcept Exception, so a single bad position cannot abort a whole redemption run.Unconfirmed vs failed transactions
tx_manager.transactreturnsNoneon timeout, onstatus == 0, and on exhausted send retries — so "failed" was misleading. Reworded the three receipt checks in the file to the house pattern (Failed to confirm <thing> tx).tx_update_vaults_stateno longer raisesRuntimeError; it returns the tx hash orNone, andupdate_vaults_statestops the chunk loop and returns a bool.process_redeemernow skips the redemption pass when the state update did not fully succeed — previously theRuntimeErroraborted the run, and simply dropping it would have let redemptions proceed against stale withdrawable assets and LTVs.error_verboselog_verboselogs only the exception instance, so the message describing what failed is lost. Addederror_verbose(msg, *args)insrc/common/utils.py, mirroring thelogger.errorsignature and delegating tologger.exceptionwhen verbose is on. Wired into the two redemption sites that previously logged tracebacks unconditionally.Note:
error_verbosemakessettings.verbosea runtime dependency of any code path that calls it, so unit tests reaching those paths need thefake_settingsfixture.Tests
update_vaults_statereturn flag, including the stop-on-failure and stop-on-unconfirmed casesprocess_redeemerskipping redemption on a failed state updateerror_verbosepreserving the message in both modes, withexc_infoattached only when verbose