Skip to content

feat(contracts-stellar): implement error mapping, event integrity, be…#247

Merged
PeterOche merged 4 commits into
degenspot:mainfrom
Cedarich:feat/contracts-error-mapping-events-benchmarking-crosschain
Apr 28, 2026
Merged

feat(contracts-stellar): implement error mapping, event integrity, be…#247
PeterOche merged 4 commits into
degenspot:mainfrom
Cedarich:feat/contracts-error-mapping-events-benchmarking-crosschain

Conversation

@Cedarich
Copy link
Copy Markdown

Implement Error Mapping, Event Integrity, Benchmarking & Cross-Chain Oracle

Overview

This PR implements 4 critical issues for the contracts-stellar package, enhancing error handling, event reliability, performance monitoring, and cross-chain interoperability.

Changes

🔧 Issue #235: Domain-Specific Error Mapping

Problem: Generic panic! calls made error handling difficult for frontend SDKs.

Solution:

  • ✅ Created ContractError enum with 38 distinct, categorized error codes
  • ✅ Replaced 29 panic! calls in call_registry and outcome_manager
  • ✅ Made governance errors module public for SDK consumption
  • ✅ Added comprehensive documentation for each error type

Files Modified:

  • governance/src/errors.rs - Complete rewrite with 38 error codes
  • call_registry/src/lib.rs - 16 error mappings
  • outcome_manager/src/lib.rs - 13 error mappings
  • governance/src/timelock.rs - Fixed error reference

📊 Issue #233: Event Redundancy & Data Integrity

Problem: Events only emitted deltas, requiring additional queries to verify state.

Solution:

  • ✅ Enhanced all state-changing events to include new total state
  • ✅ Added vault_balance, pool_totals, participant_count to events
  • ✅ Updated Event enum structure in outcome_manager
  • ✅ Ensured event data integrity for indexers

Events Enhanced:

  • StakeAdded - Now includes: pool state, vault balance, participant count
  • PayoutWithdrawn - Now includes: vault balance
  • EarlyExit - Now includes: pool state, vault balance
  • CallFinalized - Now includes: vault balance, settlement state
  • DividendsDistributed - Now includes: new fees balance (0)
  • Plus 7 outcome_manager events with additional state fields

⚡ Issue #232: Gas/Resource Benchmarking Suite

Problem: No systematic way to measure Soroban resource consumption.

Solution:

  • ✅ Created comprehensive Rust benchmark test suite (6 scenarios)
  • ✅ Built Python automation script for CI/CD integration
  • ✅ Measure CPU instructions & memory bytes for stake_on_call
  • ✅ Test scaling across binary (2), categorical (8), and max (32) outcomes

Usage:

# Run benchmarks
cd packages/contracts-stellar
python benchmark_stake.py --iterations 10 --output results.json

# Or run specific test
cargo test benchmark_resource_report --features testutils -- --nocapture

closes #232 
closes #233 
closes #234 
closes #235 

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Apr 27, 2026

@Cedarich 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

@PeterOche PeterOche merged commit 4ef2c4a into degenspot:main Apr 28, 2026
3 checks passed
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.

3 participants