Network settings (#1019)
* rpc get network settings * breakpoints * don't log canceled * fix test coin store * cancel task on exit * use network prefix for prefarm * rebase and change network type * network type * missing config * add timeout
This commit is contained in:
parent
5063ad058c
commit
1d91a20112
30 changed files with 110 additions and 66 deletions
|
@ -65,12 +65,14 @@ def check_keys(new_root):
|
|||
stop_searching_for_farmer = "xch_target_address" not in config["farmer"]
|
||||
stop_searching_for_pool = "xch_target_address" not in config["pool"]
|
||||
number_of_ph_to_search = 500
|
||||
selected = config["selected_network"]
|
||||
prefix = config["network_overrides"]["config"][selected]["address_prefix"]
|
||||
for i in range(number_of_ph_to_search):
|
||||
if stop_searching_for_farmer and stop_searching_for_pool and i > 0:
|
||||
break
|
||||
for sk, _ in all_sks:
|
||||
all_targets.append(
|
||||
encode_puzzle_hash(create_puzzlehash_for_pk(master_sk_to_wallet_sk(sk, uint32(i)).get_g1()))
|
||||
encode_puzzle_hash(create_puzzlehash_for_pk(master_sk_to_wallet_sk(sk, uint32(i)).get_g1()), prefix)
|
||||
)
|
||||
if all_targets[-1] == config["farmer"].get("xch_target_address"):
|
||||
stop_searching_for_farmer = True
|
||||
|
|
|
@ -7,6 +7,8 @@ from blspy import AugSchemeMPL, G1Element, G2Element
|
|||
|
||||
from src.cmds.init import check_keys
|
||||
from src.util.bech32m import encode_puzzle_hash
|
||||
from src.util.config import load_config
|
||||
from src.util.default_root import DEFAULT_ROOT_PATH
|
||||
from src.util.keychain import (
|
||||
generate_mnemonic,
|
||||
bytes_to_mnemonic,
|
||||
|
@ -67,8 +69,11 @@ def show_all_keys():
|
|||
"""
|
||||
Prints all keys and mnemonics (if available).
|
||||
"""
|
||||
|
||||
root_path = DEFAULT_ROOT_PATH
|
||||
config = load_config(root_path, "config.yaml")
|
||||
private_keys = keychain.get_all_private_keys()
|
||||
selected = config["selected_network"]
|
||||
prefix = config["network_overrides"]["config"][selected]["address_prefix"]
|
||||
if len(private_keys) == 0:
|
||||
print("There are no saved private keys")
|
||||
return
|
||||
|
@ -89,7 +94,7 @@ def show_all_keys():
|
|||
)
|
||||
print(
|
||||
"First wallet address:",
|
||||
encode_puzzle_hash(create_puzzlehash_for_pk(master_sk_to_wallet_sk(sk, uint32(0)).get_g1())),
|
||||
encode_puzzle_hash(create_puzzlehash_for_pk(master_sk_to_wallet_sk(sk, uint32(0)).get_g1()), prefix),
|
||||
)
|
||||
assert seed is not None
|
||||
mnemonic = bytes_to_mnemonic(seed)
|
||||
|
|
|
@ -229,6 +229,9 @@ async def show_async(
|
|||
cost = "Not a transaction block"
|
||||
tx_filter_hash = "Not a transaction block"
|
||||
print("Block at height", block.height, ":")
|
||||
address_prefix = config["network_overrides"]["config"][config["selected_network"]]["address_prefix"]
|
||||
farmer_address = encode_puzzle_hash(block.farmer_puzzle_hash, address_prefix)
|
||||
pool_address = encode_puzzle_hash(block.pool_puzzle_hash, address_prefix)
|
||||
print(
|
||||
f"Header Hash 0x{block.header_hash.hex()}\n"
|
||||
f"Timestamp {block_time_string}\n"
|
||||
|
@ -248,8 +251,8 @@ async def show_async(
|
|||
f"0x{full_block.reward_chain_block.proof_of_space.pool_contract_puzzle_hash}\n"
|
||||
f"{full_block.reward_chain_block.proof_of_space.pool_contract_puzzle_hash}\n"
|
||||
f"Tx Filter Hash {tx_filter_hash}\n"
|
||||
f"Farmer Address {encode_puzzle_hash(block.farmer_puzzle_hash)}\n"
|
||||
f"Pool Address {encode_puzzle_hash(block.pool_puzzle_hash)}\n"
|
||||
f"Farmer Address {farmer_address}\n"
|
||||
f"Pool Address {pool_address}\n"
|
||||
f"Fees Amount {block.fees}\n"
|
||||
)
|
||||
else:
|
||||
|
|
|
@ -8,9 +8,10 @@ import aiohttp
|
|||
import asyncio
|
||||
|
||||
from src.rpc.wallet_rpc_client import WalletRpcClient
|
||||
from src.server.start_wallet import SERVICE_NAME
|
||||
from src.util.bech32m import encode_puzzle_hash
|
||||
from src.util.byte_types import hexstr_to_bytes
|
||||
from src.util.config import load_config
|
||||
from src.util.config import load_config, load_config_cli
|
||||
from src.util.default_root import DEFAULT_ROOT_PATH
|
||||
from src.util.ints import uint64, uint16
|
||||
from src.wallet.transaction_record import TransactionRecord
|
||||
|
@ -19,15 +20,15 @@ from src.cmds.units import units
|
|||
from decimal import Decimal
|
||||
|
||||
|
||||
def print_transaction(tx: TransactionRecord, verbose: bool) -> None:
|
||||
def print_transaction(tx: TransactionRecord, verbose: bool, name) -> None:
|
||||
if verbose:
|
||||
print(tx)
|
||||
else:
|
||||
chia_amount = Decimal(int(tx.amount)) / units["chia"]
|
||||
to_address = encode_puzzle_hash(tx.to_puzzle_hash)
|
||||
to_address = encode_puzzle_hash(tx.to_puzzle_hash, name)
|
||||
print(f"Transaction {tx.name}")
|
||||
print(f"Status: {'Confirmed' if tx.confirmed else ('In mempool' if tx.is_in_mempool() else 'Pending')}")
|
||||
print(f"Amount: {chia_amount} TXCH")
|
||||
print(f"Amount: {chia_amount} {name}")
|
||||
print(f"To address: {to_address}")
|
||||
print("Created at:", datetime.fromtimestamp(tx.created_at_time).strftime("%Y-%m-%d %H:%M:%S"))
|
||||
print("")
|
||||
|
@ -36,18 +37,22 @@ def print_transaction(tx: TransactionRecord, verbose: bool) -> None:
|
|||
async def get_transaction(args: dict, wallet_client: WalletRpcClient, fingerprint: int) -> None:
|
||||
wallet_id = args["id"]
|
||||
transaction_id = hexstr_to_bytes(args["tx_id"])
|
||||
config = load_config_cli(DEFAULT_ROOT_PATH, "config.yaml", SERVICE_NAME)
|
||||
name = config["network_overrides"]["config"][config["selected_network"]]["address_prefix"]
|
||||
tx: TransactionRecord = await wallet_client.get_transaction(wallet_id, transaction_id=transaction_id)
|
||||
print_transaction(tx, verbose=(args["verbose"] > 0))
|
||||
print_transaction(tx, verbose=(args["verbose"] > 0), name=name)
|
||||
|
||||
|
||||
async def get_transactions(args: dict, wallet_client: WalletRpcClient, fingerprint: int) -> None:
|
||||
wallet_id = args["id"]
|
||||
txs: List[TransactionRecord] = await wallet_client.get_transactions(wallet_id)
|
||||
config = load_config_cli(DEFAULT_ROOT_PATH, "config.yaml", SERVICE_NAME)
|
||||
name = config["network_overrides"]["config"][config["selected_network"]]["address_prefix"]
|
||||
if len(txs) == 0:
|
||||
print("There are no transactions to this address")
|
||||
for i in range(0, len(txs), 5):
|
||||
for j in range(0, 5):
|
||||
print_transaction(txs[i + j], verbose=(args["verbose"] > 0))
|
||||
print_transaction(txs[i + j], verbose=(args["verbose"] > 0), name=name)
|
||||
print("Press q to quit, or c to continue")
|
||||
while True:
|
||||
entered_key = sys.stdin.read(1)
|
||||
|
|
|
@ -152,7 +152,7 @@ async def validate_block_body(
|
|||
if height <= constants.INITIAL_FREEZE_PERIOD and block.transactions_generator is not None:
|
||||
return Err.INITIAL_TRANSACTION_FREEZE, None
|
||||
|
||||
if constants.NETWORK == NetworkType.MAINNET:
|
||||
if constants.NETWORK_TYPE == NetworkType.MAINNET:
|
||||
if block.transactions_generator is not None:
|
||||
if len(bytes(block.transactions_generator)) > constants.MAX_GENERATOR_SIZE:
|
||||
return Err.PRE_SOFT_FORK_MAX_GENERATOR_SIZE, None
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import dataclasses
|
||||
|
||||
from src.types.blockchain_format.sized_bytes import bytes32
|
||||
from src.util.byte_types import hexstr_to_bytes
|
||||
from src.util.ints import uint64, uint32, uint8, uint128
|
||||
|
||||
|
||||
|
@ -59,7 +60,7 @@ class ConsensusConstants:
|
|||
MAX_BLOCK_COUNT_PER_REQUESTS: uint32
|
||||
INITIAL_FREEZE_PERIOD: uint32
|
||||
BLOCKS_CACHE_SIZE: uint32
|
||||
NETWORK: int
|
||||
NETWORK_TYPE: int
|
||||
MAX_GENERATOR_SIZE: uint32
|
||||
|
||||
def replace(self, **changes):
|
||||
|
@ -71,7 +72,7 @@ class ConsensusConstants:
|
|||
"""
|
||||
|
||||
for k, v in changes.items():
|
||||
if isinstance(v, str):
|
||||
changes[k] = bytes.fromhex(v)
|
||||
if isinstance(v, str) and v.startswith("0x"):
|
||||
changes[k] = hexstr_to_bytes(v)
|
||||
|
||||
return dataclasses.replace(self, **changes)
|
||||
|
|
|
@ -58,7 +58,7 @@ testnet_kwargs = {
|
|||
"WEIGHT_PROOF_RECENT_BLOCKS": 800,
|
||||
"MAX_BLOCK_COUNT_PER_REQUESTS": 32, # Allow up to 32 blocks per request
|
||||
"INITIAL_FREEZE_PERIOD": 5000, # Transaction are disabled first 10000 blocks
|
||||
"NETWORK": 0,
|
||||
"NETWORK_TYPE": 0,
|
||||
"MAX_GENERATOR_SIZE": 1000000,
|
||||
}
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ def batch_pre_validate_blocks(
|
|||
error_int: Optional[uint16] = None
|
||||
if error is not None:
|
||||
error_int = uint16(error.code.value)
|
||||
if constants_dict["NETWORK"] == NetworkType.MAINNET.value:
|
||||
if constants_dict["NETWORK_TYPE"] == NetworkType.MAINNET.value:
|
||||
cost_result = None
|
||||
else:
|
||||
if not error and generator is not None and validate_transactions:
|
||||
|
|
|
@ -3,8 +3,4 @@ from enum import IntEnum
|
|||
|
||||
class NetworkType(IntEnum):
|
||||
MAINNET = 0
|
||||
TESTNET_1 = 1
|
||||
TESTNET_2 = 2
|
||||
TESTNET_3 = 3
|
||||
TESTNET_4 = 4
|
||||
TESTNET_5 = 5
|
||||
TESTNET = 1
|
||||
|
|
|
@ -33,6 +33,7 @@ class FullNodeRpcApi:
|
|||
"/get_network_space": self.get_network_space,
|
||||
"/get_additions_and_removals": self.get_additions_and_removals,
|
||||
"/get_initial_freeze_period": self.get_initial_freeze_period,
|
||||
"/get_network_info": self.get_network_info,
|
||||
# Coins
|
||||
"/get_coin_records_by_puzzle_hash": self.get_coin_records_by_puzzle_hash,
|
||||
"/get_coin_record_by_name": self.get_coin_record_by_name,
|
||||
|
@ -133,6 +134,11 @@ class FullNodeRpcApi:
|
|||
self.cached_blockchain_state = dict(response["blockchain_state"])
|
||||
return response
|
||||
|
||||
async def get_network_info(self, request: Dict):
|
||||
network_name = self.service.config["selected_network"]
|
||||
address_prefix = self.service.config["network_overrides"]["config"][network_name]["address_prefix"]
|
||||
return {"network_name": network_name, "network_prefix": address_prefix}
|
||||
|
||||
async def get_block(self, request: Dict) -> Optional[Dict]:
|
||||
if "header_hash" not in request:
|
||||
raise ValueError("No header_hash in request")
|
||||
|
|
|
@ -85,6 +85,7 @@ class WalletRpcApi:
|
|||
"/add_rate_limited_funds:": self.add_rate_limited_funds,
|
||||
"/get_transaction_count": self.get_transaction_count,
|
||||
"/get_initial_freeze_period": self.get_initial_freeze_period,
|
||||
"/get_network_info": self.get_network_info,
|
||||
}
|
||||
|
||||
async def _state_changed(self, *args) -> List[str]:
|
||||
|
@ -270,6 +271,12 @@ class WalletRpcApi:
|
|||
else:
|
||||
return {"height": peak.height}
|
||||
|
||||
async def get_network_info(self, request: Dict):
|
||||
assert self.service.wallet_state_manager is not None
|
||||
network_name = self.service.config["selected_network"]
|
||||
address_prefix = self.service.config["network_overrides"]["config"][network_name]["address_prefix"]
|
||||
return {"network_name": network_name, "network_prefix": address_prefix}
|
||||
|
||||
async def farm_block(self, request):
|
||||
raw_puzzle_hash = decode_puzzle_hash(request["address"])
|
||||
request = FarmNewBlockProtocol(raw_puzzle_hash)
|
||||
|
@ -412,10 +419,11 @@ class WalletRpcApi:
|
|||
|
||||
transactions = await self.service.wallet_state_manager.tx_store.get_transactions_between(wallet_id, start, end)
|
||||
formatted_transactions = []
|
||||
|
||||
selected = self.service.config["selected_network"]
|
||||
prefix = self.service.config["network_overrides"]["config"][selected]["address_prefix"]
|
||||
for tx in transactions:
|
||||
formatted = tx.to_json_dict()
|
||||
formatted["to_address"] = encode_puzzle_hash(tx.to_puzzle_hash)
|
||||
formatted["to_address"] = encode_puzzle_hash(tx.to_puzzle_hash, prefix)
|
||||
formatted_transactions.append(formatted)
|
||||
|
||||
return {
|
||||
|
@ -435,13 +443,14 @@ class WalletRpcApi:
|
|||
|
||||
wallet_id = uint32(int(request["wallet_id"]))
|
||||
wallet = self.service.wallet_state_manager.wallets[wallet_id]
|
||||
|
||||
selected = self.service.config["selected_network"]
|
||||
prefix = self.service.config["network_overrides"]["config"][selected]["address_prefix"]
|
||||
if wallet.type() == WalletType.STANDARD_WALLET:
|
||||
raw_puzzle_hash = await wallet.get_new_puzzlehash()
|
||||
address = encode_puzzle_hash(raw_puzzle_hash)
|
||||
address = encode_puzzle_hash(raw_puzzle_hash, prefix)
|
||||
elif wallet.type() == WalletType.COLOURED_COIN:
|
||||
raw_puzzle_hash = await wallet.get_new_inner_hash()
|
||||
address = encode_puzzle_hash(raw_puzzle_hash)
|
||||
address = encode_puzzle_hash(raw_puzzle_hash, prefix)
|
||||
else:
|
||||
raise ValueError(f"Wallet type {wallet.type()} cannot create puzzle hashes")
|
||||
|
||||
|
|
|
@ -481,6 +481,8 @@ class ChiaServer:
|
|||
try:
|
||||
result = await coroutine
|
||||
return result
|
||||
except asyncio.CancelledError:
|
||||
pass
|
||||
except Exception as e:
|
||||
tb = traceback.format_exc()
|
||||
connection.log.error(f"Exception: {e}, {connection.get_peer_info()}. {tb}")
|
||||
|
|
|
@ -34,7 +34,7 @@ def service_kwargs_for_farmer(
|
|||
if fnp is not None:
|
||||
connect_peers.append(PeerInfo(fnp["host"], fnp["port"]))
|
||||
|
||||
overrides = config["network_overrides"][config["selected_network"]]
|
||||
overrides = config["network_overrides"]["constants"][config["selected_network"]]
|
||||
updated_constants = consensus_constants.replace_str_to_bytes(**overrides)
|
||||
|
||||
farmer = Farmer(config, config_pool, keychain, consensus_constants=updated_constants)
|
||||
|
|
|
@ -56,7 +56,7 @@ def service_kwargs_for_full_node(
|
|||
|
||||
def main():
|
||||
config = load_config_cli(DEFAULT_ROOT_PATH, "config.yaml", SERVICE_NAME)
|
||||
overrides = config["network_overrides"][config["selected_network"]]
|
||||
overrides = config["network_overrides"]["constants"][config["selected_network"]]
|
||||
updated_constants = DEFAULT_CONSTANTS.replace_str_to_bytes(**overrides)
|
||||
kwargs = service_kwargs_for_full_node(DEFAULT_ROOT_PATH, config, updated_constants)
|
||||
return run_service(**kwargs)
|
||||
|
|
|
@ -26,7 +26,7 @@ def service_kwargs_for_harvester(
|
|||
consensus_constants: ConsensusConstants,
|
||||
) -> Dict:
|
||||
connect_peers = [PeerInfo(config["farmer_peer"]["host"], config["farmer_peer"]["port"])]
|
||||
overrides = config["network_overrides"][config["selected_network"]]
|
||||
overrides = config["network_overrides"]["constants"][config["selected_network"]]
|
||||
updated_constants = consensus_constants.replace_str_to_bytes(**overrides)
|
||||
|
||||
harvester = Harvester(root_path, config, updated_constants)
|
||||
|
|
|
@ -21,7 +21,7 @@ def service_kwargs_for_introducer(
|
|||
root_path: pathlib.Path,
|
||||
config: Dict,
|
||||
) -> Dict:
|
||||
overrides = config["network_overrides"][config["selected_network"]]
|
||||
overrides = config["network_overrides"]["constants"][config["selected_network"]]
|
||||
updated_constants = DEFAULT_CONSTANTS.replace_str_to_bytes(**overrides)
|
||||
introducer = Introducer(config["max_peers_to_send"], config["recent_peer_threshold"])
|
||||
node__api = IntroducerAPI(introducer)
|
||||
|
|
|
@ -30,7 +30,7 @@ def service_kwargs_for_timelord(
|
|||
) -> Dict:
|
||||
|
||||
connect_peers = [PeerInfo(config["full_node_peer"]["host"], config["full_node_peer"]["port"])]
|
||||
overrides = config["network_overrides"][config["selected_network"]]
|
||||
overrides = config["network_overrides"]["constants"][config["selected_network"]]
|
||||
updated_constants = constants.replace_str_to_bytes(**overrides)
|
||||
|
||||
node = Timelord(config, updated_constants)
|
||||
|
|
|
@ -29,7 +29,7 @@ def service_kwargs_for_wallet(
|
|||
consensus_constants: ConsensusConstants,
|
||||
keychain: Keychain,
|
||||
) -> Dict:
|
||||
overrides = config["network_overrides"][config["selected_network"]]
|
||||
overrides = config["network_overrides"]["constants"][config["selected_network"]]
|
||||
updated_constants = consensus_constants.replace_str_to_bytes(**overrides)
|
||||
node = WalletNode(
|
||||
config,
|
||||
|
|
|
@ -23,6 +23,7 @@ SERVICE_NAME = "full_node"
|
|||
def service_kwargs_for_full_node_simulator(root_path: Path, config: Dict, bt: BlockTools) -> Dict:
|
||||
mkdir(path_from_root(root_path, config["database_path"]).parent)
|
||||
constants = bt.constants
|
||||
|
||||
node = FullNode(
|
||||
config,
|
||||
root_path=root_path,
|
||||
|
|
|
@ -101,6 +101,8 @@ class Timelord:
|
|||
self._shut_down = True
|
||||
for task in self.process_communication_tasks:
|
||||
task.cancel()
|
||||
if self.main_loop is not None:
|
||||
self.main_loop.cancel()
|
||||
|
||||
async def _await_closed(self):
|
||||
pass
|
||||
|
|
|
@ -105,8 +105,8 @@ def convertbits(data: List[int], frombits: int, tobits: int, pad: bool = True):
|
|||
return ret
|
||||
|
||||
|
||||
def encode_puzzle_hash(puzzle_hash: bytes32) -> str:
|
||||
encoded = bech32_encode("txch", convertbits(puzzle_hash, 8, 5))
|
||||
def encode_puzzle_hash(puzzle_hash: bytes32, prefix: str) -> str:
|
||||
encoded = bech32_encode(prefix, convertbits(puzzle_hash, 8, 5))
|
||||
return encoded
|
||||
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ test_constants = DEFAULT_CONSTANTS.replace(
|
|||
"TX_PER_SEC": 1,
|
||||
"CLVM_COST_RATIO_CONSTANT": 108,
|
||||
"INITIAL_FREEZE_PERIOD": 0,
|
||||
"NETWORK": 1,
|
||||
"NETWORK_TYPE": 1,
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -154,7 +154,7 @@ class BlockTools:
|
|||
for service in ["harvester", "farmer", "full_node", "wallet", "introducer", "timelord", "pool"]:
|
||||
self._config[service]["selected_network"] = "testnet0"
|
||||
save_config(self.root_path, "config.yaml", self._config)
|
||||
overrides = self._config["network_overrides"][self._config["selected_network"]]
|
||||
overrides = self._config["network_overrides"]["constants"][self._config["selected_network"]]
|
||||
updated_constants = constants.replace_str_to_bytes(**overrides)
|
||||
if const_dict is not None:
|
||||
updated_constants = updated_constants.replace(**const_dict)
|
||||
|
@ -201,7 +201,7 @@ class BlockTools:
|
|||
)
|
||||
# Create more plots, but to a pool address instead of public key
|
||||
args.pool_public_key = None
|
||||
args.pool_contract_address = encode_puzzle_hash(self.pool_ph)
|
||||
args.pool_contract_address = encode_puzzle_hash(self.pool_ph, "xch")
|
||||
args.num = num_pool_address_plots
|
||||
create_plots(
|
||||
args,
|
||||
|
|
|
@ -6,19 +6,24 @@ self_hostname: &self_hostname "localhost"
|
|||
daemon_port: 55400
|
||||
|
||||
network_overrides: &network_overrides
|
||||
testnet0:
|
||||
MIN_PLOT_SIZE: 18
|
||||
GENESIS_CHALLENGE: "0000000000000000000000000000000000000000000000000000000000000000"
|
||||
NETWORK: 1
|
||||
testnet4:
|
||||
MIN_PLOT_SIZE: 18
|
||||
MIN_BLOCKS_PER_CHALLENGE_BLOCK: 12
|
||||
GENESIS_CHALLENGE: "4b227777d4dd1fc61c6f884f48641d02b4d121d3fd328cb08b5531fcacdabf8a" # std_hash(b"4")
|
||||
NETWORK: 4
|
||||
testnet5:
|
||||
GENESIS_CHALLENGE: "ef2d127de37b942baad06145e54b0c619a1f22327b2ebbcfbec78f5564afe39d" # std_hash(b"5")
|
||||
NETWORK: 5
|
||||
|
||||
constants:
|
||||
mainnet:
|
||||
NETWORK_TYPE: 0
|
||||
GENESIS_CHALLENGE: null
|
||||
testnet0:
|
||||
MIN_PLOT_SIZE: 18
|
||||
GENESIS_CHALLENGE: "0x0000000000000000000000000000000000000000000000000000000000000000"
|
||||
NETWORK_TYPE: 1
|
||||
testnet4:
|
||||
GENESIS_CHALLENGE: "4b227777d4dd1fc61c6f884f48641d02b4d121d3fd328cb08b5531fcacdabf8a" # std_hash(b"4")
|
||||
NETWORK_TYPE: 1
|
||||
config:
|
||||
mainnet:
|
||||
address_prefix: "xch"
|
||||
testnet0:
|
||||
address_prefix: "txch"
|
||||
testnet4:
|
||||
address_prefix: "txch"
|
||||
|
||||
selected_network: &selected_network "testnet4"
|
||||
|
||||
|
|
|
@ -30,8 +30,9 @@ def make_puzzle(amount: int) -> int:
|
|||
puzzle_hash = puzzle_prog.get_tree_hash()
|
||||
|
||||
solution = "()"
|
||||
prefix = "xch"
|
||||
print("PH", puzzle_hash)
|
||||
print(f"Address: {encode_puzzle_hash(puzzle_hash)}")
|
||||
print(f"Address: {encode_puzzle_hash(puzzle_hash, prefix)}")
|
||||
|
||||
result = puzzle_prog.run(solution)
|
||||
error, result_human = parse_sexp_to_conditions(result)
|
||||
|
@ -45,7 +46,7 @@ def make_puzzle(amount: int) -> int:
|
|||
assert len(cvp.vars) == 2
|
||||
total_chia += int_from_bytes(cvp.vars[1])
|
||||
print(
|
||||
f"{ConditionOpcode(cvp.opcode).name}: {encode_puzzle_hash(cvp.vars[0])},"
|
||||
f"{ConditionOpcode(cvp.opcode).name}: {encode_puzzle_hash(cvp.vars[0], prefix)},"
|
||||
f" amount: {int_from_bytes(cvp.vars[1])}"
|
||||
)
|
||||
return total_chia
|
||||
|
|
|
@ -256,7 +256,14 @@ class TestCoinStore:
|
|||
@pytest.mark.asyncio
|
||||
async def test_get_puzzle_hash(self):
|
||||
num_blocks = 20
|
||||
blocks = bt.get_consecutive_blocks(num_blocks, guarantee_transaction_block=True)
|
||||
farmer_ph = 32 * b"0"
|
||||
pool_ph = 32 * b"1"
|
||||
blocks = bt.get_consecutive_blocks(
|
||||
num_blocks,
|
||||
farmer_reward_puzzle_hash=farmer_ph,
|
||||
pool_reward_puzzle_hash=pool_ph,
|
||||
guarantee_transaction_block=True,
|
||||
)
|
||||
db_path = Path("blockchain_test.db")
|
||||
if db_path.exists():
|
||||
db_path.unlink()
|
||||
|
@ -270,10 +277,9 @@ class TestCoinStore:
|
|||
assert res == ReceiveBlockResult.NEW_PEAK
|
||||
assert b.get_peak().height == num_blocks - 1
|
||||
|
||||
pool_coin, farmer_coin = get_future_reward_coins(blocks[-2])
|
||||
coins_farmer = await coin_store.get_coin_records_by_puzzle_hash(True, pool_ph)
|
||||
coins_pool = await coin_store.get_coin_records_by_puzzle_hash(True, farmer_ph)
|
||||
|
||||
coins_farmer = await coin_store.get_coin_records_by_puzzle_hash(True, farmer_coin.puzzle_hash)
|
||||
coins_pool = await coin_store.get_coin_records_by_puzzle_hash(True, pool_coin.puzzle_hash)
|
||||
assert len(coins_farmer) == num_blocks - 2
|
||||
assert len(coins_pool) == num_blocks - 2
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ async def setup_two_nodes():
|
|||
|
||||
@pytest.fixture(scope="function")
|
||||
async def wallet_nodes_mainnet():
|
||||
async_gen = setup_simulators_and_wallets(2, 1, {"NETWORK": 0}, starting_port=40000)
|
||||
async_gen = setup_simulators_and_wallets(2, 1, {"NETWORK_TYPE": 0}, starting_port=40000)
|
||||
nodes, wallets = await async_gen.__anext__()
|
||||
full_node_1 = nodes[0]
|
||||
full_node_2 = nodes[1]
|
||||
|
|
|
@ -65,7 +65,7 @@ async def setup_full_node(
|
|||
config["introducer_peer"] = None
|
||||
config["port"] = port
|
||||
config["rpc_port"] = port + 1000
|
||||
overrides = config["network_overrides"][config["selected_network"]]
|
||||
overrides = config["network_overrides"]["constants"][config["selected_network"]]
|
||||
updated_constants = consensus_constants.replace_str_to_bytes(**overrides)
|
||||
if simulator:
|
||||
kwargs = service_kwargs_for_full_node_simulator(local_bt.root_path, config, local_bt)
|
||||
|
@ -184,10 +184,10 @@ async def setup_farmer(
|
|||
config = bt.config["farmer"]
|
||||
config_pool = bt.config["pool"]
|
||||
|
||||
config["xch_target_address"] = encode_puzzle_hash(b_tools.farmer_ph)
|
||||
config["xch_target_address"] = encode_puzzle_hash(b_tools.farmer_ph, "xch")
|
||||
config["pool_public_keys"] = [bytes(pk).hex() for pk in b_tools.pool_pubkeys]
|
||||
config["port"] = port
|
||||
config_pool["xch_target_address"] = encode_puzzle_hash(b_tools.pool_ph)
|
||||
config_pool["xch_target_address"] = encode_puzzle_hash(b_tools.pool_ph, "xch")
|
||||
|
||||
if full_node_port:
|
||||
config["full_node_peer"]["host"] = self_hostname
|
||||
|
|
|
@ -434,7 +434,6 @@ class TestCCWallet:
|
|||
await time_out_assert(30, cc_wallet_2.get_unconfirmed_balance, 0)
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.skip(reason="broken")
|
||||
async def test_cc_max_amount_send(self, two_wallet_nodes):
|
||||
num_blocks = 3
|
||||
full_nodes, wallets = two_wallet_nodes
|
||||
|
@ -507,6 +506,7 @@ class TestCCWallet:
|
|||
return True
|
||||
|
||||
await time_out_assert(15, check_all_there, True)
|
||||
await asyncio.sleep(5)
|
||||
max_sent_amount = await cc_wallet.get_max_send_amount()
|
||||
|
||||
# 1) Generate transaction that is under the limit
|
||||
|
|
|
@ -111,7 +111,7 @@ class TestRLWallet:
|
|||
|
||||
await time_out_assert(15, check_balance, 100, api_user, user_wallet_id)
|
||||
receiving_wallet = wallet_node_2.wallet_state_manager.main_wallet
|
||||
address = encode_puzzle_hash(await receiving_wallet.get_new_puzzlehash())
|
||||
address = encode_puzzle_hash(await receiving_wallet.get_new_puzzlehash(), "xch")
|
||||
assert await receiving_wallet.get_spendable_balance() == 0
|
||||
val = await api_user.send_transaction({"wallet_id": user_wallet_id, "amount": 3, "fee": 2, "address": address})
|
||||
assert "transaction_id" in val
|
||||
|
@ -142,7 +142,7 @@ class TestRLWallet:
|
|||
await time_out_assert(15, check_balance, 195, api_user, user_wallet_id)
|
||||
|
||||
# test spending
|
||||
puzzle_hash = encode_puzzle_hash(await receiving_wallet.get_new_puzzlehash())
|
||||
puzzle_hash = encode_puzzle_hash(await receiving_wallet.get_new_puzzlehash(), "xch")
|
||||
val = await api_user.send_transaction(
|
||||
{
|
||||
"wallet_id": user_wallet_id,
|
||||
|
|
|
@ -78,7 +78,7 @@ class TestWalletRpc:
|
|||
|
||||
client = await WalletRpcClient.create("localhost", test_rpc_port, bt.root_path, config)
|
||||
try:
|
||||
addr = encode_puzzle_hash(await wallet_node_2.wallet_state_manager.main_wallet.get_new_puzzlehash())
|
||||
addr = encode_puzzle_hash(await wallet_node_2.wallet_state_manager.main_wallet.get_new_puzzlehash(), "xch")
|
||||
tx_amount = 15600000
|
||||
try:
|
||||
await client.send_transaction("1", 100000000000000001, addr)
|
||||
|
@ -99,7 +99,7 @@ class TestWalletRpc:
|
|||
assert (await client.get_wallet_balance("1"))["confirmed_wallet_balance"] == initial_funds
|
||||
|
||||
for i in range(0, 5):
|
||||
await client.farm_block(encode_puzzle_hash(ph_2))
|
||||
await client.farm_block(encode_puzzle_hash(ph_2, "xch"))
|
||||
await asyncio.sleep(1)
|
||||
|
||||
async def eventual_balance():
|
||||
|
|
Loading…
Reference in a new issue