This repository has been archived by the owner on Apr 17, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 297
MST: fixed expired incoming state logic #2211
Open
MBoldyrev
wants to merge
5
commits into
develop
Choose a base branch
from
fix/mst-expired-incoming-state
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0238768
fixed expired batches notification
MBoldyrev f74603f
added test
MBoldyrev fe6f365
Merge branch 'develop' into fix/mst-expired-incoming-state
8bd0f00
pr issues
MBoldyrev 34ddda2
Merge branch 'develop' into fix/mst-expired-incoming-state
MBoldyrev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,10 +86,12 @@ namespace iroha { | |
// -------------------| MstTransportNotification override |------------------- | ||
|
||
void FairMstProcessor::onNewState(const shared_model::crypto::PublicKey &from, | ||
ConstRefState new_state) { | ||
MstState new_state) { | ||
log_->info("Applying new state"); | ||
auto current_time = time_provider_->getCurrentTime(); | ||
|
||
// no need to add already expired batches to local state | ||
new_state.eraseExpired(current_time); | ||
auto state_update = storage_->apply(from, new_state); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems, there is missing |
||
// updated batches | ||
|
@@ -101,7 +103,8 @@ namespace iroha { | |
completedBatchesNotify(*state_update.completed_state_); | ||
|
||
// expired batches | ||
expiredBatchesNotify(storage_->getDiffState(from, current_time)); | ||
// not nesessary to do it right here, just use the occasion to clean storage | ||
expiredBatchesNotify(storage_->extractExpiredTransactions(current_time)); | ||
} | ||
|
||
// -----------------------------| private api |----------------------------- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -319,3 +319,30 @@ TEST_F(MstProcessorTest, emptyStatePropagation) { | |
another_peer}; | ||
propagation_subject.get_subscriber().on_next(peers); | ||
} | ||
|
||
/** | ||
* @given initialized mst processor with empty state | ||
* | ||
* @when received other peer's state containing an outdated batch | ||
* | ||
* @then check that transport was not invoked | ||
* @and queues are not pushed to | ||
* @and the batch does not get into our state | ||
*/ | ||
TEST_F(MstProcessorTest, receivedOutdatedState) { | ||
// ---------------------------------| then |---------------------------------- | ||
EXPECT_CALL(*transport, sendState(_, _)).Times(0); | ||
auto observers = initObservers(mst_processor, 0, 0, 0); | ||
|
||
// ---------------------------------| when |---------------------------------- | ||
shared_model::crypto::PublicKey another_peer_key("another_pubkey"); | ||
auto transported_state = MstState::empty(getTestLogger("MstState"), | ||
std::make_shared<TestCompleter>()); | ||
const auto expired_batch = makeTestBatch(txBuilder(1, time_before, 3)); | ||
transported_state += addSignaturesFromKeyPairs(expired_batch, 0, makeKey()); | ||
mst_processor->onNewState(another_peer_key, transported_state); | ||
|
||
// ---------------------------------| then |---------------------------------- | ||
EXPECT_FALSE(storage->batchInStorage(expired_batch)); | ||
check(observers); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, there could be another test which checks that expired transactions from new_state will be not propagated by the expired notifier. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
There is could be an explanation of why we throw batches from new_state