def create_helios_testnet_header_from_parent(parent_header, **header_params):
    if 'gas_limit' not in header_params:
        #        header_params['gas_limit'] = compute_gas_limit(
        #            parent_header,
        #            gas_limit_floor=GENESIS_GAS_LIMIT,
        #        )
        header_params['gas_limit'] = compute_gas_limit()

    header = BlockHeader.from_parent(parent=parent_header, **header_params)

    return header
Beispiel #2
0
def mk_header_chain(base_header, length):
    previous_header = base_header
    for _ in range(length):
        next_header = BlockHeader.from_parent(
            parent=previous_header,
            timestamp=previous_header.timestamp + 1,
            gas_limit=previous_header.gas_limit,
            difficulty=previous_header.difficulty,
            extra_data=keccak(random.randint(0, 1e18)),
        )
        yield next_header
        previous_header = next_header
Beispiel #3
0
def create_frontier_header_from_parent(parent_header, **header_params):
    if 'difficulty' not in header_params:
        # Use setdefault to ensure the new header has the same timestamp we use to calculate its
        # difficulty.
        header_params.setdefault('timestamp', parent_header.timestamp + 1)
        header_params['difficulty'] = compute_frontier_difficulty(
            parent_header,
            header_params['timestamp'],
        )
    if 'gas_limit' not in header_params:
        header_params['gas_limit'] = compute_gas_limit(
            parent_header,
            gas_limit_floor=GENESIS_GAS_LIMIT,
        )

    header = BlockHeader.from_parent(parent=parent_header, **header_params)

    return header