astreum 0.1.20__py3-none-any.whl → 0.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of astreum might be problematic. Click here for more details.

Files changed (41) hide show
  1. astreum/__init__.py +1 -2
  2. astreum/{node → _node}/relay/envelope.py +1 -1
  3. astreum/{node → _node}/relay/message.py +1 -1
  4. astreum/{node → _node}/storage/merkle.py +3 -3
  5. astreum/{node → _node}/storage/patricia.py +3 -3
  6. astreum/{node → _node}/storage/storage.py +2 -0
  7. astreum/{node → _node}/utils.py +1 -1
  8. astreum/{node → _node}/validation/account.py +3 -3
  9. astreum/{node → _node}/validation/transaction.py +3 -3
  10. astreum/lispeum/__init__.py +2 -0
  11. astreum/lispeum/parser.py +1 -1
  12. astreum/machine/environment.py +0 -25
  13. astreum/node.py +1021 -0
  14. astreum-0.2.0.dist-info/METADATA +144 -0
  15. astreum-0.2.0.dist-info/RECORD +57 -0
  16. {astreum-0.1.20.dist-info → astreum-0.2.0.dist-info}/WHEEL +1 -1
  17. astreum/utils/__init__.py +0 -0
  18. astreum-0.1.20.dist-info/METADATA +0 -90
  19. astreum-0.1.20.dist-info/RECORD +0 -57
  20. /astreum/{node → _node}/__init__.py +0 -0
  21. /astreum/{node → _node}/relay/__init__.py +0 -0
  22. /astreum/{node → _node}/relay/bucket.py +0 -0
  23. /astreum/{node → _node}/relay/peer.py +0 -0
  24. /astreum/{node → _node}/relay/route.py +0 -0
  25. /astreum/{node/crypto → _node/storage}/__init__.py +0 -0
  26. /astreum/{node → _node}/storage/utils.py +0 -0
  27. /astreum/{node/storage → _node/validation}/__init__.py +0 -0
  28. /astreum/{node/validation → _node/validation/_block}/__init__.py +0 -0
  29. /astreum/{node → _node}/validation/_block/create.py +0 -0
  30. /astreum/{node → _node}/validation/_block/model.py +0 -0
  31. /astreum/{node → _node}/validation/_block/validate.py +0 -0
  32. /astreum/{node → _node}/validation/block.py +0 -0
  33. /astreum/{node → _node}/validation/constants.py +0 -0
  34. /astreum/{node → _node}/validation/stake.py +0 -0
  35. /astreum/{node → _node}/validation/vdf.py +0 -0
  36. /astreum/{node/validation/_block → crypto}/__init__.py +0 -0
  37. /astreum/{node/crypto → crypto}/ed25519.py +0 -0
  38. /astreum/{node/crypto → crypto}/x25519.py +0 -0
  39. /astreum/{utils/bytes_format.py → format.py} +0 -0
  40. {astreum-0.1.20.dist-info → astreum-0.2.0.dist-info}/licenses/LICENSE +0 -0
  41. {astreum-0.1.20.dist-info → astreum-0.2.0.dist-info}/top_level.txt +0 -0
astreum/__init__.py CHANGED
@@ -1,2 +1 @@
1
- from .machine import AstreumMachine
2
- from .node import Node
1
+ from node import Node
@@ -34,7 +34,7 @@ import os
34
34
  from dataclasses import dataclass
35
35
  from typing import Optional, Tuple, List
36
36
  from .message import Message, Topic
37
- from astreum.utils.bytes_format import encode, decode
37
+ from astreum.format import encode, decode
38
38
  from ..utils import hash_data
39
39
 
40
40
  @dataclass
@@ -6,7 +6,7 @@ import struct
6
6
  from enum import IntEnum, auto
7
7
  from dataclasses import dataclass
8
8
  from typing import Optional
9
- from astreum.utils.bytes_format import encode, decode
9
+ from astreum.format import encode, decode
10
10
 
11
11
  class Topic(IntEnum):
12
12
  """
@@ -1,6 +1,6 @@
1
1
  import blake3
2
2
  from .storage import Storage
3
- from astreum.utils import bytes_format
3
+ from astreum import format
4
4
 
5
5
  class MerkleNode:
6
6
  def __init__(self, leaf: bool, data: bytes):
@@ -27,7 +27,7 @@ class MerkleNode:
27
27
  :param data: The serialized node data.
28
28
  :return: A new MerkleNode instance.
29
29
  """
30
- leaf_flag, node_data = bytes_format.decode(data)
30
+ leaf_flag, node_data = format.decode(data)
31
31
  return cls(True if leaf_flag == 1 else False, node_data)
32
32
 
33
33
  @classmethod
@@ -52,7 +52,7 @@ class MerkleNode:
52
52
 
53
53
  :return: The serialized bytes representing the node.
54
54
  """
55
- return bytes_format.encode([1 if self.leaf else 0, self.data])
55
+ return format.encode([1 if self.leaf else 0, self.data])
56
56
 
57
57
  def hash(self) -> bytes:
58
58
  """
@@ -1,7 +1,7 @@
1
1
  import blake3
2
2
  from typing import Optional, List
3
3
  from .storage import Storage
4
- import astreum.utils.bytes_format as bytes_format bytes_format.decode, bytes_format.encode
4
+ import astreum.format as format format.decode, format.encode
5
5
 
6
6
 
7
7
  def common_prefix_length(a: bytes, b: bytes) -> int:
@@ -35,7 +35,7 @@ class PatriciaNode:
35
35
  Expected format: [key, value, children]
36
36
  where children is a list of child node hashes (bytes).
37
37
  """
38
- decoded = bytes_format.decode(data)
38
+ decoded = format.decode(data)
39
39
  key, value, children = decoded
40
40
  return cls(key, value, children)
41
41
 
@@ -59,7 +59,7 @@ class PatriciaNode:
59
59
 
60
60
  Structure: [key, value, children]
61
61
  """
62
- return bytes_format.encode([self.key, self.value, self.children])
62
+ return format.encode([self.key, self.value, self.children])
63
63
 
64
64
  def hash(self) -> bytes:
65
65
  """
@@ -39,6 +39,8 @@ class Storage:
39
39
  self.pending_requests = {} # hash -> (start_time, event)
40
40
  self.request_lock = threading.Lock()
41
41
 
42
+
43
+
42
44
  def put(self, data_hash: bytes, data: bytes) -> bool:
43
45
  """Store data with its hash. Returns True if successful, False if space limit exceeded."""
44
46
  data_size = len(data)
@@ -4,7 +4,7 @@ Utility functions for the Astreum blockchain.
4
4
 
5
5
  import blake3
6
6
 
7
- def hash_data(data: bytes) -> bytes:
7
+ def blake3_hash(data: bytes) -> bytes:
8
8
  """
9
9
  Hash data using BLAKE3.
10
10
 
@@ -1,7 +1,7 @@
1
1
  from typing import Optional
2
2
  from ..storage.patricia import PatriciaTrie
3
3
 
4
- import astreum.utils.bytes_format as bytes_format
4
+ import astreum.format as format
5
5
  class Account:
6
6
  def __init__(self, public_key: bytes, balance: int, code: bytes, counter: int, data: bytes, secret_key: Optional[bytes] = None):
7
7
  """
@@ -30,7 +30,7 @@ class Account:
30
30
 
31
31
  The public_key (and optional secret_key) must be provided separately.
32
32
  """
33
- decoded = bytes_format.decode(data)
33
+ decoded = format.decode(data)
34
34
  balance, code, counter, account_data = decoded
35
35
  return cls(public_key, balance, code, counter, account_data, secret_key=secret_key)
36
36
 
@@ -40,7 +40,7 @@ class Account:
40
40
 
41
41
  Format: [balance, code, counter, data]
42
42
  """
43
- return bytes_format.encode([
43
+ return format.encode([
44
44
  self.balance,
45
45
  self.code,
46
46
  self.counter,
@@ -1,7 +1,7 @@
1
1
  from typing import Optional
2
2
  import time
3
3
  from .account import Account, get_account_from_storage
4
- import astreum.utils.bytes_format as bytes_format
4
+ import astreum.format as format
5
5
 
6
6
  class Transaction:
7
7
  def __init__(
@@ -36,7 +36,7 @@ class Transaction:
36
36
  Returns:
37
37
  Transaction object
38
38
  """
39
- decoded = bytes_format.decode(data)
39
+ decoded = format.decode(data)
40
40
  sender_public_key, recipient_public_key, amount, tx_data, counter, timestamp, signature = decoded
41
41
 
42
42
  sender_account = None
@@ -63,7 +63,7 @@ class Transaction:
63
63
 
64
64
  Format: [sender_hash, recipient_hash, amount, data, counter, timestamp, signature]
65
65
  """
66
- return bytes_format.encode([
66
+ return format.encode([
67
67
  self.sender.public_key,
68
68
  self.recipient.public_key,
69
69
  self.amount,
@@ -0,0 +1,2 @@
1
+ from parser import parse
2
+ from tokenizer import tokenize
astreum/lispeum/parser.py CHANGED
@@ -1,6 +1,6 @@
1
1
  from typing import List, Tuple
2
2
  from astreum.machine.error import ParseError
3
- from astreum.lispeum.expression import Expr
3
+ from astreum.node import Expr
4
4
 
5
5
 
6
6
  def parse(tokens: List[str]) -> Tuple[Expr, List[str]]:
@@ -2,28 +2,3 @@ from typing import Dict, Optional
2
2
  from astreum.lispeum.expression import Expr
3
3
 
4
4
 
5
- class Environment:
6
- def __init__(self, parent: 'Environment' = None, node: 'Node' = None):
7
- self.data: Dict[str, Expr] = {}
8
- self.parent = parent
9
- self.node = node
10
-
11
- def set(self, name: str, value: Expr):
12
- if self.node:
13
- self.node.post_global_storage(name, value)
14
- else:
15
- self.data[name] = value
16
-
17
- def get(self, name: str) -> Optional[Expr]:
18
- if self.node:
19
- return self.node.query_global_storage(name)
20
-
21
- if name in self.data:
22
- return self.data[name]
23
- elif self.parent:
24
- return self.parent.get(name)
25
- else:
26
- return None
27
-
28
- def __repr__(self):
29
- return f"Environment({self.data})"