提交 d2574cfa 编写于 作者: K Kevin Heifner

Fix for gcc compiler errors #665

上级 688593d2
......@@ -1564,9 +1564,9 @@ processed_transaction chain_controller::transaction_from_variant( const fc::vari
result.messages[i].data = message_to_binary( result.messages[i].code, result.messages[i].type, data );
/*
const auto& code_account = _db.get<account_object,by_name>( result.messages[i].code );
eosio::types::abi abi;
if( abi_serializer::to_abi(code_account.abi, abi) ) {
types::abi_serializer abis( abi );
eosio::types::abi code_abi;
if( abi_serializer::to_abi(code_account.code_abi, code_abi) ) {
types::abi_serializer abis( code_abi );
result.messages[i].data = abis.variant_to_binary( abis.get_action_type( result.messages[i].type ), data );
}
*/
......
......@@ -197,7 +197,7 @@ void apply_eos_setcode(apply_context& context) {
/// if an ABI is specified make sure it is well formed and doesn't
/// reference any undefined types
abi_serializer( msg.abi ).validate();
abi_serializer( msg.code_abi ).validate();
const auto& account = db.get<account_object,by_name>(msg.account);
......@@ -209,7 +209,7 @@ void apply_eos_setcode(apply_context& context) {
a.code.resize( msg.code.size() );
memcpy( a.code.data(), msg.code.data(), msg.code.size() );
a.set_abi( msg.abi );
a.set_abi( msg.code_abi );
});
apply_context init_context( context.mutable_controller, context.mutable_db, context.trx, context.msg, msg.account );
......@@ -370,8 +370,8 @@ void apply_eos_updateauth(apply_context& context) {
EOS_ASSERT(!update.permission.empty(), message_validate_exception, "Cannot create authority with empty name");
EOS_ASSERT(update.permission != update.parent, message_validate_exception,
"Cannot set an authority as its own parent");
EOS_ASSERT(validate(update.authority), message_validate_exception,
"Invalid authority: ${auth}", ("auth", update.authority));
EOS_ASSERT(validate(update.new_authority), message_validate_exception,
"Invalid authority: ${auth}", ("auth", update.new_authority));
if (update.permission == "active")
EOS_ASSERT(update.parent == "owner", message_validate_exception, "Cannot change active authority's parent");
if (update.permission == "owner")
......@@ -381,7 +381,7 @@ void apply_eos_updateauth(apply_context& context) {
context.require_authorization(update.account);
db.get<account_object, by_name>(update.account);
validate_authority_precondition(context, update.authority);
validate_authority_precondition(context, update.new_authority);
auto permission = db.find<permission_object, by_owner>(boost::make_tuple(update.account, update.permission));
......@@ -398,7 +398,7 @@ void apply_eos_updateauth(apply_context& context) {
// TODO/QUESTION: If we are updating an existing permission, should we check if the message declared
// permission satisfies the permission we want to modify?
db.modify(*permission, [&update, &parent_id](permission_object& po) {
po.auth = update.authority;
po.auth = update.new_authority;
po.parent = parent_id;
});
} else if (context.controller.is_applying_block()) {
......@@ -407,7 +407,7 @@ void apply_eos_updateauth(apply_context& context) {
db.create<permission_object>([&update, &parent_id](permission_object& po) {
po.name = update.permission;
po.owner = update.account;
po.auth = update.authority;
po.auth = update.new_authority;
po.parent = parent_id;
});
}
......
......@@ -39,7 +39,7 @@ namespace eosio { namespace types {
abi_serializer::abi_serializer( const abi& abi ) {
configure_built_in_types();
setAbi(abi);
set_abi(abi);
}
void abi_serializer::configure_built_in_types() {
......@@ -98,7 +98,7 @@ namespace eosio { namespace types {
built_in_types.emplace("abi", packUnpack<abi>());
}
void abi_serializer::setAbi( const abi& abi ) {
void abi_serializer::set_abi(const abi& abi) {
typedefs.clear();
structs.clear();
actions.clear();
......
......@@ -19,7 +19,7 @@ using std::pair;
struct abi_serializer {
abi_serializer(){ configure_built_in_types(); }
abi_serializer( const abi& abi );
void setAbi( const abi& abi );
void set_abi(const abi& abi);
map<type_name, type_name> typedefs;
map<type_name, struct_t> structs;
......
......@@ -104,10 +104,10 @@ struct newaccount
struct setcode
account account_name # the account that is handling the message
vm_type uint8 # the virtual machine type
vm_version uint8 # the virtual machine version
vm_type uint8 # the virtual machine type
vm_version uint8 # the virtual machine version
code bytes # the apply
abi abi # the interface description of the code
code_abi abi # the interface description of the code
struct setproducer
......@@ -130,7 +130,7 @@ struct updateauth
account account_name
permission permission_name
parent permission_name
authority authority
new_authority authority
struct deleteauth
account account_name
......
......@@ -333,10 +333,10 @@ void account_history_plugin_impl::applied_block(const signed_block& block)
{
const auto update = msg.as<types::updateauth>();
remove<public_key_history_multi_index, by_account_permission>(db, update.account, update.permission);
add(db, update.authority.keys, update.account, update.permission);
add(db, update.new_authority.keys, update.account, update.permission);
remove<account_control_history_multi_index, by_controlled_authority>(db, update.account, update.permission);
add(db, update.authority.accounts, update.account, update.permission);
add(db, update.new_authority.accounts, update.account, update.permission);
}
else if (msg.type == DELETE_AUTH)
{
......
......@@ -338,7 +338,7 @@ read_only::get_table_rows_result read_only::get_table_rows( const read_only::get
if( table_key == TERTIARY )
return get_table_rows_ex<chain::key64x64x64_value_index, chain::by_scope_tertiary>(p,abi);
}
FC_ASSERT( false, "invalid table type/key ${type}/${key}", ("type",table_type)("key",table_key)("abi",abi));
FC_ASSERT( false, "invalid table type/key ${type}/${key}", ("type",table_type)("key",table_key)("code_abi",abi));
}
read_only::get_block_results read_only::get_block(const read_only::get_block_params& params) const {
......@@ -385,9 +385,9 @@ read_write::push_transactions_results read_write::push_transactions(const read_w
read_only::get_code_results read_only::get_code( const get_code_params& params )const {
get_code_results result;
result.name = params.name;
result.account_name = params.account_name;
const auto& d = db.get_database();
const auto& accnt = d.get<account_object,by_name>( params.name );
const auto& accnt = d.get<account_object,by_name>( params.account_name );
if( accnt.code.size() ) {
result.wast = chain::wasm_to_wast( (const uint8_t*)accnt.code.data(), accnt.code.size() );
......@@ -404,11 +404,11 @@ read_only::get_account_results read_only::get_account( const get_account_params&
using namespace native::eosio;
get_account_results result;
result.name = params.name;
result.account_name = params.account_name;
const auto& d = db.get_database();
const auto& balance = d.get<balance_object,by_owner_name>( params.name );
const auto& staked_balance = d.get<staked_balance_object,by_owner_name>( params.name );
const auto& balance = d.get<balance_object,by_owner_name>( params.account_name );
const auto& staked_balance = d.get<staked_balance_object,by_owner_name>( params.account_name );
result.eos_balance = asset(balance.balance, EOS_SYMBOL);
result.staked_balance = asset(staked_balance.staked_balance);
......@@ -416,8 +416,8 @@ read_only::get_account_results read_only::get_account( const get_account_params&
result.last_unstaking_time = staked_balance.last_unstaking_time;
const auto& permissions = d.get_index<permission_index,by_owner>();
auto perm = permissions.lower_bound( boost::make_tuple( params.name ) );
while( perm != permissions.end() && perm->owner == params.name ) {
auto perm = permissions.lower_bound( boost::make_tuple( params.account_name ) );
while( perm != permissions.end() && perm->owner == params.account_name ) {
/// TODO: lookup perm->parent name
name parent;
......
......@@ -64,12 +64,12 @@ public:
get_info_results get_info(const get_info_params&) const;
struct producer_info {
name name;
name producer_name;
};
struct get_account_results {
name name;
name account_name;
asset eos_balance = asset(0,EOS_SYMBOL);
asset staked_balance;
asset unstaking_balance;
......@@ -78,20 +78,20 @@ public:
optional<producer_info> producer;
};
struct get_account_params {
name name;
name account_name;
};
get_account_results get_account( const get_account_params& params )const;
struct get_code_results {
name name;
name account_name;
string wast;
fc::sha256 code_hash;
optional<types::abi> abi;
};
struct get_code_params {
name name;
name account_name;
};
get_code_results get_code( const get_code_params& params )const;
......@@ -209,7 +209,7 @@ public:
const auto& d = db.get_database();
types::abi_serializer abis;
abis.setAbi(abi);
abis.set_abi(abi);
const auto& idx = d.get_index<IndexType, Scope>();
auto lower = idx.lower_bound( boost::make_tuple(p.scope, p.code, p.table ) );
......@@ -321,11 +321,11 @@ FC_REFLECT( eosio::chain_apis::read_write::push_transaction_results, (transactio
FC_REFLECT( eosio::chain_apis::read_only::get_table_rows_params, (json)(table_key)(scope)(code)(table)(lower_bound)(upper_bound)(limit) )
FC_REFLECT( eosio::chain_apis::read_only::get_table_rows_result, (rows)(more) );
FC_REFLECT( eosio::chain_apis::read_only::get_account_results, (name)(eos_balance)(staked_balance)(unstaking_balance)(last_unstaking_time)(permissions)(producer) )
FC_REFLECT( eosio::chain_apis::read_only::get_code_results, (name)(code_hash)(wast)(abi) )
FC_REFLECT( eosio::chain_apis::read_only::get_account_params, (name) )
FC_REFLECT( eosio::chain_apis::read_only::get_code_params, (name) )
FC_REFLECT( eosio::chain_apis::read_only::producer_info, (name) )
FC_REFLECT( eosio::chain_apis::read_only::get_account_results, (account_name)(eos_balance)(staked_balance)(unstaking_balance)(last_unstaking_time)(permissions)(producer) )
FC_REFLECT( eosio::chain_apis::read_only::get_code_results, (account_name)(code_hash)(wast)(abi) )
FC_REFLECT( eosio::chain_apis::read_only::get_account_params, (account_name) )
FC_REFLECT( eosio::chain_apis::read_only::get_code_params, (account_name) )
FC_REFLECT( eosio::chain_apis::read_only::producer_info, (producer_name) )
FC_REFLECT( eosio::chain_apis::read_only::abi_json_to_bin_params, (code)(action)(args) )
FC_REFLECT( eosio::chain_apis::read_only::abi_json_to_bin_result, (binargs)(required_scope)(required_auth) )
FC_REFLECT( eosio::chain_apis::read_only::abi_bin_to_json_params, (code)(action)(binargs) )
......
......@@ -190,11 +190,11 @@ namespace {
try {
types::abi_serializer abis;
if (msg.code == config::eos_contract_name) {
abis.setAbi(db_plugin_impl::eos_abi);
abis.set_abi(db_plugin_impl::eos_abi);
} else {
auto from_account = find_account(accounts, msg.code);
auto abi = fc::json::from_string(bsoncxx::to_json(from_account.view()["abi"].get_document())).as<types::abi>();
abis.setAbi(abi);
abis.set_abi(abi);
}
auto v = abis.binary_to_variant(abis.get_action_type(msg.type), msg.data);
auto json = fc::json::to_string(v);
......@@ -208,6 +208,10 @@ namespace {
}
} catch (fc::exception& e) {
elog("Unable to convert message.data to ABI type: ${t}, what: ${e}", ("t", msg.type)("e", e.to_string()));
} catch (std::exception& e) {
elog("Unable to convert message.data to ABI type: ${t}, std what: ${e}", ("t", msg.type)("e", e.what()));
} catch (...) {
elog("Unable to convert message.data to ABI type: ${t}", ("t", msg.type));
}
// if anything went wrong just store raw hex_data
msg_doc.append(kvp("hex_data", fc::variant(msg.data).as_string()));
......@@ -552,7 +556,7 @@ void db_plugin_impl::update_account(const chain::message& msg) {
document update_from{};
update_from << "$set" << open_document
<< "abi" << bsoncxx::from_json(fc::json::to_string(setcode.abi))
<< "abi" << bsoncxx::from_json(fc::json::to_string(setcode.code_abi))
<< "updatedAt" << b_date{now}
<< close_document;
......
......@@ -387,7 +387,7 @@ struct set_account_permission_subcommand {
name parent;
if (parentStr.size() == 0) {
// see if we can auto-determine the proper parent
const auto account_result = call(get_account_func, fc::mutable_variant_object("name", accountStr));
const auto account_result = call(get_account_func, fc::mutable_variant_object("account_name", accountStr));
const auto& existing_permissions = account_result.get_object()["permissions"].get_array();
auto permissionPredicate = [this](const auto& perm) {
return perm.is_object() &&
......@@ -540,7 +540,7 @@ int main( int argc, char** argv ) {
getAccount->add_option("name", accountName, localized("The name of the account to retrieve"))->required();
getAccount->set_callback([&] {
std::cout << fc::json::to_pretty_string(call(get_account_func,
fc::mutable_variant_object("name", accountName)))
fc::mutable_variant_object("account_name", accountName)))
<< std::endl;
});
......@@ -552,7 +552,7 @@ int main( int argc, char** argv ) {
getCode->add_option("-c,--code",codeFilename, localized("The name of the file to save the contract .wast to") );
getCode->add_option("-a,--abi",abiFilename, localized("The name of the file to save the contract .abi to") );
getCode->set_callback([&] {
auto result = call(get_code_func, fc::mutable_variant_object("name", accountName));
auto result = call(get_code_func, fc::mutable_variant_object("account_name", accountName));
std::cout << localized("code hash: ${code_hash}", ("code_hash", result["code_hash"].as_string())) << std::endl;
......@@ -686,7 +686,7 @@ int main( int argc, char** argv ) {
handler.account = account;
handler.code.assign(wasm.begin(), wasm.end());
if (abi->count())
handler.abi = fc::json::from_file(abiPath).as<types::abi>();
handler.code_abi = fc::json::from_file(abiPath).as<types::abi>();
signed_transaction trx;
trx.scope = sort_names({config::eos_contract_name, account});
......
......@@ -526,7 +526,7 @@ BOOST_FIXTURE_TEST_CASE(test_case_name, testing_fixture)
#define RUN_CODE_ABI_WITH_TRANSFER(account_name, test_wast, test_abi) \
types::setcode handler; \
handler.abi = fc::json::from_string(test_abi).as<types::abi>(); \
handler.code_abi = fc::json::from_string(test_abi).as<types::abi>(); \
RUN_CODE_HANDLER_WITH_TRANSFER(account_name, test_wast)
#define TEST_CASE_RUN_CODE_ABI_W_XFER(test_case_name, account_name, test_wast, test_abi) \
......
......@@ -446,7 +446,7 @@ BOOST_FIXTURE_TEST_CASE(abi_cycle, testing_fixture)
BOOST_CHECK_EXCEPTION( abis.validate(), fc::assert_exception, is_assert_exception );
abi = fc::json::from_string(struct_cycle_abi).as<types::abi>();
abis.setAbi(abi);
abis.set_abi(abi);
BOOST_CHECK_EXCEPTION( abis.validate(), fc::assert_exception, is_assert_exception );
} FC_LOG_AND_RETHROW() }
......@@ -751,7 +751,7 @@ BOOST_FIXTURE_TEST_CASE(updateauth, testing_fixture)
"account" : "updauth.acct",
"permission" : "updauth.prm",
"parent" : "updauth.prnt",
"authority" : {
"new_authority" : {
"threshold" : "2147483145",
"keys" : [ {"key" : "EOS65rXebLhtk2aTTzP4e9x1AQZs7c5NNXJp89W8R3HyaA6Zyd4im", "weight" : 57005},
{"key" : "EOS5eVr9TVnqwnUBNwf9kwMTbrHvX5aPyyEG97dz2b2TNeqWRzbJf", "weight" : 57605} ],
......@@ -767,21 +767,21 @@ BOOST_FIXTURE_TEST_CASE(updateauth, testing_fixture)
BOOST_CHECK_EQUAL("updauth.acct", updateauth.account);
BOOST_CHECK_EQUAL("updauth.prm", updateauth.permission);
BOOST_CHECK_EQUAL("updauth.prnt", updateauth.parent);
BOOST_CHECK_EQUAL(2147483145u, updateauth.authority.threshold);
BOOST_REQUIRE_EQUAL(2, updateauth.authority.keys.size());
BOOST_CHECK_EQUAL("EOS65rXebLhtk2aTTzP4e9x1AQZs7c5NNXJp89W8R3HyaA6Zyd4im", (std::string)updateauth.authority.keys[0].key);
BOOST_CHECK_EQUAL(57005u, updateauth.authority.keys[0].weight);
BOOST_CHECK_EQUAL("EOS5eVr9TVnqwnUBNwf9kwMTbrHvX5aPyyEG97dz2b2TNeqWRzbJf", (std::string)updateauth.authority.keys[1].key);
BOOST_CHECK_EQUAL(57605u, updateauth.authority.keys[1].weight);
BOOST_REQUIRE_EQUAL(2, updateauth.authority.accounts.size());
BOOST_CHECK_EQUAL("prm.acct1", updateauth.authority.accounts[0].permission.account);
BOOST_CHECK_EQUAL("prm.prm1", updateauth.authority.accounts[0].permission.permission);
BOOST_CHECK_EQUAL(53005u, updateauth.authority.accounts[0].weight);
BOOST_CHECK_EQUAL("prm.acct2", updateauth.authority.accounts[1].permission.account);
BOOST_CHECK_EQUAL("prm.prm2", updateauth.authority.accounts[1].permission.permission);
BOOST_CHECK_EQUAL(53405u, updateauth.authority.accounts[1].weight);
BOOST_CHECK_EQUAL(2147483145u, updateauth.new_authority.threshold);
BOOST_REQUIRE_EQUAL(2, updateauth.new_authority.keys.size());
BOOST_CHECK_EQUAL("EOS65rXebLhtk2aTTzP4e9x1AQZs7c5NNXJp89W8R3HyaA6Zyd4im", (std::string)updateauth.new_authority.keys[0].key);
BOOST_CHECK_EQUAL(57005u, updateauth.new_authority.keys[0].weight);
BOOST_CHECK_EQUAL("EOS5eVr9TVnqwnUBNwf9kwMTbrHvX5aPyyEG97dz2b2TNeqWRzbJf", (std::string)updateauth.new_authority.keys[1].key);
BOOST_CHECK_EQUAL(57605u, updateauth.new_authority.keys[1].weight);
BOOST_REQUIRE_EQUAL(2, updateauth.new_authority.accounts.size());
BOOST_CHECK_EQUAL("prm.acct1", updateauth.new_authority.accounts[0].permission.account);
BOOST_CHECK_EQUAL("prm.prm1", updateauth.new_authority.accounts[0].permission.permission);
BOOST_CHECK_EQUAL(53005u, updateauth.new_authority.accounts[0].weight);
BOOST_CHECK_EQUAL("prm.acct2", updateauth.new_authority.accounts[1].permission.account);
BOOST_CHECK_EQUAL("prm.prm2", updateauth.new_authority.accounts[1].permission.permission);
BOOST_CHECK_EQUAL(53405u, updateauth.new_authority.accounts[1].weight);
auto var2 = verify_round_trip_conversion( abis, "updateauth", var );
auto updateauth2 = var2.as<eosio::types::updateauth>();
......@@ -789,21 +789,21 @@ BOOST_FIXTURE_TEST_CASE(updateauth, testing_fixture)
BOOST_CHECK_EQUAL(updateauth.permission, updateauth2.permission);
BOOST_CHECK_EQUAL(updateauth.parent, updateauth2.parent);
BOOST_CHECK_EQUAL(updateauth.authority.threshold, updateauth2.authority.threshold);
BOOST_REQUIRE_EQUAL(updateauth.authority.keys.size(), updateauth2.authority.keys.size());
BOOST_CHECK_EQUAL(updateauth.authority.keys[0].key, updateauth2.authority.keys[0].key);
BOOST_CHECK_EQUAL(updateauth.authority.keys[0].weight, updateauth2.authority.keys[0].weight);
BOOST_CHECK_EQUAL(updateauth.authority.keys[1].key, updateauth2.authority.keys[1].key);
BOOST_CHECK_EQUAL(updateauth.authority.keys[1].weight, updateauth2.authority.keys[1].weight);
BOOST_REQUIRE_EQUAL(updateauth.authority.accounts.size(), updateauth2.authority.accounts.size());
BOOST_CHECK_EQUAL(updateauth.authority.accounts[0].permission.account, updateauth2.authority.accounts[0].permission.account);
BOOST_CHECK_EQUAL(updateauth.authority.accounts[0].permission.permission, updateauth2.authority.accounts[0].permission.permission);
BOOST_CHECK_EQUAL(updateauth.authority.accounts[0].weight, updateauth2.authority.accounts[0].weight);
BOOST_CHECK_EQUAL(updateauth.authority.accounts[1].permission.account, updateauth2.authority.accounts[1].permission.account);
BOOST_CHECK_EQUAL(updateauth.authority.accounts[1].permission.permission, updateauth2.authority.accounts[1].permission.permission);
BOOST_CHECK_EQUAL(updateauth.authority.accounts[1].weight, updateauth2.authority.accounts[1].weight);
BOOST_CHECK_EQUAL(updateauth.new_authority.threshold, updateauth2.new_authority.threshold);
BOOST_REQUIRE_EQUAL(updateauth.new_authority.keys.size(), updateauth2.new_authority.keys.size());
BOOST_CHECK_EQUAL(updateauth.new_authority.keys[0].key, updateauth2.new_authority.keys[0].key);
BOOST_CHECK_EQUAL(updateauth.new_authority.keys[0].weight, updateauth2.new_authority.keys[0].weight);
BOOST_CHECK_EQUAL(updateauth.new_authority.keys[1].key, updateauth2.new_authority.keys[1].key);
BOOST_CHECK_EQUAL(updateauth.new_authority.keys[1].weight, updateauth2.new_authority.keys[1].weight);
BOOST_REQUIRE_EQUAL(updateauth.new_authority.accounts.size(), updateauth2.new_authority.accounts.size());
BOOST_CHECK_EQUAL(updateauth.new_authority.accounts[0].permission.account, updateauth2.new_authority.accounts[0].permission.account);
BOOST_CHECK_EQUAL(updateauth.new_authority.accounts[0].permission.permission, updateauth2.new_authority.accounts[0].permission.permission);
BOOST_CHECK_EQUAL(updateauth.new_authority.accounts[0].weight, updateauth2.new_authority.accounts[0].weight);
BOOST_CHECK_EQUAL(updateauth.new_authority.accounts[1].permission.account, updateauth2.new_authority.accounts[1].permission.account);
BOOST_CHECK_EQUAL(updateauth.new_authority.accounts[1].permission.permission, updateauth2.new_authority.accounts[1].permission.permission);
BOOST_CHECK_EQUAL(updateauth.new_authority.accounts[1].weight, updateauth2.new_authority.accounts[1].weight);
} FC_LOG_AND_RETHROW() }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册