CityOfZion / neo-mamba

Python SDK for the NEO3 blockchain
https://mamba.coz.io/
MIT License
22 stars 12 forks source link

Possible in memory DB issue on OSX #97

Closed comountainclimber closed 3 years ago

comountainclimber commented 3 years ago

MacOS Version :10.15.7 Python Version: 3.7 Neoexpress version: 2.0.23-preview

When following the tutorial here: https://dojo.coz.io/neo3/mamba/tutorial/index.html I seem to encounter the following error if the chain is longer than a few blocks:

Screen Shot 2021-05-19 at 7 49 56 AM
2021-05-19 07:49:38,889 DEBUG - node:105 Connected to /Neo:3.0.0-rc1/ @ 127.0.0.1:50013: 1420.
connection_done!
2021-05-19 07:49:38,889 DEBUG - node:396 Waiting for a message.
2021-05-19 07:49:38,939 DEBUG - syncmanager:60 Starting services
2021-05-19 07:49:38,942 DEBUG - syncmanager:254 Asking for blocks 1 - 500 from DRCvlWGQ (blocks in cache: 0).
block received! []
block received! []
...
 Python(45970,0x10d7d7dc0) malloc: Incorrect checksum for freed object 0x7fae946049f8: probably modified after being freed.
Corrupt value: 0x0
Python(45970,0x10d7d7dc0) malloc: *** set a breakpoint in malloc_error_break to debug
[1]    45970 abort      python3.7 main.py

code:

import asyncio

# web specific imports
from quart import Quart, websocket
import logging

# neo3 specific imports
from neo3 import settings, blockchain
from neo3.network import convenience, payloads
from neo3.core import msgrouter
from neo3.storage import implementations as db

msg_queue = asyncio.Queue()

# web specific part
app = Quart(__name__)

with open('./index.html', 'r') as f:
    html_page = f.read()

@app.route('/')
async def index():
    return html_page

@app.websocket('/ws')
async def ws():
    while True:
        msg = await msg_queue.get()
        await websocket.send(msg)

def enable_network_logging():
    stdio_handler = logging.StreamHandler()
    stdio_handler.setLevel(logging.DEBUG)
    stdio_handler.setFormatter(logging.Formatter(
        "%(asctime)s %(levelname)s - %(module)s:%(lineno)s %(message)s"))

    network_logger = logging.getLogger('neo3.network')
    network_logger.addHandler(stdio_handler)
    network_logger.setLevel(logging.DEBUG)

def connection_done(node_client, failure):
    print('connection_done!')
    if failure:
        asyncio.create_task(
            msg_queue.put(f"Failed to connect to {failure[0]} reason: {failure[1]}."))
    else:
        asyncio.create_task(
            msg_queue.put(f"Connected to node {node_client.version.user_agent} @ {node_client.address}"))

def block_received(from_nodeid: int, block: payloads.Block):
    print('block received!', block.transactions)
    asyncio.create_task(msg_queue.put(
        f"Received block with height {block.index} and hash {block.hash()}"))

async def run_neo():
    # set network magic to NEO TestNet
    settings.network.magic = 692804366

    # add a node to test against
    settings.network.seedlist = ['127.0.0.1:50013']

    # listen to the connection events broad casted by the node manager
    msgrouter.on_client_connect_done += connection_done

    # listen to block received events
    msgrouter.on_block += block_received

    node_mgr = convenience.NodeManager()
    node_mgr.start()

    sync_mgr = convenience.SyncManager()
    await sync_mgr.start()

async def main():
    settings.network.magic = 692804366
    settings.network.seedlist = ['127.0.0.1:50013']
    node_mgr = convenience.NodeManager()
    node_mgr.start()

    sync_mgr = convenience.SyncManager()
    await sync_mgr.start()

    async def print_height():
        while True:
            print(f"Local chain height: {bc.height}")
            await asyncio.sleep(2)

    # Start an endless loop informing us about our local chain height
    await print_height()

if __name__ == "__main__":
    enable_network_logging()
    loop = asyncio.get_event_loop()
    loop.create_task(run_neo())
    app.run(loop=loop)
ixje commented 3 years ago

Can you please paste the output of python --version. I'm interested in the minor version (e.g. 3.7.1, 3.7.2 ... 3.7.9, or 3.7.10)

ixje commented 3 years ago

I can't reproduce and we've also dropped 3.7 support. Let me know if this happens on 3.8 and I'll re-open