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

internal/ethapi: return detail insufficient fund error in EstimateGas #28161

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

jsvisa
Copy link
Contributor

@jsvisa jsvisa commented Sep 20, 2023

No description provided.

Comment on lines +1241 to +1242
value := args.Value.ToInt()
if value.Cmp(available) >= 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Hm, isn't it odd that the comparison (now and before) uses >=, as opposed to just > ? Why error on equality?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

IMHO, as feeCap is not zero, we need to consider the gasFee, so = is not enough, maybe I need to adjust the error message.

Copy link
Contributor Author

@jsvisa jsvisa Sep 20, 2023

Choose a reason for hiding this comment

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

BTW, I think we should always check value with balance, no matter feeCap is zero or not, in that case = should be omited.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed the error from core.ErrInsufficientFundsForTransfer to core.ErrInsufficient(the later contains the gas*price part)

Copy link
Contributor

Choose a reason for hiding this comment

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

Why not ErrInsufficientFundsForTransfer? This clause is specifically comparing the value against the 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.

As ErrInsufficientFundsForTransfer only considered the transferred value's part, not including the gasFee, and here as the feeCap is not zero, we need to add the feeCap. So ErrInsufficientFunds probably more accurate, because his error log is insufficient funds for gas * price + value

Signed-off-by: jsvisa <delweng@gmail.com>
Signed-off-by: jsvisa <delweng@gmail.com>
return 0, core.ErrInsufficientFundsForTransfer
value := args.Value.ToInt()
if value.Cmp(available) >= 0 {
return 0, fmt.Errorf("%w: address: %s, have: %v, want: %v+(gas)", core.ErrInsufficientFunds, *args.From, available, value)
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know why it says (gas) ? The unit is wei

Suggested change
return 0, fmt.Errorf("%w: address: %s, have: %v, want: %v+(gas)", core.ErrInsufficientFunds, *args.From, available, value)
return 0, fmt.Errorf("%w: address: %v, have: %v, want: >%v", core.ErrInsufficientFundsForTransfer, *args.From, available, value))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, I intended to say that there was an extra gasFee here. maybe changed into something like below:

-                               return 0, fmt.Errorf("%w: address: %s, have: %v, want: %v+(gas)", core.ErrInsufficientFunds, *args.From, available, value)
+                               return 0, fmt.Errorf("%w: address: %s, have: %v, want: %v+(gasFee)", core.ErrInsufficientFunds, *args.From, available, value)

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.

3 participants