提交 97f664e6 编写于 作者: A arhag

bill 5 ms by default for all transactions pushed via tester

上级 7beeb828
......@@ -405,7 +405,7 @@ struct controller_impl {
trx_context.finalize(); // Automatically rounds up network and CPU usage in trace and bills payers if successful
auto restore = make_block_restore_point();
trace->receipt = push_receipt( gto.trx_id, transaction_receipt::soft_fail,
trace->receipt = push_receipt( gto.trx_id, transaction_receipt::soft_fail,
trx_context.billed_cpu_time_us, trace->net_usage );
fc::move_append( pending->_actions, move(trx_context.executed) );
......@@ -1062,12 +1062,12 @@ void controller::push_confirmation( const header_confirmation& c ) {
my->push_confirmation( c );
}
transaction_trace_ptr controller::push_transaction( const transaction_metadata_ptr& trx, fc::time_point deadline ) {
return my->push_transaction(trx, deadline, false, 0);
transaction_trace_ptr controller::push_transaction( const transaction_metadata_ptr& trx, fc::time_point deadline, uint32_t billed_cpu_time_us ) {
return my->push_transaction(trx, deadline, false, billed_cpu_time_us);
}
transaction_trace_ptr controller::push_scheduled_transaction( const transaction_id_type& trxid, fc::time_point deadline ) {
return my->push_scheduled_transaction( trxid, deadline, 0 );
transaction_trace_ptr controller::push_scheduled_transaction( const transaction_id_type& trxid, fc::time_point deadline, uint32_t billed_cpu_time_us ) {
return my->push_scheduled_transaction( trxid, deadline, billed_cpu_time_us );
}
uint32_t controller::head_block_num()const {
......
......@@ -602,9 +602,6 @@ class apply_context {
action_trace trace;
uint64_t cpu_usage = 0;
uint64_t cpu_usage_limit = 0;
private:
iterator_cache<key_value_object> keyval_cache;
......
......@@ -85,13 +85,13 @@ namespace eosio { namespace chain {
/**
*
*/
transaction_trace_ptr push_transaction( const transaction_metadata_ptr& trx, fc::time_point deadline );
transaction_trace_ptr push_transaction( const transaction_metadata_ptr& trx, fc::time_point deadline, uint32_t billed_cpu_time_us = 0 );
/**
* Attempt to execute a specific transaction in our deferred trx database
*
*/
transaction_trace_ptr push_scheduled_transaction( const transaction_id_type& scheduled, fc::time_point deadline );
transaction_trace_ptr push_scheduled_transaction( const transaction_id_type& scheduled, fc::time_point deadline, uint32_t billed_cpu_time_us = 0 );
void finalize_block();
void sign_block( const std::function<signature_type( const digest_type& )>& signer_callback );
......
......@@ -32,7 +32,7 @@ namespace eosio { namespace chain {
uint16_t ref_block_num = 0U; ///< specifies a block num in the last 2^16 blocks.
uint32_t ref_block_prefix = 0UL; ///< specifies the lower 32 bits of the blockid at get_ref_blocknum
fc::unsigned_int max_net_usage_words = 0UL; /// upper limit on total network bandwidth (in 8 byte words) billed for this transaction
uint8_t max_cpu_usage_ms = 0UL; /// upper limit on the total number of kilo CPU usage units billed for this transaction
uint8_t max_cpu_usage_ms = 0; /// upper limit on the total CPU time billed for this transaction
fc::unsigned_int delay_sec = 0UL; /// number of seconds to delay this transaction for during which it may be canceled.
/**
......
......@@ -72,6 +72,8 @@ namespace eosio { namespace testing {
static const uint32_t DEFAULT_EXPIRATION_DELTA = 6;
static const uint32_t DEFAULT_BILLED_CPU_TIME_US = 5000;
void init(bool push_genesis = true);
void init(controller::config config);
......@@ -85,8 +87,8 @@ namespace eosio { namespace testing {
void produce_blocks_until_end_of_round();
signed_block_ptr push_block(signed_block_ptr b);
transaction_trace_ptr push_transaction( packed_transaction& trx, uint32_t skip_flag = 0/*skip_nothing */, fc::time_point deadline = fc::time_point::maximum() );
transaction_trace_ptr push_transaction( signed_transaction& trx, uint32_t skip_flag = 0/*skip_nothing*/, fc::time_point deadline = fc::time_point::maximum() );
transaction_trace_ptr push_transaction( packed_transaction& trx, uint32_t skip_flag = 0/*skip_nothing */, fc::time_point deadline = fc::time_point::maximum(), uint32_t billed_cpu_time_us = DEFAULT_BILLED_CPU_TIME_US );
transaction_trace_ptr push_transaction( signed_transaction& trx, uint32_t skip_flag = 0/*skip_nothing*/, fc::time_point deadline = fc::time_point::maximum(), uint32_t billed_cpu_time_us = DEFAULT_BILLED_CPU_TIME_US );
action_result push_action(action&& cert_act, uint64_t authorizer); // TODO/QUESTION: Is this needed?
transaction_trace_ptr push_action( const account_name& code,
......
......@@ -242,16 +242,26 @@ namespace eosio { namespace testing {
return push_transaction( trx );
}
transaction_trace_ptr base_tester::push_transaction( packed_transaction& trx, uint32_t skip_flag, fc::time_point deadline ) { try {
transaction_trace_ptr base_tester::push_transaction( packed_transaction& trx,
uint32_t skip_flag,
fc::time_point deadline,
uint32_t billed_cpu_time_us
)
{ try {
if( !control->pending_block_state() )
_start_block(control->head_block_time() + fc::microseconds(config::block_interval_us));
auto r = control->push_transaction( std::make_shared<transaction_metadata>(trx), deadline );
auto r = control->push_transaction( std::make_shared<transaction_metadata>(trx), deadline, billed_cpu_time_us );
if( r->except_ptr ) std::rethrow_exception( r->except_ptr );
if( r->except ) throw *r->except;
return r;
} FC_CAPTURE_AND_RETHROW( (transaction_header(trx.get_transaction())) ) }
transaction_trace_ptr base_tester::push_transaction( signed_transaction& trx, uint32_t skip_flag, fc::time_point deadline ) { try {
transaction_trace_ptr base_tester::push_transaction( signed_transaction& trx,
uint32_t skip_flag,
fc::time_point deadline,
uint32_t billed_cpu_time_us
)
{ try {
if( !control->pending_block_state() )
_start_block(control->head_block_time() + fc::microseconds(config::block_interval_us));
auto c = packed_transaction::none;
......@@ -262,7 +272,7 @@ namespace eosio { namespace testing {
c = packed_transaction::zlib;
}
auto r = control->push_transaction( std::make_shared<transaction_metadata>(trx,c), deadline );
auto r = control->push_transaction( std::make_shared<transaction_metadata>(trx,c), deadline, billed_cpu_time_us );
if( r->except_ptr ) std::rethrow_exception( r->except_ptr );
if( r->except) throw *r->except;
return r;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册