Skip to main content

check_compactness

Function check_compactness 

Source
pub fn check_compactness(
    twice_area: u128,
    perimeter: u128,
    config: &ProtocolConfig,
) -> CompactnessOutcome
Expand description

Core compactness check matching polygon.move::validate_compactness.

Formula: 8_000_000 * twice_area >= min_compactness_ppm * perimeter_l1².

Overflow semantics (matches Move):

  • perimeter² overflow → not compact (pathologically long boundary).
  • rhs (min_ppm * perimeter²) overflow → not compact.
  • lhs (8_000_000 * twice_area) overflow → compact (massive area wins).

This is the canonical implementation. Both the string-based validate_compactness and the TopologyError-based wrapper in topology.rs delegate to this function so all callers agree byte-for-byte with on-chain.