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

feat: Add incentivization PoC for RLNaaS in Lightpush #3166

Merged
merged 40 commits into from
Jan 22, 2025

Conversation

s-tikhomirov
Copy link
Contributor

@s-tikhomirov s-tikhomirov commented Nov 1, 2024

Description

This WIP PR implements a PoC for light protocol incentivization as outlined in:

Associated deliverable: waku-org/pm#245

Changes

  • cherry-pick prior PoC work from an experimental branch
  • remove the dummy protocol (not needed anymore)
  • implement the required transaction checks (payment amount, address)
  • use Anvil for testing instead of a hard-coded Infura RPC endpoint

Changes planned for future PRs

@s-tikhomirov s-tikhomirov changed the title [WIP] Add incentivization PoC for RLNaaS in Lightpush [WIP] feat: Add incentivization PoC for RLNaaS in Lightpush Nov 1, 2024
@s-tikhomirov s-tikhomirov changed the title [WIP] feat: Add incentivization PoC for RLNaaS in Lightpush feat: Add incentivization PoC for RLNaaS in Lightpush Nov 1, 2024
Copy link

github-actions bot commented Nov 1, 2024

You can find the image built from this PR at

quay.io/wakuorg/nwaku-pr:3166

Built from 53aea7f

@s-tikhomirov s-tikhomirov force-pushed the feat/incentivization-poc-txid-check branch from 24f9aa8 to 3bf670b Compare November 28, 2024 06:23
@Ivansete-status
Copy link
Collaborator

@s-tikhomirov - is there anything blocking this PR?

@s-tikhomirov
Copy link
Contributor Author

@s-tikhomirov - is there anything blocking this PR?

Good question.

On the one hand, there are still things to implement before this can be considered a fully-fledged PoC. For example, the properties of a transaction that is checked for "eligibility" are now simply hard-coded. In the final vision, those should be node-specific and stored in a config file or something like that (and I'd have to figure out where such files should be located, how to manage them, etc). On the other hand, the current version is more or less self-contained, and in the spirit of merging things incrementally, I could see this PR at least considered for review.

For context: the overall vision of this PoC is that a client would attach a txid as proof of payment alongside its Lightpush request, and the server would check for eligibility of that txid. By eligibility we mean that the transaction:

  • has been confirmed;
  • is not a contract creation transaction;
  • pays the expected amount;
  • pays to the expected destination;
  • hasn't been used in a previous request.

Here is what is implemented now:

  • check that the tx has been confirmed;
  • check that the tx is a simple transfer (not a contract creation and not a contract call);
  • check that the amount is "expected" (a hard-coded amount from a totally random tx used in tests);
  • check that the destination is "expected" (also hard-coded, same as with the amount).

These could be the next steps:

  • avoid hard-coded values (use server-specific expected amounts and destinations);
  • use token transfer transactions and not simple transfers (as described here; I'm using simple transfers now for simplicity);
  • account for double-spent txids;
  • avoid hard-coded Infura endpoint for querying the blockchain;
  • attach this to Lightpush (behind a feature flag).

Given this, do you think it makes sense to consider this PR for review as it stands now?

@jm-clius , WDYT?

@jm-clius
Copy link
Contributor

jm-clius commented Dec 5, 2024

Without having looked at the code itself yet, based on your description I would certainly suggest opening for review - or even selecting a smaller increment that illustrates a specific function and creating a PR for that. This way we can show the POC growing, remain clear about next steps and what is WIP, while making the turnaround from PR to merge shorter due to the easier review burden on nwaku contributors.

Copy link
Contributor

@gabrielmer gabrielmer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing work! Thanks so much! 🤩

I added some questions and comments, please let me know if I'm missing anything in any of them :)

I also see that the Lint CI job is failing, please try installing the latest version of https://github.com/arnetheduck/nph/tree/latest and integrate it with your IDE (let me know if you have any issues with it, I can help out!)

waku/incentivization/common.nim Outdated Show resolved Hide resolved
waku/incentivization/rpc_codec.nim Outdated Show resolved Hide resolved
waku/incentivization/txid_proof.nim Outdated Show resolved Hide resolved
waku/incentivization/txid_proof.nim Outdated Show resolved Hide resolved
waku/incentivization/txid_proof.nim Outdated Show resolved Hide resolved
waku/incentivization/txid_proof.nim Outdated Show resolved Hide resolved
tests/incentivization/test_poc.nim Outdated Show resolved Hide resolved
Copy link
Collaborator

@Ivansete-status Ivansete-status left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for it!
I just added some nitpick comment that I hope you find useful

tests/incentivization/test_poc.nim Show resolved Hide resolved
tests/incentivization/test_poc.nim Show resolved Hide resolved
waku/incentivization/eligibility.nim Outdated Show resolved Hide resolved
waku/incentivization/txid_proof.nim Outdated Show resolved Hide resolved
waku/incentivization/txid_proof.nim Outdated Show resolved Hide resolved
waku/incentivization/txid_proof.nim Outdated Show resolved Hide resolved
waku/incentivization/txid_proof.nim Outdated Show resolved Hide resolved
waku/incentivization/txid_proof.nim Outdated Show resolved Hide resolved
waku/incentivization/txid_proof.nim Outdated Show resolved Hide resolved
Copy link
Contributor

@jm-clius jm-clius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Added a couple of initial comments to address below.

waku/incentivization/eligibility.nim Outdated Show resolved Hide resolved
waku/incentivization/txid_proof.nim Outdated Show resolved Hide resolved
waku/incentivization/txid_proof.nim Outdated Show resolved Hide resolved
waku/incentivization/txid_proof.nim Outdated Show resolved Hide resolved
waku/incentivization/txid_proof.nim Outdated Show resolved Hide resolved
waku/incentivization/txid_proof.nim Outdated Show resolved Hide resolved
waku/incentivization/txid_proof.nim Outdated Show resolved Hide resolved
waku/incentivization/txid_proof.nim Outdated Show resolved Hide resolved
waku/incentivization/common.nim Outdated Show resolved Hide resolved
@s-tikhomirov s-tikhomirov force-pushed the feat/incentivization-poc-txid-check branch 2 times, most recently from b3890ca to d865b1a Compare December 13, 2024 16:57
@s-tikhomirov s-tikhomirov force-pushed the feat/incentivization-poc-txid-check branch from 35e2479 to ae9fb73 Compare December 13, 2024 18:09
s-tikhomirov and others added 25 commits January 22, 2025 11:06
Co-authored-by: gabrielmer <[email protected]>
Co-authored-by: Ivan FB <[email protected]>
@s-tikhomirov s-tikhomirov force-pushed the feat/incentivization-poc-txid-check branch from 4d8173f to 56ea04d Compare January 22, 2025 10:08
@s-tikhomirov s-tikhomirov merged commit 505ec84 into master Jan 22, 2025
9 of 11 checks passed
@s-tikhomirov s-tikhomirov deleted the feat/incentivization-poc-txid-check branch January 22, 2025 10:16
@jm-clius
Copy link
Contributor

Btw, useful to add links to the associated deliverable in the PR description: waku-org/pm#245

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.

4 participants