Skip to content

feat: allow any spl paid token flag#175

Merged
dev-jodee merged 9 commits intosolana-foundation:mainfrom
Yolley:feat/allow_any_paid_token
Aug 28, 2025
Merged

feat: allow any spl paid token flag#175
dev-jodee merged 9 commits intosolana-foundation:mainfrom
Yolley:feat/allow_any_paid_token

Conversation

@Yolley
Copy link
Copy Markdown
Contributor

@Yolley Yolley commented Aug 18, 2025

Add allow_any_spl_paid_token flag that will bypass check (and takes precedence) for whether token is in allowed_spl_paid_tokens when checking whether transaction is paid.

For our use case we need to allow to use any SPL token for payment - the price of the token will be checked by the oracle. An alternative would be to allow allowed_spl_paid_tokens be empty, but I think that having this flag set explicitly makes more sense for backwards compatibility and security reasons.

@Yolley Yolley force-pushed the feat/allow_any_paid_token branch from df8f2cc to 37d14a0 Compare August 19, 2025 12:25
@Yolley
Copy link
Copy Markdown
Contributor Author

Yolley commented Aug 19, 2025

@dev-jodee @amilz please take a look, I can't assign reviewers.

Copy link
Copy Markdown
Contributor

@dev-jodee dev-jodee left a comment

Choose a reason for hiding this comment

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

Small changes and you'll most likely need to rebase on release/pre-release-main-branch since there's been a lot of changes :)


let _ = update_config(config);

let rpc_client = RpcClient::new("http://localhost:8899".to_string());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we use mocked RPC client here for unit testing we don't want to require the local validator to be running.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hm, I just used the same pattern with client initialisation as in other tests, will take a look.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey, yeah might be the older version / so many changes have been happening, but here's the function to mock it https://github.com/solana-foundation/kora/pull/159/files#diff-e2aa8bf42a1b7b8111e7a9bc6b7990fa5efad819e5aa67fcdd2dbfed1ad79f53R93

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I see, thank you, updated the branch, please check.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Use the RpcMockBuilder, it still points to a local url

@Yolley Yolley force-pushed the feat/allow_any_paid_token branch from 37d14a0 to e5016e2 Compare August 20, 2025 13:21
@Yolley Yolley requested a review from dev-jodee August 20, 2025 13:36
@amilz amilz self-requested a review August 20, 2025 15:26
Copy link
Copy Markdown
Contributor

@amilz amilz 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 the PR @Yolley -- a couple of thoughts.

1. Unified SplTokenPaymentConfig

Rather than two potentially conflicting fields in the config, could we do a single one that accepts an allowlist or ALL? I think it'd be a cleaner devex and reduce risk of conflicting configs.

Something like this:

  // In config.rs
  pub enum SplTokenPaymentConfig {
      All,                    // Accept any SPL token
      Allowlist(Vec<String>), // Accept only specific tokens
  }

  impl Default for SplTokenPaymentConfig {
      fn default() -> Self {
          SplTokenPaymentConfig::Allowlist(vec![])
      }
  }

  // In ValidationConfig
  pub struct ValidationConfig {
      // ... other fields ...
      pub allowed_spl_paid_tokens: SplTokenPaymentConfig,
  }

I think this change might require a tweak to crates/lib/src/validator/config_validator.rs to skip check if All. Could even add a warning if all is enabled: "Warning allowed for payments"

2. Test coverage--would you mind adding a test or todo to make sure we throw if our oracle does not find a token.

@Yolley
Copy link
Copy Markdown
Contributor Author

Yolley commented Aug 20, 2025

Hey, @amilz I don't think that making allowed_spl_paid_tokens a dynamic type field (either constant "ALL" or a list of values) in toml will be cleaner - seems like an anti pattern to have a field of different types. An alternative could also be to have magic "all" value in the allowed_spl_paid_tokens list, but then it also seems weird to mix real pubkeys and some magic values here.

I guess we could also make allowed_spl_paid_tokens an object in toml with two fields - mode and addresses or something. But then it will be backwards incompatible with how it's managed right now.

So in my opinion having 2 fields with one taking precedence over the other could be cleaner.

@Yolley Yolley force-pushed the feat/allow_any_paid_token branch from 37680ad to a1f36fd Compare August 21, 2025 15:42
@Yolley Yolley requested a review from amilz August 21, 2025 15:42
@Yolley
Copy link
Copy Markdown
Contributor Author

Yolley commented Aug 21, 2025

@amilz I switched to the proposed solution - whilte I am not a fan of it, it's not necessarily bad. Also added a test for jup oracle for when it does not return price for a token. Please take look.

@Yolley Yolley force-pushed the feat/allow_any_paid_token branch 2 times, most recently from 91184af to dc4daf2 Compare August 22, 2025 15:20
@Yolley
Copy link
Copy Markdown
Contributor Author

Yolley commented Aug 22, 2025

@dev-jodee @amilz please take a look, with updates coming to the repo every couple of hours it becomes tedious to rebase this branch. 🌚

@dev-jodee
Copy link
Copy Markdown
Contributor

@amilz I switched to the proposed solution - whilte I am not a fan of it, it's not necessarily bad. Also added a test for jup oracle for when it does not return price for a token. Please take look.

Hey @Yolley, sorry we've been crunching out features, the pr itself seems fine, I'm just trying to think of a case where a node operator would be willing to allow any spl tokens, with Solana having many 100s of thousands of tokens created every week or so, this seems extremely dangerous, what use case did you have in mind that would warrant allowing all spl tokens as payment?

@Yolley
Copy link
Copy Markdown
Contributor Author

Yolley commented Aug 22, 2025

@amilz I switched to the proposed solution - whilte I am not a fan of it, it's not necessarily bad. Also added a test for jup oracle for when it does not return price for a token. Please take look.

Hey @Yolley, sorry we've been crunching out features, the pr itself seems fine, I'm just trying to think of a case where a node operator would be willing to allow any spl tokens, with Solana having many 100s of thousands of tokens created every week or so, this seems extremely dangerous, what use case did you have in mind that would warrant allowing all spl tokens as payment?

Hey, our use-case is to use fee relayer when claiming an Airdrop - so sol/rent fees are covered by the relayer, and user pays from their allocation. And an Airdrop can be created for any token as platform is permissionles.

Another use case I'd say could be for token-swaps? Like on a DEX - in case user does not have enough sol to cover processing fees, so the platform allows to pay with swapped tokens.

I don't see how it's "extremely" dangerous tho - we still check for the token price and make sure that the fees are covered according to pricing model configuration. I guess there could be an issue with prices changing a lot, but I don't see a clear fix for this right - I guess we could use a mix of volume/orderbook state or something, but it also depends on what Oracle can provide.

@Yolley
Copy link
Copy Markdown
Contributor Author

Yolley commented Aug 26, 2025

@dev-jodee @amilz pretty please, I am tired of rebasing the branch.

@dev-jodee
Copy link
Copy Markdown
Contributor

@dev-jodee @amilz pretty please, I am tired of rebasing the branch.

Think the pr makes sense, sorry for the recurring rebase, branch is actively being worked on, finally merged the huge pre-release PR into main, if you rebase against main (might be easier to make a new branch from main and cherry-pick your commit into it), I can do final review and merge

@Yolley Yolley force-pushed the feat/allow_any_paid_token branch from dc4daf2 to 50929b9 Compare August 28, 2025 07:49
@Yolley Yolley changed the base branch from release/pre-release-main-branch to main August 28, 2025 07:49
@Yolley
Copy link
Copy Markdown
Contributor Author

Yolley commented Aug 28, 2025

@dev-jodee Hey, I rebased from main, also aded an additional test to toml_mock, please check and let's finally get this merged.

Copy link
Copy Markdown
Contributor

@dev-jodee dev-jodee left a comment

Choose a reason for hiding this comment

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

Alright just a couple of nits for clarity and then we can merge :)


let _ = update_config(config);

let rpc_client = RpcClient::new("http://localhost:8899".to_string());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Use the RpcMockBuilder, it still points to a local url

@amilz
Copy link
Copy Markdown
Contributor

amilz commented Aug 28, 2025

thx @Yolley
@dev-jodee do we need to do anything here to protect infinite loop when usesr calls initialize_atas ? probably would give me most peace of mind if we had a test init_ata_gracefully_does_nothing_if_all_tokens_enabled
also, wdyt about adding a warning on kora config validate: warning that all tokens are accepted--node may experience volatility, etc.

@Yolley
Copy link
Copy Markdown
Contributor Author

Yolley commented Aug 28, 2025

Hey, @amilz I've added a test test_initialize_atas_when_all_tokens_are_allowed, also regarding warning - even if user passes some tokens, node can still experience volatility if they pass volatile tokens, does it really make sense to issue another warning here, given that the configuration to enable all tokens is explicit?

@Yolley Yolley requested a review from dev-jodee August 28, 2025 15:12
@dev-jodee dev-jodee merged commit 7bf4fa9 into solana-foundation:main Aug 28, 2025
1 of 2 checks passed
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.

3 participants