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

Changes for building with c++20. #1070

Merged
merged 9 commits into from
Apr 27, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ struct unapplied_transaction {

const transaction_id_type& id()const { return trx_meta->id(); }
fc::time_point_sec expiration()const { return trx_meta->packed_trx()->expiration(); }

unapplied_transaction(const unapplied_transaction&) = delete;
unapplied_transaction() = delete;
unapplied_transaction& operator=(const unapplied_transaction&) = delete;
unapplied_transaction(unapplied_transaction&&) = default;
};

/**
Expand Down
120 changes: 60 additions & 60 deletions libraries/chain/include/eosio/chain/wasm_eosio_injection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,121 +168,121 @@ namespace eosio { namespace chain { namespace wasm_injections {
constexpr const char* inject_which_op( uint16_t opcode ) {
switch ( opcode ) {
case wasm_ops::f32_add_code:
return u8"_eosio_f32_add";
return "_eosio_f32_add";
case wasm_ops::f32_sub_code:
return u8"_eosio_f32_sub";
return "_eosio_f32_sub";
case wasm_ops::f32_mul_code:
return u8"_eosio_f32_mul";
return "_eosio_f32_mul";
case wasm_ops::f32_div_code:
return u8"_eosio_f32_div";
return "_eosio_f32_div";
case wasm_ops::f32_min_code:
return u8"_eosio_f32_min";
return "_eosio_f32_min";
case wasm_ops::f32_max_code:
return u8"_eosio_f32_max";
return "_eosio_f32_max";
case wasm_ops::f32_copysign_code:
return u8"_eosio_f32_copysign";
return "_eosio_f32_copysign";
case wasm_ops::f32_abs_code:
return u8"_eosio_f32_abs";
return "_eosio_f32_abs";
case wasm_ops::f32_neg_code:
return u8"_eosio_f32_neg";
return "_eosio_f32_neg";
case wasm_ops::f32_sqrt_code:
return u8"_eosio_f32_sqrt";
return "_eosio_f32_sqrt";
case wasm_ops::f32_ceil_code:
return u8"_eosio_f32_ceil";
return "_eosio_f32_ceil";
case wasm_ops::f32_floor_code:
return u8"_eosio_f32_floor";
return "_eosio_f32_floor";
case wasm_ops::f32_trunc_code:
return u8"_eosio_f32_trunc";
return "_eosio_f32_trunc";
case wasm_ops::f32_nearest_code:
return u8"_eosio_f32_nearest";
return "_eosio_f32_nearest";
case wasm_ops::f32_eq_code:
return u8"_eosio_f32_eq";
return "_eosio_f32_eq";
case wasm_ops::f32_ne_code:
return u8"_eosio_f32_ne";
return "_eosio_f32_ne";
case wasm_ops::f32_lt_code:
return u8"_eosio_f32_lt";
return "_eosio_f32_lt";
case wasm_ops::f32_le_code:
return u8"_eosio_f32_le";
return "_eosio_f32_le";
case wasm_ops::f32_gt_code:
return u8"_eosio_f32_gt";
return "_eosio_f32_gt";
case wasm_ops::f32_ge_code:
return u8"_eosio_f32_ge";
return "_eosio_f32_ge";
case wasm_ops::f64_add_code:
return u8"_eosio_f64_add";
return "_eosio_f64_add";
case wasm_ops::f64_sub_code:
return u8"_eosio_f64_sub";
return "_eosio_f64_sub";
case wasm_ops::f64_mul_code:
return u8"_eosio_f64_mul";
return "_eosio_f64_mul";
case wasm_ops::f64_div_code:
return u8"_eosio_f64_div";
return "_eosio_f64_div";
case wasm_ops::f64_min_code:
return u8"_eosio_f64_min";
return "_eosio_f64_min";
case wasm_ops::f64_max_code:
return u8"_eosio_f64_max";
return "_eosio_f64_max";
case wasm_ops::f64_copysign_code:
return u8"_eosio_f64_copysign";
return "_eosio_f64_copysign";
case wasm_ops::f64_abs_code:
return u8"_eosio_f64_abs";
return "_eosio_f64_abs";
case wasm_ops::f64_neg_code:
return u8"_eosio_f64_neg";
return "_eosio_f64_neg";
case wasm_ops::f64_sqrt_code:
return u8"_eosio_f64_sqrt";
return "_eosio_f64_sqrt";
case wasm_ops::f64_ceil_code:
return u8"_eosio_f64_ceil";
return "_eosio_f64_ceil";
case wasm_ops::f64_floor_code:
return u8"_eosio_f64_floor";
return "_eosio_f64_floor";
case wasm_ops::f64_trunc_code:
return u8"_eosio_f64_trunc";
return "_eosio_f64_trunc";
case wasm_ops::f64_nearest_code:
return u8"_eosio_f64_nearest";
return "_eosio_f64_nearest";
case wasm_ops::f64_eq_code:
return u8"_eosio_f64_eq";
return "_eosio_f64_eq";
case wasm_ops::f64_ne_code:
return u8"_eosio_f64_ne";
return "_eosio_f64_ne";
case wasm_ops::f64_lt_code:
return u8"_eosio_f64_lt";
return "_eosio_f64_lt";
case wasm_ops::f64_le_code:
return u8"_eosio_f64_le";
return "_eosio_f64_le";
case wasm_ops::f64_gt_code:
return u8"_eosio_f64_gt";
return "_eosio_f64_gt";
case wasm_ops::f64_ge_code:
return u8"_eosio_f64_ge";
return "_eosio_f64_ge";
case wasm_ops::f64_promote_f32_code:
return u8"_eosio_f32_promote";
return "_eosio_f32_promote";
case wasm_ops::f32_demote_f64_code:
return u8"_eosio_f64_demote";
return "_eosio_f64_demote";
case wasm_ops::i32_trunc_u_f32_code:
return u8"_eosio_f32_trunc_i32u";
return "_eosio_f32_trunc_i32u";
case wasm_ops::i32_trunc_s_f32_code:
return u8"_eosio_f32_trunc_i32s";
return "_eosio_f32_trunc_i32s";
case wasm_ops::i32_trunc_u_f64_code:
return u8"_eosio_f64_trunc_i32u";
return "_eosio_f64_trunc_i32u";
case wasm_ops::i32_trunc_s_f64_code:
return u8"_eosio_f64_trunc_i32s";
return "_eosio_f64_trunc_i32s";
case wasm_ops::i64_trunc_u_f32_code:
return u8"_eosio_f32_trunc_i64u";
return "_eosio_f32_trunc_i64u";
case wasm_ops::i64_trunc_s_f32_code:
return u8"_eosio_f32_trunc_i64s";
return "_eosio_f32_trunc_i64s";
case wasm_ops::i64_trunc_u_f64_code:
return u8"_eosio_f64_trunc_i64u";
return "_eosio_f64_trunc_i64u";
case wasm_ops::i64_trunc_s_f64_code:
return u8"_eosio_f64_trunc_i64s";
return "_eosio_f64_trunc_i64s";
case wasm_ops::f32_convert_s_i32_code:
return u8"_eosio_i32_to_f32";
return "_eosio_i32_to_f32";
case wasm_ops::f32_convert_u_i32_code:
return u8"_eosio_ui32_to_f32";
return "_eosio_ui32_to_f32";
case wasm_ops::f32_convert_s_i64_code:
return u8"_eosio_i64_f32";
return "_eosio_i64_f32";
case wasm_ops::f32_convert_u_i64_code:
return u8"_eosio_ui64_to_f32";
return "_eosio_ui64_to_f32";
case wasm_ops::f64_convert_s_i32_code:
return u8"_eosio_i32_to_f64";
return "_eosio_i32_to_f64";
case wasm_ops::f64_convert_u_i32_code:
return u8"_eosio_ui32_to_f64";
return "_eosio_ui32_to_f64";
case wasm_ops::f64_convert_s_i64_code:
return u8"_eosio_i64_to_f64";
return "_eosio_i64_to_f64";
case wasm_ops::f64_convert_u_i64_code:
return u8"_eosio_ui64_to_f64";
return "_eosio_ui64_to_f64";

default:
FC_THROW_EXCEPTION( eosio::chain::wasm_execution_error, "Error, unknown opcode in injection ${op}", ("op", opcode));
Expand Down Expand Up @@ -483,7 +483,7 @@ namespace eosio { namespace chain { namespace wasm_injections {
static void init() {}
static void accept( wasm_ops::instr* inst, wasm_ops::visitor_arg& arg ) {
int32_t idx;
injector_utils::add_import<ResultType::f64, ValueType::f32>( *(arg.module), u8"_eosio_f32_promote", idx );
injector_utils::add_import<ResultType::f64, ValueType::f32>( *(arg.module), "_eosio_f32_promote", idx );
wasm_ops::op_types<>::call_t f32promote;
f32promote.field = idx;
f32promote.pack(arg.new_code);
Expand All @@ -496,7 +496,7 @@ namespace eosio { namespace chain { namespace wasm_injections {
static void init() {}
static void accept( wasm_ops::instr* inst, wasm_ops::visitor_arg& arg ) {
int32_t idx;
injector_utils::add_import<ResultType::f32, ValueType::f64>( *(arg.module), u8"_eosio_f64_demote", idx );
injector_utils::add_import<ResultType::f32, ValueType::f64>( *(arg.module), "_eosio_f64_demote", idx );
wasm_ops::op_types<>::call_t f32promote;
f32promote.field = idx;
f32promote.pack(arg.new_code);
Expand Down
8 changes: 6 additions & 2 deletions libraries/chain/webassembly/crypto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,18 @@ namespace eosio { namespace chain { namespace webassembly {

int32_t interface::alt_bn128_add(span<const char> op1, span<const char> op2, span<char> result ) const {
if (op1.size() != 64 || op2.size() != 64 || result.size() < 64 ||
bn256::g1_add({(const uint8_t*)op1.data(), 64}, {(const uint8_t*)op2.data(), 64}, { (uint8_t*)result.data(), 64}) == -1)
bn256::g1_add(std::span<const uint8_t, 64>{(const uint8_t*)op1.data(), 64},
std::span<const uint8_t, 64>{(const uint8_t*)op2.data(), 64},
std::span<uint8_t, 64>{ (uint8_t*)result.data(), 64}) == -1)
return return_code::failure;
return return_code::success;
}

int32_t interface::alt_bn128_mul(span<const char> g1_point, span<const char> scalar, span<char> result) const {
if (g1_point.size() != 64 || scalar.size() != 32 || result.size() < 64 ||
bn256::g1_scalar_mul({(const uint8_t*)g1_point.data(), 64}, {(const uint8_t*)scalar.data(), 32}, { (uint8_t*)result.data(), 64}) == -1)
bn256::g1_scalar_mul(std::span<const uint8_t, 64>{(const uint8_t*)g1_point.data(), 64},
std::span<const uint8_t, 32>{(const uint8_t*)scalar.data(), 32},
std::span<uint8_t, 64>{ (uint8_t*)result.data(), 64}) == -1)
return return_code::failure;
return return_code::success;
}
Expand Down
3 changes: 2 additions & 1 deletion plugins/chain_plugin/account_query_db.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,8 @@ namespace eosio::chain_apis {
} else {
const auto& po = *itr;

uint32_t last_updated_height = po.last_updated == bsp->header.timestamp ? bsp->block_num : last_updated_time_to_height(po.last_updated);
uint32_t last_updated_height = chain::block_timestamp_type(po.last_updated) == bsp->header.timestamp ?
bsp->block_num : last_updated_time_to_height(po.last_updated);

index.modify(index.iterator_to(pi), [&po, last_updated_height](auto& mutable_pi) {
mutable_pi.last_updated_height = last_updated_height;
Expand Down
Loading