Esempio n. 1
0
async def start_pool_server(pool_store: Optional[AbstractPoolStore] = None):
    global server
    global runner
    config = load_config(DEFAULT_ROOT_PATH, "config.yaml")
    overrides = config["network_overrides"]["constants"][
        config["selected_network"]]
    constants: ConsensusConstants = DEFAULT_CONSTANTS.replace_str_to_bytes(
        **overrides)
    server = PoolServer(config, constants, pool_store)
    await server.start()

    app = web.Application()
    app.add_routes([
        web.get("/", server.wrap_http_handler(server.index)),
        web.get("/pool_info", server.wrap_http_handler(server.get_pool_info)),
        web.get("/farmer", server.wrap_http_handler(server.get_farmer)),
        web.post("/farmer", server.wrap_http_handler(server.post_farmer)),
        web.put("/farmer", server.wrap_http_handler(server.put_farmer)),
        web.post("/partial", server.wrap_http_handler(server.post_partial)),
        web.get("/login", server.wrap_http_handler(server.get_login)),
    ])
    runner = aiohttp.web.AppRunner(app, access_log=None)
    await runner.setup()
    ssl_context = get_ssl_context(server.pool_config)
    site = aiohttp.web.TCPSite(
        runner,
        host=server.host,
        port=server.port,
        ssl_context=ssl_context,
    )
    await site.start()

    while True:
        await asyncio.sleep(3600)
Esempio n. 2
0
async def start_pool_server(args):
    global server
    global runner
    private_key: PrivateKey = AugSchemeMPL.key_gen(std_hash(b"123"))
    config = load_config(DEFAULT_ROOT_PATH, "config.yaml")
    overrides = config["network_overrides"]["constants"][
        config["selected_network"]]
    constants: ConsensusConstants = DEFAULT_CONSTANTS.replace_str_to_bytes(
        **overrides)
    server = PoolServer(private_key, config, constants, args)
    await server.start()

    # TODO(pool): support TLS
    app = web.Application()
    app.add_routes([
        web.get("/", server.wrap_http_handler(server.index)),
        web.get("/get_pool_info",
                server.wrap_http_handler(server.get_pool_info)),
        web.post("/submit_partial",
                 server.wrap_http_handler(server.submit_partial)),
    ])
    runner = aiohttp.web.AppRunner(app, access_log=None)
    await runner.setup()
    site = aiohttp.web.TCPSite(runner, config["self_hostname"], int(3000))
    await site.start()
    await asyncio.sleep(10000000)
Esempio n. 3
0
def main():
    config = load_config_cli(DEFAULT_ROOT_PATH, "config.yaml", "seeder")
    overrides = config["network_overrides"]["constants"][
        config["selected_network"]]
    updated_constants = DEFAULT_CONSTANTS.replace_str_to_bytes(**overrides)
    kwargs = service_kwargs_for_full_node_crawler(DEFAULT_ROOT_PATH, config,
                                                  updated_constants)
    return run_service(**kwargs)
Esempio n. 4
0
async def start_pool_server():
    private_key: PrivateKey = AugSchemeMPL.key_gen(std_hash(b"123"))
    config = load_config(DEFAULT_ROOT_PATH, "config.yaml", "full_node")
    overrides = config["network_overrides"]["constants"][
        config["selected_network"]]
    constants: ConsensusConstants = DEFAULT_CONSTANTS.replace_str_to_bytes(
        **overrides)
    server = PoolServer(private_key, config, constants)
    await server.start()

    # TODO: support TLS
    app = web.Application()
    app.add_routes([
        web.get("/", server.wrap_http_handler(server.index)),
        web.get("/get_pool_info",
                server.wrap_http_handler(server.get_pool_info)),
        web.post("/submit_partial",
                 server.wrap_http_handler(server.submit_partial)),
    ])
    web.run_app(app)
Esempio n. 5
0
def get_config_and_constants():
    config = load_config(DEFAULT_ROOT_PATH, "config.yaml")
    network = config["selected_network"]
    overrides = config["network_overrides"]["constants"][network]
    updated_constants = DEFAULT_CONSTANTS.replace_str_to_bytes(**overrides)
    return config, updated_constants
def make_test_constants(test_constants_overrides: Dict):
    return DEFAULT_CONSTANTS.replace(**test_constants_overrides)
Esempio n. 7
0
from pytest import raises

from chia.consensus.default_constants import DEFAULT_CONSTANTS
from chia.consensus.pos_quality import _expected_plot_size
from chia.consensus.pot_iterations import (
    calculate_ip_iters,
    calculate_iterations_quality,
    calculate_sp_iters,
    is_overflow_block,
)
from chia.util.hash import std_hash
from chia.util.ints import uint8, uint64

test_constants = DEFAULT_CONSTANTS.replace(**{
    "NUM_SPS_SUB_SLOT": 32,
    "SUB_SLOT_TIME_TARGET": 300
})


class TestPotIterations:
    def test_is_overflow_block(self):
        assert not is_overflow_block(test_constants, uint8(27))
        assert not is_overflow_block(test_constants, uint8(28))
        assert is_overflow_block(test_constants, uint8(29))
        assert is_overflow_block(test_constants, uint8(30))
        assert is_overflow_block(test_constants, uint8(31))
        with raises(ValueError):
            assert is_overflow_block(test_constants, uint8(32))

    def test_calculate_sp_iters(self):
        ssi: uint64 = uint64(100001 * 64 * 4)
Esempio n. 8
0
        "ae83525ba8d1dd3f09b277de18ca3e43fc0af20d20c4b3e92ef2a48bd291ccb2"),
    "GENESIS_PRE_FARM_FARMER_PUZZLE_HASH":
    bytes.fromhex(
        "3d8765d3a597ec1d99663f6c9816d915b9f68613ac94009884c4addaefcce6af"),
    "GENESIS_PRE_FARM_POOL_PUZZLE_HASH":
    bytes.fromhex(
        "d23da14695a188ae5708dd152263c4db883eb27edeb936178d4d988b8f3ce5fc"),
    "MEMPOOL_BLOCK_BUFFER":
    10,
    "MIN_PLOT_SIZE":
    18,
    "NETWORK_TYPE":
    1,
}

constants = DEFAULT_CONSTANTS.replace(**testnet10)
retire_bytes = (
    b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
    b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00")


def find_retirement(tocheck: List[ConditionWithArgs]) -> bool:
    for c in tocheck:
        if c.opcode != ConditionOpcode.CREATE_COIN:
            continue
        if len(c.vars) < 3:
            continue
        if c.vars[2] == retire_bytes:
            return True

    return False