-
Notifications
You must be signed in to change notification settings - Fork 297
Conversation
Signed-off-by: Fedor Muratov <muratovfyodor@yandex.ru>
Signed-off-by: Fedor Muratov <muratovfyodor@yandex.ru>
Tests logic needs to be verified. Need txBuilder that operates with signatures. Signed-off-by: Igor Egorov <igor@soramitsu.co.jp>
Signed-off-by: Fedor Muratov <muratovfyodor@yandex.ru>
Signed-off-by: Fedor Muratov <muratovfyodor@yandex.ru>
Signed-off-by: Fedor Muratov <muratovfyodor@yandex.ru>
Signed-off-by: Fedor Muratov <muratovfyodor@yandex.ru>
clean up a little bit Signed-off-by: Fedor Muratov <muratovfyodor@yandex.ru>
Signed-off-by: Fedor Muratov <muratovfyodor@yandex.ru>
Signed-off-by: Fedor Muratov <muratovfyodor@yandex.ru>
* fix ub with conditional variable * add test generator fo batches with keypair * fix operator == in transaction batch * extend delay on cv in test * mst state: fix operator ==, add sorting order to getBatches method Signed-off-by: Fedor Muratov <muratovfyodor@yandex.ru>
Signed-off-by: Fedor Muratov <muratovfyodor@yandex.ru>
also fix comments a little bit Signed-off-by: Fedor Muratov <muratovfyodor@yandex.ru>
Signed-off-by: Fedor Muratov <muratovfyodor@yandex.ru>
Signed-off-by: Fedor Muratov <muratovfyodor@yandex.ru>
Rework mst mocks with refactored interfaces; Signed-off-by: Fedor Muratov <muratovfyodor@yandex.ru>
Signed-off-by: Fedor Muratov <muratovfyodor@yandex.ru>
Rework txProcessor with batch semantic Signed-off-by: Fedor Muratov <muratovfyodor@yandex.ru>
Rework mst mocks with refactored interfaces; Signed-off-by: Fedor Muratov <muratovfyodor@yandex.ru>
Signed-off-by: Fedor Muratov <muratovfyodor@yandex.ru>
Signed-off-by: Fedor Muratov <muratovfyodor@yandex.ru>
* remove redundant logs Signed-off-by: Fedor Muratov <muratovfyodor@yandex.ru>
Signed-off-by: Fedor Muratov <muratovfyodor@yandex.ru>
Signed-off-by: Fedor Muratov <muratovfyodor@yandex.ru>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update MstStorage
too. It contains the method named getExpiredTransactions
. Actualize its naming and contents if needed.
@@ -86,17 +87,17 @@ namespace iroha { | |||
|
|||
// update state | |||
// todo wrap in method | |||
auto new_transactions = | |||
auto new_batches = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[required]
Please specify task id along with todo either remove the comment.
log_->info("New txes size: {}", new_transactions->getTransactions().size()); | ||
// completed transactions | ||
shareState(storage_->apply(from, new_state), transactions_subject_); | ||
log_->info("New batches size: {}", new_batches->getBatches().size()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[optional]
I suggest logging "new amount of batches" instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rephrasing. amount of batches is not the same as their size.
|
||
/** | ||
* Prove updating of state for handling status of signing | ||
*/ | ||
rxcpp::observable<std::shared_ptr<MstState>> onStateUpdate() const; | ||
|
||
/** | ||
* Observable emit transactions that prepared to processing in system | ||
* Observable emit batches which are prepared to processing in system |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[optional]
Observable that emits batches which are prepared for processing
or for further processing
or to be processed
rhs_batches.begin(), | ||
rhs_batches.end(), | ||
[](const auto &l, const auto &r) { | ||
return *l == *r;; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[required]
Extra ;
at the end of the line.
std::sort( | ||
result.begin(), result.end(), [](const auto &left, const auto &right) { | ||
return left->reducedHash().hex() < right->reducedHash().hex(); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[required]
Please leave a comment in code why that sorting is needed.
* Merge signatures in batches | ||
* @param target - batch for inserting | ||
* @param donor - batch with interested transactions | ||
* @return false if hashes of transactions don't satisfy each other |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[hashes satisfaction]
return false when sequences of transactions inside input batches are different
note that reduced hash of batch does not take into account batch type.
signature.publicKey()); | ||
}); | ||
} else { | ||
return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[required]
Depending on the result of DataType->reducedHash()
, now it is possible to have several signatures being merged to the target batch and then false will be returned as the result of evaluation of if (target_tx->hash() == donor_tx->hash())
.
A possible solution is to perform the check of transaction hashes equality before the act of signatures merging.
The point is avoiding an appearance of semi-merged batches.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, there is a bug. In a best case, signatures will be merged only for one pair of transactions.
} | ||
}; | ||
|
||
/** | ||
* Class provide default behaviour for transaction completer | ||
*/ | ||
class DefaultCompleter : public Completer { | ||
bool operator()(const DataType transaction) const override { | ||
return boost::size(transaction->signatures()) >= transaction->quorum(); | ||
bool operator()(const DataType &batch) const override { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[optional]
The docstring might need to be updated.
bool operator()(const DataType transaction) const override { | ||
return boost::size(transaction->signatures()) >= transaction->quorum(); | ||
bool operator()(const DataType &batch) const override { | ||
return std::accumulate( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice!
|
||
shared_model::interface::types::SharedTxsCollectionType collection; | ||
|
||
for (const auto &proto_tx : request->transactions()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[required]
Please specify task id for todo below either remove the comment.
* cleanup documentation * fix bug in mst state on merge signatures in batches * add equalByValue method to signable Signed-off-by: Fedor Muratov <muratovfyodor@yandex.ru>
add missed comments for batch helper and state test Signed-off-by: Fedor Muratov <muratovfyodor@yandex.ru>
Please update the branch and resolve conflicts |
return framework::batch::makeTestBatch(builders...); | ||
} | ||
|
||
template <typename Batch, typename... Signatures> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rework variadic templates with variadic agruments with type Signature
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems, that this is not possible, because we don't not the real type of signature here.
return batch; | ||
} | ||
|
||
template <typename Batch, typename... KeyPairs> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same, KeyPairs can be passed using variadic arguments, not templates
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems, there is, also, not possible to fix your issue because we know a type, but don't know modifiers of the type.
KeyPairs... keypairs) { | ||
auto create_signature = [&](auto &&key_pair) { | ||
auto &payload = batch->transactions().at(tx_number)->payload(); | ||
auto signedBlob = shared_model::crypto::CryptoSigner<>::sign( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use snake
batch->addSignature(tx_number, signedBlob, key_pair.publicKey()); | ||
}; | ||
|
||
int temp[] = {(create_signature(std::forward<KeyPairs>(keypairs)), 0)...}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please leave a comment explaining that construction
@@ -19,22 +19,24 @@ | |||
|
|||
namespace iroha { | |||
|
|||
MstProcessor::MstProcessor() { log_ = logger::log("MstProcessor"); } | |||
MstProcessor::MstProcessor() { | |||
log_ = logger::log("MstProcessor"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An initialization explicitly states that initialization, rather than assignment, is done and can be more elegant and efficient.
auto completed_batches = state.getBatches(); | ||
std::for_each(completed_batches.begin(), | ||
completed_batches.end(), | ||
[&subject](const auto batch) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe use const auto &
to avoid two copies - when lambda is called, and when on_next() is called in lambda.
@@ -37,26 +37,27 @@ namespace iroha { | |||
// ---------------------------| user interface |---------------------------- | |||
|
|||
/** | |||
* Propagate in network multi-signature transaction for signing by other | |||
* Propagate in network batch for signing by other |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider rephrasing, because it means 'network batch' now.
"Propagate batch in network ..."
} | ||
return false; | ||
}); | ||
auto &&lhs_batches = getBatches(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getBatches
returns a value, maybe use const auto &
instead?
std::for_each(internal_state_.begin(), | ||
internal_state_.end(), | ||
[&result](const auto &val) { | ||
val->transactions(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the purpose of this statement? Please remove or add a comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, why the previous version was changed? It can be something like:
std::vector<DataType> result(internal_state_.begin(), internal_state_.end());
std::sort(...);
return result;
} | ||
}; | ||
|
||
/** | ||
* @given state with one transaction |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-> given a timepoint AND a state with an expired transaction
when erase by time is called
then the resulting state contains the expired transaction
} | ||
|
||
/** | ||
* @given init two states |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-> given two states with expired transactions
when the states are merged
then the resulting state does not contain any transactions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
given two states with expired transactions
Batches are not expired at this time.
|
||
auto completed_state = state1 += state2; | ||
ASSERT_EQ(0, completed_state.getTransactions().size()); | ||
ASSERT_EQ(0, completed_state.getBatches().size()); | ||
|
||
auto expired_state = state1.eraseByTime(time + 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check if this case is already covered in TimeIndexInsertionByTx
} | ||
|
||
/** | ||
* @given first state with two batches, seconds is empty |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-> given a state with two expired batches AND an empty state
when the second state is removed from the first state
AND erase by time is called
then the resulting state does not contain any transactions
|
||
transport->sendState(*peer, state); | ||
std::unique_lock<std::mutex> lock(mtx); | ||
cv.wait_for(lock, std::chrono::milliseconds(100)); | ||
cv.wait_for(lock, std::chrono::milliseconds(5000)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add a task to rewrite this with gRPC mocks?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have we created it already?
# Conflicts: # irohad/multi_sig_transactions/transport/impl/mst_transport_grpc.cpp # shared_model/interfaces/iroha_internal/transaction_batch.cpp # test/framework/batch_helper.hpp
* rework many grammar issues * code clean ups * fix merge issues in mst grpc * rework state test with transaction content checks Signed-off-by: Fedor Muratov <muratovfyodor@yandex.ru>
# Conflicts: # irohad/torii/processor/impl/transaction_processor_impl.cpp
Add transaction batch ctor to explicit area; Clean up batch helper with batch ctor; Fix empty sequence test Signed-off-by: Fedor Muratov <muratovfyodor@yandex.ru>
Signed-off-by: Fedor Muratov <muratovfyodor@yandex.ru>
@@ -113,7 +112,7 @@ namespace iroha { | |||
MstState operator-(const MstState &rhs) const; | |||
|
|||
/** | |||
* @return true, if there is no transactions inside | |||
* @return true, if there is no bathes inside |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-> batches
// TODO (@l4l) 04/03/18 simplify with IR-1040 | ||
new (addtxs) protocol::Transaction( | ||
*protoState.add_transactions() = protocol::Transaction( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for additional protocol::Transaction()
, as it will make a copy anyway.
@@ -46,8 +46,12 @@ auto addSignatures(Batch &&batch, int tx_number, Signatures... signatures) { | |||
batch->addSignature(tx_number, sig_pair.first, sig_pair.second); | |||
}; | |||
|
|||
// pack expansion trick: | |||
// generate array with zeros. Operator , express left lambda and return right |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-> an ellipsis applies insert_signatures to each signature, operator comma returns the rightmost argument, which is 0
}; | ||
|
||
// pack expansion trick: | ||
// generate array with zeros. Operator , express left lambda and return right |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
* @given state with one transaction | ||
* @when call erase by time, where batch will be already expired | ||
* @then checks that expired state contains batch and initial doesn't conitain | ||
* @given given a timepoint |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One "given" can be removed
Signed-off-by: Fedor Muratov <muratovfyodor@yandex.ru>
👍 |
SonarQube analysis reported 4 issues
|
### Description of the Change Rework MST with batches; Update tests and related methods ### Benefits MST works with batches ### Possible Drawbacks Some tests are disabled.
### Description of the Change Rework MST with batches; Update tests and related methods ### Benefits MST works with batches ### Possible Drawbacks Some tests are disabled.
### Description of the Change Rework MST with batches; Update tests and related methods ### Benefits MST works with batches ### Possible Drawbacks Some tests are disabled.
### Description of the Change Rework MST with batches; Update tests and related methods ### Benefits MST works with batches ### Possible Drawbacks Some tests are disabled.
Description of the Change
Rework MST with batches;
Update tests and related methods
Benefits
MST works with batches
Possible Drawbacks
Some tests are disabled.