mirror of
https://github.com/Chia-Network/chia-blockchain.git
synced 2024-08-17 23:01:02 +03:00
remove leading newlines from indented code blocks (#14653)
* remove leading newlines from indented code blocks * catch another one
This commit is contained in:
parent
9dcba09dda
commit
ff5ef6e073
@ -49,7 +49,6 @@ REPETITIONS = 100
|
||||
|
||||
|
||||
async def main(db_path: Path):
|
||||
|
||||
random.seed(0x213FB154)
|
||||
|
||||
async with aiosqlite.connect(db_path) as connection:
|
||||
|
@ -40,7 +40,6 @@ random.seed(123456789)
|
||||
|
||||
|
||||
async def run_add_block_benchmark(version: int):
|
||||
|
||||
verbose: bool = "--verbose" in sys.argv
|
||||
db_wrapper: DBWrapper2 = await setup_db("block-store-benchmark.db", version)
|
||||
|
||||
@ -73,7 +72,6 @@ async def run_add_block_benchmark(version: int):
|
||||
print("profiling add_full_block", end="")
|
||||
|
||||
for height in range(block_height, block_height + NUM_ITERS):
|
||||
|
||||
is_transaction = transaction_block_counter == 0
|
||||
fees = uint64(random.randint(0, 150000))
|
||||
farmer_coin, pool_coin = rewards(uint32(height))
|
||||
|
@ -38,7 +38,6 @@ def make_coins(num: int) -> Tuple[List[Coin], List[bytes32]]:
|
||||
|
||||
|
||||
async def run_new_block_benchmark(version: int):
|
||||
|
||||
verbose: bool = "--verbose" in sys.argv
|
||||
db_wrapper: DBWrapper2 = await setup_db("coin-store-benchmark.db", version)
|
||||
|
||||
@ -56,7 +55,6 @@ async def run_new_block_benchmark(version: int):
|
||||
|
||||
print("Building database ", end="")
|
||||
for height in range(block_height, block_height + NUM_ITERS):
|
||||
|
||||
# add some new coins
|
||||
additions, hashes = make_coins(2000)
|
||||
|
||||
@ -94,7 +92,6 @@ async def run_new_block_benchmark(version: int):
|
||||
if verbose:
|
||||
print("Profiling mostly additions ", end="")
|
||||
for height in range(block_height, block_height + NUM_ITERS):
|
||||
|
||||
# add some new coins
|
||||
additions, hashes = make_coins(2000)
|
||||
total_add += 2000
|
||||
@ -193,7 +190,6 @@ async def run_new_block_benchmark(version: int):
|
||||
total_remove = 0
|
||||
total_time = 0
|
||||
for height in range(block_height, block_height + NUM_ITERS):
|
||||
|
||||
# add some new coins
|
||||
additions, hashes = make_coins(2000)
|
||||
total_add += 2000
|
||||
|
@ -77,7 +77,6 @@ def fake_block_record(block_height: uint32, timestamp: uint64) -> BenchBlockReco
|
||||
|
||||
|
||||
async def run_mempool_benchmark() -> None:
|
||||
|
||||
all_coins: Dict[bytes32, CoinRecord] = {}
|
||||
|
||||
async def get_coin_record(coin_id: bytes32) -> Optional[CoinRecord]:
|
||||
@ -96,7 +95,6 @@ async def run_mempool_benchmark() -> None:
|
||||
|
||||
print("Building SpendBundles")
|
||||
for peer in range(NUM_PEERS):
|
||||
|
||||
print(f" peer {peer}")
|
||||
print(" reward coins")
|
||||
unspent: List[Coin] = []
|
||||
|
@ -5,7 +5,6 @@ from setuptools_scm import get_version
|
||||
|
||||
# example: 1.0b5.dev225
|
||||
def main():
|
||||
|
||||
scm_full_version = get_version(root="..", relative_to=__file__)
|
||||
# scm_full_version = "1.0.5.dev22"
|
||||
|
||||
|
@ -129,7 +129,6 @@ _T_SpendSim = TypeVar("_T_SpendSim", bound="SpendSim")
|
||||
|
||||
|
||||
class SpendSim:
|
||||
|
||||
db_wrapper: DBWrapper2
|
||||
coin_store: CoinStore
|
||||
mempool_manager: MempoolManager
|
||||
|
@ -369,7 +369,6 @@ class WalletDBReader:
|
||||
|
||||
|
||||
async def scan(root_path: str, db_path: Optional[str] = None, *, verbose: bool = False) -> None:
|
||||
|
||||
if db_path is None:
|
||||
wallet_db_path = Path(root_path) / "wallet" / "db"
|
||||
wallet_db_paths = list(wallet_db_path.glob("blockchain_wallet_*.sqlite"))
|
||||
|
@ -49,7 +49,6 @@ async def validate_client_connection(
|
||||
fingerprint: Optional[int],
|
||||
login_to_wallet: bool,
|
||||
) -> Optional[int]:
|
||||
|
||||
try:
|
||||
await rpc_client.healthz()
|
||||
if type(rpc_client) == WalletRpcClient and login_to_wallet:
|
||||
|
@ -32,7 +32,6 @@ def db_cmd() -> None:
|
||||
)
|
||||
@click.pass_context
|
||||
def db_upgrade_cmd(ctx: click.Context, no_update_config: bool, force: bool, **kwargs) -> None:
|
||||
|
||||
try:
|
||||
in_db_path = kwargs.get("input")
|
||||
out_db_path = kwargs.get("output")
|
||||
|
@ -27,7 +27,6 @@ def db_upgrade_func(
|
||||
no_update_config: bool = False,
|
||||
force: bool = False,
|
||||
) -> None:
|
||||
|
||||
update_config: bool = in_db_path is None and out_db_path is None and not no_update_config
|
||||
|
||||
config: Dict
|
||||
@ -81,7 +80,6 @@ def db_upgrade_func(
|
||||
except RuntimeError as e:
|
||||
print(f"conversion failed with error: {e}.")
|
||||
except Exception as e:
|
||||
|
||||
print(
|
||||
textwrap.dedent(
|
||||
f"""\
|
||||
@ -202,10 +200,8 @@ def convert_v1_to_v2(in_path: Path, out_path: Path) -> None:
|
||||
"SELECT header_hash, height, is_fully_compactified, block FROM full_blocks ORDER BY height DESC"
|
||||
)
|
||||
) as cursor_2:
|
||||
|
||||
out_db.execute("begin transaction")
|
||||
for row in cursor:
|
||||
|
||||
header_hash = bytes.fromhex(row[0])
|
||||
if header_hash != hh:
|
||||
continue
|
||||
|
@ -41,7 +41,6 @@ def validate_v2(in_path: Path, *, validate_blocks: bool) -> None:
|
||||
|
||||
print(f"opening file for reading: {in_path}")
|
||||
with closing(sqlite3.connect(in_path)) as in_db:
|
||||
|
||||
# read the database version
|
||||
try:
|
||||
with closing(in_db.execute("SELECT * FROM database_version")) as cursor:
|
||||
@ -91,9 +90,7 @@ def validate_v2(in_path: Path, *, validate_blocks: bool) -> None:
|
||||
"FROM full_blocks ORDER BY height DESC"
|
||||
)
|
||||
) as cursor:
|
||||
|
||||
for row in cursor:
|
||||
|
||||
hh = row[0]
|
||||
prev = row[1]
|
||||
height = row[2]
|
||||
|
@ -428,7 +428,6 @@ class Blockchain(BlockchainInterface):
|
||||
async def get_tx_removals_and_additions(
|
||||
self, block: FullBlock, npc_result: Optional[NPCResult] = None
|
||||
) -> Tuple[List[bytes32], List[Coin], Optional[NPCResult]]:
|
||||
|
||||
if not block.is_transaction_block():
|
||||
return [], [], None
|
||||
|
||||
|
@ -27,7 +27,6 @@ def block_to_block_record(
|
||||
header_block: Optional[HeaderBlock],
|
||||
sub_slot_iters: Optional[uint64] = None,
|
||||
) -> BlockRecord:
|
||||
|
||||
if full_block is None:
|
||||
assert header_block is not None
|
||||
block: Union[HeaderBlock, FullBlock] = header_block
|
||||
@ -99,7 +98,6 @@ def header_block_to_sub_block_record(
|
||||
prev_transaction_block_height: uint32,
|
||||
ses: Optional[SubEpochSummary],
|
||||
) -> BlockRecord:
|
||||
|
||||
reward_claims_incorporated = (
|
||||
block.transactions_info.reward_claims_incorporated if block.transactions_info is not None else None
|
||||
)
|
||||
|
@ -116,7 +116,6 @@ def batch_pre_validate_blocks(
|
||||
successfully_validated_signatures = False
|
||||
# If we failed CLVM, no need to validate signature, the block is already invalid
|
||||
if error_int is None:
|
||||
|
||||
# If this is False, it means either we don't have a signature (not a tx block) or we have an invalid
|
||||
# signature (which also puts in an error) or we didn't validate the signature because we want to
|
||||
# validate it later. receive_block will attempt to validate the signature later.
|
||||
|
@ -117,7 +117,6 @@ class DataLayerServer:
|
||||
|
||||
|
||||
async def async_start(root_path: Path) -> int:
|
||||
|
||||
shutdown_event = asyncio.Event()
|
||||
|
||||
dl_config = load_config(
|
||||
|
@ -627,7 +627,6 @@ class Farmer:
|
||||
for pool_state in self.pool_state.values():
|
||||
pool_config: PoolWalletConfig = pool_state["pool_config"]
|
||||
if pool_config.launcher_id == launcher_id:
|
||||
|
||||
authentication_sk: Optional[PrivateKey] = self.get_authentication_sk(pool_config)
|
||||
if authentication_sk is None:
|
||||
self.log.error(f"Could not find authentication sk for {pool_config.p2_singleton_puzzle_hash}")
|
||||
|
@ -157,7 +157,6 @@ class BlockHeightMap:
|
||||
# time until we hit a match in the existing map, at which point we can
|
||||
# assume all previous blocks have already been populated
|
||||
async def _load_blocks_from(self, height: uint32, prev_hash: bytes32) -> None:
|
||||
|
||||
while height > 0:
|
||||
# load 5000 blocks at a time
|
||||
window_end = max(0, height - 5000)
|
||||
@ -175,7 +174,6 @@ class BlockHeightMap:
|
||||
|
||||
async with self.db.reader_no_transaction() as conn:
|
||||
async with conn.execute(query, (window_end, height)) as cursor:
|
||||
|
||||
# maps block-hash -> (height, prev-hash, sub-epoch-summary)
|
||||
ordered: Dict[bytes32, Tuple[uint32, bytes32, Optional[bytes]]] = {}
|
||||
|
||||
@ -195,7 +193,6 @@ class BlockHeightMap:
|
||||
assert height == entry[0] + 1
|
||||
height = entry[0]
|
||||
if entry[2] is not None:
|
||||
|
||||
if (
|
||||
self.get_hash(height) == prev_hash
|
||||
and height in self.__sub_epoch_summaries
|
||||
|
@ -34,10 +34,8 @@ class BlockStore:
|
||||
self = cls(LRUCache(1000), db_wrapper, LRUCache(50))
|
||||
|
||||
async with self.db_wrapper.writer_maybe_transaction() as conn:
|
||||
|
||||
log.info("DB: Creating block store tables and indexes.")
|
||||
if self.db_wrapper.db_version == 2:
|
||||
|
||||
# TODO: most data in block is duplicated in block_record. The only
|
||||
# reason for this is that our parsing of a FullBlock is so slow,
|
||||
# it's faster to store duplicate data to parse less when we just
|
||||
@ -84,7 +82,6 @@ class BlockStore:
|
||||
)
|
||||
|
||||
else:
|
||||
|
||||
await conn.execute(
|
||||
"CREATE TABLE IF NOT EXISTS full_blocks(header_hash text PRIMARY KEY, height bigint,"
|
||||
" is_block tinyint, is_fully_compactified tinyint, block blob)"
|
||||
@ -168,7 +165,6 @@ class BlockStore:
|
||||
raise RuntimeError(f"The blockchain database is corrupt. All of {header_hashes} should exist")
|
||||
|
||||
async def replace_proof(self, header_hash: bytes32, block: FullBlock) -> None:
|
||||
|
||||
assert header_hash == block.header_hash
|
||||
|
||||
block_bytes: bytes
|
||||
@ -193,7 +189,6 @@ class BlockStore:
|
||||
self.block_cache.put(header_hash, block)
|
||||
|
||||
if self.db_wrapper.db_version == 2:
|
||||
|
||||
ses: Optional[bytes] = (
|
||||
None
|
||||
if block_record.sub_epoch_summary_included is None
|
||||
@ -331,7 +326,6 @@ class BlockStore:
|
||||
return ret
|
||||
|
||||
async def get_block_info(self, header_hash: bytes32) -> Optional[GeneratorBlockInfo]:
|
||||
|
||||
cached = self.block_cache.get(header_hash)
|
||||
if cached is not None:
|
||||
log.debug(f"cache hit for block {header_hash.hex()}")
|
||||
@ -362,7 +356,6 @@ class BlockStore:
|
||||
)
|
||||
|
||||
async def get_generator(self, header_hash: bytes32) -> Optional[SerializedProgram]:
|
||||
|
||||
cached = self.block_cache.get(header_hash)
|
||||
if cached is not None:
|
||||
log.debug(f"cache hit for block {header_hash.hex()}")
|
||||
@ -521,9 +514,7 @@ class BlockStore:
|
||||
return ret
|
||||
|
||||
async def get_block_record(self, header_hash: bytes32) -> Optional[BlockRecord]:
|
||||
|
||||
if self.db_wrapper.db_version == 2:
|
||||
|
||||
async with self.db_wrapper.reader_no_transaction() as conn:
|
||||
async with conn.execute(
|
||||
"SELECT block_record FROM full_blocks WHERE header_hash=?",
|
||||
@ -556,7 +547,6 @@ class BlockStore:
|
||||
|
||||
ret: Dict[bytes32, BlockRecord] = {}
|
||||
if self.db_wrapper.db_version == 2:
|
||||
|
||||
async with self.db_wrapper.reader_no_transaction() as conn:
|
||||
async with conn.execute(
|
||||
"SELECT header_hash, block_record FROM full_blocks WHERE height >= ? AND height <= ?",
|
||||
@ -567,7 +557,6 @@ class BlockStore:
|
||||
ret[header_hash] = BlockRecord.from_bytes(row[1])
|
||||
|
||||
else:
|
||||
|
||||
formatted_str = f"SELECT header_hash, block from block_records WHERE height >= {start} and height <= {stop}"
|
||||
|
||||
async with self.db_wrapper.reader_no_transaction() as conn:
|
||||
@ -601,7 +590,6 @@ class BlockStore:
|
||||
return [maybe_decompress_blob(row[0]) for row in rows]
|
||||
|
||||
async def get_peak(self) -> Optional[Tuple[bytes32, uint32]]:
|
||||
|
||||
if self.db_wrapper.db_version == 2:
|
||||
async with self.db_wrapper.reader_no_transaction() as conn:
|
||||
async with conn.execute("SELECT hash FROM current_peak WHERE key = 0") as cursor:
|
||||
@ -636,7 +624,6 @@ class BlockStore:
|
||||
|
||||
ret: Dict[bytes32, BlockRecord] = {}
|
||||
if self.db_wrapper.db_version == 2:
|
||||
|
||||
async with self.db_wrapper.reader_no_transaction() as conn:
|
||||
async with conn.execute(
|
||||
"SELECT header_hash, block_record FROM full_blocks WHERE height >= ?",
|
||||
@ -683,7 +670,6 @@ class BlockStore:
|
||||
return bool(row[0])
|
||||
|
||||
async def get_random_not_compactified(self, number: int) -> List[int]:
|
||||
|
||||
if self.db_wrapper.db_version == 2:
|
||||
async with self.db_wrapper.reader_no_transaction() as conn:
|
||||
async with conn.execute(
|
||||
|
@ -36,10 +36,8 @@ class CoinStore:
|
||||
self = CoinStore(db_wrapper, LRUCache(100))
|
||||
|
||||
async with self.db_wrapper.writer_maybe_transaction() as conn:
|
||||
|
||||
log.info("DB: Creating coin store tables and indexes.")
|
||||
if self.db_wrapper.db_version == 2:
|
||||
|
||||
# the coin_name is unique in this table because the CoinStore always
|
||||
# only represent a single peak
|
||||
await conn.execute(
|
||||
@ -55,7 +53,6 @@ class CoinStore:
|
||||
)
|
||||
|
||||
else:
|
||||
|
||||
# the coin_name is unique in this table because the CoinStore always
|
||||
# only represent a single peak
|
||||
await conn.execute(
|
||||
@ -273,7 +270,6 @@ class CoinStore:
|
||||
start_height: uint32 = uint32(0),
|
||||
end_height: uint32 = uint32((2**32) - 1),
|
||||
) -> List[CoinRecord]:
|
||||
|
||||
coins = set()
|
||||
|
||||
async with self.db_wrapper.reader_no_transaction() as conn:
|
||||
@ -284,7 +280,6 @@ class CoinStore:
|
||||
f"{'' if include_spent_coins else 'AND spent_index=0'}",
|
||||
(self.maybe_to_hex(puzzle_hash), start_height, end_height),
|
||||
) as cursor:
|
||||
|
||||
for row in await cursor.fetchall():
|
||||
coin = self.row_to_coin(row)
|
||||
coins.add(CoinRecord(coin, row[0], row[1], row[2], row[6]))
|
||||
@ -316,7 +311,6 @@ class CoinStore:
|
||||
f"{'' if include_spent_coins else 'AND spent_index=0'}",
|
||||
puzzle_hashes_db + (start_height, end_height),
|
||||
) as cursor:
|
||||
|
||||
for row in await cursor.fetchall():
|
||||
coin = self.row_to_coin(row)
|
||||
coins.add(CoinRecord(coin, row[0], row[1], row[2], row[6]))
|
||||
@ -348,7 +342,6 @@ class CoinStore:
|
||||
f"{'' if include_spent_coins else 'AND spent_index=0'}",
|
||||
names_db + (start_height, end_height),
|
||||
) as cursor:
|
||||
|
||||
for row in await cursor.fetchall():
|
||||
coin = self.row_to_coin(row)
|
||||
coins.add(CoinRecord(coin, row[0], row[1], row[2], row[6]))
|
||||
@ -427,7 +420,6 @@ class CoinStore:
|
||||
f"{'' if include_spent_coins else 'AND spent_index=0'}",
|
||||
parent_ids_db + (start_height, end_height),
|
||||
) as cursor:
|
||||
|
||||
async for row in cursor:
|
||||
coin = self.row_to_coin(row)
|
||||
coins.add(CoinRecord(coin, row[0], row[1], row[2], row[6]))
|
||||
@ -513,7 +505,6 @@ class CoinStore:
|
||||
|
||||
# Store CoinRecord in DB
|
||||
async def _add_coin_records(self, records: List[CoinRecord]) -> None:
|
||||
|
||||
if self.db_wrapper.db_version == 2:
|
||||
values2 = []
|
||||
for record in records:
|
||||
@ -560,7 +551,6 @@ class CoinStore:
|
||||
|
||||
# Update coin_record to be spent in DB
|
||||
async def _set_spent(self, coin_names: List[bytes32], index: uint32) -> None:
|
||||
|
||||
assert len(coin_names) == 0 or index > 0
|
||||
|
||||
if len(coin_names) == 0:
|
||||
|
@ -511,7 +511,6 @@ class FeeTracker:
|
||||
self.long_horizon.tx_confirmed(blocks_to_confirm, item)
|
||||
|
||||
def add_tx(self, item: MempoolItem) -> None:
|
||||
|
||||
if item.height_added_to_mempool < self.latest_seen_height:
|
||||
self.log.info(f"Processing Item from pending pool: cost={item.cost} fee={item.fee}")
|
||||
|
||||
|
@ -2103,7 +2103,6 @@ class FullNode:
|
||||
async def add_end_of_sub_slot(
|
||||
self, end_of_slot_bundle: EndOfSubSlotBundle, peer: WSChiaConnection
|
||||
) -> Tuple[Optional[Message], bool]:
|
||||
|
||||
fetched_ss = self.full_node_store.get_sub_slot(end_of_slot_bundle.challenge_chain.get_hash())
|
||||
|
||||
# We are not interested in sub-slots which have the same challenge chain but different reward chain. If there
|
||||
@ -2355,7 +2354,6 @@ class FullNode:
|
||||
header_hash: bytes32,
|
||||
field_vdf: CompressibleVDFField,
|
||||
) -> bool:
|
||||
|
||||
block = await self.block_store.get_full_block(header_hash)
|
||||
if block is None:
|
||||
return False
|
||||
@ -2521,7 +2519,6 @@ class FullNode:
|
||||
self.log.info("Heights found for bluebox to compact: [%s]" % ", ".join(map(str, heights)))
|
||||
|
||||
for h in heights:
|
||||
|
||||
headers = await self.blockchain.get_header_blocks_in_range(h, h, tx_filter=False)
|
||||
records: Dict[bytes32, BlockRecord] = {}
|
||||
if sanitize_weight_proof_only:
|
||||
@ -2612,7 +2609,6 @@ class FullNode:
|
||||
async def node_next_block_check(
|
||||
peer: WSChiaConnection, potential_peek: uint32, blockchain: BlockchainInterface
|
||||
) -> bool:
|
||||
|
||||
block_response: Optional[Any] = await peer.call_api(
|
||||
FullNodeAPI.request_block, full_node_protocol.RequestBlock(potential_peek, True)
|
||||
)
|
||||
|
@ -558,7 +558,6 @@ class FullNodeAPI:
|
||||
async def request_signage_point_or_end_of_sub_slot(
|
||||
self, request: full_node_protocol.RequestSignagePointOrEndOfSubSlot
|
||||
) -> Optional[Message]:
|
||||
|
||||
if request.index_from_challenge == 0:
|
||||
sub_slot: Optional[Tuple[EndOfSubSlotBundle, int, uint128]] = self.full_node.full_node_store.get_sub_slot(
|
||||
request.challenge_hash
|
||||
@ -619,7 +618,6 @@ class FullNodeAPI:
|
||||
return None
|
||||
peak = self.full_node.blockchain.get_peak()
|
||||
if peak is not None and peak.height > self.full_node.constants.MAX_SUB_SLOT_BLOCKS:
|
||||
|
||||
next_sub_slot_iters = self.full_node.blockchain.get_next_slot_iters(peak.header_hash, True)
|
||||
sub_slots_for_peak = await self.full_node.blockchain.get_sp_and_ip_sub_slots(peak.header_hash)
|
||||
assert sub_slots_for_peak is not None
|
||||
@ -1096,7 +1094,6 @@ class FullNodeAPI:
|
||||
tx_additions: List[Coin] = []
|
||||
|
||||
if block.transactions_generator is not None:
|
||||
|
||||
block_generator: Optional[BlockGenerator] = await self.full_node.blockchain.get_block_generator(block)
|
||||
# get_block_generator() returns None in case the block we specify
|
||||
# does not have a generator (i.e. is not a transaction block).
|
||||
@ -1457,7 +1454,6 @@ class FullNodeAPI:
|
||||
async def register_interest_in_puzzle_hash(
|
||||
self, request: wallet_protocol.RegisterForPhUpdates, peer: WSChiaConnection
|
||||
) -> Message:
|
||||
|
||||
trusted = self.is_trusted(peer)
|
||||
if trusted:
|
||||
max_subscriptions = self.full_node.config.get("trusted_max_subscribe_items", 2000000)
|
||||
@ -1530,7 +1526,6 @@ class FullNodeAPI:
|
||||
async def register_interest_in_coin(
|
||||
self, request: wallet_protocol.RegisterForCoinUpdates, peer: WSChiaConnection
|
||||
) -> Message:
|
||||
|
||||
if self.is_trusted(peer):
|
||||
max_subscriptions = self.full_node.config.get("trusted_max_subscribe_items", 2000000)
|
||||
max_items = self.full_node.config.get("trusted_max_subscribe_response_items", 500000)
|
||||
|
@ -34,7 +34,6 @@ class ConflictTxCache:
|
||||
self._cache_cost += item.cost
|
||||
|
||||
while self._cache_cost > self._cache_max_total_cost or len(self._txs) > self._cache_max_size:
|
||||
|
||||
first_in = list(self._txs.keys())[0]
|
||||
self._cache_cost -= self._txs[first_in].cost
|
||||
self._txs.pop(first_in)
|
||||
@ -77,7 +76,6 @@ class PendingTxCache:
|
||||
self._by_height.setdefault(item.assert_height, {})[name] = item
|
||||
|
||||
while self._cache_cost > self._cache_max_total_cost or len(self._txs) > self._cache_max_size:
|
||||
|
||||
# we start removing items with the highest assert_height first
|
||||
to_evict = self._by_height.items()[-1]
|
||||
if to_evict[1] == {}:
|
||||
|
@ -112,7 +112,6 @@ class PeerSubscriptions:
|
||||
break
|
||||
|
||||
def remove_peer(self, peer_id: bytes32) -> None:
|
||||
|
||||
counter = 0
|
||||
puzzle_hashes = self._peer_puzzle_hash.get(peer_id)
|
||||
if puzzle_hashes is not None:
|
||||
|
@ -54,7 +54,6 @@ def _create_shutdown_file() -> IO:
|
||||
|
||||
|
||||
class WeightProofHandler:
|
||||
|
||||
LAMBDA_L = 100
|
||||
C = 0.5
|
||||
MAX_SAMPLES = 20
|
||||
@ -74,7 +73,6 @@ class WeightProofHandler:
|
||||
self.multiprocessing_context = multiprocessing_context
|
||||
|
||||
async def get_proof_of_weight(self, tip: bytes32) -> Optional[WeightProof]:
|
||||
|
||||
tip_rec = self.blockchain.try_block_record(tip)
|
||||
if tip_rec is None:
|
||||
log.error("unknown tip")
|
||||
@ -859,7 +857,6 @@ def _validate_sub_epoch_summaries(
|
||||
constants: ConsensusConstants,
|
||||
weight_proof: WeightProof,
|
||||
) -> Tuple[Optional[List[SubEpochSummary]], Optional[List[uint128]]]:
|
||||
|
||||
last_ses_hash, last_ses_sub_height = _get_last_ses_hash(constants, weight_proof.recent_chain_data)
|
||||
if last_ses_hash is None:
|
||||
log.warning("could not find last ses block")
|
||||
@ -1074,7 +1071,6 @@ def _validate_sub_slot_data(
|
||||
sub_slots: List[SubSlotData],
|
||||
ssi: uint64,
|
||||
) -> Tuple[bool, List[Tuple[VDFProof, ClassgroupElement, VDFInfo]]]:
|
||||
|
||||
sub_slot_data = sub_slots[sub_slot_idx]
|
||||
assert sub_slot_idx > 0
|
||||
prev_ssd = sub_slots[sub_slot_idx - 1]
|
||||
@ -1381,7 +1377,6 @@ def __get_rc_sub_slot(
|
||||
summaries: List[SubEpochSummary],
|
||||
curr_ssi: uint64,
|
||||
) -> RewardChainSubSlot:
|
||||
|
||||
ses = summaries[uint32(segment.sub_epoch_n - 1)]
|
||||
# find first challenge in sub epoch
|
||||
first_idx = None
|
||||
@ -1646,7 +1641,6 @@ def _validate_vdf_batch(
|
||||
vdf_list: List[Tuple[bytes, bytes, bytes]],
|
||||
shutdown_file_path: Optional[pathlib.Path] = None,
|
||||
):
|
||||
|
||||
for vdf_proof_bytes, class_group_bytes, info in vdf_list:
|
||||
vdf = VDFProof.from_bytes(vdf_proof_bytes)
|
||||
class_group = ClassgroupElement.from_bytes(class_group_bytes)
|
||||
|
@ -466,7 +466,6 @@ class FullNodeRpcApi:
|
||||
return {"block_record": record}
|
||||
|
||||
async def get_unfinished_block_headers(self, _request: Dict[str, Any]) -> EndpointResult:
|
||||
|
||||
peak: Optional[BlockRecord] = self.service.blockchain.get_peak()
|
||||
if peak is None:
|
||||
return {"headers": []}
|
||||
|
@ -207,7 +207,6 @@ class RpcServer:
|
||||
if change == "add_connection" or change == "close_connection" or change == "peer_changed_peak":
|
||||
data = await self.get_connections({})
|
||||
if data is not None:
|
||||
|
||||
payload = create_payload_dict(
|
||||
"get_connections",
|
||||
data,
|
||||
|
@ -247,7 +247,6 @@ class WalletRpcClient(RpcClient):
|
||||
exclude_amounts: Optional[List[uint64]] = None,
|
||||
wallet_id: Optional[int] = None,
|
||||
) -> List[TransactionRecord]:
|
||||
|
||||
# Converts bytes to hex for puzzle hashes
|
||||
additions_hex = []
|
||||
for ad in additions:
|
||||
@ -308,7 +307,6 @@ class WalletRpcClient(RpcClient):
|
||||
exclude_coins: Optional[List[Coin]] = None,
|
||||
wallet_id: Optional[int] = None,
|
||||
) -> TransactionRecord:
|
||||
|
||||
txs: List[TransactionRecord] = await self.create_signed_transactions(
|
||||
additions=additions,
|
||||
coins=coins,
|
||||
@ -521,7 +519,6 @@ class WalletRpcClient(RpcClient):
|
||||
p2_singleton_delay_time: Optional[uint64] = None,
|
||||
p2_singleton_delayed_ph: Optional[bytes32] = None,
|
||||
) -> TransactionRecord:
|
||||
|
||||
request: Dict[str, Any] = {
|
||||
"wallet_type": "pool_wallet",
|
||||
"mode": mode,
|
||||
|
@ -100,7 +100,6 @@ class Crawler:
|
||||
|
||||
async def connect_task(self, peer):
|
||||
async def peer_action(peer: WSChiaConnection):
|
||||
|
||||
peer_info = peer.get_peer_info()
|
||||
version = peer.get_version()
|
||||
if peer_info is not None and version is not None:
|
||||
|
@ -600,7 +600,6 @@ class FullNodePeers(FullNodeDiscovery):
|
||||
|
||||
async def request_peers(self, peer_info: PeerInfo) -> Optional[Message]:
|
||||
try:
|
||||
|
||||
# Prevent a fingerprint attack: do not send peers to inbound connections.
|
||||
# This asymmetric behavior for inbound and outbound connections was introduced
|
||||
# to prevent a fingerprinting attack: an attacker can send specific fake addresses
|
||||
|
@ -72,7 +72,6 @@ class RateLimiter:
|
||||
rate_limits = get_rate_limits_to_use(our_capabilities, peer_capabilities)
|
||||
|
||||
try:
|
||||
|
||||
limits: RLSettings = rate_limits["default_settings"]
|
||||
if message_type in rate_limits["rate_limits_tx"]:
|
||||
limits = rate_limits["rate_limits_tx"][message_type]
|
||||
|
@ -160,7 +160,6 @@ class ChiaServer:
|
||||
chia_ca_crt_key: Tuple[Path, Path],
|
||||
name: str = __name__,
|
||||
) -> ChiaServer:
|
||||
|
||||
log = logging.getLogger(name)
|
||||
log.info("Service capabilities: %s", capabilities)
|
||||
|
||||
|
@ -137,7 +137,6 @@ class WSChiaConnection:
|
||||
local_capabilities_for_handshake: List[Tuple[uint16, str]],
|
||||
session: Optional[ClientSession] = None,
|
||||
) -> WSChiaConnection:
|
||||
|
||||
assert ws._writer is not None
|
||||
peername = ws._writer.transport.get_extra_info("peername")
|
||||
|
||||
|
@ -147,7 +147,6 @@ test_constants = DEFAULT_CONSTANTS.replace(
|
||||
def compute_additions_unchecked(sb: SpendBundle) -> List[Coin]:
|
||||
ret: List[Coin] = []
|
||||
for cs in sb.coin_spends:
|
||||
|
||||
parent_id = cs.coin.name()
|
||||
_, r = cs.puzzle_reveal.run_with_cost(INFINITE_COST, cs.solution)
|
||||
for cond in Program.to(r).as_iter():
|
||||
@ -182,7 +181,6 @@ class BlockTools:
|
||||
plot_dir: str = "test-plots",
|
||||
log: logging.Logger = logging.getLogger(__name__),
|
||||
):
|
||||
|
||||
self._block_cache_header = bytes32([0] * 32)
|
||||
|
||||
self._tempdir = None
|
||||
@ -1285,7 +1283,6 @@ class BlockTools:
|
||||
qualities = plot_info.prover.get_qualities_for_challenge(new_challenge)
|
||||
|
||||
for proof_index, quality_str in enumerate(qualities):
|
||||
|
||||
required_iters = calculate_iterations_quality(
|
||||
constants.DIFFICULTY_CONSTANT_FACTOR,
|
||||
quality_str,
|
||||
|
@ -290,7 +290,6 @@ async def setup_farmer_multi_harvester(
|
||||
*,
|
||||
start_services: bool,
|
||||
) -> AsyncIterator[Tuple[List[Service[Harvester]], Service[Farmer], BlockTools]]:
|
||||
|
||||
farmer_node_iterators = [
|
||||
setup_farmer(
|
||||
block_tools,
|
||||
|
@ -136,7 +136,6 @@ async def get_full_chia_simulator(
|
||||
keychain = Keychain()
|
||||
|
||||
with Lockfile.create(daemon_launch_lock_path(chia_root)):
|
||||
|
||||
mnemonic, fingerprint = mnemonic_fingerprint(keychain)
|
||||
|
||||
ssl_ca_cert_and_key_wrapper: SSLTestCollateralWrapper[
|
||||
|
@ -92,7 +92,6 @@ class SerializedProgram:
|
||||
def run_as_generator(
|
||||
self, max_cost: int, flags: int, *args: Union[Program, SerializedProgram]
|
||||
) -> Tuple[Optional[int], Optional[SpendBundleConditions]]:
|
||||
|
||||
serialized_args = bytearray()
|
||||
if len(args) > 1:
|
||||
# when we have more than one argument, serialize them into a list
|
||||
|
@ -35,7 +35,6 @@ def verify_vdf(
|
||||
discriminant_size: int,
|
||||
witness_type: uint8,
|
||||
):
|
||||
|
||||
return verify_n_wesolowski(
|
||||
str(disc),
|
||||
input_el,
|
||||
|
@ -31,7 +31,6 @@ def skip_bytes(buf: memoryview) -> memoryview:
|
||||
|
||||
|
||||
def skip_optional(buf: memoryview, skip_item: Callable[[memoryview], memoryview]) -> memoryview:
|
||||
|
||||
if buf[0] == 0:
|
||||
return buf[1:]
|
||||
assert buf[0] == 1
|
||||
|
@ -19,7 +19,6 @@ class VersionedBlob(Streamable):
|
||||
|
||||
|
||||
def format_bytes(bytes: int) -> str:
|
||||
|
||||
if not isinstance(bytes, int) or bytes < 0:
|
||||
return "Invalid"
|
||||
|
||||
@ -35,7 +34,6 @@ def format_bytes(bytes: int) -> str:
|
||||
|
||||
|
||||
def format_minutes(minutes: int) -> str:
|
||||
|
||||
if not isinstance(minutes, int):
|
||||
return "Invalid"
|
||||
|
||||
|
@ -24,7 +24,6 @@ from chia.util.path import path_from_root
|
||||
|
||||
|
||||
async def profile_task(root_path: pathlib.Path, service: str, log: logging.Logger) -> None:
|
||||
|
||||
profile_dir = path_from_root(root_path, f"profile-{service}")
|
||||
log.info("Starting profiler. saving to %s" % profile_dir)
|
||||
profile_dir.mkdir(parents=True, exist_ok=True)
|
||||
@ -70,7 +69,6 @@ if __name__ == "__main__":
|
||||
# ncalls tottime percall cumtime percall filename:lineno(function)
|
||||
# 1 0.000 0.000 0.000 0.000 <function>
|
||||
for line in f:
|
||||
|
||||
if " function calls " in line and " in " in line and " seconds":
|
||||
# 304307 function calls (291692 primitive calls) in 1.031 seconds
|
||||
assert total == 0
|
||||
@ -160,7 +158,6 @@ profiler.py <profile-directory> <first-slot> <last-slot>
|
||||
|
||||
|
||||
async def mem_profile_task(root_path: pathlib.Path, service: str, log: logging.Logger) -> None:
|
||||
|
||||
profile_dir = path_from_root(root_path, f"memory-profile-{service}") / datetime.now().strftime("%Y-%m-%d_%H:%M:%S")
|
||||
log.info("Starting memory profiler. saving to %s" % profile_dir)
|
||||
profile_dir.mkdir(parents=True, exist_ok=True)
|
||||
|
@ -155,7 +155,6 @@ def get_file(frame: FrameType) -> str:
|
||||
|
||||
|
||||
def trace_fun(frame: FrameType, event: str, arg: Any) -> None:
|
||||
|
||||
if event in ["c_call", "c_return", "c_exception"]:
|
||||
return
|
||||
|
||||
@ -198,7 +197,6 @@ def trace_fun(frame: FrameType, event: str, arg: Any) -> None:
|
||||
# f.write(f"{indent}CALL {t} {get_stack(frame)}\n")
|
||||
|
||||
elif event == "return":
|
||||
|
||||
fi = ti.stack.get(frame)
|
||||
assert fi is not None
|
||||
|
||||
@ -210,7 +208,6 @@ def trace_fun(frame: FrameType, event: str, arg: Any) -> None:
|
||||
# with open("instrumentation.log", "a") as f:
|
||||
# f.write(f"{indent}SUSPEND {t} {get_stack(frame)}\n")
|
||||
else:
|
||||
|
||||
# with open("instrumentation.log", "a") as f:
|
||||
# f.write(f"{indent}RETURN {t} {get_stack(frame)}\n")
|
||||
|
||||
@ -290,7 +287,6 @@ def stop_task_instrumentation(target_dir: str = f"task-profile-{os.getpid()}") -
|
||||
|
||||
# print all nodes (functions)
|
||||
for name, fun_info in call_tree.items():
|
||||
|
||||
# frames that are less than 0.1% of the total wall-clock time are
|
||||
# filtered
|
||||
if fun_info.duration / total_duration < 0.001:
|
||||
@ -310,7 +306,6 @@ def stop_task_instrumentation(target_dir: str = f"task-profile-{os.getpid()}") -
|
||||
|
||||
# print all edges (calls)
|
||||
for name, fun_info in call_tree.items():
|
||||
|
||||
if name in filter_frames:
|
||||
continue
|
||||
|
||||
|
@ -48,7 +48,6 @@ class CATLineageStore:
|
||||
await cursor.close()
|
||||
|
||||
async def get_lineage_proof(self, coin_id: bytes32) -> Optional[LineageProof]:
|
||||
|
||||
async with self.db_wrapper.reader_no_transaction() as conn:
|
||||
cursor = await conn.execute(
|
||||
f"SELECT * FROM {self.table_name} WHERE coin_id=?;",
|
||||
|
@ -115,7 +115,6 @@ def match_address_to_sk(
|
||||
search_list: Set[bytes32] = set(addresses_to_search)
|
||||
|
||||
for i in range(max_ph_to_search):
|
||||
|
||||
phs = [
|
||||
create_puzzlehash_for_pk(master_sk_to_wallet_sk(sk, uint32(i)).get_g1()),
|
||||
create_puzzlehash_for_pk(master_sk_to_wallet_sk_unhardened(sk, uint32(i)).get_g1()),
|
||||
|
@ -1178,7 +1178,6 @@ class DIDWallet:
|
||||
raise ValueError("Missing DID inner puzzle.")
|
||||
puzzle_args = did_wallet_puzzles.uncurry_innerpuz(self.did_info.current_inner)
|
||||
if puzzle_args is not None:
|
||||
|
||||
p2_puzzle, _, _, _, _ = puzzle_args
|
||||
puzzle_hash = p2_puzzle.get_tree_hash()
|
||||
pubkey, private = await self.wallet_state_manager.get_keys(puzzle_hash)
|
||||
@ -1195,7 +1194,6 @@ class DIDWallet:
|
||||
async def sign(self, spend_bundle: SpendBundle) -> SpendBundle:
|
||||
sigs: List[G2Element] = []
|
||||
for spend in spend_bundle.coin_spends:
|
||||
|
||||
puzzle_args = did_wallet_puzzles.match_did_puzzle(*spend.puzzle_reveal.to_program().uncurry())
|
||||
if puzzle_args is not None:
|
||||
p2_puzzle, _, _, _, _ = puzzle_args
|
||||
|
@ -140,7 +140,6 @@ class NotificationStore:
|
||||
]
|
||||
|
||||
async def delete_notifications(self, coin_ids: List[bytes32]) -> None:
|
||||
|
||||
coin_ids_str_list = "("
|
||||
for _ in coin_ids:
|
||||
coin_ids_str_list += "?"
|
||||
|
@ -585,7 +585,6 @@ class TradeManager:
|
||||
return False, None, str(e)
|
||||
|
||||
async def maybe_create_wallets_for_offer(self, offer: Offer) -> None:
|
||||
|
||||
for key in offer.arbitrage():
|
||||
wsm = self.wallet_state_manager
|
||||
if key is None:
|
||||
|
@ -482,7 +482,6 @@ class TradeStore:
|
||||
return records
|
||||
|
||||
async def rollback_to_block(self, block_index: int) -> None:
|
||||
|
||||
async with self.db_wrapper.writer_maybe_transaction() as conn:
|
||||
# Delete from storage
|
||||
cursor = await conn.execute("DELETE FROM trade_records WHERE confirmed_at_index>?", (block_index,))
|
||||
|
@ -106,7 +106,6 @@ class WalletCoinStore:
|
||||
|
||||
# Update coin_record to be spent in DB
|
||||
async def set_spent(self, coin_name: bytes32, height: uint32) -> None:
|
||||
|
||||
async with self.db_wrapper.writer_maybe_transaction() as conn:
|
||||
await conn.execute_insert(
|
||||
"UPDATE coin_record SET spent_height=?,spent=? WHERE coin_name=?",
|
||||
|
@ -39,7 +39,6 @@ class WalletInterestedStore:
|
||||
return [bytes32(bytes.fromhex(row[0])) for row in rows_hex]
|
||||
|
||||
async def add_interested_coin_id(self, coin_id: bytes32) -> None:
|
||||
|
||||
async with self.db_wrapper.writer_maybe_transaction() as conn:
|
||||
cursor = await conn.execute("INSERT OR REPLACE INTO interested_coins VALUES (?)", (coin_id.hex(),))
|
||||
await cursor.close()
|
||||
@ -61,7 +60,6 @@ class WalletInterestedStore:
|
||||
return row[0]
|
||||
|
||||
async def add_interested_puzzle_hash(self, puzzle_hash: bytes32, wallet_id: int) -> None:
|
||||
|
||||
async with self.db_wrapper.writer_maybe_transaction() as conn:
|
||||
cursor = await conn.execute(
|
||||
"INSERT OR REPLACE INTO interested_puzzle_hashes VALUES (?, ?)", (puzzle_hash.hex(), wallet_id)
|
||||
|
@ -1673,7 +1673,6 @@ class WalletNode:
|
||||
async def fetch_children(
|
||||
self, coin_name: bytes32, peer: WSChiaConnection, fork_height: Optional[uint32] = None
|
||||
) -> List[CoinState]:
|
||||
|
||||
response: Optional[wallet_protocol.RespondChildren] = await peer.call_api(
|
||||
FullNodeAPI.request_children, wallet_protocol.RequestChildren(coin_name)
|
||||
)
|
||||
|
@ -16,7 +16,6 @@ if TYPE_CHECKING:
|
||||
|
||||
|
||||
class WalletProtocol(Protocol):
|
||||
|
||||
# TODO: it seems like this should return WalletType instead
|
||||
@classmethod
|
||||
def type(cls) -> uint8:
|
||||
|
@ -53,7 +53,6 @@ class WalletUserStore:
|
||||
data: str,
|
||||
id: Optional[int] = None,
|
||||
) -> WalletInfo:
|
||||
|
||||
async with self.db_wrapper.writer_maybe_transaction() as conn:
|
||||
cursor = await conn.execute(
|
||||
"INSERT INTO users_wallets VALUES(?, ?, ?, ?)",
|
||||
|
@ -1733,7 +1733,6 @@ class TestPreValidation:
|
||||
|
||||
|
||||
class TestBodyValidation:
|
||||
|
||||
# TODO: add test for
|
||||
# ASSERT_COIN_ANNOUNCEMENT,
|
||||
# CREATE_COIN_ANNOUNCEMENT,
|
||||
@ -3316,7 +3315,6 @@ async def test_reorg_flip_flop(empty_blockchain, bt):
|
||||
|
||||
counter = 0
|
||||
for b1, b2 in zip(chain_a, chain_b):
|
||||
|
||||
# alternate the order we add blocks from the two chains, to ensure one
|
||||
# chain overtakes the other one in weight every other time
|
||||
if counter % 2 == 0:
|
||||
|
@ -510,7 +510,6 @@ class TestBlockchainTransactions:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_assert_coin_announcement_consumed(self, two_nodes):
|
||||
|
||||
num_blocks = 10
|
||||
wallet_a = WALLET_A
|
||||
coinbase_puzzlehash = WALLET_A_PUZZLE_HASHES[0]
|
||||
@ -592,7 +591,6 @@ class TestBlockchainTransactions:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_assert_puzzle_announcement_consumed(self, two_nodes):
|
||||
|
||||
num_blocks = 10
|
||||
wallet_a = WALLET_A
|
||||
coinbase_puzzlehash = WALLET_A_PUZZLE_HASHES[0]
|
||||
@ -804,7 +802,6 @@ class TestBlockchainTransactions:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_assert_seconds_relative(self, two_nodes):
|
||||
|
||||
num_blocks = 10
|
||||
wallet_a = WALLET_A
|
||||
coinbase_puzzlehash = WALLET_A_PUZZLE_HASHES[0]
|
||||
@ -862,7 +859,6 @@ class TestBlockchainTransactions:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_assert_seconds_absolute(self, two_nodes):
|
||||
|
||||
num_blocks = 10
|
||||
wallet_a = WALLET_A
|
||||
coinbase_puzzlehash = WALLET_A_PUZZLE_HASHES[0]
|
||||
@ -921,7 +917,6 @@ class TestBlockchainTransactions:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_assert_fee_condition(self, two_nodes):
|
||||
|
||||
num_blocks = 10
|
||||
wallet_a = WALLET_A
|
||||
coinbase_puzzlehash = WALLET_A_PUZZLE_HASHES[0]
|
||||
|
@ -9,7 +9,6 @@ from typing import Dict, Set, Tuple
|
||||
|
||||
|
||||
def check_create(sql_type: str, cwd: str, exemptions: Set[Tuple[str, str]] = set()) -> int:
|
||||
|
||||
lines = check_output(["git", "grep", f"CREATE {sql_type}"], cwd=cwd).decode("ascii").split("\n")
|
||||
|
||||
ret = 0
|
||||
|
@ -96,7 +96,6 @@ def do_test_spend(
|
||||
def default_payments_and_conditions(
|
||||
initial_index: int, key_lookup: KeyTool
|
||||
) -> Tuple[List[Tuple[bytes32, int]], Program]:
|
||||
|
||||
# the coin we get from coin_db.farm_coin only has amount 1024, so we can
|
||||
# only make small payments to avoid failing with MINTING_COIN
|
||||
payments = [
|
||||
|
@ -11,7 +11,6 @@ from chia.util.ints import uint64
|
||||
|
||||
|
||||
def coin_serialize(amount: uint64, clvm_serialize: bytes, full_serialize: bytes):
|
||||
|
||||
c = Coin(bytes32(b"a" * 32), bytes32(b"b" * 32), amount)
|
||||
expected_hash = (b"a" * 32) + (b"b" * 32) + clvm_serialize
|
||||
|
||||
@ -27,7 +26,6 @@ def coin_serialize(amount: uint64, clvm_serialize: bytes, full_serialize: bytes)
|
||||
|
||||
|
||||
def test_serialization():
|
||||
|
||||
coin_serialize(uint64(0xFFFF), bytes([0, 0xFF, 0xFF]), bytes([0, 0, 0, 0, 0, 0, 0xFF, 0xFF]))
|
||||
coin_serialize(uint64(1337000000), bytes([0x4F, 0xB1, 0x00, 0x40]), bytes([0, 0, 0, 0, 0x4F, 0xB1, 0x00, 0x40]))
|
||||
|
||||
@ -68,7 +66,6 @@ def test_serialization():
|
||||
],
|
||||
)
|
||||
def test_name(amount: int, clvm: List[int]) -> None:
|
||||
|
||||
H1 = bytes32(b"a" * 32)
|
||||
H2 = bytes32(b"b" * 32)
|
||||
|
||||
@ -76,7 +73,6 @@ def test_name(amount: int, clvm: List[int]) -> None:
|
||||
|
||||
|
||||
def test_construction() -> None:
|
||||
|
||||
H1 = b"a" * 32
|
||||
H2 = b"b" * 32
|
||||
|
||||
|
@ -32,7 +32,6 @@ async def test_block_store(tmp_dir, db_version, bt):
|
||||
blocks = bt.get_consecutive_blocks(10)
|
||||
|
||||
async with DBConnection(db_version) as db_wrapper, DBConnection(db_version) as db_wrapper_2:
|
||||
|
||||
# Use a different file for the blockchain
|
||||
coin_store_2 = await CoinStore.create(db_wrapper_2)
|
||||
store_2 = await BlockStore.create(db_wrapper_2)
|
||||
@ -88,7 +87,6 @@ async def test_deadlock(tmp_dir, db_version, bt):
|
||||
blocks = bt.get_consecutive_blocks(10)
|
||||
|
||||
async with DBConnection(db_version) as wrapper, DBConnection(db_version) as wrapper_2:
|
||||
|
||||
store = await BlockStore.create(wrapper)
|
||||
coin_store_2 = await CoinStore.create(wrapper_2)
|
||||
store_2 = await BlockStore.create(wrapper_2)
|
||||
@ -117,7 +115,6 @@ async def test_rollback(bt, tmp_dir):
|
||||
blocks = bt.get_consecutive_blocks(10)
|
||||
|
||||
async with DBConnection(2) as db_wrapper:
|
||||
|
||||
# Use a different file for the blockchain
|
||||
coin_store = await CoinStore.create(db_wrapper)
|
||||
block_store = await BlockStore.create(db_wrapper)
|
||||
@ -286,7 +283,6 @@ async def test_get_blocks_by_hash(tmp_dir, bt, db_version):
|
||||
blocks = bt.get_consecutive_blocks(10)
|
||||
|
||||
async with DBConnection(db_version) as db_wrapper, DBConnection(db_version) as db_wrapper_2:
|
||||
|
||||
# Use a different file for the blockchain
|
||||
coin_store_2 = await CoinStore.create(db_wrapper_2)
|
||||
store_2 = await BlockStore.create(db_wrapper_2)
|
||||
@ -324,7 +320,6 @@ async def test_get_block_bytes_in_range(tmp_dir, bt, db_version):
|
||||
blocks = bt.get_consecutive_blocks(10)
|
||||
|
||||
async with DBConnection(db_version) as db_wrapper_2:
|
||||
|
||||
# Use a different file for the blockchain
|
||||
coin_store_2 = await CoinStore.create(db_wrapper_2)
|
||||
store_2 = await BlockStore.create(db_wrapper_2)
|
||||
|
@ -318,7 +318,6 @@ class TestCoinStoreWithBlocks:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_basic_reorg(self, tmp_dir, db_version, bt):
|
||||
|
||||
async with DBConnection(db_version) as db_wrapper:
|
||||
initial_block_count = 30
|
||||
reorg_length = 15
|
||||
@ -327,7 +326,6 @@ class TestCoinStoreWithBlocks:
|
||||
store = await BlockStore.create(db_wrapper)
|
||||
b: Blockchain = await Blockchain.create(coin_store, store, test_constants, tmp_dir, 2)
|
||||
try:
|
||||
|
||||
records: List[Optional[CoinRecord]] = []
|
||||
|
||||
for block in blocks:
|
||||
|
@ -64,7 +64,6 @@ async def new_block(
|
||||
|
||||
|
||||
async def setup_db(db: DBWrapper2):
|
||||
|
||||
async with db.writer_maybe_transaction() as conn:
|
||||
if db.db_version == 2:
|
||||
await conn.execute(
|
||||
@ -118,7 +117,6 @@ async def setup_chain(
|
||||
class TestBlockHeightMap:
|
||||
@pytest.mark.asyncio
|
||||
async def test_height_to_hash(self, tmp_dir, db_version):
|
||||
|
||||
async with DBConnection(db_version) as db_wrapper:
|
||||
await setup_db(db_wrapper)
|
||||
await setup_chain(db_wrapper, 10)
|
||||
@ -134,7 +132,6 @@ class TestBlockHeightMap:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_height_to_hash_long_chain(self, tmp_dir, db_version):
|
||||
|
||||
async with DBConnection(db_version) as db_wrapper:
|
||||
await setup_db(db_wrapper)
|
||||
await setup_chain(db_wrapper, 10000)
|
||||
@ -149,7 +146,6 @@ class TestBlockHeightMap:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_save_restore(self, tmp_dir, db_version):
|
||||
|
||||
async with DBConnection(db_version) as db_wrapper:
|
||||
await setup_db(db_wrapper)
|
||||
await setup_chain(db_wrapper, 10000, ses_every=20)
|
||||
@ -194,12 +190,10 @@ class TestBlockHeightMap:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_restore_entire_chain(self, tmp_dir, db_version):
|
||||
|
||||
# this is a test where the height-to-hash and height-to-ses caches are
|
||||
# entirely unrelated to the database. Make sure they can both be fully
|
||||
# replaced
|
||||
async with DBConnection(db_version) as db_wrapper:
|
||||
|
||||
heights = bytearray(900 * 32)
|
||||
for i in range(900):
|
||||
idx = i * 32
|
||||
@ -229,7 +223,6 @@ class TestBlockHeightMap:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_restore_extend(self, tmp_dir, db_version):
|
||||
|
||||
# test the case where the cache has fewer blocks than the DB, and that
|
||||
# we correctly load all the missing blocks from the DB to update the
|
||||
# cache
|
||||
@ -270,7 +263,6 @@ class TestBlockHeightMap:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_height_to_hash_with_orphans(self, tmp_dir, db_version):
|
||||
|
||||
async with DBConnection(db_version) as db_wrapper:
|
||||
await setup_db(db_wrapper)
|
||||
await setup_chain(db_wrapper, 10)
|
||||
@ -286,7 +278,6 @@ class TestBlockHeightMap:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_height_to_hash_update(self, tmp_dir, db_version):
|
||||
|
||||
async with DBConnection(db_version) as db_wrapper:
|
||||
await setup_db(db_wrapper)
|
||||
await setup_chain(db_wrapper, 10)
|
||||
@ -308,7 +299,6 @@ class TestBlockHeightMap:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_update_ses(self, tmp_dir, db_version):
|
||||
|
||||
async with DBConnection(db_version) as db_wrapper:
|
||||
await setup_db(db_wrapper)
|
||||
await setup_chain(db_wrapper, 10)
|
||||
@ -328,9 +318,7 @@ class TestBlockHeightMap:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_height_to_ses(self, tmp_dir, db_version):
|
||||
|
||||
async with DBConnection(db_version) as db_wrapper:
|
||||
|
||||
await setup_db(db_wrapper)
|
||||
await setup_chain(db_wrapper, 10, ses_every=2)
|
||||
|
||||
@ -355,9 +343,7 @@ class TestBlockHeightMap:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_rollback(self, tmp_dir, db_version):
|
||||
|
||||
async with DBConnection(db_version) as db_wrapper:
|
||||
|
||||
await setup_db(db_wrapper)
|
||||
await setup_chain(db_wrapper, 10, ses_every=2)
|
||||
|
||||
@ -393,9 +379,7 @@ class TestBlockHeightMap:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_rollback2(self, tmp_dir, db_version):
|
||||
|
||||
async with DBConnection(db_version) as db_wrapper:
|
||||
|
||||
await setup_db(db_wrapper)
|
||||
await setup_chain(db_wrapper, 10, ses_every=2)
|
||||
|
||||
|
@ -280,7 +280,6 @@ class TestPendingTxCache:
|
||||
class TestMempool:
|
||||
@pytest.mark.asyncio
|
||||
async def test_basic_mempool(self, one_node_one_block, wallet_a):
|
||||
|
||||
full_node_1, server_1, bt = one_node_one_block
|
||||
|
||||
_ = await next_block(full_node_1, wallet_a, bt)
|
||||
@ -394,7 +393,6 @@ class TestMempoolManager:
|
||||
)
|
||||
async def test_ephemeral_timelock(self, one_node_one_block, wallet_a, opcode, lock_value, expected):
|
||||
def test_fun(coin_1: Coin, coin_2: Coin) -> SpendBundle:
|
||||
|
||||
conditions = {opcode: [ConditionWithArgs(opcode, [int_to_bytes(lock_value)])]}
|
||||
tx1 = wallet_a.generate_signed_transaction(
|
||||
uint64(1000000), wallet_a.get_new_puzzlehash(), coin_2, conditions.copy(), uint64(0)
|
||||
@ -725,7 +723,6 @@ class TestMempoolManager:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_invalid_block_index(self, one_node_one_block, wallet_a):
|
||||
|
||||
full_node_1, server_1, bt = one_node_one_block
|
||||
blocks = await full_node_1.get_all_full_blocks()
|
||||
start_height = blocks[-1].height
|
||||
@ -743,7 +740,6 @@ class TestMempoolManager:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_block_index_missing_arg(self, one_node_one_block, wallet_a):
|
||||
|
||||
full_node_1, server_1, bt = one_node_one_block
|
||||
cvp = ConditionWithArgs(ConditionOpcode.ASSERT_HEIGHT_ABSOLUTE, [])
|
||||
dic = {ConditionOpcode.ASSERT_HEIGHT_ABSOLUTE: [cvp]}
|
||||
@ -756,7 +752,6 @@ class TestMempoolManager:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_correct_block_index(self, one_node_one_block, wallet_a):
|
||||
|
||||
full_node_1, server_1, bt = one_node_one_block
|
||||
cvp = ConditionWithArgs(ConditionOpcode.ASSERT_HEIGHT_ABSOLUTE, [int_to_bytes(1)])
|
||||
dic = {ConditionOpcode.ASSERT_HEIGHT_ABSOLUTE: [cvp]}
|
||||
@ -768,7 +763,6 @@ class TestMempoolManager:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_block_index_garbage(self, one_node_one_block, wallet_a):
|
||||
|
||||
full_node_1, server_1, bt = one_node_one_block
|
||||
# garbage at the end of the argument list is ignored in consensus mode,
|
||||
# but not in mempool-mode
|
||||
@ -782,7 +776,6 @@ class TestMempoolManager:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_negative_block_index(self, one_node_one_block, wallet_a):
|
||||
|
||||
full_node_1, server_1, bt = one_node_one_block
|
||||
cvp = ConditionWithArgs(ConditionOpcode.ASSERT_HEIGHT_ABSOLUTE, [int_to_bytes(-1)])
|
||||
dic = {ConditionOpcode.ASSERT_HEIGHT_ABSOLUTE: [cvp]}
|
||||
@ -794,7 +787,6 @@ class TestMempoolManager:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_invalid_block_age(self, one_node_one_block, wallet_a):
|
||||
|
||||
full_node_1, server_1, bt = one_node_one_block
|
||||
cvp = ConditionWithArgs(ConditionOpcode.ASSERT_HEIGHT_RELATIVE, [int_to_bytes(5)])
|
||||
dic = {cvp.opcode: [cvp]}
|
||||
@ -807,7 +799,6 @@ class TestMempoolManager:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_block_age_missing_arg(self, one_node_one_block, wallet_a):
|
||||
|
||||
full_node_1, server_1, bt = one_node_one_block
|
||||
cvp = ConditionWithArgs(ConditionOpcode.ASSERT_HEIGHT_RELATIVE, [])
|
||||
dic = {cvp.opcode: [cvp]}
|
||||
@ -820,7 +811,6 @@ class TestMempoolManager:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_correct_block_age(self, one_node_one_block, wallet_a):
|
||||
|
||||
full_node_1, server_1, bt = one_node_one_block
|
||||
cvp = ConditionWithArgs(ConditionOpcode.ASSERT_HEIGHT_RELATIVE, [int_to_bytes(1)])
|
||||
dic = {cvp.opcode: [cvp]}
|
||||
@ -835,7 +825,6 @@ class TestMempoolManager:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_block_age_garbage(self, one_node_one_block, wallet_a):
|
||||
|
||||
full_node_1, server_1, bt = one_node_one_block
|
||||
# garbage at the end of the argument list is ignored in consensus mode,
|
||||
# but not in mempool mode
|
||||
@ -852,7 +841,6 @@ class TestMempoolManager:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_negative_block_age(self, one_node_one_block, wallet_a):
|
||||
|
||||
full_node_1, server_1, bt = one_node_one_block
|
||||
cvp = ConditionWithArgs(ConditionOpcode.ASSERT_HEIGHT_RELATIVE, [int_to_bytes(-1)])
|
||||
dic = {cvp.opcode: [cvp]}
|
||||
@ -867,7 +855,6 @@ class TestMempoolManager:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_correct_my_id(self, one_node_one_block, wallet_a):
|
||||
|
||||
full_node_1, server_1, bt = one_node_one_block
|
||||
|
||||
_ = await next_block(full_node_1, wallet_a, bt)
|
||||
@ -886,7 +873,6 @@ class TestMempoolManager:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_my_id_garbage(self, one_node_one_block, wallet_a):
|
||||
|
||||
full_node_1, server_1, bt = one_node_one_block
|
||||
|
||||
_ = await next_block(full_node_1, wallet_a, bt)
|
||||
@ -907,7 +893,6 @@ class TestMempoolManager:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_invalid_my_id(self, one_node_one_block, wallet_a):
|
||||
|
||||
full_node_1, server_1, bt = one_node_one_block
|
||||
|
||||
_ = await next_block(full_node_1, wallet_a, bt)
|
||||
@ -927,7 +912,6 @@ class TestMempoolManager:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_my_id_missing_arg(self, one_node_one_block, wallet_a):
|
||||
|
||||
full_node_1, server_1, bt = one_node_one_block
|
||||
cvp = ConditionWithArgs(ConditionOpcode.ASSERT_MY_COIN_ID, [])
|
||||
dic = {cvp.opcode: [cvp]}
|
||||
@ -940,7 +924,6 @@ class TestMempoolManager:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_assert_time_exceeds(self, one_node_one_block, wallet_a):
|
||||
|
||||
full_node_1, server_1, bt = one_node_one_block
|
||||
# 5 seconds should be before the next block
|
||||
time_now = full_node_1.full_node.blockchain.get_peak().timestamp + 5
|
||||
@ -955,7 +938,6 @@ class TestMempoolManager:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_assert_time_fail(self, one_node_one_block, wallet_a):
|
||||
|
||||
full_node_1, server_1, bt = one_node_one_block
|
||||
time_now = full_node_1.full_node.blockchain.get_peak().timestamp + 1000
|
||||
|
||||
@ -969,7 +951,6 @@ class TestMempoolManager:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_assert_height_pending(self, one_node_one_block, wallet_a):
|
||||
|
||||
full_node_1, server_1, bt = one_node_one_block
|
||||
print(full_node_1.full_node.blockchain.get_peak())
|
||||
current_height = full_node_1.full_node.blockchain.get_peak().height
|
||||
@ -984,7 +965,6 @@ class TestMempoolManager:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_assert_time_negative(self, one_node_one_block, wallet_a):
|
||||
|
||||
full_node_1, server_1, bt = one_node_one_block
|
||||
time_now = -1
|
||||
|
||||
@ -998,7 +978,6 @@ class TestMempoolManager:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_assert_time_missing_arg(self, one_node_one_block, wallet_a):
|
||||
|
||||
full_node_1, server_1, bt = one_node_one_block
|
||||
|
||||
cvp = ConditionWithArgs(ConditionOpcode.ASSERT_SECONDS_ABSOLUTE, [])
|
||||
@ -1011,7 +990,6 @@ class TestMempoolManager:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_assert_time_garbage(self, one_node_one_block, wallet_a):
|
||||
|
||||
full_node_1, server_1, bt = one_node_one_block
|
||||
time_now = full_node_1.full_node.blockchain.get_peak().timestamp + 5
|
||||
|
||||
@ -1027,7 +1005,6 @@ class TestMempoolManager:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_assert_time_relative_exceeds(self, one_node_one_block, wallet_a):
|
||||
|
||||
full_node_1, server_1, bt = one_node_one_block
|
||||
time_relative = 3
|
||||
|
||||
@ -1054,7 +1031,6 @@ class TestMempoolManager:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_assert_time_relative_garbage(self, one_node_one_block, wallet_a):
|
||||
|
||||
full_node_1, server_1, bt = one_node_one_block
|
||||
time_relative = 0
|
||||
|
||||
@ -1071,7 +1047,6 @@ class TestMempoolManager:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_assert_time_relative_missing_arg(self, one_node_one_block, wallet_a):
|
||||
|
||||
full_node_1, server_1, bt = one_node_one_block
|
||||
|
||||
cvp = ConditionWithArgs(ConditionOpcode.ASSERT_SECONDS_RELATIVE, [])
|
||||
@ -1085,7 +1060,6 @@ class TestMempoolManager:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_assert_time_relative_negative(self, one_node_one_block, wallet_a):
|
||||
|
||||
full_node_1, server_1, bt = one_node_one_block
|
||||
time_relative = -3
|
||||
|
||||
@ -1481,7 +1455,6 @@ class TestMempoolManager:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_assert_fee_condition(self, one_node_one_block, wallet_a):
|
||||
|
||||
full_node_1, server_1, bt = one_node_one_block
|
||||
cvp = ConditionWithArgs(ConditionOpcode.RESERVE_FEE, [int_to_bytes(10)])
|
||||
dic = {cvp.opcode: [cvp]}
|
||||
@ -1496,7 +1469,6 @@ class TestMempoolManager:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_assert_fee_condition_garbage(self, one_node_one_block, wallet_a):
|
||||
|
||||
full_node_1, server_1, bt = one_node_one_block
|
||||
# garbage at the end of the arguments is ignored in consensus mode, but
|
||||
# not in mempool mode
|
||||
@ -1563,7 +1535,6 @@ class TestMempoolManager:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_assert_fee_condition_wrong_fee(self, one_node_one_block, wallet_a):
|
||||
|
||||
full_node_1, server_1, bt = one_node_one_block
|
||||
|
||||
cvp = ConditionWithArgs(ConditionOpcode.RESERVE_FEE, [int_to_bytes(10)])
|
||||
@ -1726,7 +1697,6 @@ class TestMempoolManager:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_correct_my_parent(self, one_node_one_block, wallet_a):
|
||||
|
||||
full_node_1, server_1, bt = one_node_one_block
|
||||
|
||||
_ = await next_block(full_node_1, wallet_a, bt)
|
||||
@ -1746,7 +1716,6 @@ class TestMempoolManager:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_my_parent_garbage(self, one_node_one_block, wallet_a):
|
||||
|
||||
full_node_1, server_1, bt = one_node_one_block
|
||||
|
||||
_ = await next_block(full_node_1, wallet_a, bt)
|
||||
@ -1768,7 +1737,6 @@ class TestMempoolManager:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_my_parent_missing_arg(self, one_node_one_block, wallet_a):
|
||||
|
||||
full_node_1, server_1, bt = one_node_one_block
|
||||
cvp = ConditionWithArgs(ConditionOpcode.ASSERT_MY_PARENT_ID, [])
|
||||
dic = {cvp.opcode: [cvp]}
|
||||
@ -1782,7 +1750,6 @@ class TestMempoolManager:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_invalid_my_parent(self, one_node_one_block, wallet_a):
|
||||
|
||||
full_node_1, server_1, bt = one_node_one_block
|
||||
|
||||
_ = await next_block(full_node_1, wallet_a, bt)
|
||||
@ -1803,7 +1770,6 @@ class TestMempoolManager:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_correct_my_puzhash(self, one_node_one_block, wallet_a):
|
||||
|
||||
full_node_1, server_1, bt = one_node_one_block
|
||||
|
||||
_ = await next_block(full_node_1, wallet_a, bt)
|
||||
@ -1823,7 +1789,6 @@ class TestMempoolManager:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_my_puzhash_garbage(self, one_node_one_block, wallet_a):
|
||||
|
||||
full_node_1, server_1, bt = one_node_one_block
|
||||
|
||||
_ = await next_block(full_node_1, wallet_a, bt)
|
||||
@ -1844,7 +1809,6 @@ class TestMempoolManager:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_my_puzhash_missing_arg(self, one_node_one_block, wallet_a):
|
||||
|
||||
full_node_1, server_1, bt = one_node_one_block
|
||||
cvp = ConditionWithArgs(ConditionOpcode.ASSERT_MY_PUZZLEHASH, [])
|
||||
dic = {cvp.opcode: [cvp]}
|
||||
@ -1858,7 +1822,6 @@ class TestMempoolManager:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_invalid_my_puzhash(self, one_node_one_block, wallet_a):
|
||||
|
||||
full_node_1, server_1, bt = one_node_one_block
|
||||
|
||||
_ = await next_block(full_node_1, wallet_a, bt)
|
||||
@ -1878,7 +1841,6 @@ class TestMempoolManager:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_correct_my_amount(self, one_node_one_block, wallet_a):
|
||||
|
||||
full_node_1, server_1, bt = one_node_one_block
|
||||
|
||||
_ = await next_block(full_node_1, wallet_a, bt)
|
||||
@ -1898,7 +1860,6 @@ class TestMempoolManager:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_my_amount_garbage(self, one_node_one_block, wallet_a):
|
||||
|
||||
full_node_1, server_1, bt = one_node_one_block
|
||||
|
||||
_ = await next_block(full_node_1, wallet_a, bt)
|
||||
@ -1920,7 +1881,6 @@ class TestMempoolManager:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_my_amount_missing_arg(self, one_node_one_block, wallet_a):
|
||||
|
||||
full_node_1, server_1, bt = one_node_one_block
|
||||
cvp = ConditionWithArgs(ConditionOpcode.ASSERT_MY_AMOUNT, [])
|
||||
dic = {cvp.opcode: [cvp]}
|
||||
@ -1934,7 +1894,6 @@ class TestMempoolManager:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_invalid_my_amount(self, one_node_one_block, wallet_a):
|
||||
|
||||
full_node_1, server_1, bt = one_node_one_block
|
||||
cvp = ConditionWithArgs(ConditionOpcode.ASSERT_MY_AMOUNT, [int_to_bytes(1000)])
|
||||
dic = {cvp.opcode: [cvp]}
|
||||
@ -1948,7 +1907,6 @@ class TestMempoolManager:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_negative_my_amount(self, one_node_one_block, wallet_a):
|
||||
|
||||
full_node_1, server_1, bt = one_node_one_block
|
||||
cvp = ConditionWithArgs(ConditionOpcode.ASSERT_MY_AMOUNT, [int_to_bytes(-1)])
|
||||
dic = {cvp.opcode: [cvp]}
|
||||
@ -1962,7 +1920,6 @@ class TestMempoolManager:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_my_amount_too_large(self, one_node_one_block, wallet_a):
|
||||
|
||||
full_node_1, server_1, bt = one_node_one_block
|
||||
cvp = ConditionWithArgs(ConditionOpcode.ASSERT_MY_AMOUNT, [int_to_bytes(2**64)])
|
||||
dic = {cvp.opcode: [cvp]}
|
||||
@ -2003,7 +1960,6 @@ def generator_condition_tester(
|
||||
|
||||
class TestGeneratorConditions:
|
||||
def test_invalid_condition_args_terminator(self, softfork_height):
|
||||
|
||||
# note how the condition argument list isn't correctly terminated with a
|
||||
# NIL atom. This is allowed, and all arguments beyond the ones we look
|
||||
# at are ignored, including the termination of the list
|
||||
@ -2022,7 +1978,6 @@ class TestGeneratorConditions:
|
||||
],
|
||||
)
|
||||
def test_div(self, mempool, operand, expected, softfork_height):
|
||||
|
||||
# op_div is disallowed on negative numbers in the mempool, and after the
|
||||
# softfork
|
||||
npc_result = generator_condition_tester(
|
||||
@ -2034,7 +1989,6 @@ class TestGeneratorConditions:
|
||||
assert npc_result.error == expected
|
||||
|
||||
def test_invalid_condition_list_terminator(self, softfork_height):
|
||||
|
||||
# note how the list of conditions isn't correctly terminated with a
|
||||
# NIL atom. This is a failure
|
||||
npc_result = generator_condition_tester("(80 50) . 3", height=softfork_height)
|
||||
@ -2168,7 +2122,6 @@ class TestGeneratorConditions:
|
||||
assert npc_result.error in [Err.BLOCK_COST_EXCEEDS_MAX.value, Err.INVALID_BLOCK_COST.value]
|
||||
|
||||
def test_create_coin_different_parent(self, softfork_height):
|
||||
|
||||
# if the coins we create have different parents, they are never
|
||||
# considered duplicate, even when they have the same puzzle hash and
|
||||
# amount
|
||||
@ -2353,7 +2306,6 @@ def error_for_condition(cond: ConditionOpcode) -> int:
|
||||
|
||||
|
||||
class TestMaliciousGenerators:
|
||||
|
||||
# TODO: create a lot of announcements. The messages can be made different by
|
||||
# using substr on a large buffer
|
||||
|
||||
@ -2555,7 +2507,6 @@ def softfork_fixture(request):
|
||||
|
||||
|
||||
class TestPkmPairs:
|
||||
|
||||
h1 = bytes32(b"a" * 32)
|
||||
h2 = bytes32(b"b" * 32)
|
||||
h3 = bytes32(b"c" * 32)
|
||||
@ -2579,7 +2530,6 @@ class TestPkmPairs:
|
||||
assert msgs == []
|
||||
|
||||
def test_agg_sig_me(self, softfork):
|
||||
|
||||
spends = [
|
||||
Spend(
|
||||
self.h1,
|
||||
@ -2607,7 +2557,6 @@ class TestPkmPairs:
|
||||
assert msgs == [b"msg1", b"msg2"]
|
||||
|
||||
def test_agg_sig_mixed(self, softfork):
|
||||
|
||||
spends = [Spend(self.h1, self.h2, None, 0, None, None, [], [(bytes48(self.pk1), b"msg1")], 0)]
|
||||
conds = SpendBundleConditions(spends, 0, 0, 0, None, None, [(bytes48(self.pk2), b"msg2")], 0)
|
||||
pks, msgs = pkm_pairs(conds, b"foobar", soft_fork=softfork)
|
||||
@ -2640,14 +2589,12 @@ class TestPkmPairs:
|
||||
|
||||
|
||||
class TestPkmPairsForConditionDict:
|
||||
|
||||
h1 = bytes32(b"a" * 32)
|
||||
|
||||
pk1 = G1Element.generator()
|
||||
pk2 = G1Element.generator()
|
||||
|
||||
def test_agg_sig_unsafe_restriction(self) -> None:
|
||||
|
||||
ASU = ConditionOpcode.AGG_SIG_UNSAFE
|
||||
|
||||
conds = {ASU: [ConditionWithArgs(ASU, [self.pk1, b"msg1"]), ConditionWithArgs(ASU, [self.pk2, b"msg2"])]}
|
||||
|
@ -90,7 +90,6 @@ async def test_basics() -> None:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_fee_increase() -> None:
|
||||
|
||||
async with DBConnection(db_version=2) as db_wrapper:
|
||||
coin_store = await CoinStore.create(db_wrapper)
|
||||
mempool_manager = MempoolManager(coin_store.get_coin_record, test_constants)
|
||||
|
@ -117,7 +117,6 @@ def make_test_conds(
|
||||
|
||||
|
||||
class TestCheckTimeLocks:
|
||||
|
||||
COIN_CONFIRMED_HEIGHT = uint32(10)
|
||||
COIN_TIMESTAMP = uint64(10000)
|
||||
PREV_BLOCK_HEIGHT = uint32(15)
|
||||
@ -210,7 +209,6 @@ class TestCheckTimeLocks:
|
||||
|
||||
|
||||
def test_compute_assert_height() -> None:
|
||||
|
||||
c1 = Coin(bytes32(b"a" * 32), bytes32(b"b" * 32), 1337)
|
||||
coin_id = c1.name()
|
||||
confirmed_height = uint32(12)
|
||||
|
@ -218,7 +218,6 @@ class TestCostCalculation:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_clvm_max_cost(self, softfork_height):
|
||||
|
||||
block = Program.from_bytes(bytes(SMALL_BLOCK_GENERATOR.program))
|
||||
disassembly = binutils.disassemble(block)
|
||||
# this is a valid generator program except the first clvm
|
||||
@ -280,7 +279,6 @@ class TestCostCalculation:
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.benchmark
|
||||
async def test_get_puzzle_and_solution_for_coin_performance():
|
||||
|
||||
from clvm.casts import int_from_bytes
|
||||
|
||||
from chia.full_node.mempool_check_conditions import DESERIALIZE_MOD
|
||||
|
@ -30,7 +30,6 @@ class TestDbUpgrade:
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.parametrize("with_hints", [True, False])
|
||||
async def test_blocks(self, default_1000_blocks, with_hints: bool):
|
||||
|
||||
blocks = default_1000_blocks
|
||||
|
||||
hints: List[Tuple[bytes32, bytes]] = []
|
||||
@ -54,7 +53,6 @@ class TestDbUpgrade:
|
||||
hints.append((coin_id, hint))
|
||||
|
||||
with TempFile() as in_file, TempFile() as out_file:
|
||||
|
||||
db_wrapper1 = await DBWrapper2.create(
|
||||
database=in_file,
|
||||
reader_count=1,
|
||||
|
@ -151,7 +151,6 @@ async def make_db(db_file: Path, blocks: List[FullBlock]) -> None:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_db_validate_default_1000_blocks(default_1000_blocks: List[FullBlock]) -> None:
|
||||
|
||||
with TempFile() as db_file:
|
||||
await make_db(db_file, default_1000_blocks)
|
||||
|
||||
|
@ -142,6 +142,5 @@ def test_nested() -> None:
|
||||
|
||||
|
||||
def test_recurse_jsonify() -> None:
|
||||
|
||||
d = {"a": "foo", "b": bytes([0x13, 0x37]), "c": [uint32(1), uint32(2)], "d": {"bar": None}}
|
||||
assert recurse_jsonify(d) == {"a": "foo", "b": "0x1337", "c": [1, 2], "d": {"bar": None}}
|
||||
|
@ -79,7 +79,6 @@ class DataclassOnly:
|
||||
|
||||
|
||||
def test_pure_dataclass_not_supported() -> None:
|
||||
|
||||
with pytest.raises(UnsupportedType):
|
||||
|
||||
@streamable
|
||||
@ -93,7 +92,6 @@ class PlainClass:
|
||||
|
||||
|
||||
def test_plain_class_not_supported() -> None:
|
||||
|
||||
with pytest.raises(UnsupportedType):
|
||||
|
||||
@streamable
|
||||
@ -141,7 +139,6 @@ class ConvertTupleFailures(Streamable):
|
||||
],
|
||||
)
|
||||
def test_convert_tuple_failures(input_dict: Dict[str, Any], error: Any) -> None:
|
||||
|
||||
with pytest.raises(error):
|
||||
streamable_from_dict(ConvertTupleFailures, input_dict)
|
||||
|
||||
@ -165,7 +162,6 @@ class ConvertListFailures(Streamable):
|
||||
],
|
||||
)
|
||||
def test_convert_list_failures(input_dict: Dict[str, Any], error: Any) -> None:
|
||||
|
||||
with pytest.raises(error):
|
||||
streamable_from_dict(ConvertListFailures, input_dict)
|
||||
|
||||
@ -195,7 +191,6 @@ class ConvertByteTypeFailures(Streamable):
|
||||
],
|
||||
)
|
||||
def test_convert_byte_type_failures(input_dict: Dict[str, Any], error: Any) -> None:
|
||||
|
||||
with pytest.raises(error):
|
||||
streamable_from_dict(ConvertByteTypeFailures, input_dict)
|
||||
|
||||
@ -221,7 +216,6 @@ class ConvertUnhashableTypeFailures(Streamable):
|
||||
],
|
||||
)
|
||||
def test_convert_unhashable_type_failures(input_dict: Dict[str, Any], error: Any) -> None:
|
||||
|
||||
with pytest.raises(error):
|
||||
streamable_from_dict(ConvertUnhashableTypeFailures, input_dict)
|
||||
|
||||
@ -248,7 +242,6 @@ class ConvertPrimitiveFailures(Streamable):
|
||||
],
|
||||
)
|
||||
def test_convert_primitive_failures(input_dict: Dict[str, Any], error: Any) -> None:
|
||||
|
||||
with pytest.raises(error):
|
||||
streamable_from_dict(ConvertPrimitiveFailures, input_dict)
|
||||
|
||||
@ -321,7 +314,6 @@ def test_convert_primitive_failures(input_dict: Dict[str, Any], error: Any) -> N
|
||||
def test_streamable_from_dict_failures(
|
||||
test_class: Type[Streamable], input_dict: Dict[str, Any], error: Any, error_message: str
|
||||
) -> None:
|
||||
|
||||
with pytest.raises(error, match=re.escape(error_message)):
|
||||
streamable_from_dict(test_class, input_dict)
|
||||
|
||||
@ -742,7 +734,6 @@ def test_parse_optional() -> None:
|
||||
|
||||
|
||||
def test_parse_bytes() -> None:
|
||||
|
||||
assert parse_bytes(io.BytesIO(b"\x00\x00\x00\x00")) == b""
|
||||
assert parse_bytes(io.BytesIO(b"\x00\x00\x00\x01\xff")) == b"\xff"
|
||||
|
||||
@ -768,7 +759,6 @@ def test_parse_bytes() -> None:
|
||||
|
||||
|
||||
def test_parse_list() -> None:
|
||||
|
||||
assert parse_list(io.BytesIO(b"\x00\x00\x00\x00"), parse_bool) == []
|
||||
assert parse_list(io.BytesIO(b"\x00\x00\x00\x01\x01"), parse_bool) == [True]
|
||||
assert parse_list(io.BytesIO(b"\x00\x00\x00\x03\x01\x00\x01"), parse_bool) == [True, False, True]
|
||||
@ -789,7 +779,6 @@ def test_parse_list() -> None:
|
||||
|
||||
|
||||
def test_parse_tuple() -> None:
|
||||
|
||||
assert parse_tuple(io.BytesIO(b""), []) == ()
|
||||
assert parse_tuple(io.BytesIO(b"\x00\x00"), [parse_bool, parse_bool]) == (False, False)
|
||||
assert parse_tuple(io.BytesIO(b"\x00\x01"), [parse_bool, parse_bool]) == (False, True)
|
||||
@ -832,7 +821,6 @@ def test_parse_size_hints() -> None:
|
||||
|
||||
|
||||
def test_parse_str() -> None:
|
||||
|
||||
assert parse_str(io.BytesIO(b"\x00\x00\x00\x00")) == ""
|
||||
assert parse_str(io.BytesIO(b"\x00\x00\x00\x01a")) == "a"
|
||||
|
||||
@ -858,7 +846,6 @@ def test_parse_str() -> None:
|
||||
|
||||
|
||||
def test_wrong_decorator_order() -> None:
|
||||
|
||||
with pytest.raises(DefinitionError):
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@ -868,7 +855,6 @@ def test_wrong_decorator_order() -> None:
|
||||
|
||||
|
||||
def test_dataclass_not_frozen() -> None:
|
||||
|
||||
with pytest.raises(DefinitionError):
|
||||
|
||||
@streamable
|
||||
@ -878,7 +864,6 @@ def test_dataclass_not_frozen() -> None:
|
||||
|
||||
|
||||
def test_dataclass_missing() -> None:
|
||||
|
||||
with pytest.raises(DefinitionError):
|
||||
|
||||
@streamable
|
||||
@ -887,7 +872,6 @@ def test_dataclass_missing() -> None:
|
||||
|
||||
|
||||
def test_streamable_inheritance_missing() -> None:
|
||||
|
||||
with pytest.raises(DefinitionError):
|
||||
# we want to test invalid here, hence the ignore.
|
||||
@streamable
|
||||
|
@ -106,7 +106,6 @@ def get_reader_method_fixture(request: SubRequest) -> Callable[[], ConnectionCon
|
||||
argvalues=[pytest.param(False, id="not acquired outside"), pytest.param(True, id="acquired outside")],
|
||||
)
|
||||
async def test_concurrent_writers(acquire_outside: bool, get_reader_method: GetReaderMethod) -> None:
|
||||
|
||||
async with DBConnection(2) as db_wrapper:
|
||||
await setup_table(db_wrapper)
|
||||
|
||||
@ -326,7 +325,6 @@ async def test_reader_transaction_is_deferred() -> None:
|
||||
argvalues=[pytest.param(False, id="not acquired outside"), pytest.param(True, id="acquired outside")],
|
||||
)
|
||||
async def test_concurrent_readers(acquire_outside: bool, get_reader_method: GetReaderMethod) -> None:
|
||||
|
||||
async with DBConnection(2) as db_wrapper:
|
||||
await setup_table(db_wrapper)
|
||||
|
||||
@ -356,7 +354,6 @@ async def test_concurrent_readers(acquire_outside: bool, get_reader_method: GetR
|
||||
argvalues=[pytest.param(False, id="not acquired outside"), pytest.param(True, id="acquired outside")],
|
||||
)
|
||||
async def test_mixed_readers_writers(acquire_outside: bool, get_reader_method: GetReaderMethod) -> None:
|
||||
|
||||
async with DBConnection(2) as db_wrapper:
|
||||
await setup_table(db_wrapper)
|
||||
|
||||
|
@ -32,7 +32,6 @@ def float_to_str(f):
|
||||
|
||||
|
||||
def run_and_return_cost_time(chialisp):
|
||||
|
||||
start = time.time()
|
||||
clvm_loop = "((c (q ((c (f (a)) (c (f (a)) (c (f (r (a))) (c (f (r (r (a))))"
|
||||
" (q ()))))))) (c (q ((c (i (f (r (a))) (q (i (q 1) ((c (f (a)) (c (f (a))"
|
||||
|
@ -150,7 +150,6 @@ def visit_all_messages(visitor: Callable[[Any, str], None]) -> None:
|
||||
|
||||
|
||||
def get_protocol_bytes() -> bytes:
|
||||
|
||||
result = b""
|
||||
|
||||
def visitor(obj: Any, name: str) -> None:
|
||||
@ -163,7 +162,6 @@ def get_protocol_bytes() -> bytes:
|
||||
|
||||
|
||||
def build_protocol_test() -> str:
|
||||
|
||||
result = """# this file is generated by build_network_protocol_files.py
|
||||
|
||||
from typing import Tuple
|
||||
@ -207,7 +205,6 @@ def test_protocol_bytes() -> None:
|
||||
|
||||
|
||||
def get_protocol_json() -> str:
|
||||
|
||||
result = """# this file is generated by build_network_protocol_files.py
|
||||
from typing import Any, Dict
|
||||
"""
|
||||
@ -225,7 +222,6 @@ from typing import Any, Dict
|
||||
|
||||
|
||||
def build_json_test() -> str:
|
||||
|
||||
result = """# this file is generated by build_network_protocol_files.py
|
||||
|
||||
from tests.util.network_protocol_data import * # noqa: F403
|
||||
|
@ -4,7 +4,6 @@ from chia.util.chunks import chunks
|
||||
|
||||
|
||||
def test_chunks() -> None:
|
||||
|
||||
assert list(chunks([], 0)) == []
|
||||
assert list(chunks(["a"], 0)) == [["a"]]
|
||||
assert list(chunks(["a", "b"], 0)) == [["a"], ["b"]]
|
||||
|
@ -246,7 +246,6 @@ def get_full_blocks() -> Iterator[FullBlock]:
|
||||
@pytest.mark.asyncio
|
||||
# @pytest.mark.skip("This test is expensive and has already convinced us the parser works")
|
||||
async def test_parser():
|
||||
|
||||
# loop over every combination of Optionals being set and not set
|
||||
# along with random values for the FullBlock fields. Ensure
|
||||
# generator_from_block() successfully parses out the generator object
|
||||
|
@ -11,7 +11,6 @@ from chia.util.logging import TimedDuplicateFilter
|
||||
|
||||
|
||||
def test_logging_filter(caplog: pytest.LogCaptureFixture) -> None:
|
||||
|
||||
log_interval_secs = 1
|
||||
num_logs = 11
|
||||
sleep_secs = 0.095
|
||||
@ -32,7 +31,6 @@ def test_logging_filter(caplog: pytest.LogCaptureFixture) -> None:
|
||||
|
||||
|
||||
def test_dont_filter_non_matches(caplog: pytest.LogCaptureFixture) -> None:
|
||||
|
||||
log = logging.getLogger()
|
||||
log.addFilter(TimedDuplicateFilter("Filter this log message.*", 10))
|
||||
|
||||
|
@ -20,7 +20,6 @@ def parse_blob(input_bytes: bytes) -> Tuple[bytes, bytes]:
|
||||
|
||||
|
||||
def test_protocol_bytes() -> None:
|
||||
|
||||
filename: Path = get_network_protocol_filename()
|
||||
assert filename.exists()
|
||||
with open(filename, "rb") as f:
|
||||
|
@ -46,7 +46,6 @@ def test_missing_messages_state_machine() -> None:
|
||||
|
||||
|
||||
def test_missing_messages() -> None:
|
||||
|
||||
wallet_msgs = {
|
||||
"CoinState",
|
||||
"CoinStateUpdate",
|
||||
|
@ -107,7 +107,6 @@ class TestStructStream:
|
||||
length: int,
|
||||
struct_format: Optional[str],
|
||||
) -> None:
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
t = cls(upper_boundary + 1)
|
||||
|
||||
|
@ -582,7 +582,6 @@ class TestWalletSync:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_wp_fork_point(self, default_10000_blocks):
|
||||
|
||||
blocks = default_10000_blocks
|
||||
header_cache, height_to_hash, sub_blocks, summaries = await load_blocks_dont_validate(blocks)
|
||||
wpf = WeightProofHandler(test_constants, BlockCache(sub_blocks, header_cache, height_to_hash, summaries))
|
||||
@ -673,7 +672,6 @@ class TestWalletSync:
|
||||
xch_spam_amount,
|
||||
dust_value,
|
||||
):
|
||||
|
||||
full_nodes, wallets, _ = two_wallet_nodes_custom_spam_filtering
|
||||
|
||||
farm_wallet_node, farm_wallet_server = wallets[0]
|
||||
|
@ -30,7 +30,6 @@ def enable_profiler(name: str) -> Iterator[None]:
|
||||
|
||||
@pytest.mark.benchmark
|
||||
def test_offer_parsing_performance() -> None:
|
||||
|
||||
offer_bytes = bytes.fromhex(test_offer)
|
||||
with assert_runtime(seconds=2, label="Offer.from_bytes()"):
|
||||
with enable_profiler("offer-parsing"):
|
||||
@ -41,7 +40,6 @@ def test_offer_parsing_performance() -> None:
|
||||
|
||||
@pytest.mark.benchmark
|
||||
def test_offered_coins_performance() -> None:
|
||||
|
||||
offer_bytes = bytes.fromhex(test_offer)
|
||||
o = Offer.from_bytes(offer_bytes)
|
||||
with assert_runtime(seconds=2.5, label="Offer.from_bytes()"):
|
||||
|
@ -15,9 +15,7 @@ from tests.util.db_connection import DBConnection
|
||||
class TestPuzzleStore:
|
||||
@pytest.mark.asyncio
|
||||
async def test_puzzle_store(self):
|
||||
|
||||
async with DBConnection(1) as wrapper:
|
||||
|
||||
db = await WalletPuzzleStore.create(wrapper)
|
||||
derivation_recs = []
|
||||
# wallet_types = [t for t in WalletType]
|
||||
|
@ -398,7 +398,6 @@ def assert_coin_spent(coin_store: CoinStore, coin: Coin, is_spent=True):
|
||||
def spend_coin_to_singleton(
|
||||
puzzle_db: PuzzleDB, launcher_puzzle: Program, coin_store: CoinStore, now: CoinTimestamp
|
||||
) -> Tuple[List[Coin], List[CoinSpend]]:
|
||||
|
||||
farmed_coin_amount = 100000
|
||||
metadata = [("foo", "bar")]
|
||||
|
||||
@ -471,7 +470,6 @@ def filter_p2_singleton(puzzle_db: PuzzleDB, singleton_wallet: SingletonWallet,
|
||||
|
||||
|
||||
def test_lifecycle_with_coinstore_as_wallet():
|
||||
|
||||
PUZZLE_DB = PuzzleDB()
|
||||
|
||||
interested_singletons = []
|
||||
|
@ -312,7 +312,6 @@ def record(c: Coin, *, confirmed: int, spent: int) -> WalletCoinRecord:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_coin_names_to_check() -> None:
|
||||
|
||||
r1 = record(coin_1, confirmed=1, spent=0)
|
||||
r2 = record(coin_2, confirmed=2, spent=4)
|
||||
r3 = record(coin_3, confirmed=3, spent=5)
|
||||
@ -334,7 +333,6 @@ async def test_get_coin_names_to_check() -> None:
|
||||
await store.add_coin_record(r7)
|
||||
|
||||
for i in range(10):
|
||||
|
||||
coins = await store.get_coin_names_to_check(i)
|
||||
|
||||
# r1 is unspent and should always be included, regardless of height
|
||||
@ -355,7 +353,6 @@ async def test_get_coin_names_to_check() -> None:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_first_coin_height() -> None:
|
||||
|
||||
r1 = record(coin_1, confirmed=1, spent=0)
|
||||
r2 = record(coin_2, confirmed=2, spent=4)
|
||||
r3 = record(coin_3, confirmed=3, spent=5)
|
||||
@ -381,7 +378,6 @@ async def test_get_first_coin_height() -> None:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_rollback_to_block() -> None:
|
||||
|
||||
r1 = record(coin_1, confirmed=1, spent=0)
|
||||
r2 = record(coin_2, confirmed=2, spent=4)
|
||||
r3 = record(coin_3, confirmed=3, spent=5)
|
||||
|
@ -71,7 +71,6 @@ def callable_for_module_function_path(call: str) -> Callable:
|
||||
@click.option("--end", default=None, help="last block to examine")
|
||||
@click.option("--call", default=None, help="function to pass block iterator to in form `module:function`")
|
||||
def main(file: Path, mempool_mode: bool, start: int, end: Optional[int], call: Optional[str], verify_signatures: bool):
|
||||
|
||||
call_f: Callable[[Union[BlockInfo, FullBlock], bytes32, int, List[bytes], float, int], None]
|
||||
if call is None:
|
||||
call_f = partial(default_call, verify_signatures)
|
||||
|
@ -162,7 +162,6 @@ def analyze_slot(ctx: click.Context, slot: int) -> None:
|
||||
filter_frames = set()
|
||||
|
||||
for name, fr in all_frames.items():
|
||||
|
||||
# frames that are less than 0.1% of the total allocations are
|
||||
# filtered
|
||||
if fr.size / total_size < 0.001:
|
||||
@ -181,7 +180,6 @@ def analyze_slot(ctx: click.Context, slot: int) -> None:
|
||||
|
||||
# print all edges (calls)
|
||||
for name, fr in all_frames.items():
|
||||
|
||||
if name in filter_frames:
|
||||
continue
|
||||
|
||||
|
@ -38,7 +38,6 @@ def main(pid: int, output: str, threads: bool) -> None:
|
||||
try:
|
||||
step = 0
|
||||
while process.is_running():
|
||||
|
||||
timestamps.append(time.perf_counter())
|
||||
ps = process.cpu_times()
|
||||
stats[pid][step] = Counters(ps.user, ps.system)
|
||||
|
@ -55,7 +55,6 @@ def enable_profiler(profile: bool, counter: int) -> Iterator[None]:
|
||||
"--output", type=str, required=False, default=None, help="the filename to write the resulting sqlite database to"
|
||||
)
|
||||
def main(length: int, fill_rate: int, profile: bool, block_refs: bool, output: Optional[str]) -> None:
|
||||
|
||||
if fill_rate < 0 or fill_rate > 100:
|
||||
print("fill-rate must be within [0, 100]")
|
||||
sys.exit(1)
|
||||
@ -79,7 +78,6 @@ def main(length: int, fill_rate: int, profile: bool, block_refs: bool, output: O
|
||||
root_path = Path("./test-chain").resolve()
|
||||
root_path.mkdir(parents=True, exist_ok=True)
|
||||
with TempKeyring() as keychain:
|
||||
|
||||
bt = create_block_tools(constants=test_constants, root_path=root_path, keychain=keychain)
|
||||
initialize_logging(
|
||||
"generate_chain", {"log_level": "DEBUG", "log_stdout": False, "log_syslog": False}, root_path=root_path
|
||||
@ -87,7 +85,6 @@ def main(length: int, fill_rate: int, profile: bool, block_refs: bool, output: O
|
||||
|
||||
print(f"writing blockchain to {output}")
|
||||
with closing(sqlite3.connect(output)) as db:
|
||||
|
||||
db.execute(
|
||||
"CREATE TABLE full_blocks("
|
||||
"header_hash blob PRIMARY KEY,"
|
||||
|
@ -103,7 +103,6 @@ def npc_to_dict(npc: NPC):
|
||||
|
||||
|
||||
def run_generator(block_generator: BlockGenerator, constants: ConsensusConstants, max_cost: int) -> List[CAT]:
|
||||
|
||||
block_args = [bytes(a) for a in block_generator.generator_refs]
|
||||
cost, block_result = block_generator.program.run_with_cost(max_cost, DESERIALIZE_MOD, block_args)
|
||||
|
||||
@ -111,7 +110,6 @@ def run_generator(block_generator: BlockGenerator, constants: ConsensusConstants
|
||||
|
||||
cat_list: List[CAT] = []
|
||||
for spend in coin_spends.as_iter():
|
||||
|
||||
parent, puzzle, amount, solution = spend.as_iter()
|
||||
args = match_cat_puzzle(uncurry_puzzle(puzzle))
|
||||
|
||||
|
@ -107,7 +107,6 @@ async def run_sync_test(
|
||||
node_profiler: bool,
|
||||
start_at_checkpoint: Optional[str],
|
||||
) -> None:
|
||||
|
||||
logger = logging.getLogger()
|
||||
logger.setLevel(logging.WARNING)
|
||||
handler = logging.FileHandler("test-full-sync.log")
|
||||
@ -122,7 +121,6 @@ async def run_sync_test(
|
||||
logger.addHandler(check_log)
|
||||
|
||||
with tempfile.TemporaryDirectory() as root_dir:
|
||||
|
||||
root_path = Path(root_dir)
|
||||
if start_at_checkpoint is not None:
|
||||
shutil.copytree(Path(start_at_checkpoint) / ".", root_path, dirs_exist_ok=True)
|
||||
@ -332,7 +330,6 @@ async def run_sync_checkpoint(
|
||||
root_path: Path,
|
||||
max_height: int,
|
||||
) -> None:
|
||||
|
||||
root_path.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
chia_init(root_path, should_check_keys=False, v1_db=False)
|
||||
|
Loading…
Reference in New Issue
Block a user