Fix constructor input decoding to preserve full ABI payload#954
Open
Copilot wants to merge 4 commits into
Open
Fix constructor input decoding to preserve full ABI payload#954Copilot wants to merge 4 commits into
Copilot wants to merge 4 commits into
Conversation
* Initial plan * Remove fisco-bcos.org URL, replace with GitHub repo URL in build.gradle Co-authored-by: kyonRay <32325790+kyonRay@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: kyonRay <32325790+kyonRay@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix ContractCodec.decodeConstructorInput to avoid stripping bytes
Fix constructor input decoding to preserve full ABI payload
Jun 16, 2026
kyonRay
approved these changes
Jun 17, 2026
kyonRay
approved these changes
Jun 17, 2026
There was a problem hiding this comment.
Pull request overview
Fixes ContractCodec.decodeConstructorInput(...) to decode constructor calldata correctly by decoding the full ABI-encoded parameter payload (constructor input has no 4-byte selector to strip), aligning behavior with decodeConstructorInputToString(...).
Changes:
- Route
decodeConstructorInput(...)through direct ABI payload decoding (instead of method-input decoding that strips 4 bytes). - Add a regression test that round-trips constructor params (
uint256,string) and asserts object/string decode consistency.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/main/java/org/fisco/bcos/sdk/v3/codec/ContractCodec.java | Updates constructor input decoding to avoid dropping the first 4 bytes and decode full parameter payload. |
| src/test/java/org/fisco/bcos/sdk/v3/test/codec/ABICodecTest.java | Adds a focused constructor decode test with parameters to prevent regressions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+684
to
+691
| try { | ||
| return ContractCodecTools.decodeJavaObject(inputObject, paramsInput, isWasm); | ||
| } catch (Exception e) { | ||
| logger.error(" exception in decodeConstructorInput : {}", e.getMessage()); | ||
| } | ||
| String errorMsg = " cannot decode in decodeConstructorInput with appropriate interface ABI"; | ||
| logger.error(errorMsg); | ||
| throw new ContractCodecException(errorMsg); |
|
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.



ContractCodec.decodeConstructorInput(abi, bin, input)was decoding constructor args through the method-input path, which incorrectly drops the first 4 bytes as if a function selector were present. Constructor calldata has no selector after the bytecode, so the first parameter was truncated and decoded incorrectly.Constructor decode path
decodeConstructorInput(...)through direct ABI payload decoding instead ofdecodeMethodAndGetInputObject(...).decodeConstructorInputToString(...), which already decodes the full constructor parameter bytes.Regression coverage
uint256,string).decodeConstructorInput(...)now returns the same values represented by the already-correct string decode path.Behavioral impact