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

gas param config change event #682

Merged
merged 10 commits into from
Feb 27, 2024
Merged

gas param config change event #682

merged 10 commits into from
Feb 27, 2024

Conversation

taokayan
Copy link
Contributor

Resolves #679

@taokayan taokayan requested a review from arhag January 31, 2024 03:09
include/evm_runtime/config_wrapper.hpp Outdated Show resolved Hide resolved
include/evm_runtime/tables.hpp Outdated Show resolved Hide resolved
include/evm_runtime/tables.hpp Outdated Show resolved Hide resolved
src/config_wrapper.cpp Outdated Show resolved Hide resolved
include/evm_runtime/tables.hpp Outdated Show resolved Hide resolved
src/config_wrapper.cpp Outdated Show resolved Hide resolved
include/evm_runtime/evm_contract.hpp Outdated Show resolved Hide resolved
src/actions.cpp Outdated Show resolved Hide resolved
src/config_wrapper.cpp Outdated Show resolved Hide resolved
src/config_wrapper.cpp Outdated Show resolved Hide resolved
@taokayan taokayan requested a review from arhag February 6, 2024 09:18
arhag
arhag previously requested changes Feb 21, 2024
include/evm_runtime/tables.hpp Outdated Show resolved Hide resolved
src/config_wrapper.cpp Outdated Show resolved Hide resolved
include/evm_runtime/tables.hpp Show resolved Hide resolved
src/config_wrapper.cpp Outdated Show resolved Hide resolved
src/config_wrapper.cpp Outdated Show resolved Hide resolved
src/config_wrapper.cpp Outdated Show resolved Hide resolved
src/config_wrapper.cpp Outdated Show resolved Hide resolved
@taokayan taokayan requested a review from arhag February 22, 2024 01:55
Copy link
Member

@arhag arhag left a comment

Choose a reason for hiding this comment

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

LGTM. But I would like @elmato to review as well before merging this in.

@arhag arhag dismissed their stale review February 22, 2024 19:50

All comments addressed.

@@ -43,6 +42,11 @@ struct config_wrapper {
void set_fee_parameters(const fee_parameters& fee_params,
bool allow_any_to_be_unspecified);

void update_gas_params(eosio::asset ram_price_mb, uint64_t minimum_gas_price);
void update_gas_params2(std::optional<uint64_t> gas_txnewaccount, std::optional<uint64_t> gas_newaccount, std::optional<uint64_t> gas_txcreate, std::optional<uint64_t> gas_codedeposit, std::optional<uint64_t> gas_sset, std::optional<uint64_t> minimum_gas_price);
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't this function be be update_consensus_parameters since minimum_gas_price was moved away from the gas_parameter_type ?

struct gas_parameter_type {
    uint64_t gas_txnewaccount = 0;
    uint64_t gas_newaccount = 25000;
    uint64_t gas_txcreate = 32000;
    uint64_t gas_codedeposit = 200;
    uint64_t gas_sset = 20000;
};
struct consensus_parameter_data_v0 {
    uint64_t                   minimum_gas_price = 0;
    gas_parameter_type         gas_parameter;
};

@@ -121,14 +126,29 @@ void config_wrapper::set_fee_parameters(const fee_parameters& fee_params,
bool allow_any_to_be_unspecified)
{
if (fee_params.gas_price.has_value()) {
_cached_config.gas_price = *fee_params.gas_price;
eosio::check(*fee_params.gas_price >= one_gwei, "gas_price must >= 1Gwei");
if (_cached_config.evm_version.has_value() && _cached_config.evm_version->cached_version >= 1) {
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 doing ?

if(get_evm_version() >= 1) {...

constexpr uint64_t storage_slot_bytes = 346;

eosio::check(gas_per_byte_f >= 0.0, "gas_per_byte must >= 0");
eosio::check(gas_per_byte_f * contract_fixed_bytes < (double)(0x7ffffffffffull), "gas_per_byte too big");
Copy link
Contributor

Choose a reason for hiding this comment

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

Change 0x7ffffffffffull to

constexpr uint64_t max_gas_per_byte = (1ull << 43) - 1;

void config_wrapper::update_gas_params2(std::optional<uint64_t> gas_txnewaccount, std::optional<uint64_t> gas_newaccount, std::optional<uint64_t> gas_txcreate, std::optional<uint64_t> gas_codedeposit, std::optional<uint64_t> gas_sset, std::optional<uint64_t> minimum_gas_price)
{
// for simplicity, ensure last (cached) evm_version >= 1, not touching promote logic
eosio::check(_cached_config.evm_version.has_value() && _cached_config.evm_version->cached_version >= 1,
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 doing ?

if(get_evm_version() >= 1) {...

if (gas_txcreate.has_value()) v.gas_parameter.gas_txcreate = *gas_txcreate;
if (gas_codedeposit.has_value()) v.gas_parameter.gas_codedeposit = *gas_codedeposit;
if (gas_sset.has_value()) {
eosio::check(*gas_sset >= 2900, "G_sset must >= 2900");
Copy link
Contributor

Choose a reason for hiding this comment

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

2900 is used in many places, we should create a constant

@taokayan taokayan requested a review from elmato February 23, 2024 10:37
@taokayan taokayan merged commit c5541b3 into main Feb 27, 2024
3 checks passed
@taokayan taokayan deleted the kayan_gas_param branch February 27, 2024 01:02
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.

Emit configchange event
3 participants