Skip to content

feat: refine contract deployment transaction validation - #5

Open
lily309 wants to merge 1 commit into
masterfrom
feat/refine-contract-deployment-validation
Open

feat: refine contract deployment transaction validation#5
lily309 wants to merge 1 commit into
masterfrom
feat/refine-contract-deployment-validation

Conversation

@lily309

@lily309 lily309 commented Sep 4, 2026

Copy link
Copy Markdown
Owner

Why is this needed?

This PR refines two existing validation behaviors for contract deployment transactions.

The code_hash and trx_hash fields supplied during contract deployment are unused. They do not participate in deployment processing or affect the deployment result. Since these fields have no functional meaning as deployment inputs, transactions carrying them should be preventively prohibited at the protocol level.

Contract name length validation already exists, but its current calculation relies on String.getBytes(), which depends on the system default charset. The calculation should use the original protobuf byte representation so that the same deployment transaction is evaluated consistently across environments.

Historical transaction scan

We performed a complete scan of all historical transactions across the full chain history.

No historical contract deployment transaction was found with either code_hash or trx_hash set. The number of historical transactions carrying either field is zero.

This confirms that existing contract deployments have never relied on these fields. The restriction does not invalidate any historical transaction or alter existing user behavior.

Implementation

After activation:

  • A deployment transaction containing a non-empty code_hash or trx_hash is rejected using the existing timeout semantics immediately before its contract code is persisted.
  • Contract name length is calculated directly from the original protobuf bytes instead of using the system-dependent string encoding.

Before activation, the existing behavior is preserved.

Normal contract deployments do not populate the hash fields, and ordinary contract names are unaffected by the length-calculation adjustment.

Compatibility

Both changes are controlled by VERSION_4_8_2_2, with an activation threshold of 70%.

This PR currently uses the same fork version introduced by #6920. If the version identifier or activation parameters in #6920 change, this PR should be updated accordingly.

Tests

  • Verified code_hash and trx_hash behavior before and after activation.
  • Verified empty hash fields remain unaffected.
  • Verified contract names at the 32-byte boundary.
  • Verified contract names exceeding the 32-byte boundary.
  • Verified multibyte names are calculated using protobuf bytes.
  • Verified pre-activation compatibility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants