Redeem miner rewards#498
Draft
n13 wants to merge 11 commits into
Draft
Conversation
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.
Redeem miner rewards
Mobile-app flow for redeeming wormhole rewards (claims aggregated leaf proofs and submits an unsigned
verify_aggregated_proofextrinsic to the chain).Memory optimization
The original implementation peaked at 4.4 GB resident on iOS, which OOM-killed the app on devices without the
com.apple.developer.kernel.increased-memory-limitentitlement (≈1.4 GB jetsam ceiling). After matching thewormhole-memprofconfiguration exactly, peak is now 2.3 GB resident (~50% reduction) andphys_footprintstays under 300 MB throughout the run.Root causes fixed
task_vm_infostruct layout. Earlier instrumentation readmin_addressasphys_footprinton ARM64 iOS, reporting a phantom constant ~4 GB and sending us chasing the wrong things. Fixed by matching Apple's kernel layout (integer_t = i32forregion_count/page_size) with a compile-timesize_ofassert at 152 bytes.aggregated_prover.bin(972 MB) from disk and then rebuilding the aggregation circuit anyway just to extract targets. Switched to the same fresh-build constructorwormhole-memprofuses (Layer0AggregationProver::new) viaaggregate_proofs_fresh. This skips both the disk-load peak and the redundant target-rebuild.wormhole_leaf_circuit_config()was returningstandard_recursion_config()(143 wires / 80 routed), so the aggregator had to recursively verify a larger leaf than needed. Aligned the leaf with the aggregator's wire counts (135 / 60) — the same shapewormhole-memprof'sleaf_config_matchinguses to hit its 2.5 GB benchmark.provingThreads: 1) allocated bigger contiguous FFT buffers than the chunked parallel path. Set to 8, matching thewormhole-memprofsweep's measured sweet spot.circuits→circuits_v3so the new 135/60 leaf bins regenerate on first run instead of failing common-data checks against old 143/80 bins.Diagnostic infrastructure added
wormhole.rs([mem] <tag> phys=… resident=… compressed=… internal=… external=… virt=…) with a detailed dump variant.Layer0Aggregator::aggregate()(build_prover/commit/prove) andLayer0AggregationProver::new_from_bytesso each substep is timed individually.[ClaimMem],[UtxoMem]).ZK parameters (matches
wormhole-memprofexactly)Aggregator circuit (
wormhole_aggregator_circuit_config())zk_configRowBlinding(leaf_hiding: true)num_wiresnum_routed_wiresnum_constantsuse_base_arithmetic_gatesecurity_bitsnum_challengesmax_quotient_degree_factorfri_config.rate_bitsfri_config.cap_heightfri_config.proof_of_work_bitsfri_config.num_query_roundsfri_config.reduction_strategyConstantArityBits(4, 5)Leaf circuit (
wormhole_leaf_circuit_config(), updated this PR)zk_configDisabled(leaf_hiding: false)num_wiresnum_routed_wiresnum_constantsuse_base_arithmetic_gatesecurity_bitsnum_challengesmax_quotient_degree_factorfri_config.rate_bitsfri_config.cap_heightfri_config.proof_of_work_bitsfri_config.num_query_roundsfri_config.reduction_strategyConstantArityBits(4, 5)Runtime knobs
maxProofsPerBatchproofConcurrencyprovingThreads(rayon global pool)freshBuildaggregate_proofs_fresh)PoseidonGoldilocksConfigGoldilocksFieldMemory before / after
phys_footprint(the metric iOS Jetsam evaluates) stays under 300 MB throughout — theresident_sizepeak above includes allocator-reusablepages that don't count against Jetsam.Files changed
quantus_sdk/rust/src/api/wormhole.rs— fresh-build aggregator path, accuratetask_vm_inforeading, per-phaselog_memcheckpoints.quantus_sdk/lib/src/services/wormhole_claim_service.dart— claim orchestration with memory checkpoints between every phase.quantus_sdk/lib/src/services/wormhole_utxo_service.dart— unspent-transfer discovery with memory checkpoints.quantus_sdk/lib/src/services/circuit_manager.dart— cache dir bumped tocircuits_v3.mobile-app/lib/v2/screens/settings/redeem_progress_screen.dart—maxProofsPerBatch: 16,provingThreads: 8,freshBuild: true.mobile-app/ios/Runner/Runner.entitlements— extended-virtual-addressing kept; increased-memory-limit removed (no longer required at the current peak; can be re-added if a device still hits jetsam).