Skip to content

hyptest truncates 64-byte log topics to h256 #21

Description

@moscowchill

Summary

hyptest truncates QRVM log topics from 64 bytes to 32 bytes before semantic event formatting. The QRVM host records the complete qrvmc::bytes64 topic, so this affects the test harness and can hide errors in the upper half of indexed values.

Affected path

ExecutionFramework::recordedLogs() transforms each qrvmc::bytes64 topic through QRVMHost::convertFromQRVMC(), which returns an h256. LogRecord::topics is also declared as std::vector<h256>.

Minimal reproduction

contract C {
    event Pair(address indexed first, address indexed second);

    function emitPair(address first, address second) public {
        emit Pair(first, second);
    }
}

Call emitPair with two 64-byte addresses that have the same first 32 bytes and different final 32 bytes. Raw QRVMC log inspection retains both halves of both topics. The current semantic output prints only the first half, so the two indexed values appear identical. The same truncation formats a right-aligned indexed uint256(2) as zero.

Expected behavior

hyptest must preserve all 64 topic bytes. For an indexed address, semantic output should contain Q followed by all 128 hexadecimal digits. Event signature matching should continue to compare the 32-byte Keccak digest left-aligned in the 64-byte topic.

Suggested fix

  • Store recorded topics as h512.
  • Copy all bytes from qrvmc::bytes64 into the test record.
  • Match non-anonymous event signatures against a left-aligned h512 digest.
  • Format indexed addresses from the complete 64-byte topic.
  • Keep the existing 32-byte digest interpretation for indexed dynamic and composite values where the ABI stores a hash.

Validation target

Add a semantic regression with two indexed 64-byte addresses whose upper or lower halves differ. Run it under legacy and via-IR codegen with default and optimized execution, then run the existing events suite to update any expectations that previously encoded the truncation. A local full-width recorder fix passes the two-address regression in all four modes, the 42-case event suite in default and optimized modes, and the full default semantic suite with 1,468 of 1,468 cases.

Impact

This does not indicate production QRVM topic truncation. It is a test-oracle defect: semantic tests can pass while failing to observe differences in bytes 32 through 63 of an indexed topic.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions