astreum 0.2.22__py3-none-any.whl → 0.2.23__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.

astreum/models/block.py CHANGED
@@ -1,6 +1,10 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  from typing import List, Dict, Any, Optional, Union
4
+
5
+ from astreum.models.account import Account
6
+ from astreum.models.accounts import Accounts
7
+ from astreum.models.patricia import PatriciaTrie
4
8
  from ..crypto import ed25519
5
9
  from .merkle import MerkleTree
6
10
 
@@ -128,3 +132,39 @@ class Block:
128
132
  return True
129
133
  except Exception:
130
134
  return False
135
+
136
+ @classmethod
137
+ def genesis(cls, validator_addr: bytes) -> "Block":
138
+ # 1 . validator-stakes sub-trie
139
+ stake_trie = PatriciaTrie()
140
+ stake_trie.put(validator_addr, (1).to_bytes(32, "big"))
141
+ stake_root = stake_trie.root_hash
142
+
143
+ # 2 . build the two Account bodies
144
+ validator_acct = Account.create(balance=0, data=b"", nonce=0)
145
+ treasury_acct = Account.create(balance=1, data=stake_root, nonce=0)
146
+
147
+ # 3 . global Accounts structure
148
+ accts = Accounts()
149
+ accts.set_account(validator_addr, validator_acct)
150
+ accts.set_account(b"\x11" * 32, treasury_acct)
151
+ accounts_hash = accts.root_hash
152
+
153
+ # 4 . constant body fields for genesis
154
+ body_kwargs = dict(
155
+ number = 0,
156
+ prev_block_hash = b"\x00" * 32,
157
+ timestamp = 0,
158
+ accounts_hash = accounts_hash,
159
+ transactions_total_fees = 0,
160
+ transaction_limit = 0,
161
+ transactions_root_hash = b"\x00" * 32,
162
+ delay_difficulty = 0,
163
+ delay_output = b"",
164
+ delay_proof = b"",
165
+ validator_pk = validator_addr,
166
+ signature = b"",
167
+ )
168
+
169
+ # 5 . build and return the block
170
+ return cls.create(**body_kwargs)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: astreum
3
- Version: 0.2.22
3
+ Version: 0.2.23
4
4
  Summary: Python library to interact with the Astreum blockchain and its Lispeum virtual machine.
5
5
  Author-email: "Roy R. O. Okello" <roy@stelar.xyz>
6
6
  Project-URL: Homepage, https://github.com/astreum/lib
@@ -12,12 +12,12 @@ astreum/lispeum/tokenizer.py,sha256=J-I7MEd0r2ZoVqxvRPlu-Afe2ZdM0tKXXhf1R4SxYTo,
12
12
  astreum/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
13
  astreum/models/account.py,sha256=sHujGSwtV13rvOGJ5LZXuMrJ4F9XUdvyuWKz-zJ9lkE,2986
14
14
  astreum/models/accounts.py,sha256=aFSEWlq6zRf65-KGAdNGqEJyNVY3fpKhx8y1vU6sgSc,1164
15
- astreum/models/block.py,sha256=YIY3qLneFM7OooY29khLDEs3NIEA7y8VhlXitflkxTo,4564
15
+ astreum/models/block.py,sha256=3OyAAqw853aLnnWogYdkxOg_WXNEsfn2g8jrFEip2aY,6141
16
16
  astreum/models/merkle.py,sha256=merV3rx2iRfzvglV6gNusrJf7OMbcVV854T-DUWCC64,6733
17
17
  astreum/models/patricia.py,sha256=ohmXrcaz7Ae561tyC4u4iPOkQPkKr8N0IWJek4upFIg,13392
18
18
  astreum/models/transaction.py,sha256=yBarvRK2ybMAHHEQPZpubGO7gms4U9k093xQGNQHQ4Q,3043
19
- astreum-0.2.22.dist-info/licenses/LICENSE,sha256=gYBvRDP-cPLmTyJhvZ346QkrYW_eleke4Z2Yyyu43eQ,1089
20
- astreum-0.2.22.dist-info/METADATA,sha256=sjq4dOe1ozAw17evuGntKyahKDMfqQwcrcpp_b6QhK4,5478
21
- astreum-0.2.22.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
22
- astreum-0.2.22.dist-info/top_level.txt,sha256=1EG1GmkOk3NPmUA98FZNdKouhRyget-KiFiMk0i2Uz0,8
23
- astreum-0.2.22.dist-info/RECORD,,
19
+ astreum-0.2.23.dist-info/licenses/LICENSE,sha256=gYBvRDP-cPLmTyJhvZ346QkrYW_eleke4Z2Yyyu43eQ,1089
20
+ astreum-0.2.23.dist-info/METADATA,sha256=itKxfzkJrO8JcpMVCW3nDA_8NdtdndEj9zKJaoT5GGc,5478
21
+ astreum-0.2.23.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
22
+ astreum-0.2.23.dist-info/top_level.txt,sha256=1EG1GmkOk3NPmUA98FZNdKouhRyget-KiFiMk0i2Uz0,8
23
+ astreum-0.2.23.dist-info/RECORD,,