code: def compute_frontier_difficulty(parent_header: BlockHeader, timestamp: int) -> int:
      
      validate_gt(timestamp, parent_header.timestamp, title="Header timestamp")
  
      offset = parent_header.difficulty // DIFFICULTY_ADJUSTMENT_DENOMINATOR
  
      # We set the minimum to the lowest of the protocol minimum and the parent
      # minimum to allow for the initial frontier *warming* period during which
      # the difficulty begins lower than the protocol minimum.
      difficulty_minimum = min(parent_header.difficulty, DIFFICULTY_MINIMUM)
  
      if timestamp - parent_header.timestamp < FRONTIER_DIFFICULTY_ADJUSTMENT_CUTOFF:
          base_difficulty = max(
              parent_header.difficulty + offset,
              difficulty_minimum,
          )
      else:
          base_difficulty = max(
              parent_header.difficulty - offset,
              difficulty_minimum,
          )
  
      # Adjust for difficulty bomb.
      num_bomb_periods = (
          (parent_header.block_number + 1) // BOMB_EXPONENTIAL_PERIOD
      ) - BOMB_EXPONENTIAL_FREE_PERIODS
  
      if num_bomb_periods >= 0:
          difficulty = max(
              base_difficulty + 2**num_bomb_periods,
              DIFFICULTY_MINIMUM,
          )
      else:
          difficulty = base_difficulty
  
      return difficulty
docs: Computes the difficulty for a frontier block based on the parent block.