Skip to content

Commit

Permalink
Apply deterministic virtual_op numbering rule
Browse files Browse the repository at this point in the history
  • Loading branch information
abitmore committed Mar 24, 2019
1 parent a411589 commit 3dfa222
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
11 changes: 11 additions & 0 deletions libraries/chain/db_block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,8 @@ void database::_apply_block( const signed_block& next_block )

_current_block_num = next_block_num;
_current_trx_in_block = 0;
_current_op_in_trx = 0;
_current_virtual_op = 0;

_issue_453_affected_assets.clear();

Expand All @@ -566,7 +568,14 @@ void database::_apply_block( const signed_block& next_block )
* when building a block.
*/
apply_transaction( trx, skip );
// For real operations which are explicitly included in a transaction, virtual_op is 0.
// For VOPs derived directly from a real op,
// use the real op's (block_num,trx_in_block,op_in_trx), virtual_op starts from 1.
// For VOPs created after processed all transactions,
// trx_in_block = the_block.trsanctions.size(), virtual_op starts from 0.
++_current_trx_in_block;
_current_op_in_trx = 0;
_current_virtual_op = 0;
}

const uint32_t missed = update_witness_missed_blocks( next_block );
Expand Down Expand Up @@ -669,10 +678,12 @@ processed_transaction database::_apply_transaction(const signed_transaction& trx
//Finally process the operations
processed_transaction ptrx(trx);
_current_op_in_trx = 0;
_current_virtual_op = 0;
for( const auto& op : ptrx.operations )
{
eval_state.operation_results.emplace_back(apply_operation(eval_state, op));
++_current_op_in_trx;
_current_virtual_op = 0;
}
ptrx.operation_results = std::move(eval_state.operation_results);

Expand Down
2 changes: 1 addition & 1 deletion libraries/chain/include/graphene/chain/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
#define GRAPHENE_RECENTLY_MISSED_COUNT_INCREMENT 4
#define GRAPHENE_RECENTLY_MISSED_COUNT_DECREMENT 3

#define GRAPHENE_CURRENT_DB_VERSION "20190219"
#define GRAPHENE_CURRENT_DB_VERSION "20190324"

#define GRAPHENE_IRREVERSIBLE_THRESHOLD (70 * GRAPHENE_1_PERCENT)

Expand Down
2 changes: 1 addition & 1 deletion libraries/chain/include/graphene/chain/database.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ namespace graphene { namespace chain {
uint32_t _current_block_num = 0;
uint16_t _current_trx_in_block = 0;
uint16_t _current_op_in_trx = 0;
uint16_t _current_virtual_op = 0;
uint32_t _current_virtual_op = 0;

vector<uint64_t> _vote_tally_buffer;
vector<uint64_t> _witness_count_histogram_buffer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ namespace graphene { namespace chain {
/** the operation within the transaction */
uint16_t op_in_trx = 0;
/** any virtual operations implied by operation in block */
uint16_t virtual_op = 0;
uint32_t virtual_op = 0;
};

/**
Expand Down

0 comments on commit 3dfa222

Please sign in to comment.