subtensor icon indicating copy to clipboard operation
subtensor copied to clipboard

enforce no unwrap/panic in critical paths

Open sam0x17 opened this issue 1 year ago • 0 comments

Right now it is possible to have code that panics in pallets, extrinsics, etc., which can brick the chain. Ideally we disallow this at the clippy linting level so the CI will not allow such code to be merged. This is a tall order, because there are a bunch of instances currently where we do panic, so these all need to be fixed before this CI change will pass.

AC:

  • [x] fix any existing unwrap()s
  • [ ] fix any existing expect()s
  • [ ] fix any existing unwrap_err()s
  • [ ] fix any existing panic!s
  • [ ] fix any existing unreachable!()s
  • [ ] fix any existing unimplemented!()s
  • [x] prevent unwrap()s in CI
  • [ ] prevent expect()s in CI
  • [ ] prevent unwrap_err()s in CI
  • [ ] prevent panic!s in CI
  • [ ] prevent unreachable!()s in CI
  • [ ] prevent unimplemented!()s in CI
  • [ ] #301
  • [ ] #303
  • [ ] fix any existing panicking array indexing operations (requires #301)
  • [ ] prevent panicking array indexing operations in CI (if possible)
  • [ ] Eventually once things are locked down enough, we might be able to better enforce some of these constraints by having a whitelist of types that are allowed to be returned by an extrinsic in our pallets and then a simple attribute / visitor pattern that enforces this at the pallet function signature level. The rule would be that none of these types are allowed to have a method or op that gets by CI that could panic.

sam0x17 avatar Apr 08 '24 15:04 sam0x17