feat: incentivization POC: add double-spend check for txid-based eligibility #3264
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.
Description
This is a continuation of the work started in #3166 with associated deliverable waku-org/pm#245.
The overall task is to implement a proof-of-concept service incentivization mechanism, where clients submit txids alongside their requests, and servers check eligibility of those txids as proofs of payment.
This PR adds a check against double-spending. A client is prevented from submitting the same txid twice. The server keeps track of txids it has seen, and checks every txid against that set. If the txid is in the set, the eligibility check fails.
Note the assumption: a transaction once deemed ineligible will never become eligible in the future, even (for example) in a scenario where a transaction underpaid, and later the server decreased its prices. Such scenarios look too complicated for a PoC. For now, we assume that a server declares a transaction eligible or ineligible when it is first submitted as proof of payment. No matter the result of the initial check, the same txid will be ineligible on all future submissions.
Changes