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

[CHIA-302] Handle reorgs in data layer wallet #17992

Merged
merged 6 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
52 changes: 24 additions & 28 deletions chia/_tests/wallet/db_wallet/test_dl_offers.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,22 +62,18 @@ async def test_dl_offers(wallets_prefarm: Any, trusted: bool) -> None:

fee = uint64(1_999_999_999_999)

dl_record, std_record, launcher_id_maker = await dl_wallet_maker.generate_new_reporter(
maker_root, DEFAULT_TX_CONFIG, fee=fee
)
std_record, launcher_id_maker = await dl_wallet_maker.generate_new_reporter(maker_root, DEFAULT_TX_CONFIG, fee=fee)
assert await dl_wallet_maker.get_latest_singleton(launcher_id_maker) is not None
[dl_record, std_record] = await wsm_maker.add_pending_transactions([dl_record, std_record])
await full_node_api.process_transaction_records(records=[dl_record, std_record])
[std_record] = await wsm_maker.add_pending_transactions([std_record])
await full_node_api.process_transaction_records(records=[std_record])
maker_funds -= fee
maker_funds -= 1
await time_out_assert(15, is_singleton_confirmed_and_root, True, dl_wallet_maker, launcher_id_maker, maker_root)

dl_record, std_record, launcher_id_taker = await dl_wallet_taker.generate_new_reporter(
taker_root, DEFAULT_TX_CONFIG, fee=fee
)
std_record, launcher_id_taker = await dl_wallet_taker.generate_new_reporter(taker_root, DEFAULT_TX_CONFIG, fee=fee)
assert await dl_wallet_taker.get_latest_singleton(launcher_id_taker) is not None
[dl_record, std_record] = await wsm_taker.add_pending_transactions([dl_record, std_record])
await full_node_api.process_transaction_records(records=[dl_record, std_record])
[std_record] = await wsm_taker.add_pending_transactions([std_record])
await full_node_api.process_transaction_records(records=[std_record])
taker_funds -= fee
taker_funds -= 1
await time_out_assert(15, is_singleton_confirmed_and_root, True, dl_wallet_taker, launcher_id_taker, taker_root)
Expand Down Expand Up @@ -254,14 +250,14 @@ async def test_dl_offer_cancellation(wallets_prefarm: Any, trusted: bool) -> Non
ROWS = [bytes32([i] * 32) for i in range(0, 10)]
root, _ = build_merkle_tree(ROWS)

dl_record, std_record, launcher_id = await dl_wallet.generate_new_reporter(root, DEFAULT_TX_CONFIG)
std_record, launcher_id = await dl_wallet.generate_new_reporter(root, DEFAULT_TX_CONFIG)
assert await dl_wallet.get_latest_singleton(launcher_id) is not None
[dl_record, std_record] = await wsm.add_pending_transactions([dl_record, std_record])
await full_node_api.process_transaction_records(records=[dl_record, std_record])
[std_record] = await wsm.add_pending_transactions([std_record])
await full_node_api.process_transaction_records(records=[std_record])
await time_out_assert(15, is_singleton_confirmed_and_root, True, dl_wallet, launcher_id, root)
dl_record_2, std_record_2, launcher_id_2 = await dl_wallet.generate_new_reporter(root, DEFAULT_TX_CONFIG)
[dl_record_2, std_record_2] = await wsm.add_pending_transactions([dl_record_2, std_record_2])
await full_node_api.process_transaction_records(records=[dl_record_2, std_record_2])
std_record_2, launcher_id_2 = await dl_wallet.generate_new_reporter(root, DEFAULT_TX_CONFIG)
[std_record_2] = await wsm.add_pending_transactions([std_record_2])
await full_node_api.process_transaction_records(records=[std_record_2])

trade_manager = wsm.trade_manager

Expand Down Expand Up @@ -326,40 +322,40 @@ async def test_multiple_dl_offers(wallets_prefarm: Any, trusted: bool) -> None:

fee = uint64(1_999_999_999_999)

dl_record, std_record, launcher_id_maker_1 = await dl_wallet_maker.generate_new_reporter(
std_record, launcher_id_maker_1 = await dl_wallet_maker.generate_new_reporter(
maker_root, DEFAULT_TX_CONFIG, fee=fee
)
assert await dl_wallet_maker.get_latest_singleton(launcher_id_maker_1) is not None
[dl_record, std_record] = await wsm_maker.add_pending_transactions([dl_record, std_record])
await full_node_api.process_transaction_records(records=[dl_record, std_record])
[std_record] = await wsm_maker.add_pending_transactions([std_record])
await full_node_api.process_transaction_records(records=[std_record])
maker_funds -= fee
maker_funds -= 1
await time_out_assert(15, is_singleton_confirmed_and_root, True, dl_wallet_maker, launcher_id_maker_1, maker_root)
dl_record, std_record, launcher_id_maker_2 = await dl_wallet_maker.generate_new_reporter(
std_record, launcher_id_maker_2 = await dl_wallet_maker.generate_new_reporter(
maker_root, DEFAULT_TX_CONFIG, fee=fee
)
assert await dl_wallet_maker.get_latest_singleton(launcher_id_maker_2) is not None
[dl_record, std_record] = await wsm_maker.add_pending_transactions([dl_record, std_record])
await full_node_api.process_transaction_records(records=[dl_record, std_record])
[std_record] = await wsm_maker.add_pending_transactions([std_record])
await full_node_api.process_transaction_records(records=[std_record])
maker_funds -= fee
maker_funds -= 1
await time_out_assert(15, is_singleton_confirmed_and_root, True, dl_wallet_maker, launcher_id_maker_2, maker_root)

dl_record, std_record, launcher_id_taker_1 = await dl_wallet_taker.generate_new_reporter(
std_record, launcher_id_taker_1 = await dl_wallet_taker.generate_new_reporter(
taker_root, DEFAULT_TX_CONFIG, fee=fee
)
assert await dl_wallet_taker.get_latest_singleton(launcher_id_taker_1) is not None
[dl_record, std_record] = await wsm_taker.add_pending_transactions([dl_record, std_record])
await full_node_api.process_transaction_records(records=[dl_record, std_record])
[std_record] = await wsm_taker.add_pending_transactions([std_record])
await full_node_api.process_transaction_records(records=[std_record])
taker_funds -= fee
taker_funds -= 1
await time_out_assert(15, is_singleton_confirmed_and_root, True, dl_wallet_taker, launcher_id_taker_1, taker_root)
dl_record, std_record, launcher_id_taker_2 = await dl_wallet_taker.generate_new_reporter(
std_record, launcher_id_taker_2 = await dl_wallet_taker.generate_new_reporter(
taker_root, DEFAULT_TX_CONFIG, fee=fee
)
assert await dl_wallet_taker.get_latest_singleton(launcher_id_taker_2) is not None
[dl_record, std_record] = await wsm_taker.add_pending_transactions([dl_record, std_record])
await full_node_api.process_transaction_records(records=[dl_record, std_record])
[std_record] = await wsm_taker.add_pending_transactions([std_record])
await full_node_api.process_transaction_records(records=[std_record])
taker_funds -= fee
taker_funds -= 1
await time_out_assert(15, is_singleton_confirmed_and_root, True, dl_wallet_taker, launcher_id_taker_2, taker_root)
Expand Down