Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plan to Increase Logging in Payments #2502

Open
humansinstitute opened this issue Jan 29, 2025 · 1 comment
Open

Plan to Increase Logging in Payments #2502

humansinstitute opened this issue Jan 29, 2025 · 1 comment
Assignees
Labels
bug Something isn't working Logging Project

Comments

@humansinstitute
Copy link
Contributor

humansinstitute commented Jan 29, 2025

@kevkevinpal tracking here.

Can we introduce Logging to activities on attempts to make invoice payments through the Sphinx Payment Architecture.

This will be to address issues where we have observed rare occurrences of a payment being made, failing and then the balance being deducted from the Sphinx App.

The plan would be to introduce three additional logging records for each of the attempts to pay an invoice so we can begin to track any specific balance issues.

ON SEND:
Track the state of the balance on every attempt to make a payment. As I understand it he sphinx wallet will try this once and the LSP will attempt multiple retries if the first fails.

The idea is to track the state of the wallet prior to a send happening, this is like having a user write down their balance before they try and send.
{
 SendID: // I'm assuming we might track a unique ID for each attempt to pay perhaps we track that here if we do.
 timestamps: timestamp // log time of send
 balance state: int. // Should be the balance of Pubkey account prior to sending
 invoice: string
 amount: int
 sphinxPubKey: // pubkey of account holder

}

ON SEND SUCCESS:
Track the balance state immediately after we see the receipt of payment and preImage is received by our node.
{
 SendID: // If we can track the specific Send that led to success we can track that to make reconcilliation easier.
 timestamps: timestamp // log time of success
 balance state: int // Check curent balance after successful payment - should be less than ON SEND
 invoice: string
 amount: int
preImage: string // acts as a receipt so we know the funds were definitely received
 sphinxPubKey: // pubkey of account holder
}

ON SEND FAIL:
If a send fails. Then we will track the balance
{
 SendID: // If we can track the specific Send that led to success we can track that to make reconcilliation easier.
 timestamps: timestamp // log time of fail
 balance state: int. // IF we refund the balance on the failed payment, we need to log the current balance state after payment refund - this hsould be the same as ON SEND - if not we could trigger an alert.
 invoice: string
 amount: int
error: string // any error messages we are throwing.
 sphinxPubKey: // pubkey of account holder
}

  • From a single invoice we should then be able to see an entire timeline of sends, success and failures.
  • If a hunter has a failed payment we should be able to track to the set of invoices, use the preimages to ensure receipt or not and see where the balance state os getting updated correctly or not.
@humansinstitute
Copy link
Contributor Author

Current implementation Logic:

  • Balance is deducted on send
  • Balance is then refunded when we know it is failed
  • Balance could get out of sync if we don't get the failure reversal executed correctly

We could potentially reverse this logic.

or we could log and monitor figure out the frequency, triggers (e.g. channels down, restarts)

Current plan we should log first prior to updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Logging Project
Projects
None yet
Development

No branches or pull requests

2 participants