-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Link payer to gateway envelopes (#536)
### TL;DR Added payer tracking to gateway envelopes by linking them to payer records in the database. It's very hard to fill this link in after-the-fact, since it requires recovering the signer address from the `PayerEnvelope`, so I think it makes sense to store it on every row even if we don't have an immediate use for querying by the field. ### Issues - #527 - #529 ### What changed? - Added a `payer_id` column to the `gateway_envelopes` table that references the `payers` table - Modified the `InsertGatewayEnvelope` query to include the `payer_id` field - Updated the publish worker and sync worker to extract payer information from envelopes and store it - Added validation of originator envelopes before processing - Updated tests to include payer IDs in test data ### How to test? - Run existing test suite which has been updated to include payer tracking - Verify that gateway envelopes are properly linked to payer records - Confirm that invalid envelopes are rejected during validation - Check that payer addresses are correctly recovered from signatures ### Why make this change? This change enables tracking of message payers in the system, which is essential for: - Monitoring message usage per payer - Supporting future billing and rate limiting features - Improving system accountability and auditability <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Enhanced envelope processing now includes robust validation and integration of payer information, improving reliability and message tracking. - **Chores** - Updated the database schema and migrations to support a new payer identifier. - Refined internal setups to align with the enhanced payer-data integration. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
- Loading branch information
Showing
12 changed files
with
106 additions
and
13 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
pkg/migrations/00006_link-payer-to-gateway-envelopes.down.sql
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
ALTER TABLE gateway_envelopes | ||
DROP COLUMN payer_id; | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
ALTER TABLE gateway_envelopes | ||
-- Leave column nullable since blockchain originated messages won't have a payer_id | ||
ADD COLUMN payer_id INT REFERENCES payers(id); | ||
|
This file contains 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
This file contains 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
Oops, something went wrong.