Skip to content
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

Utilize HDF5 for state #471

Open
wants to merge 76 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
d2781e0
file queue added
StuartFarmer Apr 26, 2021
3bc90a6
request body
StuartFarmer Apr 26, 2021
277082b
import
StuartFarmer Apr 26, 2021
1010739
updated file q
StuartFarmer Apr 26, 2021
baaafeb
log
StuartFarmer Apr 26, 2021
a86dd66
logs
StuartFarmer Apr 26, 2021
9de5502
decode
StuartFarmer Apr 26, 2021
4625077
no webserver actually
StuartFarmer Apr 26, 2021
87ec8b5
webserver arg parsing
StuartFarmer Apr 26, 2021
b142da1
parse
StuartFarmer Apr 26, 2021
28e2827
key
StuartFarmer Apr 26, 2021
a3a9e4c
complete
StuartFarmer Apr 26, 2021
a306a70
webserver again
StuartFarmer Apr 26, 2021
b347032
port
StuartFarmer Apr 27, 2021
74480e1
parser
StuartFarmer Apr 27, 2021
55c3182
bytes
StuartFarmer Apr 27, 2021
8efdeb9
non decode
StuartFarmer Apr 27, 2021
ac729ac
file system nonces and blocks
StuartFarmer Apr 28, 2021
e91711f
clean up
StuartFarmer Apr 28, 2021
f75cb55
storage home and migration start
StuartFarmer Apr 28, 2021
5bc7c75
commit
StuartFarmer Apr 28, 2021
56de3b8
migration
StuartFarmer Apr 28, 2021
19daa68
const
StuartFarmer Apr 28, 2021
7d85134
file
StuartFarmer Apr 28, 2021
f32c0dd
fs driver
StuartFarmer Apr 28, 2021
b7c3953
pass current
StuartFarmer Apr 28, 2021
d43b871
no hang
StuartFarmer Apr 28, 2021
b6b1c44
not none
StuartFarmer Apr 28, 2021
07a850e
lmdb
StuartFarmer Apr 30, 2021
3b70ebd
better block storage
StuartFarmer May 1, 2021
b9fb141
cleaner
StuartFarmer May 1, 2021
a46bc03
encoding
StuartFarmer May 1, 2021
3e85ca0
fixed
StuartFarmer May 1, 2021
ef66275
rsync conf
StuartFarmer May 3, 2021
442d791
rsync conf
StuartFarmer May 3, 2021
297b6e4
another rsync conf
StuartFarmer May 4, 2021
1545e48
ordering
StuartFarmer May 4, 2021
170f77b
webserver fixes pt 1
StuartFarmer May 4, 2021
73fab6b
encodee
StuartFarmer May 4, 2021
982808b
webserver fix pt 2
StuartFarmer May 4, 2021
ee8dada
nonce fix
StuartFarmer May 4, 2021
41dffeb
log
StuartFarmer May 4, 2021
3618c3d
nonce issue
StuartFarmer May 4, 2021
a59eccb
log
StuartFarmer May 4, 2021
8a9ee4e
nonce
StuartFarmer May 4, 2021
ee5c1bb
log
StuartFarmer May 4, 2021
575334b
nonsense
StuartFarmer May 4, 2021
c3d7744
logs
StuartFarmer May 4, 2021
8119242
fileq change
StuartFarmer May 4, 2021
90d5019
write block error
StuartFarmer May 4, 2021
c339455
log
StuartFarmer May 4, 2021
60a38b1
log2
StuartFarmer May 4, 2021
6fb25ee
location change
StuartFarmer May 4, 2021
12be592
fix
StuartFarmer May 4, 2021
2c59b69
copy
StuartFarmer May 4, 2021
669dbbe
clear pending
StuartFarmer May 4, 2021
6652b83
new block
StuartFarmer May 5, 2021
84e40ef
remove logs
StuartFarmer May 5, 2021
c9d2e5f
subblock idx fix
StuartFarmer May 5, 2021
378e498
fix
StuartFarmer May 5, 2021
be8e99d
decoder
StuartFarmer May 6, 2021
804e25b
webserver fix
StuartFarmer May 9, 2021
7cfe15b
pending tx
StuartFarmer May 14, 2021
f1f011a
Merge branch 'dev-nodes' into dev-filebased-system
nsmkhn Feb 1, 2022
4a88837
use FSDriver
nsmkhn Feb 11, 2022
d0b7b0e
fix encoded_block is not defined
nsmkhn Feb 12, 2022
47adb98
seed genesis contracts when running migration
nsmkhn Feb 14, 2022
d19d4fe
skip update state for now
nsmkhn Feb 16, 2022
bbd91a7
hdf5 poc base
nsmkhn Feb 23, 2022
901c222
add update latest block hash & height
nsmkhn Feb 23, 2022
41b4d90
revert change key names
nsmkhn Feb 23, 2022
46f4679
update key format according to new fs storage driver
nsmkhn Feb 28, 2022
56b7af0
prepend non contract keys with underscores
nsmkhn Mar 2, 2022
dccc0cd
fix error: object of type Decimal is not json serializable
nsmkhn Mar 2, 2022
28e3015
fixes to get network up with hdf5 storage
nsmkhn Mar 9, 2022
7a34711
handle empty blocks during catchup
nsmkhn Mar 9, 2022
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
22 changes: 0 additions & 22 deletions lamden/db_config.py

This file was deleted.

3 changes: 3 additions & 0 deletions lamden/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,3 +180,6 @@ def all_vks_found(self, vks):
if self.peers.get(vk) is None:
return False
return True

def discover_peer(vk, ip):
pass
10 changes: 4 additions & 6 deletions lamden/nodes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,8 @@ async def catchup(self, mn_seed, mn_vk):
wallet=self.wallet,
ctx=self.ctx
)
self.process_new_block(block)
if not block.get('error'):
self.process_new_block(block)

# Process any blocks that were made while we were catching up
while len(self.new_block_processor.q) > 0:
Expand Down Expand Up @@ -318,8 +319,6 @@ def update_state(self, block):
client=self.client
)

#self.nonces.flush_pending()

self.log.info('Updating metadata.')
self.current_height = storage.get_latest_block_height(self.driver)
self.current_hash = storage.get_latest_block_hash(self.driver)
Expand All @@ -335,15 +334,14 @@ def process_new_block(self, block):
if self.store:
encoded_block = encode(block)
encoded_block = json.loads(encoded_block)

self.blocks.store_block(encoded_block)

# create Event File
self.event_writer.write_event(Event(
topics=[NEW_BLOCK_EVENT],
data=encoded_block
))

self.blocks.store_block(block)

# Prepare for the next block by flushing out driver and notification state
# self.new_block_processor.clean()

Expand Down
8 changes: 5 additions & 3 deletions lamden/nodes/delegate/delegate.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ def __init__(self, client: ContractingClient, nonces: storage.NonceStorage, debu

async def process_message(self, msg):
self.log.info(f'Received work from {msg["sender"][:8]}')
# if msg['sender'] not in self.masters:
# self.log.error(f'TX Batch received from non-master {msg["sender"][:8]}')
# return
self.log.info(msg)

if msg['sender'] not in self.masters:
self.log.error(f'TX Batch received from non-master {msg["sender"][:8]}')
return

shim = {
'transactions': [],
Expand Down
4 changes: 2 additions & 2 deletions lamden/nodes/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from sanic import Sanic
import json
import argparse
from contracting.db.encoder import encode, decode

EVENTS_HOME = pathlib.Path().home().joinpath('.lamden').joinpath('events')
EXTENSION = '.e'
Expand Down Expand Up @@ -51,8 +52,7 @@ def get_events(self) -> List[Event]:
with open(file, 'r') as f:
try:
e = json.load(f)
event = Event(e['topics'], e['data'])
events.append(event)
events.append(Event(e['topics'], e['data']))
except:
# TODO(nikita): proper handling
print('failed to load event')
Expand Down
2 changes: 1 addition & 1 deletion lamden/nodes/masternode/masternode.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def get_block(self, command):
block = self.blocks.get_block(num)

if block is None:
return None
return {"error": "block does not exist"}

return block

Expand Down
10 changes: 5 additions & 5 deletions lamden/nodes/masternode/webserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ async def disconnect():
@self.sio.event
async def event(data):
for client in self.ws_clients:
await client.send(json.dumps(data))
await client.send(encode(data))

def __register_app_listeners(self):
@self.app.listener('after_server_start')
Expand All @@ -180,7 +180,7 @@ async def ws_handler(self, request, ws):
'data': block
}

await ws.send(json.dumps(eventData))
await ws.send(encode(eventData))

async for message in ws:
pass
Expand Down Expand Up @@ -386,7 +386,7 @@ async def get_latest_block(self, request):

num = storage.get_latest_block_height(self.driver)
block = self.blocks.get_block(int(num))
return response.json(block, dumps=NonceEncoder().encode, headers={'Access-Control-Allow-Origin': '*'})
return response.json(block, dumps=encode, headers={'Access-Control-Allow-Origin': '*'})

async def get_latest_block_number(self, request):
self.driver.clear_pending_state()
Expand Down Expand Up @@ -417,7 +417,7 @@ async def get_block(self, request):
return response.json({'error': 'Block not found.'}, status=400,
headers={'Access-Control-Allow-Origin': '*'})

return response.json(block, dumps=NonceEncoder().encode, headers={'Access-Control-Allow-Origin': '*'})
return response.json(block, dumps=encode, headers={'Access-Control-Allow-Origin': '*'})

async def get_tx(self, request):
_hash = request.args.get('hash')
Expand All @@ -437,7 +437,7 @@ async def get_tx(self, request):
return response.json({'error': 'Transaction not found.'}, status=400,
headers={'Access-Control-Allow-Origin': '*'})

return response.json(tx, dumps=NonceEncoder().encode, headers={'Access-Control-Allow-Origin': '*'})
return response.json(tx, dumps=encode, headers={'Access-Control-Allow-Origin': '*'})

async def get_constitution(self, request):
self.client.raw_driver.clear_pending_state()
Expand Down
29 changes: 29 additions & 0 deletions lamden/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,3 +277,32 @@ async def secure_multicast(msg: dict, service, wallet: Wallet, peer_map: dict, c
)

await asyncio.gather(*coroutines)


def build_secure_socket(wallet: Wallet, vk: str, ip: str, ctx: zmq.asyncio.Context, linger=500, cert_dir=DEFAULT_DIR):
socket = ctx.socket(zmq.DEALER)
socket.setsockopt(zmq.LINGER, linger)
socket.setsockopt(zmq.TCP_KEEPALIVE, 1)

socket.curve_secretkey = wallet.curve_sk
socket.curve_publickey = wallet.curve_vk

filename = str(cert_dir / f'{vk}.key')
if not os.path.exists(filename):
return None

server_pub, _ = load_certificate(filename)

socket.curve_serverkey = server_pub

try:
socket.connect(ip)
except ZMQBaseError:
socket.close()
return None

return socket


def discover_peer():
pass
Loading