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

[PAY-2178] Initial implementation of payment router indexing #6892

Merged
merged 14 commits into from
Dec 11, 2023
1 change: 1 addition & 0 deletions dev-tools/compose/docker-compose.discovery.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ services:
audius_solana_track_listen_count_address: '${SOLANA_TRACK_LISTEN_COUNT_PUBLIC_KEY}'
audius_solana_signer_group_address: '${SOLANA_SIGNER_GROUP_PUBLIC_KEY}'
audius_solana_user_bank_program_address: '${SOLANA_CLAIMABLE_TOKENS_PUBLIC_KEY}'
audius_solana_payment_router_program_address: '${SOLANA_PAYMENT_ROUTER_PUBLIC_KEY}'
audius_solana_waudio_mint: '${SOLANA_TOKEN_MINT_PUBLIC_KEY}'
audius_solana_usdc_mint: '${SOLANA_USDC_TOKEN_MINT_PUBLIC_KEY}'
audius_solana_rewards_manager_program_address: '${SOLANA_REWARD_MANAGER_PUBLIC_KEY}'
Expand Down
1 change: 1 addition & 0 deletions dev-tools/compose/docker-compose.pedalboard.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ services:
audius_solana_rewards_manager_program_address: '${SOLANA_REWARD_MANAGER_PUBLIC_KEY}'
audius_solana_rewards_manager_account: '${SOLANA_REWARD_MANAGER_PDA_PUBLIC_KEY}'
audius_solana_user_bank_program_address: '${SOLANA_CLAIMABLE_TOKENS_PUBLIC_KEY}'
audius_solana_payment_router_program_address: '${SOLANA_PAYMENT_ROUTER_PUBLIC_KEY}'
audius_solana_waudio_mint: '${SOLANA_TOKEN_MINT_PUBLIC_KEY}'
audius_solana_usdc_mint: '${SOLANA_USDC_TOKEN_MINT_PUBLIC_KEY}'
audius_solana_fee_payer_wallets: '[{"privateKey":${SOLANA_FEEPAYER_SECRET_KEY}}]'
Expand Down
4 changes: 4 additions & 0 deletions monitoring/uptime/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ type Config struct {
ClaimableTokenPda string
SolanaFeePayerAddress string
ClaimableTokenProgramAddress string
PaymentRouterProgramAddress string
RewardsManagerProgramId string
RewardsManagerProgramPda string
RewardsManagerTokenPda string
Expand Down Expand Up @@ -118,6 +119,7 @@ func startStagingOrProd(isProd bool, nodeType, env string) {
claimableTokenPda := ""
solanaFeePayerAddress := ""
claimableTokenProgramAddress := ""
paymentRouterProgramAddress := ""
rewardsManagerProgramId := ""
rewardsManagerProgramPda := ""
rewardsManagerTokenPda := ""
Expand Down Expand Up @@ -179,6 +181,7 @@ func startStagingOrProd(isProd bool, nodeType, env string) {
claimableTokenPda = mustGetenv("audius_solana_claimable_token_pda")
solanaFeePayerAddress = mustGetenv("audius_solana_fee_payer_address")
claimableTokenProgramAddress = mustGetenv("audius_solana_user_bank_program_address")
paymentRouterProgramAddress = mustGetenv("audius_solana_payment_router_program_address")
rewardsManagerProgramId = mustGetenv("audius_solana_rewards_manager_program_address")
rewardsManagerProgramPda = mustGetenv("audius_solana_rewards_manager_account")
rewardsManagerTokenPda = mustGetenv("audius_solana_rewards_manager_token_pda")
Expand Down Expand Up @@ -240,6 +243,7 @@ func startStagingOrProd(isProd bool, nodeType, env string) {
ClaimableTokenPda: claimableTokenPda,
SolanaFeePayerAddress: solanaFeePayerAddress,
ClaimableTokenProgramAddress: claimableTokenProgramAddress,
PaymentRouterProgramAddress: paymentRouterProgramAddress,
schottra marked this conversation as resolved.
Show resolved Hide resolved
RewardsManagerProgramId: rewardsManagerProgramId,
RewardsManagerProgramPda: rewardsManagerProgramPda,
RewardsManagerTokenPda: rewardsManagerTokenPda,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
begin;

CREATE TABLE IF NOT EXISTS payment_router_txs (
signature character varying NOT NULL,
slot integer NOT NULL,
created_at timestamp without time zone NOT NULL
);

CREATE INDEX IF NOT EXISTS idx_payment_router_txs_slot ON payment_router_txs USING btree (slot);

commit;
4 changes: 3 additions & 1 deletion packages/discovery-provider/default_config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ eth_provider_url = http://localhost:8546
[solana]
track_listen_count_address = 7K3UpbZViPnQDLn2DAM853B9J5GBxd1L1rLHy4KqSmWG
signer_group_address = FbfwE8ZmVdwUbbEXdq4ofhuUEiAxeSk5kaoYrJJekpnZ
endpoint =
endpoint =
user_bank_min_slot = 0
payment_router_min_slot = 0
user_bank_program_address = Ewkv3JahEFRKkcJmpoKB7pXbnUHwjAyXiwEo4ZY2rezQ
payment_router_program_address = paytYpX3LPN98TAeen6bFFeraGSuWnomZmCXjAsoqPa
schottra marked this conversation as resolved.
Show resolved Hide resolved
waudio_mint = 9LzCMqDgTKYz9Drzqnpgee3SGa89up3a247ypMj2xrqM
usdc_mint = EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
rewards_manager_program_address = DDZDcYdQFEMwcu2Mwo75yGFjJ1mUQyyXLWzhZLEVFcei
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ const readConfig = () => {
audius_solana_user_bank_program_address: str({
default: 'testHKV1B56fbvop4w6f2cTGEub9dRQ2Euta5VmqdX9'
}),
audius_solana_payment_router_program_address: str({
default: 'apaySbqV1XAmuiGszeN4NyWrXkkMrnuJVoNhzmS1AMa'
}),
audius_solana_rewards_manager_program_address: str({
default: 'testLsJKtyABc9UXJF8JWFKf1YH4LmqCWBC42c6akPb'
}),
Expand Down Expand Up @@ -89,6 +92,7 @@ const readConfig = () => {
rewardsManagerProgramId: env.audius_solana_rewards_manager_program_address,
rewardsManagerAccountAddress: env.audius_solana_rewards_manager_account,
claimableTokenProgramId: env.audius_solana_user_bank_program_address,
paymentRouterProgramId: env.audius_solana_payment_router_program_address,
trackListenCountProgramId: env.audius_solana_track_listen_count_address,
usdcMintAddress: env.audius_solana_usdc_mint,
waudioMintAddress: env.audius_solana_waudio_mint,
Expand Down
6 changes: 6 additions & 0 deletions packages/discovery-provider/src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ def configure_celery(celery, test_config=None):
"src.tasks.index_solana_plays",
"src.tasks.index_challenges",
"src.tasks.index_user_bank",
"src.tasks.index_payment_router",
"src.tasks.index_eth",
"src.tasks.index_oracles",
"src.tasks.index_rewards_manager",
Expand Down Expand Up @@ -370,6 +371,10 @@ def configure_celery(celery, test_config=None):
"task": "index_user_bank",
"schedule": timedelta(seconds=5),
},
"index_payment_router": {
"task": "index_payment_router",
"schedule": timedelta(seconds=5),
Copy link
Member

Choose a reason for hiding this comment

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

I actually don't recall the original reason for 5s interrupts in these on solana, but might improve our overall indexing speed if we lower it... (not this PR)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Worth a test! I would imagine the volume being processed on prod is much higher so maybe we don't want to get overwhelmed? But as it was, I was seeing up to 10 seconds locally for the transaction to be picked up.

},
"index_challenges": {
"task": "index_challenges",
"schedule": timedelta(seconds=5),
Expand Down Expand Up @@ -481,6 +486,7 @@ def configure_celery(celery, test_config=None):
redis_inst.delete("solana_plays_lock")
redis_inst.delete("index_challenges_lock")
redis_inst.delete("user_bank_lock")
redis_inst.delete("payment_router_lock")
redis_inst.delete("index_eth_lock")
redis_inst.delete("index_oracles_lock")
redis_inst.delete("solana_rewards_manager_lock")
Expand Down
12 changes: 12 additions & 0 deletions packages/discovery-provider/src/models/users/payment_router.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from sqlalchemy import Column, DateTime, Integer, String

from src.models.base import Base
from src.models.model_utils import RepresentableMixin


class PaymentRouterTx(Base, RepresentableMixin):
__tablename__ = "payment_router_txs"

signature = Column(String, primary_key=True)
slot = Column(Integer, nullable=False, index=True)
created_at = Column(DateTime, nullable=False)
Loading