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 #5030 from EOSIO/release/1.1.x
Browse files Browse the repository at this point in the history
Version 1.1.3
  • Loading branch information
arhag authored Aug 3, 2018
2 parents 7412253 + d0ca583 commit ad4ba28
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 59 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ set( CXX_STANDARD_REQUIRED ON)

set(VERSION_MAJOR 1)
set(VERSION_MINOR 1)
set(VERSION_PATCH 2)
set(VERSION_PATCH 3)

set( CLI_CLIENT_EXECUTABLE_NAME cleos )
set( GUI_CLIENT_EXECUTABLE_NAME eosio )
Expand Down
4 changes: 2 additions & 2 deletions Docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ cd eos/Docker
docker build . -t eosio/eos
```

The above will build off the most recent commit to the master branch by default. If you would like to target a specific branch/tag, you may use a build argument. For example, if you wished to generate a docker image based off of the v1.1.2 tag, you could do the following:
The above will build off the most recent commit to the master branch by default. If you would like to target a specific branch/tag, you may use a build argument. For example, if you wished to generate a docker image based off of the v1.1.3 tag, you could do the following:

```bash
docker build -t eosio/eos:v1.1.2 --build-arg branch=v1.1.2 .
docker build -t eosio/eos:v1.1.3 --build-arg branch=v1.1.3 .
```

By default, the symbol in eosio.system is set to SYS. You can override this using the symbol argument while building the docker image.
Expand Down
62 changes: 41 additions & 21 deletions libraries/chain/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,9 @@ struct controller_impl {
transaction_trace_ptr apply_onerror( const generated_transaction& gtrx,
fc::time_point deadline,
fc::time_point start,
uint32_t billed_cpu_time_us) {
uint32_t& cpu_time_to_bill_us, // only set on failure
uint32_t billed_cpu_time_us,
bool explicit_billed_cpu_time = false ) {
signed_transaction etrx;
// Deliver onerror action containing the failed deferred transaction directly back to the sender.
etrx.actions.emplace_back( vector<permission_level>{{gtrx.sender, config::active_name}},
Expand All @@ -477,6 +479,7 @@ struct controller_impl {

transaction_context trx_context( self, etrx, etrx.id(), start );
trx_context.deadline = deadline;
trx_context.explicit_billed_cpu_time = explicit_billed_cpu_time;
trx_context.billed_cpu_time_us = billed_cpu_time_us;
transaction_trace_ptr trace = trx_context.trace;
try {
Expand All @@ -497,6 +500,7 @@ struct controller_impl {
restore.cancel();
return trace;
} catch( const fc::exception& e ) {
cpu_time_to_bill_us = trx_context.update_billed_cpu_time( fc::time_point::now() );
trace->except = e;
trace->except_ptr = std::current_exception();
}
Expand Down Expand Up @@ -529,14 +533,14 @@ struct controller_impl {
|| (code == key_blacklist_exception::code_value);
}

transaction_trace_ptr push_scheduled_transaction( const transaction_id_type& trxid, fc::time_point deadline, uint32_t billed_cpu_time_us ) {
transaction_trace_ptr push_scheduled_transaction( const transaction_id_type& trxid, fc::time_point deadline, uint32_t billed_cpu_time_us, bool explicit_billed_cpu_time = false ) {
const auto& idx = db.get_index<generated_transaction_multi_index,by_trx_id>();
auto itr = idx.find( trxid );
EOS_ASSERT( itr != idx.end(), unknown_transaction_exception, "unknown transaction" );
return push_scheduled_transaction( *itr, deadline, billed_cpu_time_us );
return push_scheduled_transaction( *itr, deadline, billed_cpu_time_us, explicit_billed_cpu_time );
}

transaction_trace_ptr push_scheduled_transaction( const generated_transaction_object& gto, fc::time_point deadline, uint32_t billed_cpu_time_us )
transaction_trace_ptr push_scheduled_transaction( const generated_transaction_object& gto, fc::time_point deadline, uint32_t billed_cpu_time_us, bool explicit_billed_cpu_time = false )
{ try {
auto undo_session = db.start_undo_session(true);
auto gtrx = generated_transaction(gto);
Expand Down Expand Up @@ -572,15 +576,16 @@ struct controller_impl {
});
in_trx_requiring_checks = true;

uint32_t cpu_time_to_bill_us = billed_cpu_time_us;

transaction_context trx_context( self, dtrx, gtrx.trx_id );
trx_context.leeway = fc::microseconds(0); // avoid stealing cpu resource
trx_context.leeway = fc::microseconds(0); // avoid stealing cpu resource
trx_context.deadline = deadline;
trx_context.explicit_billed_cpu_time = explicit_billed_cpu_time;
trx_context.billed_cpu_time_us = billed_cpu_time_us;
transaction_trace_ptr trace = trx_context.trace;
flat_set<account_name> bill_to_accounts;
try {
trx_context.init_for_deferred_trx( gtrx.published );
bill_to_accounts = trx_context.bill_to_accounts;
trx_context.exec();
trx_context.finalize(); // Automatically rounds up network and CPU usage in trace and bills payers if successful

Expand All @@ -600,35 +605,48 @@ struct controller_impl {
restore.cancel();
return trace;
} catch( const fc::exception& e ) {
cpu_time_to_bill_us = trx_context.update_billed_cpu_time( fc::time_point::now() );
trace->except = e;
trace->except_ptr = std::current_exception();
trace->elapsed = fc::time_point::now() - trx_context.start;
}
trx_context.undo_session.undo();

// Only soft or hard failure logic below:
// Only subjective OR soft OR hard failure logic below:

if( gtrx.sender != account_name() && !failure_is_subjective(*trace->except)) {
// Attempt error handling for the generated transaction.
dlog("${detail}", ("detail", trace->except->to_detail_string()));
auto error_trace = apply_onerror( gtrx, deadline, trx_context.start, trx_context.billed_cpu_time_us );
auto error_trace = apply_onerror( gtrx, deadline, trx_context.pseudo_start, cpu_time_to_bill_us, billed_cpu_time_us, explicit_billed_cpu_time );
error_trace->failed_dtrx_trace = trace;
trace = error_trace;
if( !trace->except_ptr ) {
undo_session.squash();
return trace;
}
trace->elapsed = fc::time_point::now() - trx_context.start;
}

// Only hard failure OR subjective failure logic below:
// Only subjective OR hard failure logic below:

trace->elapsed = fc::time_point::now() - trx_context.start;
if (!failure_is_subjective(*trace->except)) {
// hard failure logic

resource_limits.add_transaction_usage( bill_to_accounts, trx_context.billed_cpu_time_us, 0,
block_timestamp_type(self.pending_block_time()).slot ); // Should never fail
if( !explicit_billed_cpu_time ) {
auto& rl = self.get_mutable_resource_limits_manager();
rl.update_account_usage( trx_context.bill_to_accounts, block_timestamp_type(self.pending_block_time()).slot );
int64_t account_cpu_limit = 0;
std::tie( std::ignore, account_cpu_limit, std::ignore ) = trx_context.max_bandwidth_billed_accounts_can_pay( true );

if (!failure_is_subjective(*trace->except)) {
trace->receipt = push_receipt(gtrx.trx_id, transaction_receipt::hard_fail, trx_context.billed_cpu_time_us, 0);
cpu_time_to_bill_us = static_cast<uint32_t>( std::min( std::min( static_cast<int64_t>(cpu_time_to_bill_us),
account_cpu_limit ),
trx_context.initial_objective_duration_limit.count() ) );
}

resource_limits.add_transaction_usage( trx_context.bill_to_accounts, cpu_time_to_bill_us, 0,
block_timestamp_type(self.pending_block_time()).slot ); // Should never fail

trace->receipt = push_receipt(gtrx.trx_id, transaction_receipt::hard_fail, cpu_time_to_bill_us, 0);
emit( self.applied_transaction, trace );
undo_session.squash();
}
Expand Down Expand Up @@ -661,7 +679,8 @@ struct controller_impl {
transaction_trace_ptr push_transaction( const transaction_metadata_ptr& trx,
fc::time_point deadline,
bool implicit,
uint32_t billed_cpu_time_us)
uint32_t billed_cpu_time_us,
bool explicit_billed_cpu_time = false )
{
EOS_ASSERT(deadline != fc::time_point(), transaction_exception, "deadline cannot be uninitialized");

Expand All @@ -672,6 +691,7 @@ struct controller_impl {
trx_context.leeway = *subjective_cpu_leeway;
}
trx_context.deadline = deadline;
trx_context.explicit_billed_cpu_time = explicit_billed_cpu_time;
trx_context.billed_cpu_time_us = billed_cpu_time_us;
trace = trx_context.trace;
try {
Expand Down Expand Up @@ -810,7 +830,7 @@ struct controller_impl {
in_trx_requiring_checks = old_value;
});
in_trx_requiring_checks = true;
push_transaction( onbtrx, fc::time_point::maximum(), true, self.get_global_properties().configuration.min_transaction_cpu_usage );
push_transaction( onbtrx, fc::time_point::maximum(), true, self.get_global_properties().configuration.min_transaction_cpu_usage, true );
} catch( const boost::interprocess::bad_alloc& e ) {
elog( "on block transaction failed due to a bad allocation" );
throw;
Expand Down Expand Up @@ -849,9 +869,9 @@ struct controller_impl {
if( receipt.trx.contains<packed_transaction>() ) {
auto& pt = receipt.trx.get<packed_transaction>();
auto mtrx = std::make_shared<transaction_metadata>(pt);
trace = push_transaction( mtrx, fc::time_point::maximum(), false, receipt.cpu_usage_us);
trace = push_transaction( mtrx, fc::time_point::maximum(), false, receipt.cpu_usage_us, true );
} else if( receipt.trx.contains<transaction_id_type>() ) {
trace = push_scheduled_transaction( receipt.trx.get<transaction_id_type>(), fc::time_point::maximum(), receipt.cpu_usage_us );
trace = push_scheduled_transaction( receipt.trx.get<transaction_id_type>(), fc::time_point::maximum(), receipt.cpu_usage_us, true );
} else {
EOS_ASSERT( false, block_validate_exception, "encountered unexpected receipt type" );
}
Expand Down Expand Up @@ -1311,13 +1331,13 @@ void controller::push_confirmation( const header_confirmation& c ) {

transaction_trace_ptr controller::push_transaction( const transaction_metadata_ptr& trx, fc::time_point deadline, uint32_t billed_cpu_time_us ) {
validate_db_available_size();
return my->push_transaction(trx, deadline, false, billed_cpu_time_us);
return my->push_transaction(trx, deadline, false, billed_cpu_time_us, billed_cpu_time_us > 0 );
}

transaction_trace_ptr controller::push_scheduled_transaction( const transaction_id_type& trxid, fc::time_point deadline, uint32_t billed_cpu_time_us )
{
validate_db_available_size();
return my->push_scheduled_transaction( trxid, deadline, billed_cpu_time_us );
return my->push_scheduled_transaction( trxid, deadline, billed_cpu_time_us, billed_cpu_time_us > 0 );
}

uint32_t controller::head_block_num()const {
Expand Down
6 changes: 6 additions & 0 deletions libraries/chain/include/eosio/chain/transaction_context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ namespace eosio { namespace chain {

void add_ram_usage( account_name account, int64_t ram_delta );

uint32_t update_billed_cpu_time( fc::time_point now );

std::tuple<int64_t, int64_t, bool> max_bandwidth_billed_accounts_can_pay( bool force_elastic_limits = false )const;

private:

friend struct controller_impl;
Expand Down Expand Up @@ -81,6 +85,7 @@ namespace eosio { namespace chain {
fc::time_point deadline = fc::time_point::maximum();
fc::microseconds leeway = fc::microseconds(3000);
int64_t billed_cpu_time_us = 0;
bool explicit_billed_cpu_time = false;

private:
bool is_initialized = false;
Expand All @@ -92,6 +97,7 @@ namespace eosio { namespace chain {
uint64_t eager_net_limit = 0;
uint64_t& net_usage; /// reference to trace->net_usage

fc::microseconds initial_objective_duration_limit;
fc::microseconds objective_duration_limit;
fc::time_point _deadline = fc::time_point::maximum();
int64_t deadline_exception_code = block_cpu_usage_exceeded::code_value;
Expand Down
Loading

0 comments on commit ad4ba28

Please sign in to comment.