fix: finish eth2registration method in cluster/distvalidator#298
fix: finish eth2registration method in cluster/distvalidator#298
eth2registration method in cluster/distvalidator#298Conversation
eaeb1c9 to
65143a6
Compare
|
Claude finished @iamquang95's task in 1m 56s —— View job PR Review
SummaryThis PR implements Findings[High] Length checks on fixed-size arrays are dead code — validation never fires
if reg.signature.len() != BLS_SIGNATURE_LEN // always false
|| reg.message.pub_key.len() != BLS_PUBKEY_LEN // always false
|| reg.message.fee_recipient.len() != ADDRESS_LEN // always falseLooking at
In Rust, fixed-size arrays have a compile-time constant length, so these three conditions are always The idiomatic fix would be: if reg.signature == [0u8; BLS_SIGNATURE_LEN]
|| reg.message.pub_key == [0u8; BLS_PUBKEY_LEN]
|| reg.message.fee_recipient == [0u8; ADDRESS_LEN]
|| reg.message.gas_limit == 0
|| reg.message.timestamp.timestamp() == 0
{
return Err(DistValidatorError::InvalidRegistration);
}[Low] No tests addedThe method has no corresponding test. A unit test covering at least the happy path and the zero-registration error path would ensure functional correctness and serve as a regression guard. Ideally a test vector derived from the Go reference (Go [Low] Pre-existing:
|
| Component | Go ref (v1.7.1) | Rust | Match | Notes |
|---|---|---|---|---|
| Return type | eth2api.VersionedSignedValidatorRegistration |
VersionedSignedValidatorRegistration |
yes | |
| Zero-registration check | validates non-empty fields | length checks (always pass) | no | Fixed-size array lengths are constant |
| Timestamp conversion | int64 → direct |
i64.try_into::<u64>() |
yes | Negative timestamps map to InvalidRegistration |
| Field mapping | direct copy | direct copy | yes |
|
The finding is valid, but the |
emlautarom1
left a comment
There was a problem hiding this comment.
Agree with the comments from @iamquang95.
Small PR, was done by testing codex with claude skills (I asked what we can do small but needed -> asked to implement it)