-
Notifications
You must be signed in to change notification settings - Fork 43
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
Problem: unnecessary GetBalance in ante handlers #514
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #514 +/- ##
===========================================
+ Coverage 61.57% 61.60% +0.03%
===========================================
Files 128 128
Lines 9512 9520 +8
===========================================
+ Hits 5857 5865 +8
Misses 3115 3115
Partials 540 540
|
reuse balance after verify account balance to avoid get again when check can transfer
// canTransfer adapted the core.CanTransfer from go-ethereum | ||
func canTransfer(ctx sdk.Context, evmKeeper EVMKeeper, denom string, from common.Address, amount *big.Int) bool { | ||
balance := evmKeeper.GetBalance(ctx, sdk.AccAddress(from.Bytes()), denom) | ||
return balance.Cmp(amount) >= 0 |
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.
balance could be nil, but there was no nil check before
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.
try to reproduce in integration test?
again, how does this affect the benchmark result, I guess the effect of this is even smaller than the account PR, which is almost unnoticeable in the benchmark result. |
Do you mean GetBalance is faster than GetAccount, no need to cache? |
what do you think we are caching here? the raw bytes fetched from db is already cached by cachekv store, so what we are caching here is just to avoid the decoding step, if the decoding speed is similar to or even faster than the added map operations, then there's no point to add this cache, right? |
reuse balance after verify account balance to avoid get again when check can transfer
benchmark need remove the skip part
Description
For contributor use:
docs/
) or specification (x/<module>/spec/
)godoc
comments.Unreleased
section inCHANGELOG.md
Files changed
in the Github PR explorerFor admin use:
WIP
,R4R
,docs
, etc)