Skip to content

feat: Implement ledger-sync (#407) and memory-sanitization (#408) features#514

Open
vic-Gray wants to merge 1 commit into
StellarFlow-Network:mainfrom
vic-Gray:main
Open

feat: Implement ledger-sync (#407) and memory-sanitization (#408) features#514
vic-Gray wants to merge 1 commit into
StellarFlow-Network:mainfrom
vic-Gray:main

Conversation

@vic-Gray

Copy link
Copy Markdown

Summary

This PR implements two security and performance enhancements for the StellarFlow contracts:

Issue #407 - Ledger-Sync: Enforcing Minimum Ledger Gaps Between Node Ingestions

High-frequency automated scripts can flood the network with consecutive price updates within the same ledger window, creating block noise and running up operations costs.

Changes:

  • Created with a persistent ledger tracking map () that records the exact block height of a relayer's most recent submission
  • Added function to reject any incoming transaction payloads if the current network ledger index has not advanced by at least 3 blocks since that node's last write operation
  • Added function to persist ledger checkpoints
  • Added error variant to enum
  • Integrated ledger gap enforcement into , , and functions

Issue #408 - Memory-Sanitization: Zero-Allocation Array Re-indexing for Quorum Verifications

Spawning temporary vectors inside loop structures during multi-sig signature parsing runs up unnecessary memory allocation fees on the Soroban host engine.

Changes:

  • Refactored in to scan incoming signature arrays directly without allocating intermediate heap objects
  • Removed the that was used for duplicate tracking
  • Implemented duplicate detection by scanning the raw slice parameters directly in O(n²) time without allocations
  • This keeps runtime memory footprints as light as possible during quorum verifications

Tests Added

  • Unit tests for ledger gap rejection when same ledger is used twice
  • Unit tests for ledger gap allowance after 3+ ledgers have passed
  • Unit tests for zero-allocation multisig validation with duplicate signers

Closes #407
Closes #408

- Add src/models.rs with ledger tracking map for minimum 3-block gap enforcement (StellarFlow-Network#407)
- Refactor auth.rs signature validation to use zero-allocation array scanning without intermediate Map (StellarFlow-Network#408)
- Add LedgerGapNotSatisfied error variant
- Update stake_and_register and update_validator_profile to enforce ledger gaps
- Add unit tests for ledger gap verification
- Add unit tests for zero-allocation multisig validation

Closes StellarFlow-Network#407
Closes StellarFlow-Network#408
@drips-wave

drips-wave Bot commented Jun 26, 2026

Copy link
Copy Markdown

@vic-Gray Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@GBOYEE

GBOYEE commented Jun 28, 2026

Copy link
Copy Markdown

@GBOYEE has applied to work on this issue as part of the Stellar Wave Program's 6th wave.

Implement following existing patterns and conventions. Add tests, ensure CI passes, and document any new API surface.

ℹ️ Repo Maintainers: To accept this application, review their application or assign @GBOYEE to this issue.

@Sadeequ

Sadeequ commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

why you go dey send from main broooooooooooooooooooooo

Resolve conflicts ASAP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants