Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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: no required gas log in precompiles #1223
Problem: no required gas log in precompiles #1223
Changes from 4 commits
5e07a2b
df59ecf
707a600
a9d070e
41f3ebc
74860a9
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
The
BankContract
struct is updated to embed theBaseContract
struct. ThekvGasConfig
field is removed fromBankContract
as it is now part ofBaseContract
. TheNewBankContract
function is updated to initialize theBaseContract
with additional parameters including the contract address, gas configuration, method map, gas required by method, a boolean indicating if the contract is stateless, and a logger with a specific context. This change enhances the modularity and maintainability of the code by moving common functionality to theBaseContract
.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.
The
RequiredGas
method is removed from theBankContract
struct. This is likely because the method is now part of theBaseContract
and can be accessed through it. This change reduces code duplication and enhances maintainability.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.
what's this for, temporary debugging?
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.
I thought we want to record required gas for each method
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.
for debugging or what reason?
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.
yes debugging, we could collect the data on some nodes to tune the requiredgas map later on
but the data has to be the gas consumed at cosmos level during execution, not the value returned from the map
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.
I see, so this could be a draft PR for building a local binary, no need to merge, right?
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.
I wonder if we could use those data on mainnet
https://cronos.yummy.capital/txs/E2B835B672BC046028E3FEBEB1770CD8A506DB505380982AD16C39F13E5DD861
Somehow hermes in mainnet is spending more gas than that. But may be also because of hermez config?
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.
we should have bigger client header like more validators, and I'm not sure why we use TransientGasConfig
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.
For the TransientGasConfig, it inspired from evmos implementation of the
gasRequired
https://github.com/evmos/evmos/blob/main/precompiles/common/precompile.go#L34
They also use the
TransientGasConfig
, I think that make sense since the goal for us is just to add an "extra" fee based on the length of the input, to avoid DDOS attack for very large inputBut in practice, the additional fee does not make much sense since input length is not related to the cost of operation in memory
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.
I think evmos use KvGasConfig instead and input length does related to TxSizeCost which is the major cost in cosmos tx
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.
mmm in the original context, the base cost is just an extra cost to avoid DDOS attack, since the input it never written in store, it would make sense to use TransientGasConfig for the computation.
But I think what you are trying to do is to replicate the cosmos intrinsic cost? In that case KvGasConfig is used
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.
The
NewIcaContract
function signature has been updated to include two new parameters:kvGasConfig
of typestoretypes.GasConfig
andlogger
of typelog.Logger
. ThekvGasConfig
parameter is used to configure the gas usage for key-value store operations, while thelogger
parameter is used for logging. ThekvGasConfig
field has been removed from theIcaContract
struct, and thelogger
field has been added to theBaseContract
struct. TheRequiredGas
function has been removed from theIcaContract
and moved to theBaseContract
. These changes are part of the effort to enhance the functionality and configurability of the contracts.Committable suggestion (Beta)
Check failure
Code scanning / gosec
Potential integer overflow by integer type conversion 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.
The
assignMethodGas
function is well implemented. It populates therelayerMethodMap
andrelayerGasRequiredByMethod
maps with the correct values. However, there is a potential integer overflow issue on line 29 as pointed out by the bot in the previous comments. You should handle this potential overflow.