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

feaT:refactor event + add more info in parse pm data #30

Merged
merged 3 commits into from
Oct 22, 2024

Conversation

livingrockrises
Copy link
Contributor

No description provided.

Comment on lines 287 to 289
} else {
// here chargedAmount accounts for penalty with maxGasPenalty
emit GasBalanceDeducted(paymasterId, prechargedAmount, premium);
Copy link
Collaborator

Choose a reason for hiding this comment

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

can it really happen?
if prechargedAmount < adjustedGasCost doesn't paymaster lose money?

if we only expect else to mean prechargedAmount == adjustedGasCost, we do need else at all

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I feel it would never go into the else case, but if it does then want to emit different value in the event.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if we pre charged less than we want to charge more yeah. in that case otherwise paymaster loses money. so diff of that adjusted - pre charged should be deduced from paymasterId balance.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

wdyt

Copy link
Collaborator

Choose a reason for hiding this comment

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

Makes sense. Does it make sense to emit different event to easily recognize we charged less

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can do it but it will be overhead on the paymaster service.
so, should I leave this

  1. as it is
  2. as it is but different event name
  3. same/different event name but in the else case doing
    paymasterIdBalances[paymasterId] += (adjustedGasCost - prechargedAmount);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

going with 3 with same event name.

// deduct what needs to be deducted from paymasterId
paymasterIdBalances[paymasterId] -= (adjustedGasCost - prechargedAmount);
// here chargedAmount accounts for penalty with maxGasPenalty
emit GasBalanceDeducted(paymasterId, prechargedAmount, premium);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe you should emit adjustedGasCost in this case as it is now what in fact was charged after L289 right?
so emit can be moved out of if/else

Copy link
Contributor Author

Choose a reason for hiding this comment

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

right. with this addition it makes sense
I wanted to emit different things that's the whole reason I added if else.
but it's ok.
knowing that charge can never be accurately emitted here and will need some off-chain component for penalties.

@filmakarov filmakarov merged commit 708b1ff into develop Oct 22, 2024
3 checks passed
@filmakarov filmakarov deleted the feat/refactor-events-and-tests branch October 22, 2024 10:51
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