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(testnet): add two new parameters --base-fee and --min-gas-price to the command evmosd testnet init-files
#1864
Conversation
evmosd testnet init-files
evmosd testnet init-files
@luchenqun can you fix the conflicts? |
@@ -148,6 +154,18 @@ | |||
args.startingIPAddress, _ = cmd.Flags().GetString(flagStartingIPAddress) | |||
args.numValidators, _ = cmd.Flags().GetInt(flagNumValidators) | |||
args.algo, _ = cmd.Flags().GetString(flags.FlagKeyType) | |||
baseFee, _ := cmd.Flags().GetString(flagBaseFee) |
Check warning
Code scanning / gosec
Returned error is not propagated up the stack. Warning
@fedekunze The conflict has been resolved. I was using v14 code at the time, and it is now v15. In addition, I saw that lint did not pass, and it seems was not my relevant code. |
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.
Thanks for the contribution @luchenqun!!
Left a few comments
Actually, the default value for minimum_gas_prices flag is not zero
However, for some reason, this is not stored properly in the |
You are right, it does not take effect. You can directly modify the app.toml file manually after production configuration and change --minimum-gas-prices to the value you need. |
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.
Thanks for addressing the comments @luchenqun!!
Left a few more
Please address the lint issue |
…ock transaction in the local_node.sh and init-node.sh file
@@ -148,6 +160,22 @@ | |||
args.startingIPAddress, _ = cmd.Flags().GetString(flagStartingIPAddress) | |||
args.numValidators, _ = cmd.Flags().GetInt(flagNumValidators) | |||
args.algo, _ = cmd.Flags().GetString(flags.FlagKeyType) | |||
baseFee, _ := cmd.Flags().GetString(flagBaseFee) | |||
minGasPrice, _ := cmd.Flags().GetString(flagMinGasPrice) |
Check warning
Code scanning / gosec
Returned error is not propagated up the stack. Warning
Codecov Report
@@ Coverage Diff @@
## main #1864 +/- ##
==========================================
+ Coverage 69.70% 69.98% +0.27%
==========================================
Files 331 327 -4
Lines 24514 24271 -243
==========================================
- Hits 17088 16985 -103
+ Misses 6543 6415 -128
+ Partials 883 871 -12
|
…rMinGasPrices for block 0
I have found the reason. It is because there is probably $HOME/.evmosd in your computer, and the minimum-gas-prices configured in app.toml has a higher priority than the fmt.Sprintf("0.000006%s" configured in the code. ", cmdcfg.BaseDenom) |
Description
Use the command
evmosd testnet init-files --v 1 --output-dir ./nodes --chain-id evmos_9000-1 --keyring-backend test
to generate the genesis.json file for the initial block. The feemarket params are as follows:In the
genutil
module, there is at least one genesis transaction for creating a validator, with the following content:Based on the params in feemarket, The gasPrice for the transaction executed in block 0 must be
max(base_fee, min_gas_price) = max(1000000000, 0.000000000000000000) = 1gwei
However, the MsgCreateValidator transaction does not meet the requirements of the feemarket params because the amount array in the fee is empty and the gas_limit is 0.
So why can this transaction be executed correctly? First, regarding the gasPrice check, when checking the transaction fee in
NewDynamicFeeChecker
, if the block height is 0, the check does not use the global fee, which is the feemarket related params. Instead, it uses the local fee, which is set in the app.toml asminimum-gas-prices
. The default value for this parameter is0aevmos
. You can find the relevant code here: https://github.com/evmos/evmos/blob/v14.1.0/app/ante/evm/fee_checker.go#L27-L93One possible issue that may arise from this is that when modifying the local fee, it may not be possible to start the chain using the genesis block. However, when I changed the local fee to
minimum-gas-prices = "6aevmos"
before start the chain using the genesis block, you can still use the genesis block to start the chain. In other words, although thecheckTxFeeWithValidatorMinGasPrices
function has been executed, it did not take effect.After analyzing, this is because when executing transactions in the
genutil
module at block height 0, it directly skips theCheckTx
stage and goes intoDeliverTx
. In theDeliverTx
stage,ctx.minGasPrice
is always an empty array. Only in theCheckTx
stage isctx.minGasPrice
the one we set as6aevmos
. Therefore, checking the transaction fees withcheckTxFeeWithValidatorMinGasPrices
for the transactions in thegenutil
module at block 0 has no meaning.In #1760, I mentioned that we can treat transactions in genutil as special transactions. This way, I can modify the min_gas_price parameter in the genesis block's feemarket to be greater than 0, allowing the execution of transactions within the genutil module even when the transaction fee is 0. However, this suggestion was rejected. There was a suggestion to manually modify the transactions in the genutil module, but I find it inconvenient. I hope that the genesis.json file generated by
evmosd testnet init-files
can directly run without manual intervention.I think the best solution would be to treat the transactions in the
genutil
module as regular transactions without any special handling, meaning that they must also comply with thefeemarket
params. When generating the genesis block using theevmosd testnet init-files
command, the generatedfeemarket
params would have a defaultmin_gas_price
of 0, which is not suitable for real scenarios. The solution is to specify the--base-fee
and--min-gas-price
parameters when executing theevmosd testnet init-files
command to adjust the fees in thegenutil
module transactions based on the base fee and min gas price.Ultimately, after implementing this feature, if you run the
evmosd testnet init-files --v 1 --output-dir ./nodes --chain-id evmos_9000-1 --keyring-backend test --base-fee 10000000000 --min-gas-price 800000000
command, the generatedfeemarket
parameters would be as follows:genutil
generates the genesis block transaction based on the feemarket params. The content is roughly as follows:Note: fee = max(baseFee, minGasPrice)*gasLimit. The gasLimit is declared as a constant in the code as
const CreateValidatorTxGasLimit = 300000
.Also, the
evmosd testnet init-files
command has an optional parameter called--minimum-gas-prices
. This parameter is used to set the--minimum-gas-prices
in the app.toml file, which affects the local fee. It should be noted that the-min-gas-price
option mentioned in this commit modifies the global fee for feemarket params.Closes #XXX