Skip to content

refactor: project-wide time types to u64 aliases for ScVal compatibility#708

Open
precious-akpan wants to merge 120 commits intoJagadeeshftw:masterfrom
precious-akpan:refactor/type-safe-time-values
Open

refactor: project-wide time types to u64 aliases for ScVal compatibility#708
precious-akpan wants to merge 120 commits intoJagadeeshftw:masterfrom
precious-akpan:refactor/type-safe-time-values

Conversation

@precious-akpan
Copy link
Contributor

@precious-akpan precious-akpan commented Feb 26, 2026

Resolves #589

Overview

This PR implements project-wide type-safe time wrappers by refactoring Timestamp and Duration to u64 type aliases. This resolves the persistent E0277 errors encountered when using these types within Option in contract storage and events across crate boundaries.

Key Changes

  • grainlify-time: Introduced a shared library for time types using u64 aliases and trait-based extensions (TimestampExt, DurationExt).
  • Top-Level Logic: Added safe constructors (now, from_hours, etc.) to improve type inference and usability.
  • Contract Refactors: Updated bounty-escrow, program-escrow, and grainlify-core to adopt the new architecture.
  • Testing: Fixed all contract test suites to align with the new logic.
  • Lint Cleanup: Resolved 10+ clippy warnings and dead code in grainlify-core.
  • Synchronization: Merged latest upstream master changes.

Verification

All contract tests pass cleanly:

  • bounty-escrow: 27 tests passed
  • program-escrow: 15 tests passed
  • grainlify-core: 11 tests passed

Jayrodri088 and others added 30 commits January 23, 2026 13:06
- Add comprehensive event schema documentation (EVENT_SCHEMA.md)
  * Define event structures for all contracts
  * Document event versioning strategy
  * Provide indexing strategies and retention policies
  * Include monitoring hooks and filtering examples

- Implement event indexing infrastructure (internal/events/indexing.go)
  * EventIndexer for efficient event querying
  * Support for time-series, entity-based, and composite queries
  * Event aggregation capabilities
  * Event statistics and unindexed event tracking

- Implement event monitoring system (internal/events/monitoring.go)
  * EventMonitor for real-time event listening
  * AnomalyDetector for detecting unusual patterns
  * Alert generation and handling
  * EventFilter and EventAggregator utilities

- Implement advanced event filtering (internal/events/filtering.go)
  * FilterBuilder with fluent API
  * AdvancedEventFilter with operators (eq, ne, gt, gte, lt, lte, contains, in)
  * EventFilterStatistics for analytics
  * EventFilterExporter for JSON/CSV export

- Create database migration (migrations/000025_contract_events_indexing.up.sql)
  * contract_events table with comprehensive indexing
  * event_alerts table for monitoring alerts
  * event_metrics table for performance tracking
  * event_replay_log table for event replay capability
  * Materialized views for daily statistics
  * Database functions for cleanup and queries

- Add event indexing strategy guide (EVENT_INDEXING_STRATEGY.md)
  * Architecture overview and data flow
  * Database schema documentation
  * Indexing strategies (time-series, entity, composite, JSONB, materialized views)
  * Query patterns and monitoring hooks
  * Performance optimization techniques
  * Event retention policy

- Add event versioning documentation (contracts/EVENT_VERSIONING.md)
  * Semantic versioning scheme (MAJOR.MINOR.PATCH)
  * Version evolution rules and migration strategies
  * Deprecation timeline and best practices
  * Indexer compatibility patterns
  * Version roadmap

- Add implementation guide (EVENT_INDEXING_README.md)
  * Component overview and architecture
  * Usage examples for all major features
  * API integration patterns
  * Monitoring dashboard metrics
  * Performance tuning guide
  * Troubleshooting section

Key Features:
- Efficient off-chain event indexing with multiple strategies
- Real-time event monitoring and anomaly detection
- Comprehensive event schema with backward compatibility
- Event versioning for smooth schema evolution
- Advanced filtering and aggregation capabilities
- Performance metrics and SLA tracking
- Event retention policies for compliance
- Monitoring alerts and dashboards

Closes #[event-indexing-issue]
… Soroban contracts

- Add error classification system (transient, permanent, partial)
- Implement exponential backoff with jitter for retry logic
- Add circuit breaker pattern to prevent cascading failures
- Support partial success in batch operations with detailed tracking
- Implement error state persistence and monitoring
- Add comprehensive event emission for all error scenarios
- Create 20 passing unit tests covering all error recovery scenarios
- Integrate error recovery into program-escrow contract

This implementation significantly improves platform reliability by:
- Automatically retrying transient failures (network timeouts, rate limits)
- Preventing permanent error retries (insufficient funds, invalid addresses)
- Allowing batch operations to partially succeed instead of all-or-nothing
- Tracking failed batch items for targeted retry
- Implementing circuit breakers to prevent system overload
- Providing detailed error events for monitoring and debugging

All tests passing (36/36)
- Create comprehensive SDK for Grainlify contracts
- TypeScript bindings from contract ABIs
- Client classes for Core and Escrow contracts
- Examples for all workflows: lock funds, release funds, batch payouts, query escrow
- Error handling utilities
- Complete documentation and usage guide
- Remove node_modules directory from contracts/sdk
- Add node_modules/ to root .gitignore to prevent future commits
Jayrodri088 and others added 28 commits January 29, 2026 16:05
…oject-leaderboard-from-backend

Frontend/fetch project leaderboard from backend
Add support for daily, weekly, quarterly, and yearly intervals in the contributor activity chart on the data page. Update authentication context to handle mock auth scenarios.
…ctivity-interval-filtering

Fix/contributor activity interval filtering
…support

Issue 150: Feat/partial payout support
…ple-languages-project-cards

feat: display multiple languages used in projects on project cards
…figuration

feat: admin configuration functions
@vercel
Copy link

vercel bot commented Feb 26, 2026

@precious-akpan is attempting to deploy a commit to the Jagadeesh B's projects Team on Vercel.

A member of the Team first needs to authorize it.

@Jagadeeshftw
Copy link
Owner

@precious-akpan Did you mind resolving the conflicts?

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.

Add Strict Type-Safe Wrappers for Time Values