-
Notifications
You must be signed in to change notification settings - Fork 240
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: precompiles required-gas need adjustments #1178
Problem: precompiles required-gas need adjustments #1178
Conversation
6818d9a
to
3f4ac9c
Compare
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #1178 +/- ##
===========================================
+ Coverage 16.25% 36.97% +20.71%
===========================================
Files 79 115 +36
Lines 5698 10235 +4537
===========================================
+ Hits 926 3784 +2858
- Misses 4694 6078 +1384
- Partials 78 373 +295
|
5c6c9a4
to
c0459fb
Compare
083ab67
to
c04a708
Compare
d3eacc5
to
408def7
Compare
d5b8a37
to
4e44e7c
Compare
Not sure how the caller handles the return |
x/cronos/keeper/precompiles/ica.go
Outdated
for methodName := range icaABI.Methods { | ||
var methodID [4]byte | ||
copy(methodID[:], icaABI.Methods[methodName].ID[:4]) | ||
switch methodName { | ||
case RegisterAccountMethodName: | ||
icaGasRequiredByMethod[methodID] = 10000 | ||
case QueryAccountMethodName: | ||
icaGasRequiredByMethod[methodID] = 10000 | ||
case SubmitMsgsMethodName: | ||
icaGasRequiredByMethod[methodID] = 10000 | ||
default: | ||
icaGasRequiredByMethod[methodID] = 0 | ||
} | ||
} |
Check failure
Code scanning / gosec
the value in the range statement should be _ unless copying a map: want: for key := range m Error
for methodName := range bankABI.Methods { | ||
var methodID [4]byte | ||
copy(methodID[:], bankABI.Methods[methodName].ID[:4]) | ||
switch methodName { | ||
case MintMethodName, BurnMethodName: | ||
bankGasRequiredByMethod[methodID] = 200000 | ||
case BalanceOfMethodName: | ||
bankGasRequiredByMethod[methodID] = 10000 | ||
case TransferMethodName: | ||
bankGasRequiredByMethod[methodID] = 150000 | ||
default: | ||
bankGasRequiredByMethod[methodID] = 0 | ||
} | ||
} |
Check failure
Code scanning / gosec
the value in the range statement should be _ unless copying a map: want: for key := range m Error
for methodName := range bankABI.Methods { | ||
var methodID [4]byte | ||
copy(methodID[:], bankABI.Methods[methodName].ID[:4]) | ||
switch methodName { | ||
case MintMethodName, BurnMethodName: | ||
bankGasRequiredByMethod[methodID] = 200000 | ||
case BalanceOfMethodName: | ||
bankGasRequiredByMethod[methodID] = 10000 | ||
case TransferMethodName: | ||
bankGasRequiredByMethod[methodID] = 150000 | ||
default: | ||
bankGasRequiredByMethod[methodID] = 0 | ||
} | ||
} |
Check warning
Code scanning / CodeQL
Iteration over map Warning
x/cronos/keeper/precompiles/ica.go
Outdated
for methodName := range icaABI.Methods { | ||
var methodID [4]byte | ||
copy(methodID[:], icaABI.Methods[methodName].ID[:4]) | ||
switch methodName { | ||
case RegisterAccountMethodName: | ||
icaGasRequiredByMethod[methodID] = 10000 | ||
case QueryAccountMethodName: | ||
icaGasRequiredByMethod[methodID] = 10000 | ||
case SubmitMsgsMethodName: | ||
icaGasRequiredByMethod[methodID] = 10000 | ||
default: | ||
icaGasRequiredByMethod[methodID] = 0 | ||
} | ||
} |
Check warning
Code scanning / CodeQL
Iteration over map Warning
079c936
to
4248963
Compare
0982937
to
f2ac99a
Compare
So the handler would reverts and consumes some gas (like transaction base cost) but no addition cost for calling this pre-compiled contract, right? Yes, the gas estimation can detect the error but cannot prevent attack. So my question is should we charge some gas for the contract (if we don't charge extra gas for entering the precompile contract, or we do?) if their is any executing errors or revert, perhaps can charge gas like half of the minimum gas cost of method in the contract? |
f2ac99a
to
e4e1083
Compare
Half the minimum of which method? In case method does not exists, there will be no execution on cosmos side. I think charging the base cost should be enough |
68d8466
to
6ee2418
Compare
6ee2418
to
51309ee
Compare
update integration tests config add switch fix lint rename const revert gas cost estimate cost convert to map fix alert fix golangci update gas value based on estimation add basecost to the precompile increase gas in integration test
9d986ee
to
9580897
Compare
768d1fb
to
47ba27e
Compare
47ba27e
to
caa5109
Compare
caa5109
to
2e220af
Compare
79c911c
👮🏻👮🏻👮🏻 !!!! REFERENCE THE PROBLEM YOUR ARE SOLVING IN THE PR TITLE AND DESCRIBE YOUR SOLUTION HERE !!!! DO NOT FORGET !!!! 👮🏻👮🏻👮🏻
Using some base line value for estimation, may need adjustment in the future
Open for suggestions. Keeping this open as it is important to have this fixed before an official release.
PR Checklist:
make
)make test
)go fmt
)golangci-lint run
)go list -json -m all | nancy sleuth
)Thank you for your code, it's appreciated! :)