cluster: fix dead deposit amounts validation in unmarshalers - #4636
Conversation
Validate the parsed deposit amounts instead of the zero-valued named return in the v1.8, v1.9 and v1.10-11 definition unmarshalers. The checks called VerifyDepositAmounts on the empty named return value, so they always passed and definitions with invalid deposit amounts unmarshaled without error. The v1.10-11 unmarshaler now also passes the parsed compounding flag. category: bug ticket: none Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4636 +/- ##
==========================================
+ Coverage 58.22% 58.27% +0.04%
==========================================
Files 247 247
Lines 34082 34082
==========================================
+ Hits 19843 19860 +17
+ Misses 11768 11754 -14
+ Partials 2471 2468 -3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…ts-validation-fix # Conflicts: # cluster/cluster_test.go
|
There was a problem hiding this comment.
Pull request overview
Fixes a long-standing bug in cluster definition unmarshaling where deposit amount validation was inadvertently performed against the zero-valued named return (def) instead of the parsed JSON struct (defJSON), causing invalid deposit_amounts to be accepted for v1.8, v1.9, and v1.10–v1.11 definitions.
Changes:
- Validate
defJSON.DepositAmounts(and parseddefJSON.Compoundingfor v1.10–v1.11) instead ofdef.DepositAmounts/def.Compoundingduring unmarshaling. - Force
compounding=falsefor v1.8 and v1.9 definitions (since those versions don’t support compounding). - Add a regression test covering invalid/valid deposit amount cases across v1.8–v1.11, including the compounding-specific upper bound.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
cluster/definition.go |
Fixes dead deposit amount validation by checking parsed JSON fields (and correct compounding behavior by version). |
cluster/cluster_test.go |
Adds regression tests ensuring invalid deposit amounts fail unmarshaling and compounding rules are enforced. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.



Validate the parsed deposit amounts instead of the zero-valued named return in the v1.8, v1.9 and v1.10-11 definition unmarshalers.
The checks called
deposit.VerifyDepositAmounts(def.DepositAmounts, def.Compounding)wheredefis the named return value, still zero at that point — the parsed data lives indefJSON.VerifyDepositAmounts(nil, false)returns nil via its empty-slice early return, so the checks always passed and definitions with invalid deposit amounts (below the 1ETH minimum, above the maximum, or summing to less than 32ETH) unmarshaled without error. The bug dates back to the introduction of partial deposits in v1.8 and was copied into the v1.9 and v1.10-11 unmarshalers.The v1.8 and v1.9 unmarshalers now pass
compounding=falsesince those versions don't support compounding; the v1.10-11 unmarshaler passes the parsed compounding flag so large amounts are only accepted for compounding validators.Note this is defense in depth: the DKG path already re-validates amounts after loading (
dkg/disk.go), but other consumers of definition/lock unmarshaling relied on the dead check.category: bug
ticket: none