-
Notifications
You must be signed in to change notification settings - Fork 377
ST-623 -- Init Commit multi-sig process #1325
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
df147fe
ST-623 -- Init Commit multi-sig process
6a0f792
ST-623 -- Making more tests, fixing bugs
693cb32
Add more unit tests
KitHat f71bc07
ST-623 -- Finish unit-tests
59fa9e0
Merge branch 'master' of github.com:hyperledger/indy-plenum
ad122a8
Fix order of fields
a276234
Fix order of fields
722c942
ST-623 -- Make fixture yield and fix
f62ce3f
ST-623 -- Fix Yield
cbecb24
ST-623 -- Fix some validation
3985050
ST-623 -- Add release validation test
f16dc42
ST-623 -- Fix some tests
9ad4f0f
ST-623 -- Fix flake8
1293fda
ST-623 -- Fix some tests
121e6b0
ST-623 -- Fix audit txn search
f5c4a52
ST-623 -- Fix audit txn search
b5cb01b
ST-623 -- Fix possible malicious node
645b812
Merge branch 'master' of github.com:hyperledger/indy-plenum
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 hidden or 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 hidden or 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 |
---|---|---|
|
@@ -4,11 +4,13 @@ | |
from crypto.bls.bls_bft import BlsBft | ||
from crypto.bls.bls_bft_replica import BlsBftReplica | ||
from crypto.bls.bls_multi_signature import MultiSignature, MultiSignatureValue | ||
from plenum.common.constants import DOMAIN_LEDGER_ID, BLS_PREFIX, POOL_LEDGER_ID | ||
from plenum.common.constants import DOMAIN_LEDGER_ID, BLS_PREFIX, POOL_LEDGER_ID, AUDIT_LEDGER_ID, TXN_PAYLOAD, \ | ||
TXN_PAYLOAD_DATA, AUDIT_TXN_LEDGER_ROOT, AUDIT_TXN_STATE_ROOT | ||
from plenum.common.messages.node_messages import PrePrepare, Prepare, Commit | ||
from plenum.common.metrics_collector import MetricsCollector, NullMetricsCollector, measure_time, MetricsName | ||
from plenum.common.types import f | ||
from plenum.common.util import compare_3PC_keys | ||
from plenum.server.database_manager import DatabaseManager | ||
from stp_core.common.log import getlogger | ||
|
||
logger = getlogger() | ||
|
@@ -19,10 +21,13 @@ def __init__(self, | |
node_id, | ||
bls_bft: BlsBft, | ||
is_master, | ||
database_manager: DatabaseManager, | ||
metrics: MetricsCollector = NullMetricsCollector()): | ||
super().__init__(bls_bft, is_master) | ||
self.node_id = node_id | ||
self._database_manager = database_manager | ||
self._signatures = {} | ||
self._all_signatures = {} | ||
self._bls_latest_multi_sig = None # MultiSignature | ||
self.state_root_serializer = state_roots_serializer | ||
self.metrics = metrics | ||
|
@@ -92,6 +97,36 @@ def update_commit(self, commit_params, pre_prepare: PrePrepare): | |
logger.debug("{}{} signed COMMIT {} for state {} with sig {}" | ||
.format(BLS_PREFIX, self, commit_params, state_root_hash, bls_signature)) | ||
commit_params.append(bls_signature) | ||
|
||
audit_ledger = self._database_manager.get_ledger(AUDIT_LEDGER_ID) | ||
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. Do we have unit tests for the new functionality? |
||
if audit_ledger is not None: | ||
last_audit_txn = audit_ledger.get_last_txn() | ||
res = {} | ||
payload_data = last_audit_txn[TXN_PAYLOAD][TXN_PAYLOAD_DATA] | ||
for ledger_id in payload_data[AUDIT_TXN_STATE_ROOT].keys(): | ||
params = [ | ||
pre_prepare.instId, | ||
pre_prepare.viewNo, | ||
pre_prepare.ppSeqNo, | ||
pre_prepare.ppTime, | ||
pre_prepare.reqIdr, | ||
pre_prepare.discarded, | ||
pre_prepare.digest, | ||
ledger_id, | ||
payload_data[AUDIT_TXN_STATE_ROOT].get(ledger_id), | ||
payload_data[AUDIT_TXN_LEDGER_ROOT].get(ledger_id), | ||
pre_prepare.sub_seq_no, | ||
pre_prepare.final, | ||
pre_prepare.poolStateRootHash, | ||
pre_prepare.auditTxnRootHash | ||
] | ||
|
||
fake_pp = PrePrepare(*params) | ||
bls_signature = self._sign_state(fake_pp) | ||
res[ledger_id] = bls_signature | ||
commit_params.append(None) # for plugin fields | ||
commit_params.append(res) | ||
|
||
return commit_params | ||
|
||
# ----PROCESS---- | ||
|
@@ -115,6 +150,18 @@ def process_commit(self, commit: Commit, sender): | |
self._signatures[key_3PC] = {} | ||
self._signatures[key_3PC][self.get_node_name(sender)] = commit.blsSig | ||
|
||
if f.BLS_SIGS.nm not in commit: | ||
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. Can it be that |
||
return | ||
if commit.blsSigs is None: | ||
return | ||
|
||
if key_3PC not in self._all_signatures: | ||
self._all_signatures[key_3PC] = {} | ||
for ledger_id in commit.blsSigs.keys(): | ||
if ledger_id not in self._all_signatures[key_3PC]: | ||
self._all_signatures[key_3PC][ledger_id] = {} | ||
self._all_signatures[key_3PC][ledger_id][self.get_node_name(sender)] = commit.blsSigs[ledger_id] | ||
ashcherbakov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
def process_order(self, key, quorums, pre_prepare): | ||
if not self._can_process_ledger(pre_prepare.ledgerId): | ||
return | ||
|
This file contains hidden or 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 hidden or 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 hidden or 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
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.
Do we really need
self._all_signatures
andself._signatures
? (self._all_bls_latest_multi_sigs
andself._bls_latest_multi_sig
)?Can we make
self._signatures
(self._bls_latest_multi_sig
) to be a special case inself._all_signatures
(self._all_bls_latest_multi_sigs
)?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.
I have thought about it. This way we will always need to fetch the correct ledger from
_all_signatures
according toPrePrepare
. On the other hand we have some code duplication -- but it is pretty obvious and we will remove it with the next release and there will be no problems.