Compare commits
5 commits
master
...
issue317-t
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
307bd4e3ee | ||
|
|
746d4a345b | ||
|
|
7cbd9139d7 | ||
|
|
948624df2a | ||
|
|
aa988d3fdc |
18 changed files with 108 additions and 33 deletions
|
|
@ -9,6 +9,9 @@ set( GUI_CLIENT_EXECUTABLE_NAME Peerplays )
|
|||
set( CUSTOM_URL_SCHEME "gcs" )
|
||||
set( INSTALLER_APP_ID "68ad7005-8eee-49c9-95ce-9eed97e5b347" )
|
||||
|
||||
#add_compile_options(-fsanitize=address -fsanitize-recover=address)
|
||||
#add_link_options(-fsanitize=address -fsanitize-recover=address -static-libasan)
|
||||
|
||||
# http://stackoverflow.com/a/18369825
|
||||
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8)
|
||||
|
|
@ -56,6 +59,8 @@ if (BUILD_PEERPLAYS_TESTNET)
|
|||
set(GRAPHENE_EGENESIS_JSON "${CMAKE_CURRENT_SOURCE_DIR}/genesis-testnet.json" CACHE PATH "location of the genesis.json to embed in the executable" )
|
||||
#add_compile_definitions(BUILD_PEERPLAYS_TESTNET=1)
|
||||
add_definitions(-DBUILD_PEERPLAYS_TESTNET=1)
|
||||
add_definitions(-DBOOST_MULTI_INDEX_ENABLE_INVARIANT_CHECKING=1)
|
||||
add_definitions(-DBOOST_MULTI_INDEX_ENABLE_SAFE_MODE=1)
|
||||
message ("\n====================\nBuilding for Testnet\n====================\n")
|
||||
else (BUILD_PEERPLAYS_TESTNET)
|
||||
set(GRAPHENE_EGENESIS_JSON "${CMAKE_CURRENT_SOURCE_DIR}/genesis-mainnet.json" CACHE PATH "location of the genesis.json to embed in the executable" )
|
||||
|
|
|
|||
|
|
@ -853,9 +853,10 @@ application::~application() {
|
|||
my->_p2p_network->close();
|
||||
my->_p2p_network.reset();
|
||||
}
|
||||
if (my->_chain_db) {
|
||||
my->_chain_db->close();
|
||||
}
|
||||
//if (my->_chain_db) {
|
||||
// my->_chain_db->close();
|
||||
// my->_chain_db.reset();
|
||||
//}
|
||||
}
|
||||
|
||||
void application::set_program_options(boost::program_options::options_description &cli,
|
||||
|
|
@ -1008,10 +1009,11 @@ void application::shutdown_plugins() {
|
|||
return;
|
||||
}
|
||||
void application::shutdown() {
|
||||
if (my->_p2p_network)
|
||||
my->_p2p_network->close();
|
||||
if (my->_chain_db)
|
||||
//if (my->_p2p_network)
|
||||
// my->_p2p_network->close();
|
||||
if (my->_chain_db){
|
||||
my->_chain_db->close();
|
||||
}
|
||||
}
|
||||
|
||||
void application::initialize_plugins(const boost::program_options::variables_map &options) {
|
||||
|
|
|
|||
|
|
@ -287,6 +287,8 @@ void_result account_update_evaluator::do_apply( const account_update_operation&
|
|||
{ try {
|
||||
database& d = db();
|
||||
|
||||
d.debug_dump();
|
||||
|
||||
bool sa_before = acnt->has_special_authority();
|
||||
|
||||
// update account statistics
|
||||
|
|
|
|||
|
|
@ -585,14 +585,16 @@ signed_block database::_generate_block(
|
|||
* Removes the most recent block from the database and
|
||||
* undoes any changes it made.
|
||||
*/
|
||||
void database::pop_block()
|
||||
void database::pop_block(bool check)
|
||||
{ try {
|
||||
_pending_tx_session.reset();
|
||||
auto head_id = head_block_id();
|
||||
optional<signed_block> head_block = fetch_block_by_id( head_id );
|
||||
GRAPHENE_ASSERT( head_block.valid(), pop_empty_chain, "there are no blocks to pop" );
|
||||
|
||||
_fork_db.pop_block();
|
||||
ilog( "head_block is ${dump}", ("dump", head_block) );
|
||||
|
||||
_fork_db.pop_block(check);
|
||||
pop_undo();
|
||||
|
||||
_popped_tx.insert( _popped_tx.begin(), head_block->transactions.begin(), head_block->transactions.end() );
|
||||
|
|
|
|||
|
|
@ -50,12 +50,12 @@ void database::debug_dump()
|
|||
|
||||
for( const account_balance_object& a : balance_index )
|
||||
{
|
||||
// idump(("balance")(a));
|
||||
idump(("balance")(a));
|
||||
total_balances[a.asset_type] += a.balance;
|
||||
}
|
||||
for( const account_statistics_object& s : statistics_index )
|
||||
{
|
||||
// idump(("statistics")(s));
|
||||
idump(("statistics")(s));
|
||||
reported_core_in_orders += s.total_core_in_orders;
|
||||
}
|
||||
for( const limit_order_object& o : db.get_index_type<limit_order_index>().indices() )
|
||||
|
|
@ -86,13 +86,11 @@ void database::debug_dump()
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
const auto& vbidx = db.get_index_type<simple_index<vesting_balance_object>>();
|
||||
for( const auto& s : vbidx )
|
||||
{
|
||||
// idump(("vesting_balance")(s));
|
||||
idump(("vesting_balance")(s));
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void debug_apply_update( database& db, const fc::variant_object& vo )
|
||||
|
|
|
|||
|
|
@ -332,7 +332,7 @@ void database::initialize_evaluators()
|
|||
void database::initialize_indexes()
|
||||
{
|
||||
reset_indexes();
|
||||
_undo_db.set_max_size( GRAPHENE_MIN_UNDO_HISTORY );
|
||||
_undo_db.set_max_size( 100 /*GRAPHENE_MIN_UNDO_HISTORY*/ );
|
||||
|
||||
//Protocol object indexes
|
||||
add_index< primary_index<asset_index, 13> >(); // 8192 assets per chunk
|
||||
|
|
|
|||
|
|
@ -259,11 +259,12 @@ void database::close(bool rewind)
|
|||
try
|
||||
{
|
||||
uint32_t cutoff = get_dynamic_global_properties().last_irreversible_block_num;
|
||||
|
||||
//ilog("cutoff = ${c}", ("c", cutoff));
|
||||
while( head_block_num() > cutoff )
|
||||
{
|
||||
//ilog("head_block_num() = ${id}", ("id", head_block_num()));
|
||||
block_id_type popped_block_id = head_block_id();
|
||||
pop_block();
|
||||
pop_block( head_block_num() == cutoff + 1 ? false : true);
|
||||
_fork_db.remove(popped_block_id); // doesn't throw on missing
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,6 +89,9 @@ void database::update_global_dynamic_data( const signed_block& b, const uint32_t
|
|||
("recently_missed",_dgp.recently_missed_count)("max_undo",GRAPHENE_MAX_UNDO_HISTORY) );
|
||||
}
|
||||
|
||||
ilog( "_dgp.head_block_number is ${head}", ("head", _dgp.head_block_number) );
|
||||
ilog( "_dgp.last_irreversible_block_num is ${lib}", ("lib", _dgp.last_irreversible_block_num) );
|
||||
|
||||
_undo_db.set_max_size( _dgp.head_block_number - _dgp.last_irreversible_block_num + 1 );
|
||||
_fork_db.set_max_size( _dgp.head_block_number - _dgp.last_irreversible_block_num + 1 );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,11 +35,13 @@ void fork_database::reset()
|
|||
_index.clear();
|
||||
}
|
||||
|
||||
void fork_database::pop_block()
|
||||
void fork_database::pop_block(bool check)
|
||||
{
|
||||
FC_ASSERT( _head, "no blocks to pop" );
|
||||
auto prev = _head->prev.lock();
|
||||
if (check){
|
||||
FC_ASSERT( prev, "poping block would leave head block null" );
|
||||
}
|
||||
_head = prev;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ namespace graphene { namespace chain {
|
|||
const fc::ecc::private_key& block_signing_private_key
|
||||
);
|
||||
|
||||
void pop_block();
|
||||
void pop_block(bool check = true);
|
||||
void clear_pending();
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ namespace graphene { namespace chain {
|
|||
*/
|
||||
shared_ptr<fork_item> push_block(const signed_block& b);
|
||||
shared_ptr<fork_item> head()const { return _head; }
|
||||
void pop_block();
|
||||
void pop_block(bool check);
|
||||
|
||||
/**
|
||||
* Given two head blocks, return two branches of the fork graph that
|
||||
|
|
|
|||
|
|
@ -34,9 +34,6 @@ namespace graphene { namespace chain {
|
|||
>,
|
||||
ordered_unique< tag<by_valid_from>,
|
||||
member<son_wallet_object, time_point_sec, &son_wallet_object::valid_from>
|
||||
>,
|
||||
ordered_unique< tag<by_expires>,
|
||||
member<son_wallet_object, time_point_sec, &son_wallet_object::expires>
|
||||
>
|
||||
>
|
||||
>;
|
||||
|
|
|
|||
|
|
@ -110,6 +110,7 @@ namespace graphene { namespace db {
|
|||
const object& get( object_id_type id )const
|
||||
{
|
||||
auto maybe_found = find( id );
|
||||
ilog("get ID is ${id}", ("id", id));
|
||||
FC_ASSERT( maybe_found != nullptr, "Unable to find Object", ("id",id) );
|
||||
return *maybe_found;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,9 @@
|
|||
#include <graphene/db/object.hpp>
|
||||
#include <deque>
|
||||
#include <fc/exception/exception.hpp>
|
||||
#include <fc/thread/spin_yield_lock.hpp>
|
||||
#include <fc/fwd.hpp>
|
||||
#include <fc/thread/unique_lock.hpp>
|
||||
|
||||
namespace graphene { namespace db {
|
||||
|
||||
|
|
@ -132,6 +135,8 @@ namespace graphene { namespace db {
|
|||
std::deque<undo_state> _stack;
|
||||
object_database& _db;
|
||||
size_t _max_size = 256;
|
||||
|
||||
mutable fc::spin_yield_lock _spin_yield;
|
||||
};
|
||||
|
||||
} } // graphene::db
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@
|
|||
#include <graphene/db/undo_database.hpp>
|
||||
#include <fc/reflect/variant.hpp>
|
||||
|
||||
#include <fc/thread/spin_yield_lock.hpp>
|
||||
|
||||
namespace graphene { namespace db {
|
||||
|
||||
void undo_database::enable() { _disabled = false; }
|
||||
|
|
@ -44,6 +46,8 @@ undo_database::session::~session() {
|
|||
|
||||
undo_database::session undo_database::start_undo_session( bool force_enable )
|
||||
{
|
||||
synchronized(_spin_yield)
|
||||
|
||||
if( _disabled && !force_enable ) return session(*this);
|
||||
bool disable_on_exit = _disabled && force_enable;
|
||||
if( force_enable )
|
||||
|
|
@ -54,10 +58,15 @@ undo_database::session undo_database::start_undo_session( bool force_enable )
|
|||
|
||||
_stack.emplace_back();
|
||||
++_active_sessions;
|
||||
|
||||
ilog( "active_sessions = ${a}", ("a", _active_sessions));
|
||||
|
||||
return session(*this, disable_on_exit );
|
||||
}
|
||||
void undo_database::on_create( const object& obj )
|
||||
{
|
||||
synchronized(_spin_yield)
|
||||
|
||||
if( _disabled ) return;
|
||||
|
||||
if( _stack.empty() )
|
||||
|
|
@ -68,24 +77,39 @@ void undo_database::on_create( const object& obj )
|
|||
if( itr == state.old_index_next_ids.end() )
|
||||
state.old_index_next_ids[index_id] = obj.id;
|
||||
state.new_ids.insert(obj.id);
|
||||
|
||||
ilog("obj.id = ${id}", ("id", obj.id));
|
||||
}
|
||||
void undo_database::on_modify( const object& obj )
|
||||
{
|
||||
if( _disabled ) return;
|
||||
|
||||
synchronized(_spin_yield)
|
||||
|
||||
if( _stack.empty() )
|
||||
_stack.emplace_back();
|
||||
auto& state = _stack.back();
|
||||
if( state.new_ids.find(obj.id) != state.new_ids.end() )
|
||||
if( state.new_ids.find(obj.id) != state.new_ids.end() ){
|
||||
ilog("can not modify new_ids obj.id = ${id}", ("id", obj.id));
|
||||
return;
|
||||
}
|
||||
auto itr = state.old_values.find(obj.id);
|
||||
if( itr != state.old_values.end() ) return;
|
||||
if( itr != state.old_values.end() ){
|
||||
ilog("can not modify old_values obj.id = ${id}", ("id", obj.id));
|
||||
return;
|
||||
}
|
||||
state.old_values[obj.id] = obj.clone();
|
||||
|
||||
ilog("obj.id = ${id}", ("id", obj.id));
|
||||
}
|
||||
void undo_database::on_remove( const object& obj )
|
||||
{
|
||||
if( _disabled ) return;
|
||||
|
||||
synchronized(_spin_yield)
|
||||
|
||||
ilog("obj.id = ${id}", ("id", obj.id));
|
||||
|
||||
if( _stack.empty() )
|
||||
_stack.emplace_back();
|
||||
undo_state& state = _stack.back();
|
||||
|
|
@ -105,7 +129,11 @@ void undo_database::on_remove( const object& obj )
|
|||
}
|
||||
|
||||
void undo_database::undo()
|
||||
{ try {
|
||||
{
|
||||
synchronized(_spin_yield)
|
||||
try {
|
||||
ilog("undo");
|
||||
|
||||
FC_ASSERT( !_disabled );
|
||||
FC_ASSERT( _active_sessions > 0 );
|
||||
disable();
|
||||
|
|
@ -136,6 +164,10 @@ void undo_database::undo()
|
|||
|
||||
void undo_database::merge()
|
||||
{
|
||||
synchronized(_spin_yield)
|
||||
|
||||
ilog("merge");
|
||||
|
||||
FC_ASSERT( _active_sessions > 0 );
|
||||
if( _active_sessions == 1 && _stack.size() == 1 )
|
||||
{
|
||||
|
|
@ -256,12 +288,20 @@ void undo_database::merge()
|
|||
}
|
||||
void undo_database::commit()
|
||||
{
|
||||
synchronized(_spin_yield)
|
||||
|
||||
ilog("commit");
|
||||
|
||||
FC_ASSERT( _active_sessions > 0 );
|
||||
--_active_sessions;
|
||||
}
|
||||
|
||||
void undo_database::pop_commit()
|
||||
{
|
||||
synchronized(_spin_yield)
|
||||
|
||||
ilog("pop_commit");
|
||||
|
||||
FC_ASSERT( _active_sessions == 0 );
|
||||
FC_ASSERT( !_stack.empty() );
|
||||
|
||||
|
|
@ -271,23 +311,30 @@ void undo_database::pop_commit()
|
|||
|
||||
for( auto& item : state.old_values )
|
||||
{
|
||||
ilog("item modify = ${id}", ("id", item.second->id));
|
||||
_db.modify( _db.get_object( item.second->id ), [&]( object& obj ){ obj.move_from( *item.second ); } );
|
||||
}
|
||||
|
||||
for( auto ritr = state.new_ids.begin(); ritr != state.new_ids.end(); ++ritr )
|
||||
{
|
||||
ilog("item remove = ${id}", ("id", *ritr));
|
||||
_db.remove( _db.get_object(*ritr) );
|
||||
}
|
||||
|
||||
for( auto& item : state.old_index_next_ids )
|
||||
{
|
||||
ilog("item set_next_id = ${id}", ("id", item.second));
|
||||
_db.get_mutable_index( item.first.space(), item.first.type() ).set_next_id( item.second );
|
||||
}
|
||||
|
||||
for( auto& item : state.removed )
|
||||
for( auto& item : state.removed ){
|
||||
ilog("item insert = ${id}", ("id", item));
|
||||
_db.insert( std::move(*item.second) );
|
||||
}
|
||||
|
||||
ilog("_stack.pop_back...");
|
||||
_stack.pop_back();
|
||||
ilog("_stack.pop_back done");
|
||||
}
|
||||
catch ( const fc::exception& e )
|
||||
{
|
||||
|
|
@ -299,6 +346,10 @@ void undo_database::pop_commit()
|
|||
}
|
||||
const undo_state& undo_database::head()const
|
||||
{
|
||||
synchronized(_spin_yield)
|
||||
|
||||
ilog("head()");
|
||||
|
||||
FC_ASSERT( !_stack.empty() );
|
||||
return _stack.back();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 6171e973c7fcfc9e0a39eaee2f05da84416a90e6
|
||||
Subproject commit 711b04fb4f21bcaf8fdf00f51f4d6410849bec92
|
||||
|
|
@ -114,16 +114,16 @@ namespace graphene { namespace net {
|
|||
|
||||
void peer_database_impl::close()
|
||||
{
|
||||
std::vector<potential_peer_record> peer_records;
|
||||
peer_records.reserve(_potential_peer_set.size());
|
||||
std::copy(_potential_peer_set.begin(), _potential_peer_set.end(), std::back_inserter(peer_records));
|
||||
//std::vector<potential_peer_record> peer_records;
|
||||
//peer_records.reserve(_potential_peer_set.size());
|
||||
//std::copy(_potential_peer_set.begin(), _potential_peer_set.end(), std::back_inserter(peer_records));
|
||||
|
||||
try
|
||||
{
|
||||
fc::path peer_database_filename_dir = _peer_database_filename.parent_path();
|
||||
if (!fc::exists(peer_database_filename_dir))
|
||||
fc::create_directories(peer_database_filename_dir);
|
||||
fc::json::save_to_file( peer_records, _peer_database_filename, GRAPHENE_NET_MAX_NESTED_OBJECTS );
|
||||
fc::json::save_to_file( /*peer_records*/ _potential_peer_set, _peer_database_filename, GRAPHENE_NET_MAX_NESTED_OBJECTS );
|
||||
}
|
||||
catch (const fc::exception& e)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -664,11 +664,15 @@ BOOST_FIXTURE_TEST_CASE( cli_list_active_sons, cli_fixture )
|
|||
}
|
||||
BOOST_CHECK(generate_maintenance_block());
|
||||
|
||||
//con.wallet_api_ptr->debug_dump();
|
||||
|
||||
BOOST_TEST_MESSAGE("Voting for SONs");
|
||||
|
||||
for(unsigned int i = 1; i < son_number + 1; i++)
|
||||
{
|
||||
std::string name = "sonaccount" + fc::to_pretty_string(i);
|
||||
vote_tx = con.wallet_api_ptr->vote_for_son(name, name, true, true);
|
||||
ilog("vote_tx is ${vote_tx}", ("vote_tx", vote_tx));
|
||||
}
|
||||
BOOST_CHECK(generate_maintenance_block());
|
||||
|
||||
|
|
@ -677,6 +681,7 @@ BOOST_FIXTURE_TEST_CASE( cli_list_active_sons, cli_fixture )
|
|||
std::string name1 = "sonaccount" + fc::to_pretty_string(i);
|
||||
std::string name2 = "sonaccount" + fc::to_pretty_string(i + 1);
|
||||
vote_tx = con.wallet_api_ptr->vote_for_son(name1, name2, true, true);
|
||||
ilog("2nd_vote_tx is ${vote_tx}", ("vote_tx", vote_tx));
|
||||
}
|
||||
BOOST_CHECK(generate_maintenance_block());
|
||||
gpo = con.wallet_api_ptr->get_global_properties();
|
||||
|
|
@ -693,6 +698,7 @@ BOOST_FIXTURE_TEST_CASE( cli_list_active_sons, cli_fixture )
|
|||
}
|
||||
|
||||
BOOST_CHECK_NO_THROW(con.wallet_api_ptr->list_active_sons());
|
||||
|
||||
} catch( fc::exception& e ) {
|
||||
BOOST_TEST_MESSAGE("SON cli wallet tests exception");
|
||||
edump((e.to_detail_string()));
|
||||
|
|
|
|||
Loading…
Reference in a new issue