Skip to content

Introduce integer ReturnValueTest variant and use it to coerce blocktime value string in TimeCondition#764

Draft
cygnusv wants to merge 6 commits intonucypher:signing-epicfrom
cygnusv:str-timelock
Draft

Introduce integer ReturnValueTest variant and use it to coerce blocktime value string in TimeCondition#764
cygnusv wants to merge 6 commits intonucypher:signing-epicfrom
cygnusv:str-timelock

Conversation

@cygnusv
Copy link
Copy Markdown
Member

@cygnusv cygnusv commented Feb 19, 2026

Type of PR:

  • Bugfix
  • Feature
  • Documentation
  • Other

Required reviews:

  • 1
  • 2
  • 3

What this does:

High-level summary

We fixed backend errors when returnValueTest.value was given as an integer string (e.g. "1701428400") for conditions that compare against an integer (e.g. blocktime). Rather than coercing integer-shaped strings for all blockchain params (which would assume intent everywhere), we introduced a variant return-value-test schema that only coerces such strings where the comparison is known to be integer-based. TimeCondition now uses this variant, so string values like "1701428400" are accepted and serialized as numbers. The generic blockchain return-value-test schema is unchanged and does not coerce; only conditions that explicitly use the integer variant (currently TimeCondition) get string-to-number coercion for value.

Relevant API changes

  • New exports (for use in integer-based conditions or tests):
    • From context: integerStringSchema, integerBlockchainParamOrContextParamSchema.
    • From return-value-test (and re-exported from shared): blockchainIntegerReturnValueTestSchema, BlockchainIntegerReturnValueTestProps.
  • TimeCondition: No constructor or method signature changes. Behavior change: returnValueTest.value may be an integer string (e.g. "1701428400"); it is validated and serialized (e.g. via toObj()) as a number. Number and bigint inputs are unchanged.
  • No breaking changes: Existing callers passing value as number or bigint are unchanged. Code using the generic blockchainReturnValueTestSchema and passing integer strings will now see those values remain strings in the parsed result (previously they were coerced globally; that coercion is now limited to the integer variant).

Issues fixed/closed:

Fixes issue seen by an adopter after integrating TACo and accidentally passing a string integer to a TimeCondition. taco-web didn't complain and only the nodes did, which returned with the following error:

Error
Threshold of responses not met; TACo decryption failed with errors:
{
"0xb15d5A4e2be34f4bE154A1b08a94Ab920FfD8A41":"(<class 'nucypher.network.concurrency.ThresholdDecryptionClient.ThresholdDecryptionRequestFailed'>, ThresholdDecryptionRequestFailed('Node 0xb15d5A4e2be34f4bE154A1b08a94Ab920FfD8A41 raised Invalid condition grammar: Invalid condition grammar: {\\'returnValueTest\\': [\"Invalid return value comparison type \\'<class \\'str\\'>\\'; must be an integer\"]}'), <traceback object at 0x7047b80692c0>)",
"0x48C8039c32F4c6f5cb206A5911C8Ae814929C16B":"(<class 'nucypher.network.concurrency.ThresholdDecryptionClient.ThresholdDecryptionRequestFailed'>, ThresholdDecryptionRequestFailed('Node 0x48C8039c32F4c6f5cb206A5911C8Ae814929C16B raised Invalid condition grammar: Invalid condition grammar: {\\'returnValueTest\\': [\"Invalid return value comparison type \\'<class \\'str\\'>\\'; must be an integer\"]}'), <traceback object at 0x7047b8bfa200>)",
"0x210eeAC07542F815ebB6FD6689637D8cA2689392":"(<class 'nucypher.network.concurrency.ThresholdDecryptionClient.ThresholdDecryptionRequestFailed'>, ThresholdDecryptionRequestFailed('Node 0x210eeAC07542F815ebB6FD6689637D8cA2689392 raised Invalid condition grammar: Invalid condition grammar: {\\'returnValueTest\\': [\"Invalid return value comparison type \\'<class \\'str\\'>\\'; must be an integer\"]}'), <traceback object at 0x7047b8264780>)"
}

Why it's needed:

Explain how this PR fits in the greater context of the NuCypher Network. E.g.,
if this PR address a nucypher/productdev issue, let reviewers know!

Notes for reviewers:

What should reviewers focus on? Is there a particular commit/function/section
of your PR that requires more attention from reviewers?

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (signing-epic@c6571fb). Learn more about missing BASE report.

Additional details and impacted files
@@               Coverage Diff               @@
##             signing-epic     #764   +/-   ##
===============================================
  Coverage                ?   90.20%           
===============================================
  Files                   ?       97           
  Lines                   ?     8584           
  Branches                ?      306           
===============================================
  Hits                    ?     7743           
  Misses                  ?      838           
  Partials                ?        3           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@derekpierre derekpierre marked this pull request as draft February 24, 2026 21:58
@derekpierre
Copy link
Copy Markdown
Member

derekpierre commented Feb 24, 2026

Converted to draft after conversation I had with @cygnusv about a potential alternative strategy.

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.

3 participants