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

FC update #37

Merged
merged 14 commits into from
Jan 15, 2019
Merged
10 changes: 0 additions & 10 deletions BUILD_UBUNTU.md
Original file line number Diff line number Diff line change
@@ -1,11 +1 @@
TODO: add rest of unbuntu instructions here.

If you want posts to be merged / patched then you will require Qt5 to be installed

sudo apt-get install qt5-default qttools5-dev-tools

Or you can disable it via cmake:

cmake -DENABLE_CONTENT_PATCHING=OFF .

You may need to set CMAKE_PREFIX_PATH to `Qt/5.5/clang_64/`
2 changes: 0 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ LIST(APPEND BOOST_COMPONENTS thread
system
filesystem
program_options
signals
serialization
chrono
unit_test_framework
context
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ each individual to inspect the code to understand the consensus rules.
Build Instructions
------------------
These instructions apply on Fedora 24. For other distributions, make sure you have
installed Boost 1.58-1.63 first. You also have instructions to build test net here.
installed Boost 1.60-1.66 first. You also have instructions to build test net here.
For building, you need at least 4 GB of memory available.

We are testing using Fedora 25, x64
Expand Down
8 changes: 4 additions & 4 deletions libraries/chain/base_evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ void set_withdraw_vesting_route_evaluator::do_apply( const set_withdraw_vesting_
wvdo.auto_vest = o.auto_vest;
});

db().modify( from_account, [&]( account_object& a )
db().modify( from_account, []( account_object& a )
{
a.withdraw_routes++;
});
Expand All @@ -374,7 +374,7 @@ void set_withdraw_vesting_route_evaluator::do_apply( const set_withdraw_vesting_
{
db().remove( *itr );

db().modify( from_account, [&]( account_object& a )
db().modify( from_account, []( account_object& a )
{
a.withdraw_routes--;
});
Expand All @@ -393,7 +393,7 @@ void set_withdraw_vesting_route_evaluator::do_apply( const set_withdraw_vesting_
itr = wd_idx.upper_bound( boost::make_tuple( from_account.id, account_id_type() ) );
uint16_t total_percent = 0;

while( itr->from_account == from_account.id && itr != wd_idx.end() )
while( itr != wd_idx.end() && itr->from_account == from_account.id )
{
total_percent += itr->percent;
++itr;
Expand Down Expand Up @@ -424,7 +424,7 @@ void account_witness_proxy_evaluator::do_apply( const account_witness_proxy_oper
/// check for proxy loops and fail to update the proxy if it would create a loop
auto cprox = &new_proxy;
while( cprox->proxy.size() != 0 ) {
const auto next_proxy = db().get_account( cprox->proxy );
const auto& next_proxy = db().get_account( cprox->proxy );
FC_ASSERT( proxy_chain.insert( next_proxy.get_id() ).second, "Attempt to create a proxy loop" );
cprox = &next_proxy;
FC_ASSERT( proxy_chain.size() <= MUSE_MAX_PROXY_RECURSION_DEPTH, "Proxy chain is too long" );
Expand Down
2 changes: 0 additions & 2 deletions libraries/chain/database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
#include <fc/smart_ref_impl.hpp>
#include <fc/uint128.hpp>

#include <fc/container/deque.hpp>

#include <fc/io/fstream.hpp>

#include <cstdint>
Expand Down
1 change: 0 additions & 1 deletion libraries/chain/include/muse/chain/protocol/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ namespace muse { namespace chain {
using fc::enum_type;
using fc::optional;
using fc::unsigned_int;
using fc::signed_int;
using fc::time_point_sec;
using fc::time_point;
using fc::safe;
Expand Down
23 changes: 19 additions & 4 deletions libraries/db/include/graphene/db/generic_index.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,25 @@ namespace graphene { namespace db {

virtual void modify( const object& obj, const std::function<void(object&)>& m )override
{
assert( nullptr != dynamic_cast<const ObjectType*>(&obj) );
auto ok = _indices.modify( _indices.iterator_to( static_cast<const ObjectType&>(obj) ),
[&m]( ObjectType& o ){ m(o); } );
FC_ASSERT( ok, "Could not modify object, most likely a index constraint was violated" );
assert(nullptr != dynamic_cast<const ObjectType*>(&obj));
std::exception_ptr exc;
auto ok = _indices.modify(_indices.iterator_to(static_cast<const ObjectType&>(obj)),
[&m, &exc](ObjectType& o) mutable {
try {
m(o);
} catch (fc::exception e) {
exc = std::current_exception();
elog("Exception while modifying object: ${e} -- object may be corrupted",
("e", e));
} catch (...) {
exc = std::current_exception();
elog("Unknown exception while modifying object");
}
}
);
if (exc)
std::rethrow_exception(exc);
FC_ASSERT(ok, "Could not modify object, most likely an index constraint was violated");
}

virtual void remove( const object& obj )override
Expand Down
1 change: 0 additions & 1 deletion libraries/db/include/graphene/db/object_id.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ namespace graphene { namespace db {
using fc::flat_map;
using fc::variant;
using fc::unsigned_int;
using fc::signed_int;

struct object_id_type
{
Expand Down
2 changes: 1 addition & 1 deletion libraries/fc
Submodule fc updated 66 files
+10 −17 CMakeLists.txt
+4 −4 include/fc/asio.hpp
+14 −0 include/fc/bloom_filter.hpp
+0 −9 include/fc/compress/smaz.hpp
+6 −1 include/fc/config.hpp
+0 −12 include/fc/container/deque.hpp
+21 −16 include/fc/container/flat.hpp
+4 −4 include/fc/container/flat_fwd.hpp
+1 −1 include/fc/crypto/rand.hpp
+5 −0 include/fc/crypto/sha1.hpp
+0 −27 include/fc/interprocess/container.hpp
+3 −3 include/fc/io/fstream.hpp
+0 −2 include/fc/io/json.hpp
+27 −46 include/fc/io/raw.hpp
+0 −3 include/fc/io/raw_fwd.hpp
+3 −3 include/fc/io/raw_variant.hpp
+13 −59 include/fc/io/varint.hpp
+1 −1 include/fc/log/file_appender.hpp
+1 −1 include/fc/log/gelf_appender.hpp
+10 −0 include/fc/reflect/reflect.hpp
+28 −2 include/fc/reflect/typename.hpp
+2 −0 include/fc/rpc/cli.hpp
+199 −53 include/fc/static_variant.hpp
+3 −2 include/fc/thread/future.hpp
+106 −0 include/fc/thread/parallel.hpp
+2 −0 include/fc/thread/task.hpp
+24 −4 include/fc/thread/thread.hpp
+8 −6 include/fc/variant.hpp
+10 −11 src/asio.cpp
+0 −223 src/compress/smaz.cpp
+2 −2 src/crypto/elliptic_common.cpp
+5 −1 src/crypto/openssl.cpp
+2 −2 src/crypto/pke.cpp
+4 −4 src/crypto/rand.cpp
+18 −11 src/filesystem.cpp
+12 −4 src/io/fstream.cpp
+1 −3 src/io/varint.cpp
+17 −22 src/log/file_appender.cpp
+2 −1 src/network/http/websocket.cpp
+1 −1 src/network/tcp_socket.cpp
+35 −12 src/rpc/cli.cpp
+3 −2 src/stacktrace.cpp
+31 −0 src/static_variant.cpp
+6 −4 src/thread/context.hpp
+202 −0 src/thread/parallel.cpp
+52 −52 src/thread/thread.cpp
+22 −3 src/thread/thread_d.hpp
+1 −0 src/variant.cpp
+3 −0 tests/CMakeLists.txt
+0 −32 tests/compress/compress.cpp
+2 −2 tests/crypto/dh_test.cpp
+3 −10 tests/crypto/rand_test.cpp
+2 −2 tests/io/json_tests.cpp
+30 −30 tests/io/stream_tests.cpp
+0 −4 tests/io/tcp_test.cpp
+98 −0 tests/io/varint_tests.cpp
+72 −0 tests/logging_tests.cpp
+1 −1 tests/network/http/websocket_test.cpp
+19 −6 tests/run-parallel-tests.sh
+20 −0 tests/serialization_test.cpp
+40 −2 tests/stacktrace_test.cpp
+342 −0 tests/thread/parallel_tests.cpp
+5 −4 tests/time_test.cpp
+49 −0 tests/variant_test.cpp
+1 −1 vendor/editline
+1 −1 vendor/websocketpp
1 change: 1 addition & 0 deletions libraries/manifest/mf_plugins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <muse/manifest/plugins.hpp>
#include <mf_internal_plugins.inc>
#include <mf_external_plugins.inc>
#include <functional>

#define MUSE_DECLARE_PLUGIN_CREATOR( r, data, x ) \
std::shared_ptr< muse::app::abstract_plugin > BOOST_PP_CAT( create_, BOOST_PP_CAT( x, _plugin ) )();
Expand Down
2 changes: 1 addition & 1 deletion libraries/net/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@ namespace graphene { namespace net { namespace detail {
_maximum_blocks_per_peer_during_syncing(GRAPHENE_NET_MAX_BLOCKS_PER_PEER_DURING_SYNCING)
{
_rate_limiter.set_actual_rate_time_constant(fc::seconds(2));
fc::rand_pseudo_bytes(&_node_id.data[0], (int)_node_id.size());
fc::rand_bytes(&_node_id.data[0], (int)_node_id.size());
}

node_impl::~node_impl()
Expand Down
2 changes: 1 addition & 1 deletion libraries/wallet/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ if( PERL_FOUND AND DOXYGEN_FOUND AND NOT "${CMAKE_GENERATOR}" STREQUAL "Ninja" )
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile ${CMAKE_CURRENT_SOURCE_DIR}/include/muse/wallet/wallet.hpp )

add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/api_documentation.cpp
COMMAND ${PERL_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/generate_api_documentation.pl ${CMAKE_CURRENT_BINARY_DIR}/api_documentation.cpp.new
COMMAND PERLLIB=${CMAKE_CURRENT_BINARY_DIR} ${PERL_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/generate_api_documentation.pl ${CMAKE_CURRENT_BINARY_DIR}/api_documentation.cpp.new

COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_BINARY_DIR}/api_documentation.cpp.new ${CMAKE_CURRENT_BINARY_DIR}/api_documentation.cpp
COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_CURRENT_BINARY_DIR}/api_documentation.cpp.new
Expand Down
35 changes: 19 additions & 16 deletions libraries/wallet/include/muse/wallet/wallet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

#include <graphene/utilities/key_conversion.hpp>

#include <fc/real128.hpp>
#include <fc/crypto/base58.hpp>

using namespace muse::app;
Expand Down Expand Up @@ -227,8 +226,12 @@ class wallet_api
*/
string get_private_key( public_key_type pubkey )const;

/**
* @param role - active | owner | basic | memo
/** Generates public and private key pair using account name + role + password
* as the seed string. Should be compatible with how the UI does it.
* @param account account name to which the password belongs
* @param role active | owner | basic | memo
* @param password the actual password
* @return the key pair (public,private)
*/
pair<public_key_type,string> get_private_key_from_password( string account, string role, string password )const;

Expand Down Expand Up @@ -840,10 +843,11 @@ class wallet_api
uint64_t get_content_scoring( string content );

/**
* Create a new UIA.
* Create a new UIA with 6 digits precision
* @param issuer Account name used for creating the asset
* @param asset_name Unique asset name
* @param description Description
* @param max_supply Maximum supply
* @param max_supply Maximum supply (in satoshis!)
* @param broadcast Broadcast the transaction?
*/
annotated_signed_transaction create_asset(string issuer, string asset_name, string description, uint64_t max_supply, bool broadcast);
Expand All @@ -855,7 +859,7 @@ class wallet_api
* @param amount Issued amount
* @param broadcast Broadcast the transaction?
*/
annotated_signed_transaction issue_asset(string asset_name, string to_account, fc::real128 amount, bool broadcast);
annotated_signed_transaction issue_asset(string asset_name, string to_account, string amount, bool broadcast);

/**
* Reserve asset from an account
Expand All @@ -864,7 +868,7 @@ class wallet_api
* @param amount Reserved amount
* @param broadcast Broadcast the transaction?
*/
annotated_signed_transaction reserve_asset(string asset_name, string from_account, fc::real128 amount, bool broadcast);
annotated_signed_transaction reserve_asset(string asset_name, string from_account, string amount, bool broadcast);

/**
* Update an UIA.
Expand Down Expand Up @@ -896,8 +900,9 @@ class wallet_api
vector<content_object> lookup_content(const string& start, uint32_t limit );

/**
* Get content list, by namei, filtered by approver
* @param start Starting name
* Get content list, by approver, filtered by approver
* @param start Starting content id
* @param approver Account name that approved the content
* @param limit Limit, less than 1000
*/
vector<content_object> lookup_content_by_approver(const string& start, const string& approver, uint32_t limit );
Expand All @@ -915,11 +920,10 @@ class wallet_api
message_body try_decrypt_message( const message_object& mo );

/**
* Vote on a comment to be paid MUSE
* Vote for content
*
* @param voter The account voting
* @param author The author of the comment to be voted on
* @param url The permlink of the comment to be voted on. (author, permlink) is a unique pair
* @param voter The voting account
* @param url The ID of the comment to be voted on
* @param weight The weight [-100,100] of the vote
* @param broadcast true if you wish to broadcast the transaction
*/
Expand Down Expand Up @@ -1044,7 +1048,6 @@ class wallet_api

/** Approve or disapprove a proposal.
*
* @param fee_paying_account The account paying the fee for the op.
* @param proposal_id The proposal to modify.
* @param delta Members contain approvals to create or remove. In JSON you can leave empty members undefined.
* @param broadcast true if you wish to broadcast the transaction
Expand Down Expand Up @@ -1086,7 +1089,7 @@ FC_REFLECT( muse::wallet::wallet_data,
(ws_password)
)

FC_REFLECT( muse::wallet::brain_key_info, (brain_priv_key)(wif_priv_key) (pub_key));
FC_REFLECT( muse::wallet::brain_key_info, (brain_priv_key)(wif_priv_key) (pub_key))

FC_REFLECT_DERIVED( muse::wallet::signed_block_with_info, (muse::chain::signed_block),
(block_id)(signing_key)(transaction_ids) )
Expand Down Expand Up @@ -1218,4 +1221,4 @@ FC_REFLECT( muse::wallet::approval_delta,
(key_approvals_to_add)
(key_approvals_to_remove)
)
FC_REFLECT( muse::wallet::memo_data, (from)(to)(nonce)(check)(encrypted) );
FC_REFLECT( muse::wallet::memo_data, (from)(to)(nonce)(check)(encrypted) )
24 changes: 9 additions & 15 deletions libraries/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@
#include <boost/multi_index/sequenced_index.hpp>
#include <boost/multi_index/hashed_index.hpp>

#include <fc/container/deque.hpp>
#include <fc/git_revision.hpp>
#include <fc/real128.hpp>
#include <fc/io/fstream.hpp>
#include <fc/io/json.hpp>
#include <fc/io/stdio.hpp>
Expand Down Expand Up @@ -1128,18 +1126,17 @@ class wallet_api_impl
}FC_CAPTURE_AND_RETHROW( (asset_name)(description)(max_supply)(new_issuer)(broadcast) )
}

annotated_signed_transaction issue_asset(string asset_name, string to_account, fc::real128 amount, bool broadcast)
annotated_signed_transaction issue_asset(string asset_name, string to_account, string amount, bool broadcast)
{
auto asset_obj = find_asset(asset_name);
auto to_account_obj = get_account(to_account);
if (!asset_obj)
FC_THROW("No asset with that symbol exists!");
get_account(to_account); // verify that it exists
auto issuer = get_account_from_id(asset_obj->issuer);
asset_issue_operation issue_op;
issue_op.issuer = issuer->name;
uint64_t amount_i = (amount*asset::static_precision()).to_uint64();
issue_op.asset_to_issue = asset(amount_i, asset_obj->id);
issue_op.issue_to_account=to_account;
issue_op.asset_to_issue = asset::from_string( amount + std::string(" ") + std::string(asset_obj->id) );
issue_op.issue_to_account = to_account;

signed_transaction tx;
tx.operations.push_back(issue_op);
Expand All @@ -1148,20 +1145,17 @@ class wallet_api_impl
return sign_transaction(tx, broadcast);
}

annotated_signed_transaction reserve_asset(string asset_name, string from_account, fc::real128 amount, bool broadcast)
annotated_signed_transaction reserve_asset(string asset_name, string from_account, string amount, bool broadcast)
{
auto asset_obj = find_asset(asset_name);
auto from_account_obj = get_account(from_account);
if (!asset_obj)
FC_THROW("No asset with that symbol exists!");
get_account(from_account); // verify that it exists
auto issuer = get_account_from_id(asset_obj->issuer);

asset_reserve_operation reserve_op;
reserve_op.issuer = issuer->name;

uint64_t amount_i = (amount*asset::static_precision()).to_uint64();

reserve_op.amount_to_reserve = asset(amount_i, asset_obj->id);
reserve_op.amount_to_reserve = asset::from_string( amount + std::string(" ") + std::string(asset_obj->id) );
reserve_op.payer = from_account;

signed_transaction tx;
Expand Down Expand Up @@ -2612,12 +2606,12 @@ annotated_signed_transaction wallet_api::create_asset(string issuer, string asse
return my->create_asset(issuer, asset_name, description, max_supply, broadcast);
}

annotated_signed_transaction wallet_api::issue_asset(string asset_name, string to_account, fc::real128 amount, bool broadcast)
annotated_signed_transaction wallet_api::issue_asset(string asset_name, string to_account, string amount, bool broadcast)
{
return my->issue_asset(asset_name, to_account, amount, broadcast);
}

annotated_signed_transaction wallet_api::reserve_asset(string asset_name, string from_account, fc::real128 amount, bool broadcast)
annotated_signed_transaction wallet_api::reserve_asset(string asset_name, string from_account, string amount, bool broadcast)
{
return my->reserve_asset(asset_name, from_account, amount, broadcast);
}
Expand Down
1 change: 0 additions & 1 deletion programs/js_operation_serializer/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ template<> struct js_name<fc::uint160> { static std::string name(){ retu
template<> struct js_name<fc::sha224> { static std::string name(){ return "bytes 28"; } };
template<> struct js_name<fc::sha256> { static std::string name(){ return "bytes 32"; } };
template<> struct js_name<fc::unsigned_int> { static std::string name(){ return "varuint32"; } };
template<> struct js_name<fc::signed_int> { static std::string name(){ return "varint32"; } };
template<> struct js_name< time_point_sec > { static std::string name(){ return "time_point_sec"; } };

template<uint8_t S, uint8_t T, typename O>
Expand Down
2 changes: 2 additions & 0 deletions tests/tests/api_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,8 @@ BOOST_AUTO_TEST_CASE( get_accounts_test )
cup.url = url;
cup.side = content_update_operation::side_t::publisher;
cup.new_threshold = 60;
cup.new_playing_reward = 0;
cup.new_publishers_share = 0;

proposal_create_operation pco;
pco.proposed_ops.emplace_back( cup );
Expand Down
1 change: 1 addition & 0 deletions tests/tests/authority_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1281,6 +1281,7 @@ BOOST_AUTO_TEST_CASE( proposals_with_mixed_authorities )
cup.url = "ipfs://abcdefg1";
cup.side = content_update_operation::side_t::master;
cup.new_playing_reward = 500;
cup.new_publishers_share = 0;
pc.proposed_ops.emplace_back( cup );
pc.expiration_time = db.head_block_time() + fc::minutes(1);
trx.operations.push_back( pc );
Expand Down
28 changes: 27 additions & 1 deletion tests/tests/database_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <boost/test/unit_test.hpp>

#include <muse/chain/database.hpp>

#include <muse/chain/content_object.hpp>
#include <muse/chain/streaming_platform_objects.hpp>

#include <fc/crypto/digest.hpp>
Expand Down Expand Up @@ -62,6 +62,32 @@ BOOST_AUTO_TEST_CASE( undo_test )
}
}

/**
* Check that database modify() functors that throw do not get caught by boost, which will remove the object
*/
BOOST_AUTO_TEST_CASE(failed_modify_test)
{ try {
database db;
// Create dummy object
const auto& obj = db.create<content_object>([](content_object& obj) {
obj.manage_master = authority( 1, "test", 1 );
});
content_id_type obj_id = obj.id;
BOOST_CHECK_EQUAL( 1, obj.manage_master.weight_threshold );

// Modify dummy object, check that changes stick
db.modify(obj, [](content_object& obj) {
obj.manage_master = authority( 2, "tester", 2 );
});
BOOST_CHECK_EQUAL( 2, obj_id(db).manage_master.weight_threshold );

// Throw exception when modifying object, check that object still exists after
BOOST_CHECK_THROW(db.modify(obj, [](content_object& obj) {
throw 5;
}), int);
BOOST_CHECK_NE((long)db.find_object(obj_id), (long)nullptr);
} FC_LOG_AND_RETHROW() }

BOOST_AUTO_TEST_CASE( merge_test )
{
try {
Expand Down