Repository navigation
feat(simulator): pass scoped-transaction options to live calls - #195
Conversation
midnight-js encrypts each shielded coin a circuit creates to its recipient's encryption key and only knows the calling wallet's, so a live circuit that sent a coin to another wallet's coin public key failed to build. The deployed handle's callTx leaves the additionalCoinEncPublicKeyMappings slot empty, so with the option set each call is rebuilt on createCallTxOptions + submitCallTx, the pair callTx itself runs.
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Essentials Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Essentials Run ID: 📒 Files selected for processing (4)
Included review availability: 4 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 5 reviews per hour. WalkthroughThe live context accepts optional coin-to-encryption-public-key mappings. When mappings are supplied, circuit calls use them to create and submit transactions. The README and changelog describe the option and its use for shielded recipients. ChangesLive coin encryption key mappings
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Feature · Severity of issue fixed: Low Sequence Diagram(s)sequenceDiagram
participant Caller
participant LiveContext
participant ContractsModule
participant AliasProviders
Caller->>LiveContext: Resolve handle with encryption mappings
LiveContext->>ContractsModule: Find deployed handle
LiveContext-->>Caller: Return handle with rebuilt call methods
Caller->>LiveContext: Invoke circuit call
LiveContext->>ContractsModule: Create call options with mappings and arguments
LiveContext->>AliasProviders: Submit call transaction
AliasProviders-->>Caller: Return finalized call result
Suggested reviewers: Merge Risk: ⚪ Minimal · up to The mapped-call path has no established merge-blocking issue; normal checks can proceed. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
A rabbit maps the keys with care, Comment |
The lazy module and the mappings option take their types from midnight-js-contracts instead of local copies. The imports are type-only, so the dependency wall is unchanged.
Each call runs through the handle's own callTx inside withContractScopedTransaction, the midnight-js entry point that takes these options, instead of a callTx rebuilt from createCallTxOptions and submitCallTx. New scope options pass through without a simulator change.
Types of changes
A live circuit could not send a shielded coin to a wallet other than the caller. midnight-js encrypts that output to the recipient's encryption key, knows only the caller's, and throws
Unable to resolve encryption public key.withContractScopedTransactionis the midnight-js entry point that takes the key mappings. WithscopedTransactionOptionsset, each call runs through the handle's owncallTxin a scope holding just that call, so the.private.resultthatLiveBackendreads is unchanged. Without the option, handles are untouched.Inside a scope, midnight-js wraps circuit and submission errors (
Unexpected error executing scoped transaction ...). The original message stays inside, so substring matches still hold.The end-to-end check is a compact-contracts live spec where one pool wallet pays another, which lands there once this is released.
PR Checklist
Further comments
Rebuilding
callTxoncreateCallTxOptions+submitCallTxavoids the error wrapping, but copies midnight-js'scallTxbody and needs an option type carved out ofCallOptionsBase.