Skip to content

Commit

Permalink
Remove min_gas_price from ConsensusParameters
Browse files Browse the repository at this point in the history
  • Loading branch information
elmato committed Apr 8, 2024
1 parent d3e6ead commit ee4b4a0
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 14 deletions.
14 changes: 6 additions & 8 deletions eosevm/consensus_parameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
namespace eosevm {
bool operator==(const eosevm::GasFeeParameters& a, const eosevm::GasFeeParameters& b) {
return a.gas_codedeposit == b.gas_codedeposit && a.gas_newaccount == b.gas_newaccount &&
a.gas_sset == b.gas_sset && a.gas_txcreate == b.gas_txcreate && a.gas_txnewaccount == b.gas_txnewaccount;
a.gas_sset == b.gas_sset && a.gas_txcreate == b.gas_txcreate && a.gas_txnewaccount == b.gas_txnewaccount;
}

bool operator==(const eosevm::ConsensusParameters& a, const eosevm::ConsensusParameters& b) {
return a.min_gas_price == b.min_gas_price && a.gas_fee_parameters == b.gas_fee_parameters; }
return a.gas_fee_parameters == b.gas_fee_parameters;
}


#if not defined(ANTELOPE)
Expand Down Expand Up @@ -43,14 +44,12 @@ std::optional<GasFeeParameters> GasFeeParameters::decode(silkworm::ByteView enco

#if not defined(ANTELOPE)
[[nodiscard]] silkworm::Bytes ConsensusParameters::encode() const noexcept {
SILKWORM_ASSERT(min_gas_price.has_value());
SILKWORM_ASSERT(gas_fee_parameters.has_value());
constexpr size_t size_before_fee_param = 2 * sizeof(uint64_t);
constexpr size_t size_before_fee_param = sizeof(uint64_t);
auto value = gas_fee_parameters->encode();
silkworm::Bytes ret(value.length() + size_before_fee_param, '\0');
// Always store as latest supported version: currently 0.
silkworm::endian::store_big_u64(&ret[0], 0);
silkworm::endian::store_big_u64(&ret[sizeof(uint64_t)], *min_gas_price);
std::memcpy(&ret[size_before_fee_param], &value[0], value.length());
return ret;
};
Expand All @@ -63,9 +62,8 @@ std::optional<ConsensusParameters> ConsensusParameters::decode(silkworm::ByteVie
// Parse according to version. For now, only 0.
switch (version) {
case 0: {
constexpr size_t size_before_fee_param = 2 * sizeof(uint64_t);
constexpr size_t size_before_fee_param = sizeof(uint64_t);
SILKWORM_ASSERT(encoded.length() > size_before_fee_param);
config.min_gas_price = silkworm::endian::load_big_u64(&encoded[sizeof(uint64_t)]);
config.gas_fee_parameters = GasFeeParameters::decode(silkworm::ByteView{&encoded[size_before_fee_param], encoded.length() - size_before_fee_param});
break;
}
Expand All @@ -82,4 +80,4 @@ std::optional<ConsensusParameters> ConsensusParameters::decode(silkworm::ByteVie
}
#endif

} // namespace eosevm
} // namespace eosevm
1 change: 0 additions & 1 deletion eosevm/consensus_parameters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ struct GasFeeParameters {
};

struct ConsensusParameters {
std::optional<uint64_t> min_gas_price;
std::optional<GasFeeParameters> gas_fee_parameters;

#if not defined(ANTELOPE)
Expand Down
2 changes: 0 additions & 2 deletions silkworm/node/db/access_layer_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -919,7 +919,6 @@ TEST_CASE("ConsensusParameters") {
auto& txn{context.rw_txn()};

constexpr eosevm::ConsensusParameters value1{
.min_gas_price = 1,
.gas_fee_parameters = eosevm::GasFeeParameters{
.gas_txnewaccount = 1,
.gas_newaccount = 1,
Expand All @@ -930,7 +929,6 @@ TEST_CASE("ConsensusParameters") {
};

constexpr eosevm::ConsensusParameters value2{
.min_gas_price = 2,
.gas_fee_parameters = eosevm::GasFeeParameters{
.gas_txnewaccount = 2,
.gas_newaccount = 2,
Expand Down
3 changes: 0 additions & 3 deletions silkworm/silkrpc/json/block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ void to_json(nlohmann::json& json, const Block& b) {
if(b.consensus_parameter.has_value()) {
auto& cp = b.consensus_parameter.value();
json["consensusParameter"] = nlohmann::json{};
if(cp.min_gas_price.has_value()) {
json["consensusParameter"]["minGasPrice"] = cp.min_gas_price.value();
}
if(cp.gas_fee_parameters.has_value()) {
json["consensusParameter"]["gasFeeParameters"] = nlohmann::json{};
auto& v = cp.gas_fee_parameters.value();
Expand Down

0 comments on commit ee4b4a0

Please sign in to comment.