Repository navigation
Conversation
…ng tail is dropped A client that follows a codama IDL's omitted optional-account strategy leaves an absent trailing optional account out entirely (the Stake program's lockup authority), so the source arrives with fewer accounts than the index map covers. The proxy sized the mapped array by the difference and read past the accounts it was given, an ArrayIndexOutOfBoundsException. It now maps what arrives when every missing position is one the map drops, and refuses by message when it would have to seat an account it was not given; accounts beyond the map still pass through as remaining accounts.
jpe7s
added a commit
to glamsystems/glam-sdk-java
that referenced
this pull request
Sep 22, 2026
… set at glam 47df4f7 The Stake program's authorize and withdraw keep a dropped entry for the optional lockup authority again: supplied, it is dropped; left out, the mapper maps what arrives from glamsystems/ix-mapper-java#5 on, which this embedding depends on before it merges.
Index zero is a seat like any other; the review of this fix asked for the boundary to be pinned: a source that leaves out an account the proxy maps there is refused by message.
…divergence recorded Review of the short-source fix. The check loop already refuses by position, so the Math.min bound and the reset of the extras loop were redundant and are gone; the earlier message said the old code read past the accounts, when it wrote past an undersized mapped array, or failed to size it. A new test pins that which positions are missing decides, not how many: index_map [-1, -1, 2, -1] with one account is refused by message, where a check by counts would return a null account. The fixture is named for the shape it models, a Stake authorize whose map is [4, -1, -1]. This mapper maps any short source whose missing positions the map drops, required or optional, since the map carries no such distinction and a missing dropped account maps exactly as a supplied one; the TypeScript mapper refuses every short source. The README's index_map section and the ported TS test record the difference. Fuzzing: a seed reaches the short-source success path; the harness asserts that a mapped instruction carries no null account; and its catch around the mapping is IllegalStateException, the refusal in contract, so an index or array error can no longer hide behind it.
…DME's prose pitestIxProxyBaselineRetag moves the two empty-copy-equivalent rows to the line the guard now sits on; the README's prose named lines the rows had left behind before this branch.
jpe7s
added a commit
to glamsystems/glam-sdk-java
that referenced
this pull request
Sep 23, 2026
… set at glam 47df4f7 The Stake program's authorize and withdraw keep a dropped entry for the optional lockup authority again: supplied, it is dropped; left out, the mapper maps what arrives from glamsystems/ix-mapper-java#5 on, which this embedding depends on before it merges.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A client that follows a codama IDL's omitted optional-account strategy leaves an absent trailing optional account out entirely, so the source instruction arrives with fewer accounts than the index map covers.
IxProxyRecordsized the mapped array by the difference and wrote past it, or failed to size it (ArrayIndexOutOfBoundsExceptionorNegativeArraySizeException). It now maps what arrives when every missing position is one the map drops (-1), refuses with a message naming the position and slot when it would have to seat an account it was not given, and still passes accounts beyond the map through as remaining accounts.The case in hand is the Stake program's
authorizeandwithdraw, whose trailing lockup authority is an optional signer: glamsystems/glam#1393 generates their maps as[4, -1, -1]and[4, -1, -1, -1], so a client that leaves the lockup authority out maps, and one that supplies it has it dropped like any authority the vault stands in for. Against those configs, onmainthe two-accountauthorizethrows; on this branch it maps to the same accounts as the full form.Design point, recorded rather than decided here: this mapper maps any short source whose missing positions the map drops, required or optional, because the map carries no such distinction and a missing dropped account maps exactly as a supplied one (two independent refuters confirmed no new mapped instruction becomes reachable). The TypeScript mapper refuses every short source. Narrowing to positions the generator marks omittable would need a config field the v1 schema does not have. The README's
index_mapsection states the rule and the other two places the engines differ on the same document, both older than this PR: the TypeScript mapper refusesindex_mapvalues below-1and non-dense proxy indices at load, where this mapper treats any negative value as dropped and checks no density; and data shorter than a fixed-length discriminator matches nothing there, while this mapper's fixed-length lookup zero-pads it and the mapping then refuses by message. GLAM-1422 carries the alignment.Tests,
OmittedTrailingAccountsTests: every declared account; the trailing dropped ones left out; accounts beyond the map; a missing account the proxy seats; the seat at index zero; and a dropped missing position ahead of a seated one, which a check by counts would pass and then fail at the seat with an index error instead of a refusal. The ported too-few-keys test assertsIllegalStateExceptionand the message namingtoat index 4, so a deleted check loop cannot pass it on an index error.Fuzzing: the harness's catch around the mapping is
IllegalStateException, so an index or array error can no longer hide behind it, and it asserts no mapped account is null. Its "payer" entry carried a proxy discriminator and so built a full rewrite;PayerIxProxywas never fuzzed. A third fixed-length entry now builds one, the account pool carries the source program id so the optional-account sentinel swap is reachable, the catch aroundlookupProxyis gone (neither lookup throws: the fixed-length one zero-pads short data, the scan skips a longer discriminator), and the class doc states the precondition the rejection branch relies on: no configured discriminator ends in a zero byte. Seeds are named for what they pin (four new, three renamed; all 13 replay incheck). A 90 s campaign ran 39.5M inputs with no finding.Hardening:
pitestIxProxy -PnoMutationHistory— 341 mutants, 328 killed, the 13 survivors are the accepted baseline rows, none new on the changed lines;pitestIxProxyBaselineRetagmoved the twoempty-copy-equivalenthints to the guard's new line and the README prose follows. Clusters: Property: a source shorter than the map maps iff every missing position is dropped, refused by position otherwise | Oracle: codama's omitted strategy and the map's-1meaning | Outcome: production bug, fixed. Property: a mapped instruction never carries a null account | Oracle: sava'sInstructionaccepts one, the runtime would not | Outcome: missing assertion, fuzz property added.Merge: squash under this title;
c6cb8b0is typedtest:but also touchesIxProxyRecord.Outside this PR: sava's own
StakeProgrambuilders emit the legacy layout with the Clock sysvar, which the generated Stake maps do not fit (the authority lands as a remaining account and GLAM's handlers refuse it).-PglamMappingsDirreaches onlyTesttasks, not PIT (from71b00a2); sava-build'sminionJvmArgswould carry it, at the cost of a different evidence hash for that override run.glam-sdk-java consumes
ix-proxy25.0.4; a release with this fix lets it bump.