Skip to content

Commit

Permalink
Merge branch 'develop' into merge-appbase
Browse files Browse the repository at this point in the history
  • Loading branch information
mvandeberg committed Feb 6, 2018
2 parents 621a35f + d565372 commit 631964c
Show file tree
Hide file tree
Showing 73 changed files with 2,299 additions and 484 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,10 @@ if(ENABLE_COVERAGE_TESTING)
SET(CMAKE_CXX_FLAGS "--coverage ${CMAKE_CXX_FLAGS}")
endif()

# fc/src/compress/miniz.c breaks strict aliasing. The Linux kernel builds with no strict aliasing
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing -Werror" )
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-strict-aliasing -Werror" )

# external_plugins needs to be compiled first because libraries/app depends on STEEM_EXTERNAL_PLUGINS being fully populated
add_subdirectory( external_plugins )
add_subdirectory( libraries )
Expand Down
4 changes: 2 additions & 2 deletions contrib/config-for-ahnode.ini
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ p2p-user-agent = Graphene Reference Implementation
# The local IP and port to listen for incoming websocket connections.
# webserver-ws-endpoint =

# Number of threads used to handle queries. Default: 256.
webserver-thread-pool-size = 1024
# Number of threads used to handle queries. Default: 32.
# webserver-thread-pool-size = 1024

# Enable block production, even if the chain is stale.
enable-stale-production = false
Expand Down
4 changes: 2 additions & 2 deletions contrib/config-for-broadcaster.ini
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ p2p-user-agent = Graphene Reference Implementation
# The local IP and port to listen for incoming websocket connections.
# webserver-ws-endpoint =

# Number of threads used to handle queries. Default: 256.
webserver-thread-pool-size = 1024
# Number of threads used to handle queries. Default: 32.
# webserver-thread-pool-size = 1024

# Enable block production, even if the chain is stale.
enable-stale-production = false
Expand Down
4 changes: 2 additions & 2 deletions contrib/config-for-docker.ini
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ p2p-user-agent = Graphene Reference Implementation
# The local IP and port to listen for incoming websocket connections.
# webserver-ws-endpoint =

# Number of threads used to handle queries. Default: 256.
webserver-thread-pool-size = 1024
# Number of threads used to handle queries. Default: 32.
# webserver-thread-pool-size = 1024

# Enable block production, even if the chain is stale.
enable-stale-production = false
Expand Down
4 changes: 2 additions & 2 deletions contrib/fullnode.config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ p2p-user-agent = Graphene Reference Implementation
# The local IP and port to listen for incoming websocket connections.
# webserver-ws-endpoint =

# Number of threads used to handle queries. Default: 256.
webserver-thread-pool-size = 1024
# Number of threads used to handle queries. Default: 32.
# webserver-thread-pool-size = 1024

# Enable block production, even if the chain is stale.
enable-stale-production = false
Expand Down
4 changes: 2 additions & 2 deletions contrib/fullnode.opswhitelist.config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ p2p-user-agent = Graphene Reference Implementation
# The local IP and port to listen for incoming websocket connections.
# webserver-ws-endpoint =

# Number of threads used to handle queries. Default: 256.
webserver-thread-pool-size = 1024
# Number of threads used to handle queries. Default: 32.
# webserver-thread-pool-size = 1024

# Enable block production, even if the chain is stale.
enable-stale-production = false
Expand Down
9 changes: 2 additions & 7 deletions contrib/startpaassteemd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,6 @@ if [[ ! "$DISABLE_BLOCK_API" ]]; then
ARGS+=" --plugin=block_api"
fi

if [[ ! "$IS_BROADCAST_NODE" ]]; then
ARGS+=" --follow-start-feeds=$STEEMD_FEED_START_TIME"
ARGS+=" --disable-get-block"
fi

# overwrite local config with image one
if [[ "$IS_BROADCAST_NODE" ]]; then
cp /etc/steemd/config-for-broadcaster.ini $HOME/config.ini
Expand Down Expand Up @@ -90,7 +85,7 @@ if [[ "$USE_RAMDISK" ]]; then
elif [[ "$IS_AH_NODE" ]]; then
s3cmd get s3://$S3_BUCKET/ahnode-$VERSION-latest.tar.bz2 - | pbzip2 -m2000dc | tar x --wildcards 'blockchain/block*' -C /mnt/ramdisk 'blockchain/shared*'
else
s3cmd get s3://$S3_BUCKET/blockchain-$VERSION-latest.tar.bz2 - | lbzip2 -dc | tar x --wildcards 'blockchain/block*' -C /mnt/ramdisk 'blockchain/shared*'
s3cmd get s3://$S3_BUCKET/blockchain-$VERSION-latest.tar.bz2 - | pbzip2 -m2000dc | tar x --wildcards 'blockchain/block*' -C /mnt/ramdisk 'blockchain/shared*'
fi
chown -R steemd:steemd /mnt/ramdisk/blockchain
else
Expand All @@ -99,7 +94,7 @@ else
elif [[ "$IS_AH_NODE" ]]; then
s3cmd get s3://$S3_BUCKET/ahnode-$VERSION-latest.tar.bz2 - | pbzip2 -m2000dc | tar x
else
s3cmd get s3://$S3_BUCKET/blockchain-$VERSION-latest.tar.bz2 - | lbzip2 -dc | tar x
s3cmd get s3://$S3_BUCKET/blockchain-$VERSION-latest.tar.bz2 - | pbzip2 -m2000dc | tar x
fi
fi
if [[ $? -ne 0 ]]; then
Expand Down
27 changes: 14 additions & 13 deletions libraries/chain/database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,13 @@ void database::open( const open_args& args )
{
init_hardforks(); // Writes to local state, but reads from db
});

if (args.benchmark.first)
{
args.benchmark.second(0, get_abstract_index_cntr());
auto last_block_num = _block_log.head()->block_num();
args.benchmark.second(last_block_num, get_abstract_index_cntr());
}
}
FC_CAPTURE_LOG_AND_RETHROW( (args.data_dir)(args.shared_mem_dir)(args.shared_file_size) )
}
Expand Down Expand Up @@ -180,7 +187,7 @@ uint32_t database::reindex( const open_args& args )
last_block_num = args.stop_replay_at;
if( args.benchmark.first > 0 )
{
args.benchmark.second( 0, true /*is_initial_call*/ );
args.benchmark.second( 0, get_abstract_index_cntr() );
}

while( itr.first.block_num() != last_block_num )
Expand All @@ -190,22 +197,16 @@ uint32_t database::reindex( const open_args& args )
std::cerr << " " << double( cur_block_num * 100 ) / last_block_num << "% " << cur_block_num << " of " << last_block_num <<
" (" << (get_free_memory() / (1024*1024)) << "M free)\n";
apply_block( itr.first, skip_flags );
if( (args.benchmark.first > 0)
&& (cur_block_num % args.benchmark.first == 0) )
{
args.benchmark.second( cur_block_num, false /*is_initial_call*/ );
}
if( (args.benchmark.first > 0) && (cur_block_num % args.benchmark.first == 0) )
args.benchmark.second( cur_block_num, get_abstract_index_cntr() );
itr = _block_log.read_block( itr.second );
}

apply_block( itr.first, skip_flags );
last_block_number = itr.first.block_num();

if( (args.benchmark.first > 0)
&& (last_block_number % args.benchmark.first == 0) )
{
args.benchmark.second( last_block_number, false /*is_initial_call*/ );
}
if( (args.benchmark.first > 0) && (last_block_number % args.benchmark.first == 0) )
args.benchmark.second( last_block_number, get_abstract_index_cntr() );
set_revision( head_block_num() );
_block_log.set_locking( true );
});
Expand Down Expand Up @@ -4381,7 +4382,7 @@ void database::validate_smt_invariants()const
const smt_token_object& smt = *itr;
auto totalIt = theMap.find( smt.symbol );
asset total_supply = totalIt == theMap.end() ? asset(0, smt.symbol) : totalIt->second;
FC_ASSERT( asset(smt.current_supply, smt.symbol) == total_supply, "", ("smt.current_supply",smt.current_supply)("total_supply",total_supply) );
FC_ASSERT( asset(smt.current_supply, smt.symbol) == total_supply, "", ("smt current_supply",smt.current_supply)("total_supply",total_supply) );
}
}
FC_CAPTURE_LOG_AND_RETHROW( (head_block_num()) );
Expand Down Expand Up @@ -4559,7 +4560,7 @@ vector< asset_symbol_type > database::get_smt_next_identifier()
new_symbol.validate();
FC_ASSERT( new_symbol.space() == asset_symbol_type::smt_nai_space );

return std::move( vector< asset_symbol_type >( 1, new_symbol ) );
return vector< asset_symbol_type >( 1, new_symbol );
}
#endif

Expand Down
61 changes: 60 additions & 1 deletion libraries/chain/include/steem/chain/comment_object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ namespace steem { namespace chain {
bool allow_votes = true; /// allows a post to receive votes;
bool allow_curation_rewards = true;

bip::vector< beneficiary_route_type, allocator< beneficiary_route_type > > beneficiaries;
typedef bip::vector< beneficiary_route_type, allocator< beneficiary_route_type > > t_beneficiaries;
t_beneficiaries beneficiaries;
};

class comment_content_object : public object< comment_content_object_type, comment_content_object >
Expand Down Expand Up @@ -284,3 +285,61 @@ FC_REFLECT( steem::chain::comment_vote_object,
(id)(voter)(comment)(weight)(rshares)(vote_percent)(last_update)(num_changes)
)
CHAINBASE_SET_INDEX_TYPE( steem::chain::comment_vote_object, steem::chain::comment_vote_index )

namespace helpers
{
using steem::chain::shared_string;

template <>
class index_statistic_provider<steem::chain::comment_index>
{
public:
typedef steem::chain::comment_index IndexType;
typedef typename steem::chain::comment_object::t_beneficiaries t_beneficiaries;

index_statistic_info gather_statistics(const IndexType& index, bool onlyStaticInfo) const
{
index_statistic_info info;
gather_index_static_data(index, &info);

if(onlyStaticInfo == false)
{
for(const auto& o : index)
{
info._item_additional_allocation += o.category.capacity()*sizeof(shared_string::value_type);
info._item_additional_allocation += o.parent_permlink.capacity()*sizeof(shared_string::value_type);
info._item_additional_allocation += o.permlink.capacity()*sizeof(shared_string::value_type);
info._item_additional_allocation += o.beneficiaries.capacity()*sizeof(t_beneficiaries::value_type);
}
}

return info;
}
};

template <>
class index_statistic_provider<steem::chain::comment_content_index>
{
public:
typedef steem::chain::comment_content_index IndexType;

index_statistic_info gather_statistics(const IndexType& index, bool onlyStaticInfo) const
{
index_statistic_info info;
gather_index_static_data(index, &info);

if(onlyStaticInfo == false)
{
for(const auto& o : index)
{
info._item_additional_allocation += o.title.capacity()*sizeof(shared_string::value_type);
info._item_additional_allocation += o.body.capacity()*sizeof(shared_string::value_type);
info._item_additional_allocation += o.json_metadata.capacity()*sizeof(shared_string::value_type);
}
}

return info;
}
};

} /// namespace helpers
8 changes: 4 additions & 4 deletions libraries/chain/include/steem/chain/database.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ namespace steem { namespace chain {
skip_block_log = 1 << 13 ///< used to skip block logging on reindex
};

typedef std::function<void(uint32_t current_block_number, bool is_initial_call)> TBenchmarkMidReport;
typedef std::function<void(uint32_t, const abstract_index_cntr_t&)> TBenchmarkMidReport;
typedef std::pair<uint32_t, TBenchmarkMidReport> TBenchmark;

struct open_args
Expand All @@ -84,7 +84,7 @@ namespace steem { namespace chain {

// The following fields are only used on reindexing
uint32_t stop_replay_at = 0;
TBenchmark benchmark = TBenchmark(0, [](uint32_t,bool){;});
TBenchmark benchmark = TBenchmark(0, []( uint32_t, const abstract_index_cntr_t& ){});
};

/**
Expand Down Expand Up @@ -445,7 +445,7 @@ namespace steem { namespace chain {
vector< asset_symbol_type > get_smt_next_identifier();

///@}
#endif
#endif

protected:
//Mark pop_undo() as protected -- we do not want outside calling pop_undo(); it should call pop_block() instead
Expand Down Expand Up @@ -517,7 +517,7 @@ namespace steem { namespace chain {
uint32_t _next_flush_block = 0;

uint32_t _last_free_gb_printed = 0;
uint32_t _next_available_nai = 1;
uint32_t _next_available_nai = 4;

flat_map< std::string, std::shared_ptr< custom_operation_interpreter > > _custom_operation_interpreters;
std::string _json_schema;
Expand Down
49 changes: 49 additions & 0 deletions libraries/chain/include/steem/chain/history_object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,52 @@ CHAINBASE_SET_INDEX_TYPE( steem::chain::operation_object, steem::chain::operatio

FC_REFLECT( steem::chain::account_history_object, (id)(account)(sequence)(op) )
CHAINBASE_SET_INDEX_TYPE( steem::chain::account_history_object, steem::chain::account_history_index )

namespace helpers
{
template <>
class index_statistic_provider<steem::chain::operation_index>
{
public:
typedef steem::chain::operation_index IndexType;

index_statistic_info gather_statistics(const IndexType& index, bool onlyStaticInfo) const
{
index_statistic_info info;
gather_index_static_data(index, &info);

if(onlyStaticInfo == false)
{
for(const auto& o : index)
info._item_additional_allocation +=
o.serialized_op.capacity()*sizeof(steem::chain::buffer_type::value_type);
}

return info;
}
};

template <>
class index_statistic_provider<steem::chain::account_history_index>
{
public:
typedef steem::chain::account_history_index IndexType;

index_statistic_info gather_statistics(const IndexType& index, bool onlyStaticInfo) const
{
index_statistic_info info;
gather_index_static_data(index, &info);

if(onlyStaticInfo == false)
{
//for(const auto& o : index)
// info._item_additional_allocation += o.get_ops().capacity()*
// sizeof(steem::chain::account_history_object::operation_container::value_type);
}

return info;
}
};

} /// namespace helpers

Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ class smt_token_object : public object< smt_token_object_type, smt_token_object
setup_completed,
};

struct smt_market_maker_state
{
asset steem_balance;
asset token_balance;
uint32_t reserve_ratio = 0;
};

public:
template< typename Constructor, typename Allocator >
smt_token_object( Constructor&& c, allocator< Allocator > a )
Expand All @@ -37,7 +44,8 @@ class smt_token_object : public object< smt_token_object_type, smt_token_object
account_name_type control_account;
smt_phase phase = smt_phase::account_elevated;

share_type current_supply = 0;
share_type current_supply = 0;
smt_market_maker_state market_maker;

/// set_setup_parameters
bool allow_voting = false;
Expand Down Expand Up @@ -97,11 +105,19 @@ FC_REFLECT_ENUM( steem::chain::smt_token_object::smt_phase,
(setup_completed)
)

FC_REFLECT( steem::chain::smt_token_object::smt_market_maker_state,
(steem_balance)
(token_balance)
(reserve_ratio)
)

FC_REFLECT( steem::chain::smt_token_object,
(id)
(symbol)
(control_account)
(phase)
(current_supply)
(market_maker)
(allow_voting)
(allow_vesting)
(schedule_time)
Expand Down
Loading

0 comments on commit 631964c

Please sign in to comment.