Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unity build: prepare support in irohad #238

Merged
merged 3 commits into from
Oct 21, 2019

Conversation

lebdron
Copy link
Contributor

@lebdron lebdron commented Aug 28, 2019

Description of the Change

  • Remove code duplication in ametsuchi
  • Simplify transaction collection deserialization in MST and OrderingService

Benefits

Potential support for unity build of irohad

Possible Drawbacks

None

@lebdron lebdron force-pushed the refactor/unity-build-prepare branch 2 times, most recently from 7096c5d to fdbb2ad Compare August 29, 2019 05:39
Copy link
Contributor

@luckychess luckychess left a comment

Choose a reason for hiding this comment

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

Looks like a build wants to be fixed but looks great overall.

Copy link
Contributor

@MBoldyrev MBoldyrev left a comment

Choose a reason for hiding this comment

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

as we discussed, please make the messages be dropped if they cannot be completely restored (in MST and Ordering). i.e. some deserialization failure -> drop whole message.

log_->warn("Transaction deserialization failed: hash {}, {}",
e->error.hash,
e->error.error);
return ::grpc::Status::OK;
Copy link
Contributor

Choose a reason for hiding this comment

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

it seems not OK at all. Also in other similar cases.

Copy link
Contributor

Choose a reason for hiding this comment

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

Do we still use transport error codes for business logic?


iroha::expected::Result<interface::types::SharedTxsCollectionType,
TransactionFactoryType::Error>
deserializeTransactions(
Copy link
Contributor

Choose a reason for hiding this comment

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

it seems OK for this PR just to speed up the merge, but apart from that, I think that this approach is wrong, because the task it solves is not constrained to proto transactions. I would solve it with something like

namespace expected {
  template<typename V, typename E>
  Result<std::vector<V>, E> allValuesOrFirstError(std::vector<Result<V, E>> results) {
    std::vector<V> values;
    for (auto &result : results) {
      if (auto e = resultToOptionalError(result)) {
        return e.value();
      }
      values.emplace_back(resultToOptionalValue(std::move(result)).value());
    }
    return values;
  }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is no need to generalize until there are at least two places where it can be reused. Templates are cool, but it is better to avoid them if possible

Copy link
Contributor

Choose a reason for hiding this comment

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

when there will be a second place, this piece will most likely not be reused

Copy link
Contributor

Choose a reason for hiding this comment

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

also I think that there are places besides this pr, where the proposed code can be used.

test/module/irohad/torii/torii_transport_command_test.cpp Outdated Show resolved Hide resolved
test/module/irohad/torii/torii_transport_command_test.cpp Outdated Show resolved Hide resolved
log_->warn("Transaction deserialization failed: hash {}, {}",
e->error.hash,
e->error.error);
return ::grpc::Status::OK;
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we still use transport error codes for business logic?

Network transaction endpoints: remove code duplication and make more
strict validation

Signed-off-by: Andrei Lebedev <lebdron@gmail.com>
@lebdron lebdron force-pushed the refactor/unity-build-prepare branch from d966dab to fcb68b4 Compare October 21, 2019 06:21
@lebdron lebdron merged commit fbe494d into hyperledger:master Oct 21, 2019
@lebdron lebdron deleted the refactor/unity-build-prepare branch October 21, 2019 18:16
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants