Skip to content

feat: implement batch operations across contracts for gas optimization#56

Open
WillNovus wants to merge 3 commits intoGalactiGuild:mainfrom
WillNovus:feature/batch-operations
Open

feat: implement batch operations across contracts for gas optimization#56
WillNovus wants to merge 3 commits intoGalactiGuild:mainfrom
WillNovus:feature/batch-operations

Conversation

@WillNovus
Copy link

@WillNovus WillNovus commented Feb 20, 2026

Closes #38


Implemented Batch Operations

Implemented batch operations across 5 core contracts and updated the shared library to reduce transaction costs and improve efficiency.

Shared Library Updates

  • Added BatchResult type to track total, successful, and failed operations
  • Set MAX_BATCH_SIZE to 20 to safeguard against resource limits
  • Introduced BatchLimitExceeded and BatchEmpty error variants
  • Defined BATCH_COMPLETED and BATCH_ITEM_FAILED event symbols

Contract Enhancements

Contract Added Methods
Escrow batch_create_milestones and batch_vote_milestones
Governance batch_vote
Reputation batch_update_scores and batch_award_badges
Project Launch batch_contribute
Profit Distribution batch_claim_dividends

Implementation Strategy

  • Partial Failure Handling: Batches skip invalid items and return a summary result instead of reverting the whole transaction
  • Gas Optimization: Performs require_auth() once per batch, significantly reducing auth overhead
  • Robustness: Each item is individually validated to maintain contract integrity

@WillNovus
Copy link
Author

@gabito1451 please review.

@gabito1451
Copy link
Contributor

@WillNovus pleas look in to the failed tests

@gabito1451
Copy link
Contributor

@WillNovus

@WillNovus
Copy link
Author

It has been resolved.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Batch Operations for Efficiency

2 participants