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

Absorb fee into action scope #19056

Closed
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
4 changes: 2 additions & 2 deletions chia/_tests/core/full_node/test_transactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ async def peak_height(fna: FullNodeAPI):
await time_out_assert(20, peak_height, num_blocks, full_node_api_2)

async with wallet_0.wallet_state_manager.new_action_scope(DEFAULT_TX_CONFIG, push=True) as action_scope:
await wallet_0.wallet_state_manager.main_wallet.generate_signed_transaction(10, ph1, action_scope, 0)
await wallet_0.wallet_state_manager.main_wallet.generate_signed_transaction(10, ph1, action_scope)
[tx] = action_scope.side_effects.transactions

await time_out_assert(
Expand Down Expand Up @@ -155,7 +155,7 @@ async def test_mempool_tx_sync(self, three_nodes_two_wallets, self_hostname, see

async with wallet_0.wallet_state_manager.new_action_scope(DEFAULT_TX_CONFIG, push=True) as action_scope:
await wallet_0.wallet_state_manager.main_wallet.generate_signed_transaction(
10, bytes32.random(seeded_random), action_scope, 0
10, bytes32.random(seeded_random), action_scope
)
[tx] = action_scope.side_effects.transactions

Expand Down
4 changes: 1 addition & 3 deletions chia/_tests/core/mempool/test_mempool_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -1719,21 +1719,19 @@ async def make_setup_and_coins(
e_announcement = AssertCoinAnnouncement(asserted_id=e_coin_id, asserted_msg=message)
# Create transactions D and F that consume an announcement created by E
async with wallet.wallet_state_manager.new_action_scope(
DEFAULT_TX_CONFIG, push=False, merge_spends=False, sign=True
DEFAULT_TX_CONFIG, push=False, merge_spends=False, sign=True, fee=uint64(0)
) as action_scope:
await wallet.generate_signed_transaction(
uint64(100),
ph,
action_scope,
fee=uint64(0),
coins={coins[4].coin},
extra_conditions=(e_announcement,),
)
await wallet.generate_signed_transaction(
uint64(150),
ph,
action_scope,
fee=uint64(0),
coins={coins[5].coin},
extra_conditions=(e_announcement,),
)
Expand Down
6 changes: 4 additions & 2 deletions chia/_tests/core/mempool/test_mempool_performance.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ async def test_mempool_update_performance(
await time_out_assert(30, wallet_balance_at_least, True, wallet_node, send_amount + fee_amount)

ph = await wallet.get_new_puzzlehash()
async with wallet.wallet_state_manager.new_action_scope(DEFAULT_TX_CONFIG, push=False, sign=True) as action_scope:
await wallet.generate_signed_transaction(send_amount, ph, action_scope, fee_amount)
async with wallet.wallet_state_manager.new_action_scope(
DEFAULT_TX_CONFIG, push=False, sign=True, fee=fee_amount
) as action_scope:
await wallet.generate_signed_transaction(send_amount, ph, action_scope)
[big_transaction] = action_scope.side_effects.transactions
assert big_transaction.spend_bundle is not None
status, err = await full_node.add_transaction(
Expand Down
1 change: 0 additions & 1 deletion chia/_tests/simulation/test_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ async def test_simulator_auto_farm_and_get_coins(
uint64(10),
await wallet_node_2.wallet_state_manager.main_wallet.get_new_puzzlehash(),
action_scope,
uint64(0),
)
[tx] = await wallet.wallet_state_manager.add_pending_transactions(action_scope.side_effects.transactions)
# wait till out of mempool
Expand Down
15 changes: 9 additions & 6 deletions chia/_tests/wallet/cat_wallet/test_cat_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,15 @@ async def test_cat_creation(wallet_environments: WalletTestFramework) -> None:
}
test_amount = 100
test_fee = 10
async with wallet.wallet_state_manager.new_action_scope(wallet_environments.tx_config, push=True) as action_scope:
async with wallet.wallet_state_manager.new_action_scope(
wallet_environments.tx_config, push=True, fee=uint64(test_fee)
) as action_scope:
cat_wallet = await CATWallet.create_new_cat_wallet(
wsm,
wallet,
{"identifier": "genesis_by_id"},
uint64(test_amount),
action_scope,
fee=uint64(test_fee),
)
# The next 2 lines are basically a noop, it just adds test coverage
cat_wallet = await CATWallet.create(wsm, wallet, cat_wallet.wallet_info)
Expand Down Expand Up @@ -324,8 +325,10 @@ async def test_cat_spend(wallet_environments: WalletTestFramework) -> None:
assert cat_wallet.cat_info.limitations_program_hash == cat_wallet_2.cat_info.limitations_program_hash

cat_2_hash = await cat_wallet_2.standard_wallet.get_puzzle_hash(new=False)
async with cat_wallet.wallet_state_manager.new_action_scope(DEFAULT_TX_CONFIG, push=True) as action_scope:
await cat_wallet.generate_signed_transaction([uint64(60)], [cat_2_hash], action_scope, fee=uint64(1))
async with cat_wallet.wallet_state_manager.new_action_scope(
DEFAULT_TX_CONFIG, push=True, fee=uint64(1)
) as action_scope:
await cat_wallet.generate_signed_transaction([uint64(60)], [cat_2_hash], action_scope)
tx_id = None
for tx_record in action_scope.side_effects.transactions:
if tx_record.wallet_id == cat_wallet.id():
Expand Down Expand Up @@ -617,9 +620,9 @@ async def test_cat_doesnt_see_eve(wallet_environments: WalletTestFramework) -> N

cat_2_hash = await cat_wallet_2.standard_wallet.get_puzzle_hash(new=False)
async with cat_wallet.wallet_state_manager.new_action_scope(
wallet_environments.tx_config, push=True
wallet_environments.tx_config, push=True, fee=uint64(1)
) as action_scope:
await cat_wallet.generate_signed_transaction([uint64(60)], [cat_2_hash], action_scope, fee=uint64(1))
await cat_wallet.generate_signed_transaction([uint64(60)], [cat_2_hash], action_scope)

await wallet_environments.process_pending_states(
[
Expand Down
44 changes: 20 additions & 24 deletions chia/_tests/wallet/cat_wallet/test_trades.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,11 +479,9 @@ async def test_cat_trades(
# Execute all of the trades
# chia_for_cat
async with trade_manager_maker.wallet_state_manager.new_action_scope(
wallet_environments.tx_config, push=False
wallet_environments.tx_config, push=False, fee=uint64(1)
) as action_scope:
success, trade_make, error = await trade_manager_maker.create_offer_for_ids(
chia_for_cat, action_scope, fee=uint64(1)
)
success, trade_make, error = await trade_manager_maker.create_offer_for_ids(chia_for_cat, action_scope)
assert error is None
assert success is True
assert trade_make is not None
Expand All @@ -493,13 +491,12 @@ async def test_cat_trades(
[Offer.from_bytes(trade_make.offer)]
)
async with trade_manager_taker.wallet_state_manager.new_action_scope(
wallet_environments.tx_config, push=True, additional_signing_responses=signing_response
wallet_environments.tx_config, push=True, additional_signing_responses=signing_response, fee=uint64(1)
) as action_scope:
trade_take = await trade_manager_taker.respond_to_offer(
maker_offer,
peer,
action_scope,
fee=uint64(1),
)

if test_aggregation:
Expand Down Expand Up @@ -711,13 +708,12 @@ async def assert_trade_tx_number(wallet_node: WalletNode, trade_id: bytes32, num
[Offer.from_bytes(trade_make.offer)]
)
async with trade_manager_taker.wallet_state_manager.new_action_scope(
wallet_environments.tx_config, push=True, additional_signing_responses=signing_response
wallet_environments.tx_config, push=True, additional_signing_responses=signing_response, fee=uint64(1)
) as action_scope:
trade_take = await trade_manager_taker.respond_to_offer(
Offer.from_bytes(trade_make.offer),
peer,
action_scope,
fee=uint64(1),
)

# Testing a precious display bug real quick
Expand Down Expand Up @@ -1732,9 +1728,9 @@ async def test_trade_cancellation(wallet_environments: WalletTestFramework) -> N
fee = uint64(2_000_000_000_000)

async with env_maker.wallet_state_manager.new_action_scope(
wallet_environments.tx_config, push=True
wallet_environments.tx_config, push=True, fee=fee
) as action_scope:
await trade_manager_maker.cancel_pending_offers([trade_make.trade_id], action_scope, fee=fee, secure=True)
await trade_manager_maker.cancel_pending_offers([trade_make.trade_id], action_scope, secure=True)
await time_out_assert(15, get_trade_and_status, TradeStatus.PENDING_CANCEL, trade_manager_maker, trade_make)

await wallet_environments.process_pending_states(
Expand Down Expand Up @@ -1815,9 +1811,9 @@ async def test_trade_cancellation(wallet_environments: WalletTestFramework) -> N
await trade_manager_taker.respond_to_offer(Offer.from_bytes(trade_make.offer), peer, action_scope)

async with env_maker.wallet_state_manager.new_action_scope(
wallet_environments.tx_config, push=True
wallet_environments.tx_config, push=True, fee=uint64(0)
) as action_scope:
await trade_manager_maker.cancel_pending_offers([trade_make.trade_id], action_scope, fee=uint64(0), secure=True)
await trade_manager_maker.cancel_pending_offers([trade_make.trade_id], action_scope, secure=True)
await time_out_assert(15, get_trade_and_status, TradeStatus.PENDING_CANCEL, trade_manager_maker, trade_make)

await wallet_environments.process_pending_states(
Expand Down Expand Up @@ -1868,9 +1864,9 @@ async def test_trade_cancellation(wallet_environments: WalletTestFramework) -> N
assert trade_make is not None

async with env_maker.wallet_state_manager.new_action_scope(
wallet_environments.tx_config, push=True
wallet_environments.tx_config, push=True, fee=uint64(0)
) as action_scope:
await trade_manager_maker.cancel_pending_offers([trade_make.trade_id], action_scope, fee=uint64(0), secure=True)
await trade_manager_maker.cancel_pending_offers([trade_make.trade_id], action_scope, secure=True)

# Check an announcement ring has been created
total_spend = SpendBundle.aggregate(
Expand Down Expand Up @@ -2014,9 +2010,9 @@ async def test_trade_conflict(wallet_environments: WalletTestFramework) -> None:
offer = Offer.from_bytes(trade_make.offer)
[offer], signing_response = await env_maker.wallet_state_manager.sign_offers([offer])
async with trade_manager_taker.wallet_state_manager.new_action_scope(
wallet_environments.tx_config, push=True, additional_signing_responses=signing_response
wallet_environments.tx_config, push=True, additional_signing_responses=signing_response, fee=fee
) as action_scope:
tr1 = await trade_manager_taker.respond_to_offer(offer, peer, action_scope, fee=fee)
tr1 = await trade_manager_taker.respond_to_offer(offer, peer, action_scope)

await wallet_environments.full_node.wait_transaction_records_entered_mempool(
records=action_scope.side_effects.transactions
Expand All @@ -2025,16 +2021,16 @@ async def test_trade_conflict(wallet_environments: WalletTestFramework) -> None:
# we shouldn't be able to respond to a duplicate offer
with pytest.raises(ValueError):
async with trade_manager_taker.wallet_state_manager.new_action_scope(
wallet_environments.tx_config, push=False
wallet_environments.tx_config, push=False, fee=fee
) as action_scope:
await trade_manager_taker.respond_to_offer(offer, peer, action_scope, fee=fee)
await trade_manager_taker.respond_to_offer(offer, peer, action_scope)
await time_out_assert(15, get_trade_and_status, TradeStatus.PENDING_CONFIRM, trade_manager_taker, tr1)
# pushing into mempool while already in it should fail
[offer], signing_response = await env_maker.wallet_state_manager.sign_offers([offer])
async with trade_manager_trader.wallet_state_manager.new_action_scope(
wallet_environments.tx_config, push=True, additional_signing_responses=signing_response
wallet_environments.tx_config, push=True, additional_signing_responses=signing_response, fee=fee
) as action_scope:
tr2 = await trade_manager_trader.respond_to_offer(offer, peer, action_scope, fee=fee)
tr2 = await trade_manager_trader.respond_to_offer(offer, peer, action_scope)
assert await trade_manager_trader.get_coins_of_interest()
await wallet_environments.process_pending_states(
[
Expand Down Expand Up @@ -2206,9 +2202,9 @@ async def test_trade_bad_spend(wallet_environments: WalletTestFramework) -> None
offer = dataclasses.replace(offer, _bundle=bundle)
fee = uint64(10)
async with trade_manager_taker.wallet_state_manager.new_action_scope(
wallet_environments.tx_config, push=True, sign=False
wallet_environments.tx_config, push=True, sign=False, fee=fee
) as action_scope:
tr1 = await trade_manager_taker.respond_to_offer(offer, peer, action_scope, fee=fee)
tr1 = await trade_manager_taker.respond_to_offer(offer, peer, action_scope)
env_taker.node.wallet_tx_resend_timeout_secs = 0 # don't wait for resend

def check_wallet_cache_empty() -> bool:
Expand Down Expand Up @@ -2326,9 +2322,9 @@ async def test_trade_high_fee(wallet_environments: WalletTestFramework) -> None:
[offer], signing_response = await env_maker.wallet_state_manager.sign_offers([Offer.from_bytes(trade_make.offer)])
fee = uint64(1_000_000_000_000)
async with trade_manager_taker.wallet_state_manager.new_action_scope(
wallet_environments.tx_config, push=True, additional_signing_responses=signing_response
wallet_environments.tx_config, push=True, additional_signing_responses=signing_response, fee=fee
) as action_scope:
tr1 = await trade_manager_taker.respond_to_offer(offer, peer, action_scope, fee=fee)
tr1 = await trade_manager_taker.respond_to_offer(offer, peer, action_scope)

await wallet_environments.process_pending_states(
[
Expand Down
Loading
Loading