Skip to content

Implement missing host calls - #127

Merged
RaoulSchaffranek merged 3 commits into
masterfrom
feat/missing-host-calls
Aug 20, 2026
Merged

RaoulSchaffranek merged 3 commits into
masterfrom
feat/missing-host-calls

Conversation

@RaoulSchaffranek

@RaoulSchaffranek RaoulSchaffranek commented Aug 18, 2026 •

Copy link
Copy Markdown
Member

Add host calls for i256 arithmetic, get_max_live_until_ledger and hostCallAux-vec-first-index-of.
Additionally contains a bugfix for setting the time-to-live on contract uploads and deployments.

@RaoulSchaffranek
RaoulSchaffranek merged commit a078e29 into master Aug 20, 2026
3 of 6 checks passed
@RaoulSchaffranek
RaoulSchaffranek deleted the feat/missing-host-calls branch August 20, 2026 09:45
mihaieremia added a commit to mihaieremia/komet that referenced this pull request Sep 15, 2026
… tag

Three defects in the I256 support added by runtimeverification#127, each checked against the
Soroban host rather than against the surrounding rules.

- The i256 arithmetic host functions report `(Object, ArithDomain)`, not
  `(Value, ArithDomain)`. `impl_bignum_host_fns!` builds the error with
  `ScErrorType::Object` (soroban-env-host/src/host/num.rs), and every one of
  `i256_add`, `_sub`, `_mul`, `_div`, `_rem_euclid` goes through it.

- `i256_rem_euclid` accepted `i256::MIN` by `-1` and returned `0`.
  `ethnum`'s `checked_rem_euclid` rejects exactly the same two operand pairs
  as `checked_div` -- a zero divisor, and `MIN` by `-1` -- so the rule now
  excludes both and throws for both. This was a silent wrong answer, not a
  stuck term: the old rules returned `I256(0)` where the host errors.

  The comment above the rule was also wrong about `modInt`: K's `modInt` is
  e-division and always lands in `[0, absInt(B))` (domains.md), so `absInt(B)`
  is redundant rather than load-bearing. Left the expression alone, corrected
  the claim.

- `getTagWithFlag(true, I256(_))` was missing, so under `alwaysAllocate` an
  I256 stored in `<hostObjects>` fell through to the `owise` rule and was
  tagged `I256Small` (13) instead of `I256Object` (71) whenever the value
  happened to fit the small encoding -- an object handle wearing a small tag.
  U64, I64, U128, I128 and Symbol all carry this line for that reason.

Tag numbers confirmed against `Tag` in soroban-env-common/src/val.rs
(`I256Small = 13`, `I256Object = 71`).

i256.wast pins all of it: the six existing error assertions move to
`ErrObject`, and `i256::MIN rem_euclid -1` is added.
mihaieremia added a commit to mihaieremia/komet that referenced this pull request Sep 15, 2026
…t object tags

Three defects in the I256 support added by runtimeverification#127, each checked against the
Soroban host rather than against the surrounding rules.

- The i256 arithmetic host functions report `(Object, ArithDomain)`, not
  `(Value, ArithDomain)`. The 6-argument arm of `impl_bignum_host_fns!` builds
  its error with `ScErrorType::Object`
  (soroban-env-host/src/host/num.rs:39-45), and `i256_add`, `_sub`, `_mul`,
  `_div` and `_rem_euclid` all expand through that arm
  (soroban-env-host/src/host.rs:1568-1578).

- `i256_rem_euclid` accepted `i256::MIN` by `-1` and returned `0`. `I256` is
  `ethnum::I256` (soroban-env-common/src/num.rs:10), whose
  `checked_rem_euclid` rejects `rhs == 0 || (self == MIN && rhs == -1)`
  (ethnum-1.5.2/src/int/api.rs:635-641) -- the same two pairs as
  `checked_div`, even though the mathematical remainder is representable.
  This was a silent wrong answer, not a stuck term.

  The comment above the rule was also wrong about `modInt`: K's `modInt` is
  e-division and always lands in `[0, absInt(B))` (domains.md:1262), so
  `absInt(B)` is redundant rather than load-bearing. Left the expression
  alone, corrected the claim.

- `getTagWithFlag(true, _)` was missing both 256-bit types. Under
  `alwaysAllocate`, `addObject` tags the handle with `getTagWithFlag(AA, SCV)`;
  with no entry, a value that fits the small encoding fell through to `owise`
  and took `getTag`, so an object stored in `<hostObjects>` was tagged
  `U256Small` (12) / `I256Small` (13). `isObject` is tag 64..77, so such a
  handle then failed `isObject` and `loadObject` took the `-small` branch,
  making `fromSmall` decode the object index as the value. U64, I64, U128,
  I128 and Symbol all carry this line for that reason; U256 and I256 were the
  only two small-capable types missing it.

Tag numbers confirmed against `Tag` in soroban-env-common/src/val.rs
(`U256Small = 12`, `U256Object = 70`, `I256Small = 13`, `I256Object = 71`).

i256.wast pins the first two: the six existing error assertions move to
`ErrObject`, and `i256::MIN rem_euclid -1` is added. The tag rules are only
reachable with `alwaysAllocate` set, which the .wast harness does not do;
they were checked by building with the cell forced to `true`, under which
u256.wast, double_u256.wast and i256.wast all fail before the change and pass
after.
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