Skip to content

Silent overflow in release mode in size and weight functions #2086

@tcharding

Description

@tcharding

#2076 introduced silent overflows ("normal" arithmetic) in size and weight calculations - they all need to be fixed / thought about to close this issue.

During work on weight, size, base_size, total_size etc. (on Transaction and Block) it was realized that overflowing ops could potentially be an attack vector. However doing checked_ ops and returning Option is unergonomic considering that overflow should never happen under normal conditions.

Two possible solutions discussed were:

  • saturating add/mul
  • explicit panic on overflow

Also need to consider if doing bounds checks introducesa any additional/unwanted overhead.

References:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions