Conversation
|
All GitHub workflows were cancelled due to failure one of the required jobs. |
| .and_then(|(final_score, winner_count)| { | ||
| let desired_targets = crate::Snapshot::<T>::desired_targets().unwrap(); | ||
| let desired_targets = | ||
| crate::Snapshot::<T>::desired_targets().defensive_unwrap_or(u32::MAX); |
There was a problem hiding this comment.
This code path is a bit messy because:
• DataProvider::desired_targets() returns a Result, but it’s infallible.
• Staking::ValidatorCount is a ValueQuery and defaults to 0 if not set.
• From this pallet’s pov, DesiredTargets might be unset, so we default to u32::MAX, whereas staking defaults to 0.
Practically this is of no significance — this code path should never be hit. But it’s a bit amusing and maybe a sign that our interfaces could use some cleanup.
There was a problem hiding this comment.
agree - maybe something to address next week when we do a complete review / cleanup of the staking code?
There was a problem hiding this comment.
Yeah I think a good follow-up would be to actually create_targets_snapshot and create_voters_snapshot to not return a (pointless) Result<_>, and handle everything internally.
If any of them fail, it should handle triggering a defensive panic + emit Unexpected event.
Replace unwrap() with defensive_unwrap_or_default() in the on_initialize path to gracefully handle runtime misconfigurations where voter snapshot conversion fails, preventing potential panics during block initialization.
Replace unwrap() with defensive_unwrap_or(u32::MAX) to ensure solution fails verification gracefully when desired_targets is unavailable rather than panicking.
The commit adds new events to track when snapshot creation fails. This helps with monitoring and debugging failures in target/voter snapshot operations.
e4dea84 to
b6d96c4
Compare
Snapshot creation functions now emit failure events and trigger a defensive panic instead of returning errors. Call sites updated accordingly.
* master: omni-node: fix `benchmark pallet` to work with `--runtime` (#8594) Handle and suppress "New unknown `FromSwarm` libp2p event" warning (#8731) Implement detailed logging for XCM failures (#8724) [pallet-revive] contract's nonce starts at 1 (#8734) sync/fix: Clear gap sync on known imported blocks (#8445) [PoP] Add personhood tracking pallets (#8164) client/net: Use litep2p as the default network backend (#8461) Unflake `returns_status_for_pruned_blocks` (#8709) [AHM] Report the weights of epmb pallet to expose kusama and polkadot weights (#8704) Remove all XCM dependencies from `pallet-revive` (#8584) Docker master image tag fix (#8711) Record ed as part of the storage deposit (#8718) [pallet-revive] update dry-run logic (#8662) feat: add collator peer ID to ParachainInherentData (#8708) Nest errors in pallet-xcm (#7730) pallet-assets ERC20 precompile (#8554) Broker: Introduce min price + adjust renewals to lower market. (#8630) [AHM] Staking async fixes for XCM and election planning (#8422) Staking (EPMB): Add defensive error handling to voter snapshot creation and solution verification (#8687)
…on and solution verification (#8687) - Refactor snapshot creation to emit events and triggers defensive panic on failure - Replace unwrap() with defensive_unwrap_or(u32::MAX) to ensure solution fails verification gracefully when desired_targets is unavailable rather than panicking. - Add error events for failed target and voter snapshots Close #8685.
…on and solution verification (#8687) - Refactor snapshot creation to emit events and triggers defensive panic on failure - Replace unwrap() with defensive_unwrap_or(u32::MAX) to ensure solution fails verification gracefully when desired_targets is unavailable rather than panicking. - Add error events for failed target and voter snapshots Close #8685.
Close #8685.