forked from lthn/blockchain
fixed few errors discovered by multiasset_test, still problem with emmit
This commit is contained in:
parent
4c666aa6a4
commit
3996567462
5 changed files with 24 additions and 12 deletions
|
|
@ -3865,11 +3865,12 @@ bool blockchain_storage::put_asset_info(const transaction& tx, const crypto::has
|
|||
}
|
||||
|
||||
avc.amout_to_validate = 0;
|
||||
//validate balance proof
|
||||
bool need_to_validate_balance_proof = true;
|
||||
if (ado.operation_type == ASSET_DESCRIPTOR_OPERATION_UPDATE)
|
||||
{
|
||||
//check that total current_supply haven't changed
|
||||
CHECK_AND_ASSERT_MES(ado.descriptor.current_supply != avc.asset_op_history->back().descriptor.current_supply, false, "update operation actually try to change emission, failed");
|
||||
CHECK_AND_ASSERT_MES(ado.descriptor.current_supply == avc.asset_op_history->back().descriptor.current_supply, false, "update operation actually try to change emission, failed");
|
||||
need_to_validate_balance_proof = false;
|
||||
}
|
||||
else if (ado.operation_type == ASSET_DESCRIPTOR_OPERATION_EMMIT)
|
||||
{
|
||||
|
|
@ -3886,13 +3887,17 @@ bool blockchain_storage::put_asset_info(const transaction& tx, const crypto::has
|
|||
LOG_ERROR("Unknown operation type: " << ado.operation_type);
|
||||
return false;
|
||||
}
|
||||
bool r = validate_asset_operation_balance_proof(avc);
|
||||
CHECK_AND_ASSERT_MES(r, false, "Balance proof validation failed for asset_descriptor_operation");
|
||||
if (need_to_validate_balance_proof)
|
||||
{
|
||||
bool r = validate_asset_operation_balance_proof(avc);
|
||||
CHECK_AND_ASSERT_MES(r, false, "Balance proof validation failed for asset_descriptor_operation");
|
||||
}
|
||||
|
||||
assets_container::t_value_type local_asset_history = *avc.asset_op_history;
|
||||
|
||||
local_asset_history.push_back(ado);
|
||||
m_db_assets.set(avc.asset_id, local_asset_history);
|
||||
LOG_PRINT_MAGENTA("[ASSET_UPDATED]: " << avc.asset_id << ": " << ado.descriptor.full_name, LOG_LEVEL_1);
|
||||
m_db_assets.set(*avc.ado.opt_asset_id, local_asset_history);
|
||||
LOG_PRINT_MAGENTA("[ASSET_UPDATED]: " << *avc.ado.opt_asset_id << ": " << ado.descriptor.full_name, LOG_LEVEL_1);
|
||||
|
||||
//TODO:
|
||||
//rise_core_event(CORE_EVENT_ADD_ASSET, alias_info_to_rpc_alias_info(ai));
|
||||
|
|
|
|||
|
|
@ -769,6 +769,7 @@ namespace currency
|
|||
BOOST_SERIALIZE(full_name)
|
||||
BOOST_SERIALIZE(meta_info)
|
||||
BOOST_SERIALIZE(owner)
|
||||
BOOST_SERIALIZE(hidden_supply)
|
||||
END_BOOST_SERIALIZATION()
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
|
|
@ -779,6 +780,7 @@ namespace currency
|
|||
KV_SERIALIZE(full_name)
|
||||
KV_SERIALIZE(meta_info)
|
||||
KV_SERIALIZE_POD_AS_HEX_STRING(owner)
|
||||
KV_SERIALIZE(hidden_supply)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -2133,9 +2133,10 @@ namespace currency
|
|||
uint64_t amount_of_emitted_asset = 0;
|
||||
for (auto& item : shuffled_dsts)
|
||||
{
|
||||
if (item.asset_id == gen_context.ao_asset_id)
|
||||
if (item.asset_id == currency::null_pkey)
|
||||
{
|
||||
amount_of_emitted_asset += item.amount;
|
||||
item.asset_id = gen_context.ao_asset_id;
|
||||
}
|
||||
}
|
||||
ado.descriptor.current_supply += amount_of_emitted_asset; // TODO: consider setting current_supply beforehand, not setting it hear in ad-hoc manner -- sowle
|
||||
|
|
@ -2147,7 +2148,7 @@ namespace currency
|
|||
else if (ado.operation_type == ASSET_DESCRIPTOR_OPERATION_UPDATE)
|
||||
{
|
||||
CHECK_AND_ASSERT_MES(ado.opt_asset_id, false, "ado.opt_asset_id is not found at ado.operation_type == ASSET_DESCRIPTOR_OPERATION_EMMIT/UPDATE");
|
||||
CHECK_AND_ASSERT_MES(ado.opt_proof, false, "ado.opt_asset_id is not found at ado.operation_type == ASSET_DESCRIPTOR_OPERATION_EMMIT/UPDATE");
|
||||
//CHECK_AND_ASSERT_MES(ado.opt_proof, false, "ado.opt_asset_id is not found at ado.operation_type == ASSET_DESCRIPTOR_OPERATION_EMMIT/UPDATE");
|
||||
CHECK_AND_ASSERT_MES(!ado.opt_amount_commitment, false, "ado.opt_asset_id is not found at ado.operation_type == ASSET_DESCRIPTOR_OPERATION_EMMIT/UPDATE");
|
||||
|
||||
//fields that not supposed to be changed?
|
||||
|
|
|
|||
|
|
@ -443,6 +443,7 @@ void wallet2::process_ado_in_new_transaction(const currency::asset_descriptor_op
|
|||
WLT_THROW_IF_FALSE_WALLET_CMN_ERR_EX(m_own_asset_descriptors.count(asset_id) == 0, "asset with asset_id " << asset_id << " has already been registered in the wallet as own asset");
|
||||
wallet_own_asset_context& asset_context = m_own_asset_descriptors[asset_id];
|
||||
asset_context.asset_descriptor = ado.descriptor;
|
||||
asset_context.control_key = asset_control_key;
|
||||
|
||||
std::stringstream ss;
|
||||
ss << "New Asset Registered:"
|
||||
|
|
@ -4725,6 +4726,7 @@ void wallet2::emmit_asset(const crypto::public_key asset_id, std::vector<currenc
|
|||
asset_descriptor_operation asset_emmit_info = AUTO_VAL_INIT(asset_emmit_info);
|
||||
asset_emmit_info.descriptor = own_asset_entry_it->second.asset_descriptor;
|
||||
asset_emmit_info.operation_type = ASSET_DESCRIPTOR_OPERATION_EMMIT;
|
||||
asset_emmit_info.opt_asset_id = asset_id;
|
||||
construct_tx_param ctp = get_default_construct_tx_param();
|
||||
ctp.dsts = destinations;
|
||||
ctp.extra.push_back(asset_emmit_info);
|
||||
|
|
@ -4744,6 +4746,7 @@ void wallet2::update_asset(const crypto::public_key asset_id, const currency::as
|
|||
asset_descriptor_operation asset_update_info = AUTO_VAL_INIT(asset_update_info);
|
||||
asset_update_info.descriptor = new_descriptor;
|
||||
asset_update_info.operation_type = ASSET_DESCRIPTOR_OPERATION_UPDATE;
|
||||
asset_update_info.opt_asset_id = asset_id;
|
||||
construct_tx_param ctp = get_default_construct_tx_param();
|
||||
ctp.extra.push_back(asset_update_info);
|
||||
ctp.need_at_least_1_zc = true;
|
||||
|
|
@ -4769,6 +4772,7 @@ void wallet2::burn_asset(const crypto::public_key asset_id, uint64_t amount_to_b
|
|||
dst_to_burn.asset_id = asset_id;
|
||||
|
||||
asset_burn_info.operation_type = ASSET_DESCRIPTOR_OPERATION_PUBLIC_BURN;
|
||||
asset_burn_info.opt_asset_id = asset_id;
|
||||
construct_tx_param ctp = get_default_construct_tx_param();
|
||||
ctp.extra.push_back(asset_burn_info);
|
||||
ctp.need_at_least_1_zc = true;
|
||||
|
|
|
|||
|
|
@ -120,10 +120,6 @@ bool multiassets_basic_test::c1(currency::core& c, size_t ev_index, const std::v
|
|||
|
||||
|
||||
|
||||
miner_wlt->refresh();
|
||||
uint64_t last_miner_balance = miner_wlt->balance(asset_id, mined);
|
||||
|
||||
|
||||
{
|
||||
try {
|
||||
|
||||
|
|
@ -138,6 +134,10 @@ bool multiassets_basic_test::c1(currency::core& c, size_t ev_index, const std::v
|
|||
}
|
||||
}
|
||||
|
||||
miner_wlt->refresh();
|
||||
uint64_t last_miner_balance = miner_wlt->balance(asset_id, mined);
|
||||
|
||||
|
||||
asset_descriptor_base asset_info = AUTO_VAL_INIT(asset_info);
|
||||
/*
|
||||
adb.total_max_supply = 1000000000000000000; //1M coins
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue