Skip to content

Conversation

@BlairCurrey
Copy link
Contributor

@BlairCurrey BlairCurrey commented Nov 21, 2025

No description provided.

BlairCurrey and others added 7 commits April 10, 2025 14:29
* feat: add grant spent amount table

* fix: change interval start/end string to timestamp

* feat: fix filename, update op grant table

* fix: rm erroneously added migration to tsconfig
* feat: calculate grant spent amounts from new table

* chore: linting

* fix: revise grant spent amounts calc to track interval

* fix: throw better error, dont inti interval amounts unless they exist

* fix: linter, wip commented out code

* refactor(backend): rename interval statuses

* fix: ensure correct amount (interval/total) is used for grant spent amount

* test(backend): grant spent amounts

* fix(backend): make logic more typesafe, avoid having to defend w/ internal server error

* test(backend): legacy grant calculations

* test(backend): classify payment interval fn

* test(backend): rm commented-out classify payment interval case

* refactor(backend): improve semantics of interval helper fn

* test(backend): add non-interval cases to create op

* Apply suggestions from code review

Co-authored-by: Max Kurapov <[email protected]>

* refactor: simplifiy interval calc

* chore: rm unused imports

* refactor: validate grant payment logic

* refactor: improve grant spent amount calc type safety

* refactor: improve grant spent amount calc type safety

* fix: missing trx

* chore: handle bad interval state

* chore: rm some superfluous comments

* chore: format

---------

Co-authored-by: Max Kurapov <[email protected]>
)

* feat: calculate grant spent amounts from new table

* chore: linting

* fix: revise grant spent amounts calc to track interval

* fix: throw better error, dont inti interval amounts unless they exist

* fix: linter, wip commented out code

* refactor(backend): rename interval statuses

* fix: ensure correct amount (interval/total) is used for grant spent amount

* test(backend): grant spent amounts

* fix(backend): make logic more typesafe, avoid having to defend w/ internal server error

* test(backend): legacy grant calculations

* test(backend): classify payment interval fn

* test(backend): rm commented-out classify payment interval case

* refactor(backend): improve semantics of interval helper fn

* test(backend): add non-interval cases to create op

* Apply suggestions from code review

Co-authored-by: Max Kurapov <[email protected]>

* feat: partially handled grant spent amount scenarios on settle

* feat: handle non-interval partial settleamount cases

* test(backend): failure grant spent amount case for sucessive payment

* test(backend): some grant calc interval cases

* test(backend): counting grant payments across interval boundaries

* chore(backend): rm commented out test

* test(backend): new grant spent amount on payment completion

* test(backend): improve interval grant calc test to show summation

* test(backend): failure edge case

* chore(backend): rm comment

* chore(backend): fix lint errors

* chore(backend): rm debug logs

* test(backend): fix failing

* Update packages/backend/src/open_payments/payment/outgoing/lifecycle.ts

Co-authored-by: Max Kurapov <[email protected]>

* fix(backend): rm extra spent amount record check

* feat(backend): return debit amount from .pay

* test(backend): failing test for grant spent amount bug

- if 2 payments are create then 2 payments are processed,
it assocaites the wrong spent amount with the wrong payment

* fix(backend): grant spent amounts calc race conditions

- partially implemented fix (missing interval stuff),
not fully validated by tests yet

* test(backend): grant calc race condition

* fix(backend): grant spent amount race conditions with failure

* chore(backend): format

* test(backend): add failing interval race condition test

* fix(backend): interval boundary/race condition edge case

- edge case is when there are create/complete race conditions around interval boundaries

* test(backend): improve edge case test

- ensures we are testing that the latest interval amount is
used as the base for interval amounts, not just the payment
in the interval being completed

* fix(backend): dont query for latest interval payment unecunnecessarily

- not necessary if we are within the interval of the payment being completed

* fix(backend): type mismatch

* test(backend): payment retries do not add additional spent record

* fix(backend): use correct debit
amount for spent amount recalc

* fix(backend): set correct payment state on
grant spent amount updates

* refactor(backend): dedupe revert/handle grant spent amounts

- turned duplicated logic into shared functions
- example fn where revert/update is all in one,
but felt it was more complicated

* chore: rm unused fn

* test(backend): fix ilp pay return expectations

* refactor(backend): move revert/update grant spent amounts to op service

* chore: rm unused import

* fix: handle grant spent amounts on payment cancellation

* chore: cleanup commented out code

* chore: rm submodule added in error

* chore(backend): add error logs

* fix(backend): explicit grant spent amount formation, more test assertions

* refactor(backend): only return receive amt from .pay

* fix(backend): build error

---------

Co-authored-by: Max Kurapov <[email protected]>
@netlify
Copy link

netlify bot commented Nov 21, 2025

Deploy Preview for brilliant-pasca-3e80ec canceled.

Name Link
🔨 Latest commit e637544
🔍 Latest deploy log https://app.netlify.com/projects/brilliant-pasca-3e80ec/deploys/6924a69ed679910008e9082e

@github-actions github-actions bot added type: tests Testing related pkg: backend Changes in the backend package. type: source Changes business logic labels Nov 21, 2025
@BlairCurrey BlairCurrey changed the title Bc/raf 1031/grant spent amounts feat: grant spent amounts Nov 21, 2025
@github-actions
Copy link

github-actions bot commented Nov 21, 2025

🚀 Performance Test Results

Test Configuration:

  • VUs: 4
  • Duration: 1m0s

Test Metrics:

  • Requests/s: 34.76
  • Iterations/s: 11.59
  • Failed Requests: 0.00% (0 of 2093)
📜 Logs

> [email protected] run-tests:testenv /home/runner/work/rafiki/rafiki/test/performance
> ./scripts/run-tests.sh -e test "-k" "-q" "--vus" "4" "--duration" "1m"

Cloud Nine GraphQL API is up: http://localhost:3101/graphql
Cloud Nine Wallet Address is up: http://localhost:3100/
Happy Life Bank Address is up: http://localhost:4100/
cloud-nine-wallet-test-backend already set
cloud-nine-wallet-test-auth already set
happy-life-bank-test-backend already set
happy-life-bank-test-auth already set
     data_received..................: 756 kB 13 kB/s
     data_sent......................: 1.6 MB 27 kB/s
     http_req_blocked...............: avg=8.88µs   min=2.02µs  med=6.14µs   max=1.82ms   p(90)=7.44µs   p(95)=8.07µs  
     http_req_connecting............: avg=1.11µs   min=0s      med=0s       max=1.15ms   p(90)=0s       p(95)=0s      
     http_req_duration..............: avg=114.3ms  min=8.74ms  med=91.17ms  max=853.82ms p(90)=199.66ms p(95)=223.46ms
       { expected_response:true }...: avg=114.3ms  min=8.74ms  med=91.17ms  max=853.82ms p(90)=199.66ms p(95)=223.46ms
     http_req_failed................: 0.00%  ✓ 0         ✗ 2093
     http_req_receiving.............: avg=113.56µs min=32.34µs med=95.38µs  max=2.77ms   p(90)=137.86µs p(95)=181.86µs
     http_req_sending...............: avg=42µs     min=8.96µs  med=31.54µs  max=2.2ms    p(90)=44.08µs  p(95)=57.47µs 
     http_req_tls_handshaking.......: avg=0s       min=0s      med=0s       max=0s       p(90)=0s       p(95)=0s      
     http_req_waiting...............: avg=114.15ms min=8.52ms  med=91.05ms  max=853.67ms p(90)=199.52ms p(95)=223.32ms
     http_reqs......................: 2093   34.759068/s
     iteration_duration.............: avg=344.62ms min=226.4ms med=323.75ms max=1.47s    p(90)=420.97ms p(95)=480.49ms
     iterations.....................: 698    11.591892/s
     vus............................: 4      min=4       max=4 
     vus_max........................: 4      min=4       max=4 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: backend Changes in the backend package. type: source Changes business logic type: tests Testing related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants