Skip to content

Implement TaskSubmit PoCW with 5-stage Flux pipeline - #20

Open
ABresting wants to merge 12 commits into
dev-abhi-pocwfrom
dev-abhi-tasksubmit-pocw
Open

Implement TaskSubmit PoCW with 5-stage Flux pipeline#20
ABresting wants to merge 12 commits into
dev-abhi-pocwfrom
dev-abhi-tasksubmit-pocw

Conversation

@ABresting

@ABresting ABresting commented Mar 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

Implements the 5-stage Flux economic pipeline for TaskSubmit events, building on the flat-fee transfer mechanism from PR #15.

  • Stage 1: Formula-based burn (αC + βR + γS) for solver-executed tasks using EventMetrics
  • Stage 2: Proportional power drain (solver_power_rate × gas_used) with per-solver budget tracking
  • Stage 3: Kappa-based minting (κ × ΔPower_total)
  • Stage 4: PoCW distribution via 3 DAG signals (depth, necessity, gas)
  • Stage 5: Emission adjustment (dampened κ feedback loop)

v0.1 scope: single-solver execution. All structures designed so v0.2 multi-solver competition (fan-out same task to N solvers, winner selection via task_id grouping) requires no rework.

Closes #16

Test plan

  • Unit tests per stage (burn, power, minting, emission, scoring)
  • Processor end-to-end: mixed fold (transfers + tasks) produces correct economics
  • Backward compat: transfer-only folds still work
  • Integration test: submit task, verify EventMetrics, fold produces economics
  • All pre-existing tests pass (455/465, 10 pre-existing failures)

)

Add EventMetrics (per-event solver metrics computed after TEE execution),
SolverPowerState, EmissionState types. Extend PoCWConfig with formula
coefficients (alpha/beta/gamma), power rate, kappa, PoCW distribution
weights (distance/necessity/contribution per spec), and emission params.
Extend SolverReward with distance_score, necessity_score, contribution_score,
weight (w_i) fields matching the PoCW spec. Extend FoldEconomics with
kappa/minting fields. Add event_metrics to Event. All #[serde(default)].

Includes 9 unit tests: defaults, serde roundtrip, backward-compat
deserialize for PoCWConfig/SolverReward/FoldEconomics, EventMetrics
serde, SolverPowerState serde, EmissionState construction and serde.
Stage 1: calculate_task_burn() computes burn = α*C + β*R + γ*S where
C = complexity (compute_time + gas*10 + writes*1000), R = risk
(value_transferred), S = structural tension (dag_depth*100 + writes*500).
Minimum burn of 1. Sits alongside calculate_transfer_burn() in flux_burn
module since flux burning is common to all Setu transactions.
5 tests: disabled returns zero, known-input calculation, value
transfer risk component, minimum burn of 1, custom alpha/beta/gamma.
@ABresting
ABresting force-pushed the dev-abhi-tasksubmit-pocw branch from 7de2c34 to 158123d Compare March 3, 2026 20:40
ΔP = max(1, round(solver_power_rate × gas_used))
Returns 0 if PoCW is disabled.
Combined because they form a feedback loop on EmissionState:
Stage 3 reads κ to mint, Stage 5 uses minted amount to adjust κ.

Stage 3: FluxMinted = round(κ × ΔPower_total)
Stage 5: κ(k+1) = clamp(κ(k) × (1 + d × (target/real − 1)), κ_min, κ_max)
Three signals per solver:
- Distance: 1/(1+d) — proximity to critical path (1.0 for single solver)
- Necessity: fraction of solver events ancestral to fold tips
- Contribution: solver_depth / total_depth

w_i = α·Distance + β·Necessity + γ·Contribution, normalized.
Reward_i = w_i × FluxMinted, rounding remainder to top scorer.
…tate apply

Processor now handles both Transfer (flat) and TaskSubmit (formula-based)
events through the full pipeline: burn → power → mint → score → adjust.
FoldObserver owns EmissionState and passes DAG to processor for scoring.
TeeExecutor applies state changes immediately after TEE execution so
balance queries reflect updates without waiting for fold.
- Compute EventMetrics (flux_burn, power_delta) after TEE execution
- Initialize solver power budget on SolverRegister when PoCW enabled
- Pass PoCWConfig from ConsensusConfig through to TeeExecutor
- Add SolverPowerState::new() constructor
Wire POST /api/v1/task through validator to solver-TEE execution.
Add SubmitTaskRequest/Response RPC types, prepare_task_submission
in TaskPreparer (no coin selection), and submit_task in
ValidatorNetworkService with VLC assignment and routing.
@ABresting
ABresting marked this pull request as ready for review March 11, 2026 18:33
@ABresting ABresting self-assigned this Mar 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant