[PR #7223] [MERGED] Fix scoreboard remainder overflow for large divisors #7422

Closed
opened 2026-11-03 06:39:19 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/7223
Author: @TheMrZZ
Created: 11/2/2026
Status: ✅ Merged
Merged: 11/2/2026
Merged by: @ludovic111

Base: main ← Head: fix/7216-scoreboard-remainder-overflow


📝 Commits (1)

  • 5245320 Fix scoreboard remainder overflow for large divisors

📊 Changes

3 files changed (+62 additions, -1 deletions)

View changed files

📝 crates/horizon-client/src/scoreboard_cmd.rs (+8 -1)
📝 crates/horizon-client/src/scoreboard_cmd_tests.rs (+41 -0)
📝 tools/command_exec_corpus.py (+13 -0)

📄 Description

🤖 Opened by TheMrZZ's AI agent (T3 Code / Codex, gpt-6-astra), not by TheMrZZ personally.

What and why

Fixes #7216. 2147483646 %= 2147483647 currently produces -3 because the remainder operation unconditionally adds the divisor and overflows. Add the divisor only when the nonzero remainder has the opposite sign. The operands then have opposite signs, so the correction cannot overflow.

Add command-level regression coverage for positive and negative divisor boundaries, minimum integer modulo -1, zero remainder, unchanged divisor scores, and rejection of zero divisors. Extend the existing command execution parity corpus with the reported case and two controls.

Kind

  • parity: Horizon now does what vanilla 26.3 does

Vanilla reference

Official 26.3 bytecode: OperationArgument.getSimpleOperation calls Mth.positiveModulo(int, int), which delegates to Math.floorMod(int, int). The initial audit independently observed 2147483646 from the official Java server and -3 from Horizon for the issue's command sequence. The same faulty expression remains on this PR's base, 993eabe86.

The new command-level regression fails on unchanged source with actual -3, expected 2147483646. With the fix, all eight scoreboard command tests pass. tools/test_command_exec_parity.py now includes these boundaries in its existing social/scoreboard corpus; full server parity remains for CI because prepared client resources are unavailable locally.

The port-ledger check identifies apply_operation / OperationArgument.getSimpleOperation as the touched port and reports no new gaps.

Other projects' code

None. The implementation follows official vanilla bytecode and independently observed behavior.

Self-check

pr_ready (tools/pr_ready.py, against origin/main at 993eabe86, 1 min 6 s)

Check Result
Scope ✅ 3 files, +62 −1
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 612 passed (53 s)
rustfmt ✅ (7 s)
clippy ✅ (1 s)
tests: horizon-client-lib ✅ 1440 passed (4 s)
doc tests ✅ 0 passed (1 s)
content root tests ➖ content root untouched
mod API up to date ➖ native hooks untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ not run (no vanilla data here): CI's parity job picks the affected harnesses
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/7223 **Author:** [@TheMrZZ](https://github.com/TheMrZZ) **Created:** 11/2/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/7216-scoreboard-remainder-overflow` --- ### 📝 Commits (1) - [`5245320`](https://github.com/horizon-rust/horizon/commit/52453208cd3427cf5f324ebb64760a8247e7a0d3) Fix scoreboard remainder overflow for large divisors ### 📊 Changes **3 files changed** (+62 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/scoreboard_cmd.rs` (+8 -1) 📝 `crates/horizon-client/src/scoreboard_cmd_tests.rs` (+41 -0) 📝 `tools/command_exec_corpus.py` (+13 -0) </details> ### 📄 Description > 🤖 Opened by TheMrZZ's AI agent (T3 Code / Codex, gpt-6-astra), not by TheMrZZ personally. ## What and why Fixes #7216. `2147483646 %= 2147483647` currently produces `-3` because the remainder operation unconditionally adds the divisor and overflows. Add the divisor only when the nonzero remainder has the opposite sign. The operands then have opposite signs, so the correction cannot overflow. Add command-level regression coverage for positive and negative divisor boundaries, minimum integer modulo -1, zero remainder, unchanged divisor scores, and rejection of zero divisors. Extend the existing command execution parity corpus with the reported case and two controls. ## Kind - [x] parity: Horizon now does what vanilla 26.3 does ## Vanilla reference Official 26.3 bytecode: `OperationArgument.getSimpleOperation` calls `Mth.positiveModulo(int, int)`, which delegates to `Math.floorMod(int, int)`. The initial audit independently observed `2147483646` from the official Java server and `-3` from Horizon for the issue's command sequence. The same faulty expression remains on this PR's base, `993eabe86`. The new command-level regression fails on unchanged source with actual `-3`, expected `2147483646`. With the fix, all eight scoreboard command tests pass. `tools/test_command_exec_parity.py` now includes these boundaries in its existing social/scoreboard corpus; full server parity remains for CI because prepared client resources are unavailable locally. The port-ledger check identifies `apply_operation` / `OperationArgument.getSimpleOperation` as the touched port and reports no new gaps. ## Other projects' code None. The implementation follows official vanilla bytecode and independently observed behavior. ## Self-check **pr_ready** (`tools/pr_ready.py`, against origin/main at 993eabe86, 1 min 6 s) | Check | Result | | --- | --- | | Scope | ✅ 3 files, +62 −1 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 612 passed (53 s) | | rustfmt | ✅ (7 s) | | clippy | ✅ (1 s) | | tests: horizon-client-lib | ✅ 1440 passed (4 s) | | doc tests | ✅ 0 passed (1 s) | | content root tests | ➖ content root untouched | | mod API up to date | ➖ native hooks untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ not run (no vanilla data here): CI's parity job picks the affected harnesses | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:39:19 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#7422
No description provided.