Skip to content

Architect a constant-time binary search algorithm for evaluating time-locked vesting schedules #479

Description

@Damola-Sodiq

Description

Optimize fractional token vesting releases by implementing a constant-time binary search to locate the active temporal milestone array index.

Architecture & Context

When fractional assets are vested linearly across 100+ milestones, using a for loop to scan timestamps sequentially burns unnecessary execution limits. A binary search locates the current unlock threshold in O(log N) operations.

Technical Requirements

  • Implement a binary search strictly within the #![no_std] Soroban environment.
  • Guarantee that the initialized milestone arrays are absolutely sorted temporally upon creation.
  • Return the exact vestable amount based on the localized array index.

Acceptance Criteria

  • Active milestones are located in a fraction of the CPU cycles compared to linear scanning.
  • The algorithm gracefully handles the extreme bounds (fully locked, fully vested).
  • Unsorted milestone configurations are proactively rejected during setup.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions