Skip to content

Add enum type support to ABI serialization#10

Merged
heifner merged 2 commits into
masterfrom
feature/enum-support
Mar 30, 2026
Merged

Add enum type support to ABI serialization#10
heifner merged 2 commits into
masterfrom
feature/enum-support

Conversation

@heifner

@heifner heifner commented Mar 30, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds full enum support to abieos, matching wire-sysio's abi_serializer behavior
  • Enums defined in ABI with name, underlying integer type, and symbolic values are now parsed and used for JSON ↔ binary conversion
  • bin_to_json outputs symbolic names ("only", "first", "any"); json_to_bin accepts both names and integer strings
  • Fixes Hyperion's "Unknown type: trx_match_type" error when indexing blocks with sysio.system trx_priority enums
  • Also fixes pre-existing block_timestamp_type test failure (test dates updated for Wire's 2025 epoch)

Files changed

  • include/sysio/abi.hppenum_value_def, enum_def, abi_def.enums, abi_type::enum_
  • src/abi.cppresolve(), enum registration in convert(), underlying type validation
  • src/abieos.hpppseudo_enum serializer, enum_read_int/enum_write_int/enum_parse_value helpers
  • src/test.cpp — enum roundtrip tests, block_timestamp date fixes, fuzzer corpus mapping

heifner added 2 commits March 30, 2026 13:55
The block_timestamp epoch was changed from 946684800000 (2000-01-01) to
1735689600000 (2025-01-01) for Wire Network, but the test cases still
used pre-2025 dates causing roundtrip mismatches.
Add full enum support matching wire-sysio's abi_serializer behavior.
Enums are defined in the ABI with a name, underlying integer type, and
named values. The serializer resolves symbolic names to/from integers:

- bin_to_json: reads underlying int, outputs symbolic name string
  (falls back to string number for unknown values)
- json_to_bin: accepts symbolic name or integer string, writes as
  underlying type

This fixes Hyperion's "Unknown type: trx_match_type" error when
processing blocks containing sysio.system's trx_priority enums.

Implementation follows the existing variant_def pattern:
- enum_value_def/enum_def structs with SYSIO_REFLECT
- might_not_exist<> wrapper in abi_def for backward compatibility
- abi_type::enum_ variant with resolve() for type resolution
- pseudo_enum serializer with direct binary I/O helpers
- Underlying type validated as integer at ABI load time
@heifner
heifner requested a review from bearcubsvet March 30, 2026 19:02
@heifner
heifner merged commit 577dd8e into master Mar 30, 2026
13 of 14 checks passed
@heifner
heifner deleted the feature/enum-support branch March 30, 2026 19:04
heifner added a commit to Wire-Network/node-abieos that referenced this pull request Mar 30, 2026
Picks up Wire-Network/abieos#10 which adds full enum support to ABI
serialization. Fixes Hyperion's "Unknown type: trx_match_type" error
when indexing blocks with sysio.system trx_priority enums.
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