Skip to content

Commit e171f28

Browse files
authored
Merge pull request #1 from arcolife/devel
update master with latest
2 parents fc66f7c + 61cb4e1 commit e171f28

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+3215
-159
lines changed

doc/DEV.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
### Errors
2+
3+
Collection of sommon common errors while coding, for troubleshooting:
4+
5+
6+
#### byte-like objects or str required
7+
8+
1. `TypeError: a bytes-like object is required, not 'str'`
9+
10+
```
11+
TypeError: a bytes-like object is required, not 'str'
12+
DEBUG:pbft_complete_run.log:--> Trying client ('127.0.0.1..
13+
```
14+
15+
Your log file write mode was `wb` instead of `w`.
16+
17+
18+
2. `TypeError: key: expected bytes or bytearray, but got 'SigningKey'`
19+
20+
```
21+
File "/home/arcolife/workspace/projects/Truechain/forked/py-trueconsensus/trueconsensus/fastchain/pbft-py/node.py", line 878, in parse_request
22+
req = message.check(key,req)
23+
File "/home/arcolife/workspace/projects/Truechain/forked/py-trueconsensus/trueconsensus/fastchain/pbft-py/proto_message.py", line 40, in check
24+
s = (sig.verify(key, sig_recv, digest_recv) and digest == digest_recv)
25+
File "/home/arcolife/workspace/projects/Truechain/forked/py-trueconsensus/trueconsensus/fastchain/pbft-py/sig.py", line 25, in verify
26+
h = hmac.new(key, bytes, hashlib.sha256)
27+
File "/home/arcolife/workspace/projects/Truechain/forked/py-trueconsensus/trueconsensus/fastchain/pbft-py/venv/lib64/python3.6/hmac.py", line 144, in new
28+
return HMAC(key, msg, digestmod)
29+
File "/home/arcolife/workspace/projects/Truechain/forked/py-trueconsensus/trueconsensus/fastchain/pbft-py/venv/lib64/python3.6/hmac.py", line 42, in __init__
30+
raise TypeError("key: expected bytes or bytearray, but got %r" % type(key).__name__)
31+
TypeError: key: expected bytes or bytearray, but got 'SigningKey'
32+
DEBUG:pbft_complete_run.log:--> Trying client ('127.0.0.1', 49504) from server ID: 3
33+
```
34+
35+
Make the following changes:
36+
37+
```
38+
key = bytes(key.to_string())
39+
h = hmac.new(key, message, hashlib.sha256)
40+
```
41+
42+
3.

requirements.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
bitcoin==1.1.42
2+
docopt==0.6.2
3+
ecdsa==0.13
4+
pycrypto==2.6.1
5+
pykwalify==1.6.1
6+
PySocks==1.6.8
7+
python-dateutil==2.7.3
8+
PyYAML==3.12
9+
six==1.11.0

trueconsensus/__init__.py

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,3 @@
1-
#!/usr/bin/env python
2-
#
3-
# Copyright (c) 2018 TrueChain Foundation
4-
#
5-
# Licensed under the Apache License, Version 2.0 (the "License");
6-
# you may not use this file except in compliance with the License.
7-
# You may obtain a copy of the License at
8-
#
9-
# http://www.apache.org/licenses/LICENSE-2.0
10-
#
11-
# Unless required by applicable law or agreed to in writing, software
12-
# distributed under the License is distributed on an "AS IS" BASIS,
13-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14-
# See the License for the specific language governing permissions and
15-
# limitations under the License.
16-
17-
"""
18-
Relative package import structure
19-
"""
20-
21-
import os
22-
23-
try:
24-
# If a VERSION file exists, use it!
25-
version_file = os.path.join(os.path.dirname(__file__), 'VERSION')
26-
with open(version_file) as fh:
27-
__version__ = fh.read().strip()
28-
except NameError:
29-
__version__ = 'unknown (running code interactively?)'
30-
except IOError, ex:
31-
__version__ = "unknown (%s)" % ex
32-
33-
341
###########################################################
352
# PACKAGES
363
###########################################################
@@ -42,4 +9,5 @@
429
# they override the same names inadvertently imported
4310
# from a subpackage)
4411

45-
import snailchain, fastchain
12+
import trueconsensus.snailchain, \
13+
trueconsensus.fastchain

trueconsensus/engine.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,20 @@
1313
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
16+
17+
from snailchain import SnailChain
18+
from fastchain.bft import NodeBFT, \
19+
ViewChangeInit, \
20+
LedgerLog, \
21+
BFTcommittee, \
22+
SubProtoDailyBFT, \
23+
Mempools
24+
25+
26+
class DailyOffChainConsensus(object):
27+
def __init__(self):
28+
self.chain = []
29+
self._lambda = None
30+
31+
def preproess(self):
32+
pass

trueconsensus/fastchain/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
'''
2+
Package import structure
3+
'''
4+
5+
from fastchain.bft import *
6+
from fastchain.node import *
7+

trueconsensus/fastchain/bft.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@
2121
import random
2222
from db.backends.level import LevelDB
2323

24-
from logging import ledger
24+
# from logging import ledger
2525

26+
from fastchain.node import Node
2627
from collections import OrderedDict, \
28+
defaultdict, \
2729
namedtuple
2830

2931

@@ -48,7 +50,7 @@ def generate_txns(R, l):
4850
# return uuid.uuid4().hex
4951

5052

51-
class Node(object):
53+
class NodeBFT(Node):
5254
'''
5355
@types:
5456
committee member
@@ -81,9 +83,9 @@ def __init__(self):
8183
pass
8284

8385

84-
def LedgerLog(object):
85-
pass
86-
86+
class LedgerLog(object):
87+
def __init__(self):
88+
pass
8789

8890
class BFTcommittee(object):
8991
'''

trueconsensus/fastchain/ecdsa_sig.py

Lines changed: 0 additions & 118 deletions
This file was deleted.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import os
2+
# This Replica ID
3+
ID = 0
4+
5+
# Number of replicas
6+
N = 4
7+
8+
# Number of failures we can tolerate
9+
MAX_FAIL = 1
10+
11+
# REPLICA LIST
12+
# IP, port
13+
RL = []
14+
RL.append(("127.0.0.1", 8001))
15+
RL.append(("127.0.0.1", 8002))
16+
RL.append(("127.0.0.1", 8003))
17+
RL.append(("127.0.0.1", 8004))
18+
19+
client = (("127.0.0.1", 8101))
20+
21+
# KEY DIRECTORY
22+
KD = os.getcwd() + "/keys"
23+
print KD
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
*.pyc
2+
*log.txt
3+
*.out
4+
venv/
5+
__pycache__
6+
7+
google/
8+
9+
keys/
10+
11+
*_commits.txt
12+
tx*.txt
13+
bank*.txt
14+
log/
15+
*.dat

trueconsensus/fastchain/pbft-py/.idea/inspectionProfiles/profiles_settings.xml

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)