Skip to content

Commit

Permalink
Adds Binance L5 (#231)
Browse files Browse the repository at this point in the history
* Adds Binance L5
  • Loading branch information
deanshelton913 authored and Wingman4l7 committed Nov 5, 2019
1 parent 13e64b1 commit 64c25f4
Show file tree
Hide file tree
Showing 26 changed files with 1,087 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.1.1
4.2.0
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
# Changelog

## 4.1.1
## 4.2.0

- **Feature:**
- Add performance improvements when creating transactions and processing L1 blocks
- Add interchain support for binance
- **Packaging:**
- Update redisearch, boto3 dependencies
- Add bnb-tx, pycoin, and mnemonic dependencies for binance
- **Development:**
- Revert manual redisearch fixes with dependency fixes
- Change the way that transaction 404 stubbing is handled for pending transactions
- **Bugs:**
- Change L5 block redisearch insert to upsert to prevent an occasional edge-case error which could cause an L5 to get stuck

## 4.1.0

Expand Down
2 changes: 1 addition & 1 deletion docs/deployment/deploying.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Once the values are set, install the helm chart with:
```sh
helm repo add dragonchain https://dragonchain-charts.s3.amazonaws.com
helm repo update
helm upgrade --install my-dragonchain --values opensource-config.yaml --namespace dragonchain dragonchain/dragonchain-k8s --version 1.0.2
helm upgrade --install my-dragonchain --values opensource-config.yaml --namespace dragonchain dragonchain/dragonchain-k8s --version 1.0.3
```

If you need to change any values AFTER the helm chart has already been
Expand Down
6 changes: 3 additions & 3 deletions dragonchain/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,11 @@ class SanityCheckFailure(DragonchainException):
"""Exception raised when sanity check fails"""


class RPCError(DragonchainException):
"""Exception raise when RPC has an error"""
class InterchainConnectionError(DragonchainException):
"""Exception raise when RPC / API call has an error"""


class RPCTransactionNotFound(DragonchainException):
class TransactionNotFound(DragonchainException):
"""Exception raised when a transaction is not found on an interchain network"""


Expand Down
11 changes: 11 additions & 0 deletions dragonchain/lib/crypto.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,18 @@ def encrypt_message(encryption_type: SupportedEncryption, priv_key: Union["Priva
sig_bytes = priv_key.ecdsa_serialize(priv_key.ecdsa_signature_normalize(priv_key.ecdsa_sign(msg=message_bytes, raw=True))[1])
else:
raise NotImplementedError("Unsupported encryption type")
return base64.b64encode(sig_bytes).decode("ascii")


def encrypt_secp256k1_message_compact(priv_key: "PrivateKey", message_bytes: bytes) -> str:
"""Encrypt a 32byte message (typically a hash, to use as a signature) (in its compact form)
Args:
priv_key: private key object of encryption type secp256k1
message_bytes: 32 byte python bytes object to encrypt
Returns:
Base 64 encoded signature string
"""
sig_bytes = priv_key.ecdsa_serialize_compact(priv_key.ecdsa_signature_normalize(priv_key.ecdsa_sign(msg=message_bytes, raw=True))[1])
return base64.b64encode(sig_bytes).decode("ascii")


Expand Down
6 changes: 6 additions & 0 deletions dragonchain/lib/crypto_utest.py
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,12 @@ def test_generic_signature(self):
sig = crypto.make_generic_signature(secp256k1, sha256, key, content)
self.assertTrue(crypto.check_generic_signature(secp256k1, sha256, key.pubkey, content, b64decode(sig)))

def test_encrypt_secp256k1_message_compact(self):
content = b"Ndj\x8e`tH\x06\x9f\xe2=\xb7\xc0\x85K\xcf4{;,Wn\x7fi\xba=A\x1b\xee<d\xbb"
encrypted = crypto.encrypt_secp256k1_message_compact(key, content)
expected_result = "ozzVHgADaCfxa2jO+nfwmpeaw836dKutXvtOVngkS6U2kimcFC3JRng4Dta0d+JMOSbEhZ8dX59epnaQmxrNHQ=="
self.assertEqual(encrypted, expected_result)

def test_unsupported_crypto(self):
l1block = make_l1_block()
l1block.proof = "sig="
Expand Down
7 changes: 7 additions & 0 deletions dragonchain/lib/dao/interchain_dao.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from dragonchain import exceptions
from dragonchain.lib.dto import eth
from dragonchain.lib.dto import btc
from dragonchain.lib.dto import bnb
from dragonchain.lib.interfaces import storage

if TYPE_CHECKING:
Expand All @@ -43,6 +44,8 @@ def does_interchain_exist(blockchain: str, name: str) -> bool:
return storage.does_object_exist(f"{FOLDER}/bitcoin/{name}")
elif blockchain == "ethereum":
return storage.does_object_exist(f"{FOLDER}/ethereum/{name}")
elif blockchain == "binance":
return storage.does_object_exist(f"{FOLDER}/binance/{name}")
else:
return False

Expand All @@ -59,6 +62,8 @@ def get_interchain_client(blockchain: str, name: str) -> "model.InterchainModel"
return btc.new_from_at_rest(storage.get_json_from_object(f"{FOLDER}/bitcoin/{name}"))
elif blockchain == "ethereum":
return eth.new_from_at_rest(storage.get_json_from_object(f"{FOLDER}/ethereum/{name}"))
elif blockchain == "binance":
return bnb.new_from_at_rest(storage.get_json_from_object(f"{FOLDER}/binance/{name}"))
else:
raise exceptions.NotFound(f"Blockchain network {blockchain} is not supported")

Expand All @@ -75,6 +80,8 @@ def list_interchain_clients(blockchain: str) -> List["model.InterchainModel"]:
from_rest_function = btc.new_from_at_rest
elif blockchain == "ethereum":
from_rest_function = eth.new_from_at_rest
elif blockchain == "binance":
from_rest_function = bnb.new_from_at_rest
else:
raise exceptions.NotFound(f"Blockchain network {blockchain} is not supported")

Expand Down

0 comments on commit 64c25f4

Please sign in to comment.