Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Merge pull request #7147 from EOSIO/forced-replay
Browse files Browse the repository at this point in the history
Block header state, fork database, chainbase, and transaction trace refactors; protocol feature foundations; initial set of new protocol features
  • Loading branch information
arhag authored Apr 24, 2019
2 parents 793c6a6 + 3ed95b4 commit eb2f686
Show file tree
Hide file tree
Showing 128 changed files with 11,197 additions and 1,949 deletions.
1 change: 1 addition & 0 deletions .pipelinebranch
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use-protocol-features-sync-nodes
9 changes: 7 additions & 2 deletions libraries/chain/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,16 @@ add_library( eosio_chain
webassembly/wabt.cpp

# get_config.cpp
# global_property_object.cpp
#
# contracts/chain_initializer.cpp


trace.cpp
transaction_metadata.cpp
protocol_state_object.cpp
protocol_feature_activation.cpp
protocol_feature_manager.cpp
genesis_intrinsics.cpp
whitelisted_intrinsics.cpp
thread_utils.cpp
${HEADERS}
)
Expand Down
334 changes: 240 additions & 94 deletions libraries/chain/apply_context.cpp

Large diffs are not rendered by default.

24 changes: 14 additions & 10 deletions libraries/chain/authorization_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,16 +331,20 @@ namespace eosio { namespace chain {
EOS_ASSERT( auth.actor == link.account, irrelevant_auth_exception,
"the owner of the linked permission needs to be the actor of the declared authorization" );

EOS_ASSERT( link.type != updateauth::get_name(), action_validate_exception,
"Cannot link eosio::updateauth to a minimum permission" );
EOS_ASSERT( link.type != deleteauth::get_name(), action_validate_exception,
"Cannot link eosio::deleteauth to a minimum permission" );
EOS_ASSERT( link.type != linkauth::get_name(), action_validate_exception,
"Cannot link eosio::linkauth to a minimum permission" );
EOS_ASSERT( link.type != unlinkauth::get_name(), action_validate_exception,
"Cannot link eosio::unlinkauth to a minimum permission" );
EOS_ASSERT( link.type != canceldelay::get_name(), action_validate_exception,
"Cannot link eosio::canceldelay to a minimum permission" );
if( link.code == config::system_account_name
|| !_control.is_builtin_activated( builtin_protocol_feature_t::fix_linkauth_restriction ) )
{
EOS_ASSERT( link.type != updateauth::get_name(), action_validate_exception,
"Cannot link eosio::updateauth to a minimum permission" );
EOS_ASSERT( link.type != deleteauth::get_name(), action_validate_exception,
"Cannot link eosio::deleteauth to a minimum permission" );
EOS_ASSERT( link.type != linkauth::get_name(), action_validate_exception,
"Cannot link eosio::linkauth to a minimum permission" );
EOS_ASSERT( link.type != unlinkauth::get_name(), action_validate_exception,
"Cannot link eosio::unlinkauth to a minimum permission" );
EOS_ASSERT( link.type != canceldelay::get_name(), action_validate_exception,
"Cannot link eosio::canceldelay to a minimum permission" );
}

const auto linked_permission_name = lookup_minimum_permission(link.account, link.code, link.type);

Expand Down
39 changes: 39 additions & 0 deletions libraries/chain/block_header.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,44 @@ namespace eosio { namespace chain {
return result;
}

vector<block_header_extensions> block_header::validate_and_extract_header_extensions()const {
using block_header_extensions_t = block_header_extension_types::block_header_extensions_t;
using decompose_t = block_header_extension_types::decompose_t;

static_assert( std::is_same<block_header_extensions_t, block_header_extensions>::value,
"block_header_extensions is not setup as expected" );

vector<block_header_extensions_t> results;

uint16_t id_type_lower_bound = 0;

for( size_t i = 0; i < header_extensions.size(); ++i ) {
const auto& e = header_extensions[i];
auto id = e.first;

EOS_ASSERT( id >= id_type_lower_bound, invalid_block_header_extension,
"Block header extensions are not in the correct order (ascending id types required)"
);

results.emplace_back();

auto match = decompose_t::extract<block_header_extensions_t>( id, e.second, results.back() );
EOS_ASSERT( match, invalid_block_header_extension,
"Block header extension with id type ${id} is not supported",
("id", id)
);

if( match->enforce_unique ) {
EOS_ASSERT( i == 0 || id > id_type_lower_bound, invalid_block_header_extension,
"Block header extension with id type ${id} is not allowed to repeat",
("id", id)
);
}

id_type_lower_bound = id;
}

return results;
}

} }
496 changes: 293 additions & 203 deletions libraries/chain/block_header_state.cpp

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions libraries/chain/block_log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,9 @@ namespace eosio { namespace chain {

if (first_block) {
append(first_block);
} else {
my->head.reset();
my->head_id = {};
}

auto pos = my->block_stream.tellp();
Expand Down
43 changes: 34 additions & 9 deletions libraries/chain/block_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,42 @@

namespace eosio { namespace chain {

block_state::block_state( const block_header_state& prev, block_timestamp_type when )
:block_header_state( prev.generate_next( when ) ),
block( std::make_shared<signed_block>() )
{
static_cast<block_header&>(*block) = header;
}
block_state::block_state( const block_header_state& prev,
signed_block_ptr b,
const std::function<void( block_timestamp_type,
const flat_set<digest_type>&,
const vector<digest_type>& )>& validator,
bool skip_validate_signee
)
:block_header_state( prev.next( *b, validator, skip_validate_signee ) )
,block( std::move(b) )
{}

block_state::block_state( const block_header_state& prev, signed_block_ptr b, bool skip_validate_signee )
:block_header_state( prev.next( *b, skip_validate_signee )), block( move(b) )
{ }
block_state::block_state( pending_block_header_state&& cur,
signed_block_ptr&& b,
vector<transaction_metadata_ptr>&& trx_metas,
const std::function<void( block_timestamp_type,
const flat_set<digest_type>&,
const vector<digest_type>& )>& validator,
const std::function<signature_type(const digest_type&)>& signer
)
:block_header_state( std::move(cur).finish_next( *b, validator, signer ) )
,block( std::move(b) )
,trxs( std::move(trx_metas) )
{}


block_state::block_state( pending_block_header_state&& cur,
const signed_block_ptr& b,
vector<transaction_metadata_ptr>&& trx_metas,
const std::function<void( block_timestamp_type,
const flat_set<digest_type>&,
const vector<digest_type>& )>& validator,
bool skip_validate_signee
)
:block_header_state( std::move(cur).finish_next( *b, validator, skip_validate_signee ) )
,block( b )
,trxs( std::move(trx_metas) )
{}

} } /// eosio::chain
Loading

0 comments on commit eb2f686

Please sign in to comment.