提交 62807d66 编写于 作者: P Phil Mesnier

#1329, dawn 567, fix for initializing the signed_block for validation from the signed_block_summary

上级 b7979782
......@@ -81,22 +81,22 @@ namespace eosio { namespace chain {
*
* The primary purpose of a block is to define the order in which messages are processed.
*
* The secodnary purpose of a block is certify that the messages are valid according to
* The secodnary purpose of a block is certify that the messages are valid according to
* a group of 3rd party validators (producers).
*
* The next purpose of a block is to enable light-weight proofs that a transaction occured
* and was considered valid.
*
* The next purpose is to enable code to generate messages that are certified by the
* producers to be authorized.
* producers to be authorized.
*
* A block is therefore defined by the ordered set of executed and generated transactions,
* and the merkle proof is over set of messages delivered as a result of executing the
* transactions.
* transactions.
*
* A message is defined by { receiver, code, function, permission, data }, the merkle
* tree of a block should be generated over a set of message IDs rather than a set of
* transaction ids.
* transaction ids.
*/
struct signed_block_summary : public signed_block_header {
vector<region_summary> regions;
......@@ -109,9 +109,16 @@ namespace eosio { namespace chain {
* what would be logged to disk to enable the regeneration of blockchain state.
*
* The transactions are grouped to mirror the cycles in block_summary, generated
* transactions are not included.
* transactions are not included.
*/
struct signed_block : public signed_block_summary {
signed_block () = default;
signed_block (const signed_block& ) = default;
signed_block (const signed_block_summary&& base)
:signed_block_summary (base),
input_transactions()
{}
digest_type calculate_transaction_merkle_root()const;
vector<packed_transaction> input_transactions; /// this is loaded and indexed into map<id,trx> that is referenced by summary
};
......
......@@ -2170,7 +2170,6 @@ namespace eosio {
}
void net_plugin_impl::handle_message( connection_ptr c, const signed_block_summary &msg) {
// should only be during synch or rolling upgrade
chain_controller &cc = chain_plug->chain();
block_id_type blk_id = msg.id();
uint32_t blk_num = msg.block_num();
......@@ -2188,25 +2187,36 @@ namespace eosio {
fc_dlog(logger, "got signed_block_summary #${n} from ${p} block age in secs = ${age}",
("n",blk_num)("p",c->peer_name())("age",age.to_seconds()));
signed_block sb;
sb.regions = std::move(msg.regions);
signed_block sb(std::move(msg));
update_block_num ubn(blk_num);
for (const auto &region : sb.regions) {
for (const auto &cycle_sum : region.cycles_summary) {
for (const auto &shard : cycle_sum) {
for (const auto &recpt : shard.transactions) {
auto ltx = local_txns.get<by_id>().find(recpt.id);
if( ltx == local_txns.end()) {
fc_elog (logger,"summary references unknown transacion ${rid}",("rid",recpt.id));
close (c); // close without go away allows reconnect
return;
}
sb.input_transactions.push_back(ltx->packed_txn);
local_txns.modify( ltx, ubn );
auto ctx = c->trx_state.get<by_id>().find(recpt.id);
if( ctx != c->trx_state.end()) {
c->trx_state.modify( ctx, ubn );
switch (recpt.status) {
case transaction_receipt::executed: {
if( ltx == local_txns.end()) {
fc_elog (logger,"summary references unknown transaction ${rid}",("rid",recpt.id));
close (c); // close without go away allows reconnect
return;
}
sb.input_transactions.push_back(ltx->packed_txn);
local_txns.modify( ltx, ubn );
break;
}
case transaction_receipt::soft_fail:
case transaction_receipt::hard_fail: {
if( ltx != local_txns.end()) {
sb.input_transactions.push_back(ltx->packed_txn);
local_txns.modify( ltx, ubn );
auto ctx = c->trx_state.get<by_id>().find(recpt.id);
if( ctx != c->trx_state.end()) {
c->trx_state.modify( ctx, ubn );
}
}
break;
}}
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册