Skip to content

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 18 commits into from
Sep 13, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions plenum/bls/bls_bft_replica_plenum.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
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, AUDIT_LEDGER_ID, TXN_PAYLOAD, \
TXN_PAYLOAD_DATA, AUDIT_TXN_LEDGER_ROOT, AUDIT_TXN_STATE_ROOT
TXN_PAYLOAD_DATA, AUDIT_TXN_LEDGER_ROOT, AUDIT_TXN_STATE_ROOT, AUDIT_TXN_PP_SEQ_NO
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
Expand Down Expand Up @@ -62,7 +62,7 @@ def validate_prepare(self, prepare: Prepare, sender):
@measure_time(MetricsName.BLS_VALIDATE_COMMIT_TIME)
def validate_commit(self, commit: Commit, sender, pre_prepare: PrePrepare):
if f.BLS_SIGS.nm in commit:
audit_txn = self._get_correct_audit_transaction(pre_prepare.ledgerId, pre_prepare.stateRootHash)
audit_txn = self._get_correct_audit_transaction(pre_prepare)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we check that audit_txn contains the same number of changes (length of AUDIT_TXN_STATE_ROOT) as blsSigs? Otherwise a KeyError may be raised here.

if audit_txn:
audit_payload = audit_txn[TXN_PAYLOAD][TXN_PAYLOAD_DATA]
for lid, sig in commit.blsSigs.items():
Expand Down Expand Up @@ -121,7 +121,7 @@ def update_commit(self, commit_params, pre_prepare: PrePrepare):
.format(BLS_PREFIX, self, commit_params, state_root_hash, bls_signature))
commit_params.append(bls_signature)

last_audit_txn = self._get_correct_audit_transaction(pre_prepare.ledgerId, pre_prepare.stateRootHash)
last_audit_txn = self._get_correct_audit_transaction(pre_prepare)
if last_audit_txn:
res = {}
payload_data = last_audit_txn[TXN_PAYLOAD][TXN_PAYLOAD_DATA]
Expand Down Expand Up @@ -302,7 +302,7 @@ def _calculate_all_multi_sigs(self, key_3PC, pre_prepare) -> Optional[list]:
if sigs_for_request:
for lid in sigs_for_request:
sig = sigs_for_request[lid]
audit_txn = self._get_correct_audit_transaction(pre_prepare.ledgerId, pre_prepare.stateRootHash)
audit_txn = self._get_correct_audit_transaction(pre_prepare)
if audit_txn:
audit_payload = audit_txn[TXN_PAYLOAD][TXN_PAYLOAD_DATA]
fake_pp = BlsBftReplicaPlenum. \
Expand Down Expand Up @@ -364,7 +364,7 @@ def _save_multi_sig_shared(self, pre_prepare: PrePrepare):
multi_sig.value.state_root_hash))
# TODO: support multiple multi-sigs for multiple previous batches

def _get_correct_audit_transaction(self, lid, state_root_hash):
def _get_correct_audit_transaction(self, pp: PrePrepare):
ledger = self._database_manager.get_ledger(AUDIT_LEDGER_ID)
if ledger is None:
return None
Expand All @@ -373,7 +373,7 @@ def _get_correct_audit_transaction(self, lid, state_root_hash):
txn = ledger.get_by_seq_no_uncommitted(curSeqNo)
if txn:
payload = txn[TXN_PAYLOAD][TXN_PAYLOAD_DATA]
if (lid in payload[AUDIT_TXN_STATE_ROOT]) and (payload[AUDIT_TXN_STATE_ROOT][lid] == state_root_hash):
if pp.ppSeqNo == payload[AUDIT_TXN_PP_SEQ_NO]:
return txn
return None

Expand Down