Skip to content

Master #56

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 2 commits into from
Sep 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!groovy

// TODO remove after shared libs refactoring
@Library('SovrinHelpers') _

def name = 'indy-plenum'
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ Plenum.
### Installing Plenum

```
pip install plenum
pip install indy-plenum
```

From here, you can play with the command-line interface (see the [tutorial](https://github.com/evernym/plenum/wiki))...
From here, you can play with the command-line interface (see the [tutorial](https://github.com/hyperledger/indy-plenum/wiki))...

Note: For Windows, we recommended using either [cmder](http://cmder.net/) or [conemu](https://conemu.github.io/).

Expand All @@ -35,12 +35,12 @@ plenum
...or run the tests.

```
git clone https://github.com/evernym/plenum.git
cd plenum
git clone https://github.com/hyperledger/indy-plenum.git
cd indy-plenum
python -m plenum.test
```

**Details about the protocol, including a great tutorial, can be found on the [wiki](https://github.com/evernym/plenum/wiki).**
**Details about the protocol, including a great tutorial, can be found on the [wiki](https://github.com/hyperledger/indy-plenum/wiki).**

### Installing python 3.5 and libsodium:

Expand Down
18 changes: 9 additions & 9 deletions ci/ubuntu.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
FROM ubuntu:16.04

ARG uid=1000
ARG user=indy

# Install environment
RUN apt-get update -y
RUN apt-get install -y \
RUN apt-get update -y && apt-get install -y \
git \
wget \
python3.5 \
Expand All @@ -16,13 +16,13 @@ RUN pip3 install -U \
pip \
setuptools \
virtualenv
RUN useradd -ms /bin/bash -u $uid sovrin
USER sovrin
RUN virtualenv -p python3.5 /home/sovrin/test
RUN useradd -ms /bin/bash -u $uid $user
USER $user
RUN virtualenv -p python3.5 /home/$user/test
USER root
RUN ln -sf /home/sovrin/test/bin/python /usr/local/bin/python
RUN ln -sf /home/sovrin/test/bin/pip /usr/local/bin/pip
USER sovrin
RUN ln -sf /home/$user/test/bin/python /usr/local/bin/python
RUN ln -sf /home/$user/test/bin/pip /usr/local/bin/pip
USER $user
# TODO: Automate dependency collection
RUN pip install jsonpickle \
ujson \
Expand All @@ -46,4 +46,4 @@ RUN pip install jsonpickle \
psutil \
intervaltree \
pytest-xdist
WORKDIR /home/sovrin
WORKDIR /home/$user
2 changes: 1 addition & 1 deletion ci/windows.dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM microsoft/windowsservercore

LABEL Description="plenum" Vendor="Evernym"
LABEL Description="indy-plenum" Vendor="Hyperledger"

# Install environment

Expand Down
4 changes: 2 additions & 2 deletions data/pool_transactions_sandbox_genesis
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{"dest":"3StSG7YV2Em2Wejf9dA1dNZ9BtZLiUUdm3yJgCS4M8eK","data":{"services":["VALIDATOR"],"client_port":9722,"node_ip":"52.33.22.91","alias":"EvernymV1","client_ip":"52.33.22.91","node_port":9721},"type":"0","txnId":"d4735e3a265e16eee03f59718b9b5d03019c07d8b6c51f90da3a666eec13ab35","identifier":"5rArie7XKukPCaEwq5XGQJnM9Fc5aZE3M9HAPVfMU2xC"}
{"dest":"13qfUHjTDh3TdRHau93LtkLynwNJnLGoRGh9HQxHuiLs","data":{"services":["VALIDATOR"],"client_port":9724,"node_ip":"52.38.24.189","alias":"EvernymV2","client_ip":"52.38.24.189","node_port":9723},"type":"0","txnId":"4e07408562bedb8b60ce05c1decfe3ad16b72230967de01f640b7e4729b49fce","identifier":"2btLJAAb1S3x6hZYdVyAePjqtQYi2ZBSRGy4569RZu8h"}
{"dest":"3StSG7YV2Em2Wejf9dA1dNZ9BtZLiUUdm3yJgCS4M8eK","data":{"services":["VALIDATOR"],"client_port":9722,"node_ip":"52.33.22.91","alias":"IndyV1","client_ip":"52.33.22.91","node_port":9721},"type":"0","txnId":"d4735e3a265e16eee03f59718b9b5d03019c07d8b6c51f90da3a666eec13ab35","identifier":"5rArie7XKukPCaEwq5XGQJnM9Fc5aZE3M9HAPVfMU2xC"}
{"dest":"13qfUHjTDh3TdRHau93LtkLynwNJnLGoRGh9HQxHuiLs","data":{"services":["VALIDATOR"],"client_port":9724,"node_ip":"52.38.24.189","alias":"IndyV2","client_ip":"52.38.24.189","node_port":9723},"type":"0","txnId":"4e07408562bedb8b60ce05c1decfe3ad16b72230967de01f640b7e4729b49fce","identifier":"2btLJAAb1S3x6hZYdVyAePjqtQYi2ZBSRGy4569RZu8h"}
{"dest":"BkJAXQsFYsHtqgbMUYSVQ8n3okRvyPfozwWcn4gV538Z","data":{"services":["VALIDATOR"],"client_port":9730,"node_ip":"34.200.79.65","alias":"RespectNetwork","client_ip":"34.200.79.65","node_port":9729},"type":"0","txnId":"ef2d127de37b942baad06145e54b0c619a1f22327b2ebbcfbec78f5564afe39e","identifier":"4AdS22kC7xzb4bcqg9JATuCfAMNcQYcZa1u5eWzs6cSJ"}
{"dest":"DNJdyetPD8B6Xsr58PKHynBtEWE2NrMAdnxSMdtgbFER","data":{"services":["VALIDATOR"],"client_port":9747,"node_ip":"52.56.74.57","alias":"BULLDOG","client_ip":"52.56.74.57","node_port":9746},"type":"0","txnId":"ef2d127de37b942baad06145e54b0c619a1f22327b2ebbcfbec78f5564afe3A2","identifier":"6hbecbh36EMK6yAi5NZ9bLZEuRsWFt6qLa2SyMQGXs7H"}
5 changes: 2 additions & 3 deletions plenum/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ class Cli:
name = 'plenum'
properName = 'Plenum'
fullName = 'Plenum protocol'
githubUrl = 'https://github.com/evernym/plenum'

NodeClass = Node
ClientClass = Client
Expand Down Expand Up @@ -901,11 +900,11 @@ def isOkToRunNodeDependentCommands(self):
if not self.withNode:
self.print("This command is only available if you start "
"this cli with command line argument --with-node "
"(and it assumes you have installed sovrin-node "
"(and it assumes you have installed indy-node "
"dependency)")
return False
if not self.NodeClass:
self.print("This command requires sovrin-node dependency, "
self.print("This command requires indy-node dependency, "
"please install it and then resume.")
return False

Expand Down
2 changes: 1 addition & 1 deletion plenum/cli/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def __str__(self):
usage="use wallet <name|absolute-wallet-file-path>",
examples=[
"use wallet mywallet",
"use wallet /home/ubuntu/.sovrin/wallets/test/mywallet.wallet"])
"use wallet /home/ubuntu/.indy/wallets/test/mywallet.wallet"])

saveWalletCmd = Command(
id="save wallet",
Expand Down
2 changes: 1 addition & 1 deletion plenum/common/script_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ def changeHA(looper, config, nodeName, nodeSeed, newNodeHA,
stewardWallet = Wallet(stewardName)
stewardWallet.addIdentifier(signer=stewardSigner)

# prepare client to submit change ha request to sovrin
# prepare client to submit change ha request
_, randomClientPort = genHa()
client = Client(stewardName,
ha=('0.0.0.0', randomClientPort), config=config)
Expand Down
2 changes: 1 addition & 1 deletion plenum/common/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from stp_core.network.exceptions import \
InvalidEndpointIpAddress, InvalidEndpointPort

# Do not remove the next import until imports in sovrin are fixed
# TODO Do not remove the next import until imports in indy are fixed
from stp_core.common.util import adict


Expand Down
2 changes: 1 addition & 1 deletion plenum/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@

# OPTIONS RELATED TO TESTS

# todo test 60sec after https://evernym.atlassian.net/browse/SOV-995 closed
# TODO test 60sec
TestRunningTimeLimitSec = 100

# Expected time for one stack to get connected to another
Expand Down
95 changes: 53 additions & 42 deletions plenum/server/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -1736,8 +1736,6 @@ def processRequest(self, request: Request, frm: str):
else:
if not self.isProcessingReq(*request.key):
self.startedProcessingReq(*request.key, frm)
# If not already got the propagate request(PROPAGATE) for the
# corresponding client request(REQUEST)
self.recordAndPropagate(request, frm)
self.send_ack_to_client(request.key, frm)

Expand Down Expand Up @@ -1767,7 +1765,7 @@ def processPropagate(self, msg: Propagate, frm):
# Since some propagates might not include the client name
self.set_sender_for_req(*request.key, clientName)

self.requests.addPropagate(request, frm)
self.requests.add_propagate(request, frm)

self.propagate(request, clientName)
self.tryForwarding(request)
Expand Down Expand Up @@ -1822,47 +1820,58 @@ def handle_get_txn_req(self, request: Request, frm: str):

def processOrdered(self, ordered: Ordered):
"""
Process and orderedRequest.
Execute ordered request

Execute client request with retries if client request hasn't yet reached
this node but corresponding PROPAGATE, PRE-PREPARE, PREPARE and
COMMIT request did

:param ordered: an orderedRequest
:param retryNo: the retry number used in recursion
:return: True if successful, None otherwise
:param ordered: an ordered request
:return: whether executed
"""

inst_id, view_no, req_idrs, pp_seq_no, pp_time, ledger_id, \
state_root, txn_root = tuple(ordered)
if ordered.instId >= self.instances.count:
logger.warning('{} got ordered request for instance {} which '
'does not exist'.format(self, ordered.instId))
return False

# Only the request ordered by master protocol instance are executed by
# the client
if inst_id == self.instances.masterId:
reqs = [self.requests[i, r].finalised for (i, r) in req_idrs if (
i, r) in self.requests and self.requests[i, r].finalised]
if len(reqs) == len(req_idrs):
logger.debug(
"{} executing Ordered batch {} {} of {} requests". format(
self.name, view_no, pp_seq_no, len(req_idrs)))
self.executeBatch(view_no, pp_seq_no, pp_time, reqs, ledger_id,
state_root, txn_root)
r = True
else:
logger.info('{} did not find {} finalized requests, but '
'still ordered'.format(self,
len(req_idrs) - len(reqs)))
return None
else:
logger.trace("{} got ordered requests from backup replica {}".
format(self, inst_id))
r = False
if inst_id < self.instances.count:
self.monitor.requestOrdered(req_idrs, inst_id, byMaster=r)
else:
logger.debug('{} got ordered request for instance {} which '
'does not exist'.format(self, inst_id))
return r
if ordered.instId != self.instances.masterId:
# Requests from backup replicas are not executed
logger.trace("{} got ordered requests from backup replica {}"
.format(self, ordered.instId))
self.monitor.requestOrdered(ordered.reqIdr,
ordered.instId,
byMaster=False)
return False

logger.trace("{} got ordered requests from master replica"
.format(self))
requests = [self.requests[request_id].finalised
for request_id in ordered.reqIdr
if request_id in self.requests and
self.requests[request_id].finalised]

if len(requests) != len(ordered.reqIdr):
logger.warning('{} did not find {} finalized '
'requests, but still ordered'
.format(self, len(ordered.reqIdr) - len(requests)))
return False

logger.debug("{} executing Ordered batch {} {} of {} requests"
.format(self.name,
ordered.viewNo,
ordered.ppSeqNo,
len(ordered.reqIdr)))

self.executeBatch(ordered.viewNo,
ordered.ppSeqNo,
ordered.ppTime,
requests,
ordered.ledgerId,
ordered.stateRootHash,
ordered.txnRootHash)

self.monitor.requestOrdered(ordered.reqIdr,
ordered.instId,
byMaster=True)

return True

def force_process_ordered(self):
"""
Expand Down Expand Up @@ -2283,6 +2292,8 @@ def executeBatch(self, view_no, pp_seq_no: int, pp_time: float,
if committedTxns:
# TODO is it possible to get len(committedTxns) != len(reqs)
# someday
for request in reqs:
self.requests.mark_as_executed(request)
logger.info(
"{} committed batch request, view no {}, ppSeqNo {}, "
"ledger {}, state root {}, txn root {}, requests: {}".format(
Expand Down Expand Up @@ -2618,8 +2629,8 @@ def sendToNodes(self, msg: Any, names: Iterable[str]=None):
def getReplyFromLedger(self, ledger, request=None, seq_no=None):
# DoS attack vector, client requesting already processed request id
# results in iterating over ledger (or its subset)
seq_no = seq_no if seq_no else self.seqNoDB.get(
request.identifier, request.reqId)
seq_no = seq_no if seq_no else \
self.seqNoDB.get(request.identifier, request.reqId)
if seq_no:
txn = ledger.getBySeqNo(int(seq_no))
if txn:
Expand Down
2 changes: 1 addition & 1 deletion plenum/server/notifier_plugin_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@


class PluginManager:
prefix = 'sovrinnotifier'
prefix = 'indynotifier'
__instance = None

def __new__(cls):
Expand Down
Loading