Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

catchup: into long_lived/datalayer_merkle_blob from main @ 37df97e873836e9bd10fe20da3bd1dabab48a53e #19199

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions chia/_tests/core/full_node/full_sync/test_full_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@

from chia._tests.core.node_height import node_height_between, node_height_exactly
from chia._tests.util.time_out_assert import time_out_assert
from chia.full_node.full_node import FullNode
from chia.full_node.full_node_api import FullNodeAPI
from chia.protocols import full_node_protocol
from chia.protocols.shared_protocol import Capability
from chia.types.blockchain_format.sized_bytes import bytes32
from chia.types.blockchain_format.sub_epoch_summary import SubEpochSummary
from chia.types.full_block import FullBlock
from chia.types.peer_info import PeerInfo
Expand Down Expand Up @@ -437,7 +435,3 @@ async def test_bad_peak_cache_invalidation(
block = blocks[-1]
full_node_1.full_node.add_to_bad_peak_cache(block.header_hash, block.height)
assert len(full_node_1.full_node.bad_peak_cache) == 1


def has_peers_with_peak(node: FullNode, header_hash: bytes32) -> bool:
return len(node.sync_store.get_peers_that_have_peak([header_hash])) > 0
22 changes: 9 additions & 13 deletions chia/_tests/core/full_node/test_full_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,12 @@
from chia.types.blockchain_format.classgroup import ClassgroupElement
from chia.types.blockchain_format.foliage import Foliage, FoliageTransactionBlock, TransactionsInfo
from chia.types.blockchain_format.program import Program
from chia.types.blockchain_format.proof_of_space import ProofOfSpace, calculate_plot_id_pk, calculate_pos_challenge
from chia.types.blockchain_format.proof_of_space import (
ProofOfSpace,
calculate_plot_id_ph,
calculate_plot_id_pk,
calculate_pos_challenge,
)
from chia.types.blockchain_format.reward_chain_block import RewardChainBlockUnfinished
from chia.types.blockchain_format.serialized_program import SerializedProgram
from chia.types.blockchain_format.sized_bytes import bytes32
Expand Down Expand Up @@ -130,16 +135,6 @@ async def new_transaction_requested(incoming, new_spend):
return False


async def get_block_path(full_node: FullNodeAPI):
blocks_list = [await full_node.full_node.blockchain.get_full_peak()]
assert blocks_list[0] is not None
while blocks_list[0].height != 0:
b = await full_node.full_node.block_store.get_full_block(blocks_list[0].prev_header_hash)
assert b is not None
blocks_list.insert(0, b)
return blocks_list


@pytest.mark.anyio
async def test_sync_no_farmer(
setup_two_nodes_and_wallet,
Expand Down Expand Up @@ -1476,7 +1471,8 @@ async def test_unfinished_block_with_replaced_generator(wallet_nodes, self_hostn

if committment > 5:
if pos.pool_public_key is None:
plot_id = calculate_plot_id_pk(pos.pool_contract_puzzle_hash, public_key)
assert pos.pool_contract_puzzle_hash is not None
plot_id = calculate_plot_id_ph(pos.pool_contract_puzzle_hash, public_key)
else:
plot_id = calculate_plot_id_pk(pos.pool_public_key, public_key)
original_challenge_hash = block.reward_chain_block.pos_ss_cc_challenge_hash
Expand Down Expand Up @@ -1634,7 +1630,7 @@ async def test_request_unfinished_block2(wallet_nodes, self_hostname):
if best_unf is None:
best_unf = unf
elif (
unf.foliage.foliage_transaction_block_hash is not None
best_unf.foliage.foliage_transaction_block_hash is not None
and unf.foliage.foliage_transaction_block_hash < best_unf.foliage.foliage_transaction_block_hash
):
best_unf = unf
Expand Down
5 changes: 2 additions & 3 deletions chia/_tests/core/mempool/test_mempool_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@
from chia.types.spend_bundle_conditions import SpendBundleConditions, SpendConditions
from chia.util.errors import Err, ValidationError
from chia.util.ints import uint8, uint32, uint64
from chia.wallet.conditions import AssertCoinAnnouncement
from chia.wallet.payment import Payment
from chia.wallet.conditions import AssertCoinAnnouncement, CreateCoin
from chia.wallet.util.tx_config import DEFAULT_TX_CONFIG
from chia.wallet.wallet import Wallet
from chia.wallet.wallet_coin_record import WalletCoinRecord
Expand Down Expand Up @@ -1653,7 +1652,7 @@ async def make_setup_and_coins(
phs = [await wallet.get_new_puzzlehash() for _ in range(3)]
for _ in range(2):
await farm_a_block(full_node_api, wallet_node, ph)
other_recipients = [Payment(puzzle_hash=p, amount=uint64(200), memos=[]) for p in phs[1:]]
other_recipients = [CreateCoin(puzzle_hash=p, amount=uint64(200)) for p in phs[1:]]
async with wallet.wallet_state_manager.new_action_scope(
DEFAULT_TX_CONFIG, push=False, sign=True
) as action_scope:
Expand Down
3 changes: 3 additions & 0 deletions chia/_tests/util/full_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from chia.types.full_block import FullBlock
from chia.types.peer_info import PeerInfo
from chia.types.validation_state import ValidationState
from chia.util.augmented_chain import AugmentedBlockchain
from chia.util.config import load_config
from chia.util.ints import uint16

Expand Down Expand Up @@ -184,6 +185,7 @@ async def run_sync_test(
worst_batch_height = None
worst_batch_time_per_block = None
peer_info = peer.get_peer_logging()
blockchain = AugmentedBlockchain(full_node.blockchain)
async for r in rows:
batch_start_time = time.monotonic()
with enable_profiler(profile, height):
Expand Down Expand Up @@ -216,6 +218,7 @@ async def run_sync_test(
peer_info,
ForkInfo(fork_height, fork_height, header_hash),
ValidationState(ssi, diff, None),
blockchain,
)
end_height = block_batch[-1].height
full_node.blockchain.clean_block_record(end_height - full_node.constants.BLOCKS_CACHE_SIZE)
Expand Down
5 changes: 2 additions & 3 deletions chia/_tests/wallet/cat_wallet/test_cat_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -1641,8 +1641,7 @@ async def test_cat_melt_balance(wallet_environments: WalletTestFramework) -> Non

from chia.simulator.simulator_protocol import GetAllCoinsProtocol
from chia.wallet.cat_wallet.cat_utils import SpendableCAT, unsigned_spend_bundle_for_spendable_cats
from chia.wallet.conditions import UnknownCondition
from chia.wallet.payment import Payment
from chia.wallet.conditions import CreateCoin, UnknownCondition

await simulator.farm_blocks_to_puzzlehash(count=1, farm_to=CAT_w_ACS_HASH, guarantee_transaction_blocks=True)
await simulator.farm_blocks_to_puzzlehash(count=1)
Expand Down Expand Up @@ -1703,7 +1702,7 @@ async def test_cat_melt_balance(wallet_environments: WalletTestFramework) -> Non
limitations_program_hash=ACS_TAIL_HASH,
inner_puzzle=await cat_wallet.inner_puzzle_for_cat_puzhash(new_coin.puzzle_hash),
inner_solution=wallet.make_solution(
primaries=[Payment(wallet_ph, uint64(tx_amount), [wallet_ph])],
primaries=[CreateCoin(wallet_ph, uint64(tx_amount), [wallet_ph])],
conditions=(
UnknownCondition(
opcode=Program.to(51),
Expand Down
28 changes: 15 additions & 13 deletions chia/_tests/wallet/cat_wallet/test_offer_lifecycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@
construct_cat_puzzle,
unsigned_spend_bundle_for_spendable_cats,
)
from chia.wallet.conditions import AssertPuzzleAnnouncement, ConditionValidTimes
from chia.wallet.conditions import AssertPuzzleAnnouncement, ConditionValidTimes, CreateCoin
from chia.wallet.outer_puzzles import AssetType
from chia.wallet.payment import Payment
from chia.wallet.puzzle_drivers import PuzzleInfo
from chia.wallet.trading.offer import OFFER_MOD, Offer
from chia.wallet.wallet_spend_bundle import WalletSpendBundle
Expand Down Expand Up @@ -60,7 +59,7 @@ async def generate_coins(
tail_hash = tail.get_tree_hash()
cat_puzzle = construct_cat_puzzle(CAT_MOD, tail_hash, acs)
cat_puzzle_hash = cat_puzzle.get_tree_hash()
payments.append(Payment(cat_puzzle_hash, uint64(amount)))
payments.append(CreateCoin(cat_puzzle_hash, uint64(amount)))
cat_bundles.append(
unsigned_spend_bundle_for_spendable_cats(
CAT_MOD,
Expand All @@ -75,7 +74,7 @@ async def generate_coins(
)
)
else:
payments.append(Payment(acs_ph, uint64(amount)))
payments.append(CreateCoin(acs_ph, uint64(amount)))

# This bundle creates all of the initial coins
parent_bundle = WalletSpendBundle(
Expand Down Expand Up @@ -178,8 +177,11 @@ async def test_complex_offer(cost_logger: CostLogger) -> None:
driver_dict_as_infos = {key.hex(): value.info for key, value in driver_dict.items()}

# Create an XCH Offer for RED
chia_requested_payments: dict[Optional[bytes32], list[Payment]] = {
str_to_tail_hash("red"): [Payment(acs_ph, uint64(100), [b"memo"]), Payment(acs_ph, uint64(200), [b"memo"])]
chia_requested_payments: dict[Optional[bytes32], list[CreateCoin]] = {
str_to_tail_hash("red"): [
CreateCoin(acs_ph, uint64(100), [b"memo"]),
CreateCoin(acs_ph, uint64(200), [b"memo"]),
]
}
chia_notarized_payments = Offer.notarize_payments(chia_requested_payments, chia_coins)
chia_announcements = Offer.calculate_announcements(chia_notarized_payments, driver_dict)
Expand All @@ -190,8 +192,8 @@ async def test_complex_offer(cost_logger: CostLogger) -> None:
# Create a RED Offer for XCH
red_coins_1 = red_coins[0:1]
red_coins_2 = red_coins[1:]
red_requested_payments: dict[Optional[bytes32], list[Payment]] = {
None: [Payment(acs_ph, uint64(300), [b"red memo"]), Payment(acs_ph, uint64(350), [b"red memo"])]
red_requested_payments: dict[Optional[bytes32], list[CreateCoin]] = {
None: [CreateCoin(acs_ph, uint64(300), [b"red memo"]), CreateCoin(acs_ph, uint64(350), [b"red memo"])]
}
red_notarized_payments = Offer.notarize_payments(red_requested_payments, red_coins_1)
red_announcements = Offer.calculate_announcements(red_notarized_payments, driver_dict)
Expand All @@ -201,8 +203,8 @@ async def test_complex_offer(cost_logger: CostLogger) -> None:
red_offer = Offer(red_notarized_payments, red_secured_bundle, driver_dict)
assert not red_offer.is_valid()

red_requested_payments_2: dict[Optional[bytes32], list[Payment]] = {
None: [Payment(acs_ph, uint64(50), [b"red memo"])]
red_requested_payments_2: dict[Optional[bytes32], list[CreateCoin]] = {
None: [CreateCoin(acs_ph, uint64(50), [b"red memo"])]
}
red_notarized_payments_2 = Offer.notarize_payments(red_requested_payments_2, red_coins_2)
red_announcements_2 = Offer.calculate_announcements(red_notarized_payments_2, driver_dict)
Expand All @@ -219,9 +221,9 @@ async def test_complex_offer(cost_logger: CostLogger) -> None:
assert new_offer.is_valid()

# Create yet another offer of BLUE for XCH and RED
blue_requested_payments: dict[Optional[bytes32], list[Payment]] = {
None: [Payment(acs_ph, uint64(200), [b"blue memo"])],
str_to_tail_hash("red"): [Payment(acs_ph, uint64(50), [b"blue memo"])],
blue_requested_payments: dict[Optional[bytes32], list[CreateCoin]] = {
None: [CreateCoin(acs_ph, uint64(200), [b"blue memo"])],
str_to_tail_hash("red"): [CreateCoin(acs_ph, uint64(50), [b"blue memo"])],
}
blue_notarized_payments = Offer.notarize_payments(blue_requested_payments, blue_coins)
blue_announcements = Offer.calculate_announcements(blue_notarized_payments, driver_dict)
Expand Down
18 changes: 6 additions & 12 deletions chia/_tests/wallet/db_wallet/test_dl_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,15 +258,11 @@ async def test_lifecycle(
current_tree = MerkleTree(nodes)
current_root = current_tree.calculate_root()

async with dl_wallet.wallet_state_manager.new_action_scope(DEFAULT_TX_CONFIG, push=False) as action_scope:
async with dl_wallet.wallet_state_manager.new_action_scope(DEFAULT_TX_CONFIG, push=True) as action_scope:
launcher_id = await dl_wallet.generate_new_reporter(current_root, action_scope)

assert await dl_wallet.get_latest_singleton(launcher_id) is not None

[std_record] = await wallet_node_0.wallet_state_manager.add_pending_transactions(
action_scope.side_effects.transactions
)
await full_node_api.process_transaction_records(records=[std_record])
await full_node_api.process_transaction_records(records=action_scope.side_effects.transactions)

await time_out_assert(15, is_singleton_confirmed, True, dl_wallet, launcher_id)

Expand All @@ -276,7 +272,7 @@ async def test_lifecycle(

new_root = MerkleTree([Program.to("root").get_tree_hash()]).calculate_root()

async with dl_wallet.wallet_state_manager.new_action_scope(DEFAULT_TX_CONFIG, push=False) as action_scope:
async with dl_wallet.wallet_state_manager.new_action_scope(DEFAULT_TX_CONFIG, push=True) as action_scope:
await dl_wallet.generate_signed_transaction(
[previous_record.lineage_proof.amount],
[previous_record.inner_puzzle_hash],
Expand Down Expand Up @@ -309,8 +305,7 @@ async def test_lifecycle(
assert new_record != previous_record
assert not new_record.confirmed

txs = await wallet_node_0.wallet_state_manager.add_pending_transactions(action_scope.side_effects.transactions)
await full_node_api.process_transaction_records(records=txs)
await full_node_api.process_transaction_records(records=action_scope.side_effects.transactions)

await time_out_assert(15, is_singleton_confirmed, True, dl_wallet, launcher_id)
await time_out_assert(10, wallet_0.get_unconfirmed_balance, funds - 2000000000000)
Expand All @@ -324,15 +319,14 @@ async def test_lifecycle(
previous_record = await dl_wallet.get_latest_singleton(launcher_id)

new_root = MerkleTree([Program.to("new root").get_tree_hash()]).calculate_root()
async with dl_wallet.wallet_state_manager.new_action_scope(DEFAULT_TX_CONFIG, push=False) as action_scope:
async with dl_wallet.wallet_state_manager.new_action_scope(DEFAULT_TX_CONFIG, push=True) as action_scope:
await dl_wallet.create_update_state_spend(launcher_id, new_root, action_scope)
new_record = await dl_wallet.get_latest_singleton(launcher_id)
assert new_record is not None
assert new_record != previous_record
assert not new_record.confirmed

txs = await wallet_node_0.wallet_state_manager.add_pending_transactions(action_scope.side_effects.transactions)
await full_node_api.process_transaction_records(records=txs)
await full_node_api.process_transaction_records(records=action_scope.side_effects.transactions)

await time_out_assert(15, is_singleton_confirmed, True, dl_wallet, launcher_id)
await asyncio.sleep(0.5)
Expand Down
2 changes: 1 addition & 1 deletion chia/_tests/wallet/rpc/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from __future__ import annotations

checkout_blocks_and_plots = True
job_timeout = 90
job_timeout = 35
Loading
Loading