Skip to content

fix: account_abstraction execute_with_session uses payload_hash = payload (not a real hash) - #562

Merged
Pvsaint merged 2 commits into
MetroLogic:mainfrom
Johnpii1:issue-502
Jul 27, 2026
Merged

fix: account_abstraction execute_with_session uses payload_hash = payload (not a real hash)#562
Pvsaint merged 2 commits into
MetroLogic:mainfrom
Johnpii1:issue-502

Conversation

@Johnpii1

Copy link
Copy Markdown
Contributor

close #502

Motivation
Reduce ledger reads in batch_expire_payments by avoiding full scans of merchant payment lists and instead sweep payments grouped by approximate expiry ledger buckets.
Prevent leaking raw session payloads in events and make SessionExecutedEvent.payload_hash semantically correct by storing a real 32-byte hash.

Description
Add DataKey::PaymentsByExpiry(u32) and DataKey::PaymentExpiryBuckets to index pending payments by an approximate expiry ledger bucket. (changes in fluxapay/src/lib.rs)
Implement expiry_bucket_for, index_payment_expiry, and remove_payment_from_expiry_bucket helpers and call them from create_payment and create_payments_batch to populate the index and on cancel/expire to cleanup. (changes in fluxapay/src/lib.rs)
Update batch_expire_payments to prefer processing the lowest expired bucket (up to 50 candidates) before falling back to caller-provided IDs. (changes in fluxapay/src/lib.rs)
Change account-abstraction behavior to compute and emit a SHA-256 hash of the payload via env.crypto().sha256(&payload) and store it as BytesN<32> instead of publishing the raw payload. (changes in fluxapay/src/account_abstraction.rs and fluxapay/src/events.rs)
Add a unit test asserting deterministic/distinct hashing for session payloads. (changes in fluxapay/src/account_abstraction.rs)

Testing
Ran git diff --check and staged commit; repository changes were committed successfully. (success)
Attempted cargo test -p fluxapay --lib account_abstraction --no-default-features, but the run is blocked by a pre-existing parse error in fluxapay/src/dispute_test.rs (unclosed delimiter) unrelated to these changes. (blocked)
Ran cargo check -p fluxapay --no-default-features; full check failed due to pre-existing repository compile issues (duplicate definitions / name-length and other Soroban-related errors) that predated these changes. (blocked)
cargo fmt / rustfmt could not run because of the same pre-existing parse error in fluxapay/src/dispute_test.rs. (blocked)

Johnpii1 added 2 commits July 27, 2026 12:18
- Index payments by approximate expiry bucket for batch expiration
- Clean expiry bucket entries as payments leave pending state
- Hash account abstraction session payloads before event emission
- Closes MetroLogic#504
- Closes MetroLogic#502
…nts-with-index

perf(payment): add expiry-bucket index & fix session payload hashing
@drips-wave

drips-wave Bot commented Jul 27, 2026

Copy link
Copy Markdown

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

@Pvsaint
Pvsaint merged commit 81fbd70 into MetroLogic:main Jul 27, 2026
0 of 2 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.

fix: account_abstraction execute_with_session uses payload_hash = payload (not a real hash)

2 participants