-
Notifications
You must be signed in to change notification settings - Fork 3
DRAFT: Privacy e2e #232
base: main
Are you sure you want to change the base?
DRAFT: Privacy e2e #232
Conversation
fix: allowance refresh for testing
events := l.subscribers[log.Topics[0]] | ||
for _, event := range events { | ||
ev := event | ||
go func() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check the updated change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated according to the changes in mev-oracle/events
pkg/allowancemanager/allowance.go
Outdated
} | ||
|
||
func (a *AllowanceManager) CheckAllowance(ctx context.Context, address common.Address) error { | ||
if a.blocksPerWindow == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would need to be synchronized no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed this var to atomic
pkg/allowancemanager/allowance.go
Outdated
logger *slog.Logger | ||
} | ||
|
||
func NewAllowanceManager( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be another API which would be called after preconfirmation is sent to 'deduct' balance from the window balance. This can be done by having 1 function like CheckAndAllocateAllowance(ctx, address, amount)
where you pass in the amount of the bid to check if user has enough balance considering the initial deposit and then the deductions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added deduction/refund logic that tracks the balance of each bidder for a specific block, allowing multiple bids on the same block as long as they do not exceed the allowed amount.
pkg/allowancemanager/allowance.go
Outdated
return nil | ||
} | ||
|
||
func (a *AllowanceManager) subscribeBidderRegistered(ctx context.Context) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All these handlers need to be synchronized. If you dont want to synchronize, you can have 1 worker reading different events from the channel and then performing the updates. In which case your handlers would just write something into this channel. The worker would be the only one doing the updates. But still you need to synchronize the Check function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated this by adding events update from mev-oracle. Internally it's using store, which has Mutex functionality, so it should be synchronized
p.logger.Debug("commitment not found", "commitmentDigest", ec.CommitmentDigest) | ||
return nil | ||
} | ||
commitment.EncryptedPreConfirmation.CommitmentIndex = ec.CommitmentIndex[:] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes an assumption that the store is inmemory and you only need to update the inmem entry. Either we should have a separate function to update or have the update in the same function we called earlier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Introduced new function for this case
No description provided.