fix: remove dead branches in _encode_args and compact length encoder - #988
Closed
aliangm wants to merge 1 commit into
Closed
fix: remove dead branches in _encode_args and compact length encoder#988aliangm wants to merge 1 commit into
aliangm wants to merge 1 commit into
Conversation
aliangm
force-pushed
the
fix-contract-dead-branches
branch
from
May 5, 2026 10:22
d6e69c6 to
e03bd7f
Compare
Collaborator
|
Branches are unreachable as the issue notes; replacing them with |
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.
Fixes #987
Summary
Removes three dead/unreachable branches in
contract_client.pythat contained incorrect code and replaced them with assertions that make the invariants explicit.elsebranch (_call_contract_method_raw):input_datais always a 4-byte selector sodata_lenis always 4 — theelse(data_len ≥ 64) was never reached. The formula was also wrong:(data_len << 2) | 1overflows a single byte for data_len ≥ 64, producing aValueErrorif ever triggered.u128branch in_encode_args: onlyregister_issueusesu128, but that method is called from the CLI via a different execution path (ContractInstance.exec), never through_exec_contract_raw→_encode_args.else: raise ValueErrorfallback in_encode_args: onlystr(fromregister_issue) andunknown(fromget_issues_by_status) would reach this branch — neither method is routed through_encode_args.Changes
if/elsewithassert data_len < 64u128encoder branchraise ValueErrorfallback withassert Falseand an explanatory messageTesting
No behavior change for any current caller. The assertions will surface loudly if a future refactor accidentally routes a new method through these paths.