Skip to content

Fix/bound pause reason#61

Merged
Icahbod merged 4 commits into
ApexChainx:mainfrom
Unclebaffa:fix/bound-pause-reason
Jun 22, 2026
Merged

Fix/bound pause reason#61
Icahbod merged 4 commits into
ApexChainx:mainfrom
Unclebaffa:fix/bound-pause-reason

Conversation

@Unclebaffa

Copy link
Copy Markdown
Contributor

Closes #31

Here's a summary of what was done:

Changes in apexchainx_calculator/src/lib.rs:

  • Added MAX_REASON_LEN = 256 constant at line 59
  • Added SLAError::InvalidInput = 16 variant at line 254
  • Added reason length check in pause() at lines 790-792 — returns Err(SLAError::InvalidInput) if reason.len() > 256

Changes in apexchainx_calculator/src/tests.rs:

  • Added test_pause_rejects_long_reason test at line 1922 — verifies that a 257-byte reason triggers a HostError

2 commits created:

  1. af6559cfeat: bound pause reason to 256 bytes with SLAError::InvalidInput (#68)
  2. 85ea71btest: add test_pause_rejects_long_reason for reason >256 bytes (#68)

Note: cargo build and cargo check --tests pass. The test binary cannot link on this Windows GNU environment due to a pre-existing backtrace crate dlltool incompatibility (unrelated to these changes).

Add MAX_REASON_LEN constant (256) and SLAError::InvalidInput variant. Validate reason.len() before persisting PauseInfo, returning InvalidInput on violation instead of silently accepting multi-kilobyte payloads.
Verifies that a 257-byte pause reason triggers a HostError panic (SLAError::InvalidInput).
Line break in assignment violated rustfmt. Merged to single line.

@Icahbod Icahbod left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Icahbod Icahbod merged commit e908600 into ApexChainx:main Jun 22, 2026
1 check passed
@Unclebaffa Unclebaffa deleted the fix/bound-pause-reason branch June 22, 2026 20:43
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.

fix: pause reason accepts unbounded String risking ledger bloat

2 participants