Skip to content

Commit

Permalink
Merge pull request #310 from eosnetworkfoundation/kayan_evmtx_order
Browse files Browse the repository at this point in the history
evmtx order
  • Loading branch information
taokayan authored Oct 22, 2024
2 parents 2690ee8 + e8eca69 commit 87d4f35
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 additions & 3 deletions src/ship_receiver_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,37 @@ class ship_receiver_plugin_impl : std::enable_shared_from_this<ship_receiver_plu
throw std::runtime_error("action_trace does not have receipt");
}
uint64_t global_sequence = 0;
std::visit([&](auto &receipt) {
global_sequence = receipt.global_sequence;
std::visit([&](auto &receipt) {
if (act.act.name == evmtx_n) {
uint32_t parent_act_index = act.creator_action_ordinal;
if (parent_act_index == 0) {
throw std::runtime_error("creator_action_ordinal can't be zero in evmtx");
}
parent_act_index--; // offset by 1
if (parent_act_index >= j) {
SILK_ERROR << "current action index:" << j << ", parent_act_index:" << parent_act_index;
throw std::runtime_error("parent action index must be less than current action index");
}
std::visit([&](auto& parent_act) {
if (!parent_act.receipt.has_value()) {
SILK_ERROR << "parent action does not have receipt";
throw std::runtime_error("parent action does not have receipt");
}
std::visit([&](auto &parent_act_receipt) {
global_sequence = parent_act_receipt.global_sequence;
}, parent_act.receipt.value());
}, actions[parent_act_index]);
SILK_DEBUG << "add evmtx sequence " << global_sequence
<< ", parent action index " << parent_act_index;
} else if (act.act.name == configchange_n) {
global_sequence = 0;
SILK_DEBUG << "add configchange sequence " << global_sequence;
} else {
global_sequence = receipt.global_sequence;
SILK_DEBUG << "add pushtx sequence " << global_sequence;
}
}, act.receipt.value());
ordered_action_traces[global_sequence] = std::move(actions[j]);
SILK_DEBUG << "add action sequence " << global_sequence;
}
}, actions[j]);
}
Expand Down

0 comments on commit 87d4f35

Please sign in to comment.