Commit Graph

450 Commits

Author SHA1 Message Date
Bryan Stitt
8aac4779bf clean up some selects 2023-08-02 21:27:56 -07:00
Bryan Stitt
d25884dfbb dont cache responses larger than 2MB 2023-08-02 15:22:26 -07:00
Bryan Stitt
a696fb92f6 disable CheckEmailInput for now 2023-07-27 13:52:12 -07:00
Bryan Stitt
32a73a0c53 cargo upgrade --incompatible 2023-07-27 12:29:10 -07:00
Bryan Stitt
67fd5a2188 change log levels 2023-07-26 16:42:49 -07:00
Bryan Stitt
788ebff29f improve logging during payment parsing 2023-07-26 16:39:17 -07:00
Bryan Stitt
2b14842879 check the payment factory address against the log address 2023-07-26 13:22:13 -07:00
Bryan Stitt
05e618f74c
Anon rpc accounting (#194)
* cargo generate migrations didnt work without this

* anon rpc accounting

* Revert "anon rpc accounting"

This reverts commit f1b8cbcdeca0d5f9545da32f11dda6a90854f97a.

* 0 for anon in mysql

* only set approximate_balance_remaining on owned stats

* only set self.approximate_balance_remaining when adding if some

* todo complete
2023-07-24 22:02:33 -07:00
Bryan Stitt
439ac49495 jsonrpc formatted errors for JsonRejection 2023-07-24 16:25:58 -07:00
Bryan Stitt
39141c1e52 comments 2023-07-21 22:14:31 -07:00
Bryan Stitt
0b1cfeffed use normalize path layer to trim trailing slash 2023-07-20 20:05:37 -07:00
Bryan Stitt
cb5c1c6582 no limits on rpc_secret_key_cache and user_balance_cache 2023-07-20 19:04:32 -07:00
Bryan Stitt
ae8a12047e tarpit strange methods 2023-07-20 14:32:52 -07:00
Bryan Stitt
e7905b4344 Revert "First pass implementation of async serialize for Web3Rps (#192)"
This reverts commit 269aa32260a4c3e94d7ada55fee6c8e62d975c87.
2023-07-19 23:12:49 -07:00
Bryan Stitt
ac2d9049be improve flushing and buffering of stats 2023-07-19 22:55:14 -07:00
Bryan Stitt
e6dc64f369 add timeout as a the tower layer 2023-07-19 18:41:26 -07:00
Bryan Stitt
a97cb6a0c5 lint 2023-07-18 09:50:51 -07:00
Bryan Stitt
600c1bafb4
David/multiple proxy test (#187)
* add test_multiple_proxies_stats_add_up

* make a premium user using both proxies

* added a couple clones, must add constraints now to run for multiple-proxies (check arithmetic)

* lint and code review

* fix comment

* fix tests (now fails at todo)

* will introduce endpoint to fetch rpc stats from mysql

* added influxdb to tests, should next do asserst in stats collected by influx, and mysql for multi-proxy

* created test where influx and mysql have separate data, should help with debugging

* forgot to drop influx

* tests pass except multi-proxy

* test passes, will check out nothing broke elswhere

* go back to numbers

* some linting

* linting

* removed redundant info!

* responding to PR comments

* ULID as instance-hash for the tag in influx (for anti-dup)

---------

Co-authored-by: yenicelik <david.yenicelik@gmail.com>
2023-07-17 13:31:41 -07:00
Bryan Stitt
fe672b5189 dont disable on_failure. the log breadcrumbs can be helpful still 2023-07-14 23:04:24 -07:00
Bryan Stitt
61126bb2ac one more Cow 2023-07-14 18:35:40 -07:00
Bryan Stitt
0046a02a4a
Global db (#191)
* dont migrate on start. just connect

* it compiles

* that log is loud

* get transaction from a local clone

* import the trait

* put the test app into a thread instead of tokio::spawn

* fix one test

* try db before rpcs

* db connection is too slow. need to wait for it

* do db setup once while spawning
2023-07-14 18:30:01 -07:00
Bryan Stitt
269aa32260
First pass implementation of async serialize for Web3Rps (#192)
Co-authored-by: Rory Neithinger <rorytrent@gmail.com>
2023-07-14 18:29:48 -07:00
Bryan Stitt
fe45813e4c remove info logging 2023-07-14 01:21:50 -07:00
Bryan Stitt
6371206315 rate limit by ip if unknown key 2023-07-14 00:23:05 -07:00
David
31f840432d
Add DateCreated fields to admin and on-chain deposit (#190)
* tests seem to be passing

* bump version

* bump version
2023-07-13 19:25:14 -07:00
Bryan Stitt
45af241429 less db transactions 2023-07-13 15:44:07 -07:00
Bryan Stitt
53877ed2e5 less transactions when handling uncles 2023-07-13 10:27:44 -07:00
Bryan Stitt
28e6be5d9b handle uncles in the background and keep transaction open for a shorter time 2023-07-13 10:13:50 -07:00
Bryan Stitt
fa21b7c0a8 lint 2023-07-13 10:13:14 -07:00
David
c1a3a2dfbb
Remove stripe duplicate endpoint (#186) 2023-07-12 19:19:15 -07:00
Bryan Stitt
5d207fb2c6
Auto tier change (#184)
* lint

* change user to premium on admin credits

todo: change on other deposits

* set tier more places

* BadRequest instead of 500

* insert existing users too

* add the premium file
2023-07-12 10:24:16 -07:00
Bryan Stitt
df2f3d340f
More balance tests (#182)
* fix popularity contest

* more info in the Debug for Web3Rpc

* add frontend_requests and cache_misses to the Balance query

* add more to balance and stats flushing and improved test coverage

* it compiles

* deserializer for Ulid to Uuid

I think a wrapper type on Ulid that implements sea_orm::Value is probably better

* rename variable to match struct name

* add deserializer for Address -> Vec<u8>

* sql sum returns a Decimal. need to convert to u64

* assert more

* one log and assert more

* log more

* use a helper to get the user's rpc provider

* this should be 2 now that we have a public and authed call

* this should be zero. the public has the cache miss

* instrument cu calcs

* trace the value we took, not the default that replaced it

* move usd_per_chain into config

* remove some extra logging

* use Arc::into_inner to maybe avoid a race

* off by 1

* pass paid credits used instead of returning it

this lets us use it to write to our user balance cache first. importantly, this keeps us from holding a write lock while writing to mysql

* no cache misses expected in this test

* actually check the admin

* put the balance checks back now that the rest of the test works

* archive request is being set incorrectly

* wow howd we manage flipping the greater than sign on archive depth

* move latest_balance and premium_credits_used to before any stats are emitted

* lint

* and build undoes the linting. fun

i didnt even want to lint them in the first place, so this is fine

* missed incrementing total_spent when not incrementing total_spent_paid_credits

* use the credits on self

* use the credits on self (pt 2)

* fix type for 10 cu query

* convert the requestmetadata on the other side of the channel

* logs

* viewing stats is allowed even without a balance

* move paid_credits_used to AuthorizationChecks

* wip

* test_sum_credits_used finally passes

* UserBalanceCache::get_or_insert

* re-enable rpc_secret_key_cache

* move invalidate to a helper function

and always call it **after** the db is commited

* fix PartialEq and Eq on RpcSecretKey

* cargo upgrade
2023-07-12 00:35:07 -07:00
Bryan Stitt
0f7e370c92 drop flume. just use tokio
i dont know if this is the problem, but this will also get compile times down
2023-07-10 23:08:06 -07:00
Bryan Stitt
2dfc5dcdf3 set http keep alive to a longer time 2023-07-10 18:37:25 -07:00
Bryan Stitt
a7119f6b5b
split balance queries up (#177)
* wip

* tests pass, referee_bonus changed to one_time_referee_bonus

---------

Co-authored-by: yenicelik <david.yenicelik@gmail.com>
2023-07-10 14:03:05 -07:00
Bryan Stitt
9ef08c80e1 remove parking_lot 2023-07-10 11:05:07 -07:00
Bryan Stitt
9ee6b18172 no more lock update needed
all these things are idempodent now
2023-07-09 22:51:01 -07:00
Bryan Stitt
a43fda0c32
Bryan devel (#176)
* refactor more balance logic

* refactor more balance checks

* doc running full test suite
2023-07-09 21:37:50 -07:00
Bryan Stitt
a560d47c48 lint 2023-07-09 20:13:03 -07:00
Bryan Stitt
b527f5d0d6
David/remove balance logic non destructive (#173)
* WIP will work on locks

* added concurrent test for referral, numbers rn still add up

* will change balance table to be a view instead of a table

* merged in devel. will proceed with migrations for rpc_stats_v2 and referral

* WIP

* WIP

* WIP compiling

* gotta add the balance_v2 view

* about to add balance view

* stupid missing closing param

* compiles again, now i will just have to implement the raw sql

* need to paste the real query and play with it

* ok now on to testing

* addresses many comments in PR

* app works for simple unauthorized access. will look into tests

* some tests pass, referral logic tests fail

* not sure why the test is failing

---------

Co-authored-by: yenicelik <david.yenicelik@gmail.com>
2023-07-09 19:23:32 -07:00
Bryan Stitt
386363e295 add request id to tracing 2023-07-08 11:57:53 -07:00
Bryan Stitt
9e89304eb7 try_send instead of send 2023-07-07 21:58:00 -07:00
Bryan Stitt
b234265458
Premium tier changes (#170)
* lower premium concurrency in preparation for key+IP limits

* include the ip in the user semaphore

* 3, not 5

this is our current limit for free

* per user_id+ip rate limiting
2023-07-07 15:15:41 -07:00
Bryan Stitt
651244fbca lower log levels 2023-07-07 14:14:03 -07:00
Bryan Stitt
512bcf305b lint 2023-07-07 14:06:35 -07:00
David
f6337ce940
Update payment_stripe.rs 2023-07-07 08:37:47 -04:00
Bryan Stitt
cf3d984548
switch the lock type (#165) 2023-07-06 14:54:52 -07:00
yenicelik
af45f78ff5 added test for admin deposit endpoint, fixed bugs 2023-07-06 08:19:33 -04:00
David
659fce0e33
Deposit history for stripe and admin (endpoints) (#160)
* added endpoints for stripe and admin deposits

* modified comments
2023-07-05 19:26:03 -07:00
Bryan Stitt
eb7b98fdbe
Split errors (#158)
* add migration for splitting errors

* fix type from u32 to u64

* update entities to match migrations

* no migration needed. these are only in stats

* add user_error_response to influx

* only if detailed

* set error_response and user_error_response

* 0 cost error responses

* only 33 migrations now

* put macros back

* get the stat buffer sender to the TestApp helper

* fixes
2023-07-05 18:18:10 -07:00