Skip to content
This repository has been archived by the owner on Apr 17, 2019. It is now read-only.

MST Pending Status #1649

Merged
merged 20 commits into from
Sep 10, 2018
Merged

MST Pending Status #1649

merged 20 commits into from
Sep 10, 2018

Conversation

Akvinikym
Copy link
Contributor

Description of the Change

This PR adds a MST_PENDING status for transactions, which were sent for further processing into MST processor.

Benefits

Now users will be able to understand, if their transaction is being processed by MST.

Possible Drawbacks

None.

Signed-off-by: Akvinikym <[email protected]>
@@ -142,6 +142,11 @@ namespace iroha {
if (boost::size(transaction->signatures()) < transaction->quorum()) {
log_->info("waiting for quorum signatures");
mst_processor_->propagateTransaction(transaction);
status_bus_->publish(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe move the code to separate function?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This status publishing is done in such way throughout this file, and I think it will be unnecessary hard to move it into a separate function, because we need to put the status somehow, and it's done through the builder. In case of separate function we can pass the builder, but why?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, after a little discuss, I decided that this task actually is about creating something like status factory, which should be done outside this PR

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Offline discussion:
Move status_bus::publish to the separate method and add a task for refactoring this method in a separate PR

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Offline discussion:
Move status_bus::publish to the separate method and add a task for refactoring this method in a separate PR

* signatories
*/
class MstPendingResponse : public AbstractTxResponse<MstPendingResponse> {
private:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any reason to do it in private. Maybe change it with the public instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method is private in all similar files for other responses. Should I thus touch them as well with that change?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, in this case, add a task for refactoring this with the lowest priority.

shared_model::builder::DefaultTransactionStatusBuilder()
.mstPending()
.txHash(transaction->hash())
.build());
return;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, there is absent a code for setting status in another one, for example, stateless valid or maybe introduce a new one like prepared to consensus.

@l4l l4l added the mst multisignature transactions label Aug 27, 2018
l4l
l4l previously requested changes Aug 27, 2018
* - 0, if it's equal
* - 1, if it's greater
*/
int comparePriorities(const TransactionResponse &other) const noexcept {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use enum class instead

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enum class Result { LE, EQ, GT, };

Result comparePriorities(const T&) ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I implemented this method looking at old C functions, strcmp etc, where it's done in this way :) will change it

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe relay operator<, >, == to transactionResponse from priority directly?

.getTransport();
}())));
ResponsePtrType initial_status = cache_->findItem(hash).value_or([&] {
log_->debug("tx not received: {}", hash.toString());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tx is not ...

* @return priority this transaction response
*/
int priority() const noexcept {
return iroha::visit_in_place(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return variant_->which() ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this won't work, because then we should place classes in variant according to their priorities, and this is not as obvious as this visit_in_place function IMHO

ASSERT_NO_THROW(boost::apply_visitor(
SpecifiedVisitor<interface::MstPendingResponse>(), resp.get()));
};
// auto checkMstPassedTxStatus =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe delete commented lines?

@@ -142,6 +142,11 @@ namespace iroha {
if (boost::size(transaction->signatures()) < transaction->quorum()) {
log_->info("waiting for quorum signatures");
mst_processor_->propagateTransaction(transaction);
status_bus_->publish(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Offline discussion:
Move status_bus::publish to the separate method and add a task for refactoring this method in a separate PR

@@ -142,6 +142,11 @@ namespace iroha {
if (boost::size(transaction->signatures()) < transaction->quorum()) {
log_->info("waiting for quorum signatures");
mst_processor_->propagateTransaction(transaction);
status_bus_->publish(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Offline discussion:
Move status_bus::publish to the separate method and add a task for refactoring this method in a separate PR

* signatories
*/
class MstPendingResponse : public AbstractTxResponse<MstPendingResponse> {
private:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, in this case, add a task for refactoring this with the lowest priority.

ASSERT_NO_THROW(boost::apply_visitor(
SpecifiedVisitor<interface::MstPendingResponse>(), resp.get()));
};
// auto checkEnoughSignaturesCollectedStatus =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you forget to delete that?

@@ -85,6 +109,23 @@ namespace shared_model {
// stub hash
const Lazy<crypto::Hash> hash_{
[this] { return crypto::Hash(this->proto_->tx_hash()); }};

/**
* @return priority this transaction response
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe explain what priority means?

Signed-off-by: Akvinikym <[email protected]>
Signed-off-by: Akvinikym <[email protected]>
@Akvinikym Akvinikym dismissed stale reviews from kamilsa, muratovv, and l4l August 29, 2018 11:45

Fixed

@Akvinikym Akvinikym changed the base branch from develop to dev August 29, 2018 11:46
Signed-off-by: Akvinikym <[email protected]>
Signed-off-by: Akvinikym <[email protected]>
.build()
.getTransport();
}())));
ResponsePtrType initial_status = cache_->findItem(hash).value_or([&] {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to use auto instead of type.

* - 0, if it's equal
* - 1, if it's greater
*/
int comparePriorities(const TransactionResponse &other) const noexcept {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe relay operator<, >, == to transactionResponse from priority directly?

* @return priority of this transaction response; transaction response can
* only be replaced with one with higher priority
*/
int priority() const noexcept {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems, this table should be in the interface, not it proto backend.

[](const StatelessFailedTxResponse &) { return 6; },
[](const StatefulFailedTxResponse &) { return 7; },
[](const MstExpiredResponse &) { return 8; },
[](const NotReceivedTxResponse &) { return 9; });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, statuses are misleading. For example, why MstExpired is greater than committed?

I suggest reworking priorities with final status priority, which means maximal priority and reflects the impossibility of achieving another status for the transaction. Also, take care of intermediate statuses.

If there will be some troubles, we may arrange an offline meeting.

@@ -57,11 +57,10 @@ namespace torii {
auto tx_hash = proto_response->transactionHash();
auto cached_tx_state = cache_->findItem(tx_hash);
if (cached_tx_state
and proto_response->getTransport().tx_status()
<= cached_tx_state->tx_status()) {
and proto_response->comparePriorities(**cached_tx_state) <= 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is 0 means? Use status constants instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was a value, which compare function gave, so that <= 0 meant that first value is less or equal, than the second one, C-style. But as it's going to be replaced by enum class, doesn't matter


mst_processor_->onPreparedBatches().subscribe([this](auto &&batch) {
log_->info("MST batch prepared");
// TODO: 07/08/2018 @muratovv rework interface of pcs::propagate batch
// and mst::propagate batch IR-1584
for (const auto &tx : batch->transactions()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems, code here and at line 128is duplicated. Maybe refactor it with one method instead?

[](const StatefulValidTxResponse &) { return 4; },
// following types are the final ones
[](const CommittedTxResponse &) { return max_priority; },
[](const StatelessFailedTxResponse &) { return max_priority; },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Statuses

  • StatelessFailedTxResponse
  • StatefulFailedTxResponse
  • MstExpiredResponse
    Are not final.

By your request, I can provide situations where it happens.

* - 0, if it's equal
* - 1, if it's greater
*/
int comparePriorities(const ModelType &other) const noexcept {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use enum class for return type instead.

Copy link
Contributor

@muratovv muratovv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check new comments and fix or decline them

@Akvinikym Akvinikym merged commit ae2aa68 into dev Sep 10, 2018
@Akvinikym Akvinikym deleted the feature/mst-pending-status branch September 10, 2018 07:57
@Akvinikym Akvinikym restored the feature/mst-pending-status branch September 10, 2018 07:58
@Akvinikym Akvinikym deleted the feature/mst-pending-status branch September 10, 2018 07:59
nickaleks pushed a commit that referenced this pull request Sep 10, 2018
bakhtin pushed a commit that referenced this pull request Nov 2, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
mst multisignature transactions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants