Skip to content

Conversation

@shyba
Copy link

@shyba shyba commented Aug 7, 2025

Following the reasoning in DHA-Team/arbundles#6, this pull request does the same on HyperBEAM: Enforce that the tags section is at most 128*4096 bytes in size and that a combination of tag name and value does not exceed 4096 bytes. That still allows for tags that aren't strictly ans-104 but at least adds an upper bound on tag amount and combined size.

The changes aim at making hyperbeam backwards compatible with what's currently stored on chain and accepted by gateways and projects using arbundles.

(short change summary generated by AI)

Tag validation logic changes

  • Updated tag validation in enforce_valid_tx/1 to check the combined size of tag name and value against a new MAX_TAG_COMBINED_SIZE constant, replacing separate checks for name and value lengths. Also added a check for the total tag section size. (src/ar_tx.erl, src/ar_bundles.erl) [1] [2]
  • Changed error reporting to use {invalid_field, tag_size, {Name, Value}} when the combined size exceeds the limit, and {invalid_field, tag_section_size, Tags} when the total section size is too large. (src/ar_tx.erl, src/ar_bundles.erl) [1] [2]

Constant definitions

  • Replaced MAX_TAG_NAME_SIZE and MAX_TAG_VALUE_SIZE with a single MAX_TAG_COMBINED_SIZE and updated MAX_TAG_SECTION_SIZE to be based on the new combined size in ar.hrl. (src/include/ar.hrl)

Test updates

  • Updated happy path tests to use the new combined tag size and section size logic, including new cases for maximum combined tag size and maximum section size. (src/ar_tx.erl)
  • Updated failure tests to reflect the new validation logic, including cases for too-long combined tags and oversized tag sections. (src/ar_tx.erl) [1] [2]

@shyba
Copy link
Author

shyba commented Aug 11, 2025

Changed to reflect the arbundles PR more closely:

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.

1 participant