Exemple #1
0
async def get_validator(event_loop, event_bus, index) -> Validator:
    chain_db = await get_chain_db()
    chain = get_chain(chain_db.db)
    peer_pool = FakePeerPool()
    v = Validator(
        validator_index=index,
        chain=chain,
        peer_pool=peer_pool,
        privkey=keymap[index_to_pubkey[index]],
        event_bus=event_bus,
    )
    asyncio.ensure_future(v.run(), loop=event_loop)
    await v.events.started.wait()
    # yield to `validator._run`
    await asyncio.sleep(0)
    return v
Exemple #2
0
async def get_validator(event_loop, event_bus, index) -> Validator:
    chain_db = await helpers.get_chain_db()
    chain = get_chain_from_genesis(chain_db.db, index)
    peer_pool = FakePeerPool()
    validator_privkeys = {index: keymap[index_to_pubkey[index]]}
    v = Validator(
        chain=chain,
        peer_pool=peer_pool,
        validator_privkeys=validator_privkeys,
        event_bus=event_bus,
        genesis_epoch=XIAO_LONG_BAO_CONFIG.GENESIS_EPOCH,
        slots_per_epoch=XIAO_LONG_BAO_CONFIG.SLOTS_PER_EPOCH,
    )
    asyncio.ensure_future(v.run(), loop=event_loop)
    await v.events.started.wait()
    # yield to `validator._run`
    await asyncio.sleep(0)
    return v
Exemple #3
0
async def get_validator(event_loop, event_bus, indices) -> Validator:
    chain = BeaconChainFactory()
    validator_privkeys = {
        index: keymap[index_to_pubkey[index]]
        for index in indices
    }

    def get_ready_attestations_fn():
        return ()

    v = Validator(
        chain=chain,
        p2p_node=FakeNode(),
        validator_privkeys=validator_privkeys,
        get_ready_attestations_fn=get_ready_attestations_fn,
        event_bus=event_bus,
    )
    asyncio.ensure_future(v.run(), loop=event_loop)
    await v.events.started.wait()
    # yield to `validator._run`
    await asyncio.sleep(0)
    return v
Exemple #4
0
async def get_validator(event_loop, event_bus, indices) -> Validator:
    chain_db = await bcc_helpers.get_chain_db()
    chain = get_chain_from_genesis(chain_db.db, indices)
    peer_pool = FakePeerPool()
    validator_privkeys = {
        index: keymap[index_to_pubkey[index]]
        for index in indices
    }

    def get_ready_attestations_fn():
        return ()

    v = Validator(
        chain=chain,
        peer_pool=peer_pool,
        validator_privkeys=validator_privkeys,
        get_ready_attestations_fn=get_ready_attestations_fn,
        event_bus=event_bus,
    )
    asyncio.ensure_future(v.run(), loop=event_loop)
    await v.events.started.wait()
    # yield to `validator._run`
    await asyncio.sleep(0)
    return v