Skip to content

Commit

Permalink
check ingress fee precision
Browse files Browse the repository at this point in the history
  • Loading branch information
elmato committed Jun 13, 2024
1 parent 22f0eeb commit 2cf247f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
6 changes: 1 addition & 5 deletions include/evm_runtime/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@ namespace evm_runtime {
static constexpr uint64_t gas_sset_min = 2900;
static constexpr uint64_t grace_period_seconds = 180;

constexpr uint64_t pow10_const(int v) {
uint64_t r = 1;
while (v-- > 0) r *= 10;
return r;
}
uint64_t pow10_const(int v);

constexpr unsigned evm_precision = 18;
constexpr eosio::name default_token_account = "eosio.token"_n;
Expand Down
3 changes: 2 additions & 1 deletion src/config_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ const eosio::asset& config_wrapper::get_ingress_bridge_fee()const {
}

void config_wrapper::set_ingress_bridge_fee(const eosio::asset& ingress_bridge_fee) {
eosio::check(evm_precision >= ingress_bridge_fee.symbol.precision(), "invalid ingress fee precision");
_cached_config.ingress_bridge_fee = ingress_bridge_fee;
set_dirty();
}
Expand Down Expand Up @@ -212,7 +213,7 @@ void config_wrapper::set_fee_parameters(const fee_parameters& fee_params,
}
eosio::check(fee_params.ingress_bridge_fee->amount >= 0, "ingress bridge fee cannot be negative");

_cached_config.ingress_bridge_fee = *fee_params.ingress_bridge_fee;
set_ingress_bridge_fee(*fee_params.ingress_bridge_fee);
} else {
eosio::check(allow_any_to_be_unspecified, "All required fee parameters not specified: missing ingress_bridge_fee");
}
Expand Down
7 changes: 7 additions & 0 deletions src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,11 @@ uint256 to_uint256(const bytes& value) {
return intx::be::load<uint256>(tmp);
}

uint64_t pow10_const(int v) {
eosio::check(v >= 0, "invalid exponent");
uint64_t r = 1;
while (v-- > 0) r *= 10;
return r;
}

} // namespace silkworm

0 comments on commit 2cf247f

Please sign in to comment.