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

fix(pool): fix race condition in paymaster tracking #728

Merged
merged 1 commit into from
Jun 18, 2024

Conversation

dancoombs
Copy link
Collaborator

Proposed Changes

  • Fix race condition

Race

  1. Paymaster sends deposit transaction
  2. UO uses paymaster, paymaster is new to the pool, queries chain for balance and adds to cache, sees the balance from 1
  3. Deposit event from (1) is notified to the pool, balance is added to the balance from (2)

Since there is no ordering guarantee between (2) and (3) you can end up with either balance or 2x balance in the cache.
Instead process events as a reset event, and just query the chain for a balance after an event.

@dancoombs dancoombs force-pushed the danc/fix-paymaster-race branch 2 times, most recently from ef374b8 to b7fd2cb Compare June 17, 2024 14:58
Copy link

codecov bot commented Jun 17, 2024

Codecov Report

Attention: Patch coverage is 98.91892% with 2 lines in your changes missing coverage. Please review.

Project coverage is 55.31%. Comparing base (98f8e2c) to head (bc64d0a).

Additional details and impacted files

Impacted file tree graph

Files Coverage Δ
crates/pool/src/mempool/paymaster.rs 93.40% <100.00%> (-0.22%) ⬇️
crates/pool/src/mempool/uo_pool.rs 95.09% <99.31%> (+0.34%) ⬆️
crates/rpc/src/eth/error.rs 0.00% <0.00%> (ø)
Flag Coverage Δ
unit-tests 55.31% <98.91%> (+0.10%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
rundler binary 0.00% <ø> (ø)
builder 50.00% <ø> (ø)
dev 0.00% <ø> (ø)
pool 64.64% <99.45%> (+0.26%) ⬆️
provider 16.68% <ø> (ø)
rpc 25.66% <0.00%> (-0.02%) ⬇️
sim 77.86% <ø> (ø)
tasks ∅ <ø> (∅)
types 65.45% <ø> (ø)
utils 18.28% <ø> (ø)

@dancoombs dancoombs changed the base branch from main to feat/v0.3 June 17, 2024 19:59
Copy link
Collaborator

@dphilipson dphilipson left a comment

Choose a reason for hiding this comment

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

Great catch, thanks for fixing!

crates/pool/src/mempool/paymaster.rs Outdated Show resolved Hide resolved
@dancoombs dancoombs force-pushed the danc/fix-paymaster-race branch from b7fd2cb to bc64d0a Compare June 18, 2024 21:19
@dancoombs dancoombs merged commit 1b71cfb into feat/v0.3 Jun 18, 2024
7 checks passed
@dancoombs dancoombs deleted the danc/fix-paymaster-race branch June 18, 2024 21:37
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.

2 participants