Fix Address.fromString string corruption bug #6092
Open
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.
Summary
Fixes issue #6067 where specific Ethereum addresses would cause
Address.fromString()
to fail with empty string and "Invalid input length" error.The bug was caused by aggressive null character removal during UTF-16 to UTF-8 string conversion that could corrupt address strings in certain cases.
Root Cause Analysis
FromAscObj<AscString>
implementation strips null characters for Postgres compatibilityChanges Made
Enhanced String Conversion (
runtime/wasm/src/to_from/mod.rs
)Improved Error Messages (
runtime/wasm/src/host_exports.rs
)string_to_h160()
function with comprehensive validationComprehensive Test Suite (
runtime/test/src/test/address_from_string.rs
)0x3b44b2a187a7b3824131f8db5a74194d0a42fc15
Test plan
Before/After Error Messages
Before:
After:
This provides users with clear information about what went wrong and actionable next steps.
🤖 Generated with Claude Code