Fix constructor input decoding to preserve full ABI payload#954
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>
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.
| 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); |
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## release-3.9.0 #954 +/- ##
================================================
Coverage 64.05% 64.06%
+ Complexity 4567 4566 -1
================================================
Files 430 430
Lines 17628 17634 +6
Branches 1969 1969
================================================
+ Hits 11292 11297 +5
Misses 5576 5576
- Partials 760 761 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
@copilot fix coverage |
Added focused coverage for the constructor decode paths in commit
Also re-ran |



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