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

[INDY-1983] Tracking PP first validation time to check their obsolescences #1155

Merged

Conversation

andkononykhin
Copy link
Contributor

No description provided.

Signed-off-by: Andrey Kononykhin <andkononykhin@gmail.com>
Signed-off-by: Andrey Kononykhin <andkononykhin@gmail.com>
plenum/server/replica.py Outdated Show resolved Hide resolved
@@ -1049,11 +1057,17 @@ def process_three_phase_msg(self, msg: ThreePhaseMsg, sender: str):
"""
sender = self.generateName(sender, self.instId)

pp_key = (msg, sender) if isinstance(msg, PrePrepare) else None
if pp_key and (pp_key not in self.pre_prepare_tss):
self.pre_prepare_tss[pp_key] = self.utc_epoch
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's better to use self.get_time_for_3pc_batch for better unit tests

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

plenum/server/replica.py Outdated Show resolved Hide resolved
@@ -2650,7 +2672,7 @@ def process_requested_prepare(self, prepare: Prepare, sender: str):
def process_requested_commit(self, commit: Commit, sender: str):
return self._process_requested_three_phase_msg(commit, sender, self.requested_commits)

def is_pre_prepare_time_correct(self, pp: PrePrepare) -> bool:
def is_pre_prepare_time_correct(self, pp: PrePrepare, sender: str) -> bool:
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be great to cover this by unit tests. See, for example, test_replica_freshness.py

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Signed-off-by: Andrey Kononykhin <andkononykhin@gmail.com>
Signed-off-by: Andrey Kononykhin <andkononykhin@gmail.com>
…-1983-ts-container-for-pp

Signed-off-by: Andrey Kononykhin <andkononykhin@gmail.com>
Signed-off-by: Andrey Kononykhin <andkononykhin@gmail.com>
Signed-off-by: Andrey Kononykhin <andkononykhin@gmail.com>
Signed-off-by: Andrey Kononykhin <andkononykhin@gmail.com>
Signed-off-by: Andrey Kononykhin <andkononykhin@gmail.com>
Signed-off-by: Andrey Kononykhin <andkononykhin@gmail.com>
Signed-off-by: Andrey Kononykhin <andkononykhin@gmail.com>
plenum/server/replica.py Outdated Show resolved Hide resolved
plenum/server/replica.py Outdated Show resolved Hide resolved
@@ -165,6 +167,16 @@ class PrePrepare(MessageBase):
)
typename = PREPREPARE

def _post_process(self, input_as_dict: Dict) -> Dict:
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, to make PrePrepare hashable

# Dictionary:
# key: Tuple[pp.viewNo, pp.seqNo]
# value: Dict[PrePrepare, Tuple[sender, timestamp]]
self.pre_prepare_tss = defaultdict(dict)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need to have a dict of dict and store pre-prepares there?
I think just a simple Dict[(pp.viewNo, pp.seqNo), timestamp] is enough, isn't it?
If this is because of duplicate PrePrepares for the same 3PC key, then this is invalid PrePrepare, which is validated with PP_CHECK_DUPLICATE raised.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Dict[(pp.viewNo, pp.seqNo), timestamp] won't work since:

  • the same PrePrepare might come multiple times (e.g. for PP that includes not finalized requests, or missed previous PP or with bad timestamps), but we need to set timestamp only first time
  • (pp.viewNo, pp.seqNo) might be the same for multiple different PPs (different senders, or single malicious one)


# Now delayed 3PC messages reach lagging node, so any transactions missed during
# catch up can be ordered, ensure that all nodes will have same data after that
ensure_all_nodes_have_same_data(looper, txnPoolNodeSet)
Copy link
Contributor

Choose a reason for hiding this comment

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

We assume that all PPs will be rejected for the lagging node, don't we? If so, how the lagging node may have the same data?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

By requesting PP missed for Commits/Prepares

Signed-off-by: Andrey Kononykhin <andkononykhin@gmail.com>
Signed-off-by: Andrey Kononykhin <andkononykhin@gmail.com>
Signed-off-by: Andrey Kononykhin <andkononykhin@gmail.com>
Signed-off-by: Andrey Kononykhin <andkononykhin@gmail.com>
Signed-off-by: Andrey Kononykhin <andkononykhin@gmail.com>
Signed-off-by: Andrey Kononykhin <andkononykhin@gmail.com>
Signed-off-by: Andrey Kononykhin <andkononykhin@gmail.com>
_fields = {}


class FakePrePrepare(FakeMessageBase, PrePrepare):
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need FakePrePrepare here? Why don't use just PrePrepare?

tconf.ACCEPTABLE_DEVIATION_PREPREPARE_SECS = old_value


# TODO INDY-2047: this test should actually fail once the bug is fixed
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the test will fail after INDY-2047 is fixed?

Signed-off-by: Andrey Kononykhin <andkononykhin@gmail.com>
Signed-off-by: Andrey Kononykhin <andkononykhin@gmail.com>
…-1983-ts-container-for-pp

Signed-off-by: Andrey Kononykhin <andkononykhin@gmail.com>
@ashcherbakov ashcherbakov merged commit 54d2bd3 into hyperledger:master Apr 11, 2019
@andkononykhin andkononykhin deleted the INDY-1983-ts-container-for-pp branch April 11, 2019 10:13
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.

None yet

2 participants