fix: account_abstraction execute_with_session uses payload_hash = payload (not a real hash) - #562
Merged
Merged
Conversation
- 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
|
@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! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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)