fix: reject hard wire-structure errors in the size-flagged ErgoTree degrade gate#911
Open
mwaddip wants to merge 2 commits into
Open
fix: reject hard wire-structure errors in the size-flagged ErgoTree degrade gate#911mwaddip wants to merge 2 commits into
mwaddip wants to merge 2 commits into
Conversation
…rule 1009)
A size-flagged ErgoTree whose segregated constant has a non-serializable type code was degraded to an Unparsed tree (and re-serialized) on ANY body-parse error. sigma-state degrades only soft-forkable ValidationExceptions: ErgoTreeSerializer.deserializeErgoTree wraps the body parse in a catch that yields UnparsedErgoTree only for a ValidationException, and rule 1009 (CheckSerializableTypeCode) throws one only when the type code == OptionTypeCode (36) or > LastDataType (111).
For any other non-serializable data type code (SHeader=104, SPreHeader, SGlobal, SContext, SAny, STypeVar) a hard SerializerException escapes the fallback and the tree is rejected even with the size bit set. sigma-rust degraded these too, over-accepting trees the JVM rejects.
Add SigmaParsingError::NonSerializableTypeCode for the non-soft-forkable codes and propagate it out of the sized-parse degrade arm instead of wrapping Unparsed. SOption (36) and SFunc (112) stay soft-forkable and keep degrading. Matches sigma-state 6.0.3 (SANTA vectors ErgoTree.unparsed_soft_fork_{header,option}_constant).
…wire errors The previous commit rejected only a non-soft-forkable constant type code (rule 1009). sigma-state's ErgoTreeSerializer.deserializeErgoTree degrades a size-flagged body-parse failure to UnparsedErgoTree ONLY for a ValidationException; every other (hard) exception escapes and rejects the tree -- an IllegalArgumentException from an invalid AutolykosSolution / group element point, an IOException from a truncated constant body, or a VLQ overflow. The gate degraded all of these, so a crafted size-flagged tree carrying such a constant was accepted (degraded to Unparsed and echoed) where the JVM rejects. Generalize SigmaParsingError::escapes_sized_tree_degrade to escape all hard wire-structure errors (NonSerializableTypeCode, ScorexParsingError, Io, VlqEncode), keeping position-limit degrading -- rule 1014 CheckPositionLimit is the one soft-forkable wire error (ReaderPositionLimitExceeded -> ValidationException -> degrade). Position-limit gets a dedicated PositionLimitExceeded variant (routed from the InvalidData io::Error at the From boundary across VlqEncodingError / ScorexParsingError / SigmaParsingError, with a recursive detector) so it is distinguished from a hard EOF. The position-limit window itself (the MaxBoxSize span during box parse) is not on this branch, so the carve-out is forward-compatible.
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.
Mirror sigma-state's
deserializeErgoTree: a size-flagged body-parse failure degrades toUnparsedErgoTreeonly for aValidationException; any hard exception escapes and rejects.The gate previously degraded every error except one, so a crafted size-flagged tree whose constant hits a hard error was accepted (degraded + echoed) where the JVM rejects.
a9ba5bac— reject a non-soft-forkable constant type code (rule 1009: neitherOptionTypeCode36 nor> LastDataType111 → hardSerializerException).fa366f78— generalize: escape all hard wire errors (bad EC point, EOF/truncation, VLQ overflow); only rule-1014 position-limit keeps degrading, typed distinct from a hard EOF.Soft-forkable type/opcode/
SOption/SFunc/position-limit cases still degrade — no regression.