提交 b13e483c 编写于 作者: D Daniel Larimer

Fix #3140 unconfirmed cache invariant enforcements and related bug fixes

上级 7601fd83
......@@ -73,7 +73,10 @@ struct controller_impl {
FC_ASSERT( prev, "attempt to pop beyond last irreversible block" );
if( const auto* b = unconfirmed_blocks.find<unconfirmed_block_object,by_num>(head->block_num) )
{
edump((b->blocknum));
unconfirmed_blocks.remove( *b );
}
for( const auto& t : head->trxs )
unapplied_transactions[t->signed_id] = t;
......@@ -94,7 +97,7 @@ struct controller_impl {
cfg.shared_memory_size ),
unconfirmed_blocks( cfg.block_log_dir/"unconfirmed",
cfg.read_only ? database::read_only : database::read_write,
std::min<uint64_t>(cfg.shared_memory_size,128*1024*1024ll) ), /// 1GB should store 1000 1MB blocks + overhead
cfg.unconfirmed_cache_size ),
blog( cfg.block_log_dir ),
fork_db( cfg.shared_memory_dir ),
wasmif( cfg.wasm_runtime ),
......@@ -202,19 +205,9 @@ struct controller_impl {
("db",db.revision())("head",head->block_num)("unconfimed",unconf_blocknum) );
edump((unconf_blocknum));
/*
FC_ASSERT( head->block_num == unconf_blocknum, "unconfirmed block database out of sync",
("db",db.revision())("head",head->block_num)("unconfimed",unconf_blocknum) );
*/
/**
* The undoable state contains state transitions from blocks
* in the fork database that could be reversed. Because this
* is a new startup and the fork database is empty, we must
* unwind that pending state. This state will be regenerated
* when we catch up to the head block later.
*/
//clear_all_undo();
}
~controller_impl() {
......@@ -400,20 +393,17 @@ struct controller_impl {
}
if( !replaying ) {
auto itr = unconfirmed_blocks.find<unconfirmed_block_object,by_num>(head->block_num );
if( !itr ) {
unconfirmed_blocks.create<unconfirmed_block_object>( [&]( auto& ubo ) {
ubo.blocknum = head->block_num;
ubo.set_block( head->block );
});
}
}
// ilog((fc::json::to_pretty_string(*pending->_pending_block_state->block)));
emit( self.accepted_block, pending->_pending_block_state );
pending->push();
if( !replaying ) {
unconfirmed_blocks.create<unconfirmed_block_object>( [&]( auto& ubo ) {
ubo.blocknum = pending->_pending_block_state->block_num;
ubo.set_block( pending->_pending_block_state->block );
});
}
pending.reset();
}
......
......@@ -15,6 +15,7 @@ typedef __uint128_t uint128_t;
const static auto default_block_log_dir = "block_log";
const static auto default_shared_memory_dir = "shared_mem";
const static auto default_shared_memory_size = 1*1024*1024*1024ll;
const static auto default_unconfirmed_cache_size = 320*1024*1024ll;/// 1MB * 340 blocks based on 21 producer BFT delay
const static uint64_t system_account_name = N(eosio);
const static uint64_t null_account_name = N(eosio.null);
......
......@@ -36,7 +36,8 @@ namespace eosio { namespace chain {
class controller {
public:
struct config {
path block_log_dir = chain::config::default_block_log_dir;
path block_log_dir = chain::config::default_block_log_dir;
uint64_t unconfirmed_cache_size = chain::config::default_unconfirmed_cache_size;;
path shared_memory_dir = chain::config::default_shared_memory_dir;
uint64_t shared_memory_size = chain::config::default_shared_memory_size;
bool read_only = false;
......@@ -200,6 +201,7 @@ namespace eosio { namespace chain {
FC_REFLECT( eosio::chain::controller::config,
(block_log_dir)
(unconfirmed_cache_size)
(shared_memory_dir)(shared_memory_size)(read_only)
(genesis)
(wasm_runtime)
......
......@@ -36,6 +36,7 @@ namespace eosio { namespace testing {
cfg.block_log_dir = tempdir.path() / "blocklog";
cfg.shared_memory_dir = tempdir.path() / "shared";
cfg.shared_memory_size = 1024*1024*8;
cfg.unconfirmed_cache_size = 1024*1024*8;
cfg.genesis.initial_timestamp = fc::time_point::from_iso_string("2020-01-01T00:00:00.000");
cfg.genesis.initial_key = get_public_key( config::system_account_name, "active" );
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册