def geth_bare_genesis(genesis_path, private_keys, random_marker): """Writes a bare genesis to `genesis_path`. Args: genesis_path (str): the path in which the genesis block is written. private_keys list(str): iterable list of privatekeys whose corresponding accounts will have a premined balance available. """ account_addresses = [ privatekey_to_address(key) for key in sorted(set(private_keys)) ] alloc = { address_encoder(address): { 'balance': DEFAULT_BALANCE_BIN, } for address in account_addresses } genesis = GENESIS_STUB.copy() genesis['alloc'].update(alloc) genesis['config']['clique'] = {'period': 1, 'epoch': 30000} genesis['extraData'] = clique_extradata( random_marker, address_encoder(account_addresses[0])[2:], ) with open(genesis_path, 'w') as handler: json.dump(genesis, handler)
def geth_generate_poa_genesis( genesis_path: str, accounts_addresses: typing.List[str], seal_address: str, random_marker, ): """Writes a bare genesis to `genesis_path`. Args: genesis_path: the path in which the genesis block is written. accounts_addresses: iterable list of privatekeys whose corresponding accounts will have a premined balance available. seal_address: Address of the ethereum account that can seal blocks in the PoA chain """ alloc = { to_normalized_address(address): { 'balance': DEFAULT_BALANCE_BIN, } for address in accounts_addresses } genesis = GENESIS_STUB.copy() genesis['alloc'].update(alloc) genesis['config']['clique'] = {'period': 1, 'epoch': 30000} genesis['extraData'] = geth_clique_extradata( random_marker, to_normalized_address(seal_address)[2:], ) with open(genesis_path, 'w') as handler: json.dump(genesis, handler)
def geth_generate_poa_genesis( genesis_path: str, genesis_description: GenesisDescription, seal_account: bytes, ) -> None: """Writes a bare genesis to `genesis_path`.""" alloc = { to_normalized_address(address): { 'balance': DEFAULT_BALANCE_BIN, } for address in genesis_description.prefunded_accounts } seal_address_normalized = remove_0x_prefix( to_normalized_address(seal_account), ) extra_data = geth_clique_extradata( genesis_description.random_marker, seal_address_normalized, ) genesis = GENESIS_STUB.copy() genesis['alloc'].update(alloc) genesis['config']['ChainID'] = genesis_description.chain_id genesis['config']['clique'] = {'period': 1, 'epoch': 30000} genesis['extraData'] = extra_data with open(genesis_path, 'w') as handler: json.dump(genesis, handler)
def complete_genesis(): smoketest_genesis = GENESIS_STUB.copy() smoketest_genesis['config']['clique'] = {'period': 1, 'epoch': 30000} smoketest_genesis['extraData'] = '0x{:0<64}{:0<170}'.format( hexlify('raiden'), TEST_ACCOUNT['address'], ) smoketest_genesis['alloc'][TEST_ACCOUNT['address']] = dict( balance=hex(10**18)) raiden_config = deploy_and_open_channel_alloc(deployment_key=TEST_PRIVKEY) smoketest_genesis['alloc'].update(raiden_config['alloc']) return raiden_config, smoketest_genesis
def complete_genesis(): smoketest_genesis = GENESIS_STUB.copy() smoketest_genesis['config']['clique'] = {'period': 1, 'epoch': 30000} smoketest_genesis['extraData'] = '0x{:0<64}{:0<170}'.format( hexlify(b'raiden').decode(), TEST_ACCOUNT['address'], ) smoketest_genesis['alloc'][TEST_ACCOUNT['address']] = dict(balance=hex(10 ** 18)) raiden_config = deploy_and_open_channel_alloc(deployment_key=TEST_PRIVKEY) smoketest_genesis['alloc'].update( raiden_config['alloc'] ) return raiden_config, smoketest_genesis
def mk_genesis(accounts, initial_alloc=denoms.ether * 100000000): """ Create a genesis-block dict with allocation for all `accounts`. :param accounts: list of account addresses (hex) :param initial_alloc: the amount to allocate for the `accounts` :return: genesis dict """ genesis = GENESIS_STUB.copy() genesis['extraData'] = '0x' + hexlify(CLUSTER_NAME) genesis['alloc'].update( {account: { 'balance': str(initial_alloc), } for account in accounts}) # add the one-privatekey account ("1" * 64) for convenience genesis['alloc']['19e7e376e7c213b7e7e7e46cc70a5dd086daff2a'] = dict( balance=str(initial_alloc)) return genesis
def mk_genesis(accounts, initial_alloc=denoms.ether * 100000000): """ Create a genesis-block dict with allocation for all `accounts`. :param accounts: list of account addresses (hex) :param initial_alloc: the amount to allocate for the `accounts` :return: genesis dict """ genesis = GENESIS_STUB.copy() genesis['extraData'] = encode_hex(CLUSTER_NAME) genesis['alloc'].update({ account: { 'balance': str(initial_alloc), } for account in accounts }) # add the one-privatekey account ("1" * 64) for convenience genesis['alloc']['19e7e376e7c213b7e7e7e46cc70a5dd086daff2a'] = dict(balance=str(initial_alloc)) return genesis
def geth_generate_poa_genesis(genesis_path: str, genesis_description: GenesisDescription, seal_account: Address) -> None: """Writes a bare genesis to `genesis_path`.""" alloc = { to_normalized_address(account.address): { "balance": str(account.balance) } for account in genesis_description.prefunded_accounts } seal_address_normalized = remove_0x_prefix(encode_hex(seal_account)) extra_data = geth_clique_extradata(genesis_description.random_marker, seal_address_normalized) genesis = GENESIS_STUB.copy() genesis["alloc"].update(alloc) genesis["config"]["ChainID"] = genesis_description.chain_id genesis["config"]["clique"] = {"period": 1, "epoch": 30000} genesis["extraData"] = extra_data with open(genesis_path, "w") as handler: json.dump(genesis, handler)
def geth_bare_genesis(genesis_path, private_keys): """Writes a bare genesis to `genesis_path`. Args: genesis_path (str): the path in which the genesis block is written. private_keys list(str): iterable list of privatekeys whose corresponding accounts will have a premined balance available. """ account_addresses = [ privatekey_to_address(key) for key in set(private_keys) ] alloc = { address_encoder(address): { 'balance': DEFAULT_BALANCE_BIN, } for address in account_addresses } genesis = GENESIS_STUB.copy() genesis['alloc'].update(alloc) with open(genesis_path, 'w') as handler: json.dump(genesis, handler)