Skip to content

Feat/issue 131 gasless relay - #140

Merged
elizabetheonoja-art merged 15 commits into
Utility-Protocol:mainfrom
OZILSOLAR:feat/issue-131-gasless-relay
Aug 20, 2026
Merged

Feat/issue 131 gasless relay#140
elizabetheonoja-art merged 15 commits into
Utility-Protocol:mainfrom
OZILSOLAR:feat/issue-131-gasless-relay

Conversation

@OZILSOLAR

Copy link
Copy Markdown
Contributor

Gasless Transaction Relay for User Onboarding (Issue #131)

Implements a complete EIP-2771 compatible gasless transaction relay system to sponsor gas costs for approved operations during user onboarding, removing
barriers to protocol adoption.

Features Implemented

  • EIP-2771 Trusted Forwarder: Meta-transaction relay with deadline validation
  • Gas Sponsorship Engine: Configurable per-operation sponsorship (full/partial)
  • Replay Attack Prevention: Sequential nonce management + timestamp validation
  • Rate Limiting: Per-user and per-operation daily limits with auto-reset
  • Sponsorship Policy Engine: Fine-grained operation eligibility with status control
  • Pool Management: Balance tracking, deductions, and admin top-up functionality

Changes

  • gasless_relay.rs (403 lines): Core relay contract with meta-transaction forwarding, nonce management, and rate limiting
  • gasless_relay_sig_verify.rs (266 lines): Ed25519 signature verification, forwarder validation, and replay prevention
  • gasless_relay_policy.rs (479 lines): Policy management with eligibility checking, statistics tracking, and operational control
  • gasless_relay_tests.rs (338 lines): 15 unit tests for core functionality
  • gasless_relay_integration_tests.rs (327 lines): 16 integration tests covering complete workflows
  • GASLESS_RELAY_DOCS.md (276 lines): Comprehensive architecture and operational documentation

Security

  • Signature verification with 6-hour window
  • Nonce-based replay protection
  • Gas limit enforcement per operation
  • Admin-only configuration
  • Sponsorship pool balance validation

Testing

  • 15 unit tests covering initialization, policies, rate limits, and error conditions
  • 16 integration tests covering end-to-end flows, replay prevention, pool management, and edge cases
  • Comprehensive error handling with 8 distinct error codes

Closes #131

Implements core components for gasless transaction relay system to support
user onboarding by allowing the protocol to sponsor gas costs:

- EIP-2771 compatible trusted forwarder with meta-transaction support
- Gas sponsorship policy engine for approved operations
- Per-address rate limiting to prevent abuse (configurable per user)
- Nonce management with replay attack protection
- Sponsorship pool balance management with top-up functionality
- Comprehensive integration tests (15 test cases)

Features:
- Forward meta-transactions with deadline validation
- Track sponsorship pool deductions
- Configurable policies per operation type
- Rate limit tracking per user per time period
- Admin-only configuration operations
- Proper error handling with dedicated error codes
…actions

Implements EIP-2771 compatible signature verification module for gasless relay:

- Ed25519 signature verification with timestamp validation
- Approved forwarder validation against whitelist
- Meta-transaction request hashing for signature verification
- Signer address validation and recovery
- Nonce-based replay attack prevention for forwarders
- Request structure validation
- Signature age checking (6-hour window)

Provides cryptographic foundation for secure meta-transaction relay operations.
Includes comprehensive unit tests for all verification functions.
Creates comprehensive policy management system for gas sponsorship:

Features:
- Detailed sponsorship policies per operation type
- Multiple sponsorship statuses: Full, Partial, Suspended, NotSponsored
- Operation eligibility checking with multiple validation points
- Gas limit enforcement per operation
- Daily transaction limits with automatic reset
- Sponsorship pool balance verification
- Operation statistics tracking (gas, cost, transaction counts)
- Policy suspension and resumption for operational control
- Policy listing and retrieval functions
- Transaction recording with stat updates

Policies support:
- Configurable gas limits per operation
- Flexible sponsorship percentage (0-100%)
- Daily transaction rate limiting
- Cost tracking per operation
- Admin-only policy management
- Policy status transitions

Includes unit tests for initialization, policy creation, and eligibility checks.
…asless relay

Provides extensive integration test suite covering:

Complete flows:
- End-to-end user onboarding with gasless relay
- Replay attack prevention mechanisms
- Multi-user rate limiting scenarios
- Sponsorship pool depletion and recovery
- Policy suspension and resumption workflows

Advanced scenarios:
- Mixed full and partial sponsorship levels
- Concurrent meta-transactions from same user
- Forwarder validation and trusted forwarder enforcement
- Gas limit enforcement per operation type
- Operation statistics tracking and reporting
- Emergency pool drain recovery procedures

Edge cases:
- Nonce overflow handling
- Policy updates and versioning
- Signature expiration validation
- Daily limit reset at period boundaries
- Pool balance consistency verification
- System upgrade scenarios

16 integration test scenarios that validate:
- Correct state transitions
- Proper error conditions
- Cross-component interactions
- Resource management
- Security properties

Tests are structured to guide implementation and validate
the complete relay system functionality.
…tion

Provides complete reference documentation for the gasless relay system:

Sections:
- Architecture overview of three main components
- EIP-2771 compatibility explanation
- Detailed feature descriptions (replay prevention, rate limiting, etc.)
- Usage flow with code examples
- Comprehensive error reference table
- Security considerations and best practices
- Operational procedures for monitoring and management
- Performance characteristics
- Testing strategy (unit, integration, property tests)
- Future enhancement roadmap
- Governance model and role definitions
- Cost analysis for sponsored transactions
- Production deployment and rollback procedures
- References to standards and documentation

Documentation serves as:
- Technical reference for developers
- Operational guide for administrators
- Design rationale for stakeholders
- Integration guide for contract consumers

Includes code examples, tables, and clear explanations
of all system capabilities and constraints.
Remove unused imports:
- panic_with_error from gasless_relay.rs
- ToXdr, Symbol from gasless_relay_sig_verify.rs

This resolves clippy warnings about unused imports without changing code formatting.
@OZILSOLAR
OZILSOLAR force-pushed the feat/issue-131-gasless-relay branch from 06bd695 to ed8cdcf Compare August 20, 2026 03:42
- meter-simulator: Fixed ip-address vulnerability (v10.4.0 or higher)
- usage-dashboard: Upgraded dependencies to address minimatch and postcss vulnerabilities
- webhook-delivery-service: Already clean (0 vulnerabilities)

Results:
- meter-simulator: 0 vulnerabilities ✓
- webhook-delivery-service: 0 vulnerabilities ✓
- usage-dashboard: 2 high severity vulnerabilities remaining (requires Next.js v16+ breaking change)

The ip-address SSRF and trust-boundary bypass vulnerabilities have been resolved.
- Upgraded Next.js from ^14.2.35 to ^16.3.1 (breaking change)
- Pinned PostCSS to ^8.5.23 (security patch)
- Next.js v16 bundles patched versions of PostCSS and sharp

Results:
- Production audit (--omit=dev): 0 vulnerabilities ✓
- Resolves all npm audit checks on CI

Dev dependencies (minimatch in @typescript-eslint) remain but are omitted from production audit as per CI policy.
The upgrade from Next.js 14 to 16 resolves critical security vulnerabilities
in bundled dependencies (PostCSS, sharp). This is a necessary security fix
that allows the usage-dashboard to pass production dependency audits.
- Updated eslint-config-next from 14.0.4 to 16.3.1 (matches Next.js version)
- Updated TypeScript ESLint to v8.67.0
- Updated eslint to v10.8.1

Results:
- Production audit (--omit=dev): 0 vulnerabilities ✓
- Full audit (--audit-level=high): 0 vulnerabilities ✓

All npm audit CI checks now pass.
Upgrades rand crate to patch unsoundness vulnerability with custom logger usage.
Resolves cargo audit warning (RUSTSEC-2026-0097: rand is unsound with a custom
logger using rand::rng()).

No changes to Rust code - dependency version bump only.
The iot-payload-generator root package is for local testing and should not be
built for wasm32 target. Only build actual Soroban contracts in the contracts/
workspace.
More explicit approach to build only the contracts workspace for WASM target.
Also update artifact path to use contracts/target instead of root target.
Resolves 'no global memory allocator found' error when building Soroban contracts
for wasm32-unknown-unknown target.

Changes:
- Add wee_alloc 0.4.5 as dependency to all contracts
- Define #[global_allocator] in each contract's lib.rs
- Enable 'wasm' feature in common library for contracts that depend on it
- Feature-gate allocator for common lib (wasm-only)

This fixes the WASM compilation error across all contract packages.
…_alloc to settlement

- Move module doc comments in oracle-aggregator to the top of the file (before allocator)
  Inner doc comments (//!) must come first before any code
- Add wee_alloc dependency to settlement Cargo.toml
- Add allocator code to settlement lib.rs
@elizabetheonoja-art
elizabetheonoja-art merged commit 6a8901e into Utility-Protocol:main Aug 20, 2026
6 of 10 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.

Gasless Transaction Relay for User Onboarding

2 participants