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

Stop automatic transaction pushing by wallets #17436

Merged
merged 26 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
75555f5
Don't autopush transactions by default anywhere
Quexington Oct 11, 2023
55f519d
Remove ignore_max_send_amount
Quexington Oct 10, 2023
5102b47
Use TXConfig instead of pending_transactions for coin exclusion in sp…
Quexington Oct 10, 2023
843dcb9
Merge remote-tracking branch 'origin/long_lived/vault' into quex.remo…
Quexington Oct 12, 2023
853b793
Merge remote-tracking branch 'origin/long_lived/vault' into quex.all_…
Quexington Oct 12, 2023
c60b1b1
Merge branch 'quex.all_tx_pushing_optional' into quex.rework_spend_cl…
Quexington Oct 12, 2023
773e492
Merge remote-tracking branch 'origin/long_lived/vault' into quex.all_…
Quexington Oct 17, 2023
15103a6
Merge remote-tracking branch 'origin/long_lived/vault' into quex.remo…
Quexington Oct 17, 2023
4c1b289
Merge branch 'quex.all_tx_pushing_optional' into quex.rework_spend_cl…
Quexington Oct 17, 2023
5e9002f
Merge remote-tracking branch 'origin/long_lived/vault' into quex.remo…
Quexington Oct 19, 2023
8ae964d
Merge remote-tracking branch 'origin/long_lived/vault' into quex.all_…
Quexington Oct 19, 2023
2ba148e
Merge branch 'quex.all_tx_pushing_optional' into quex.rework_spend_cl…
Quexington Oct 19, 2023
409f5d5
Merge remote-tracking branch 'origin/long_lived/vault' into quex.remo…
Quexington Oct 30, 2023
cd64522
Address offline comments by @emlowe
Quexington Oct 31, 2023
46e816a
Rework max send amount to be based on coin quantity rather than amount
Quexington Nov 1, 2023
188bb20
Remove `ignore_max_send_amount` (#16395)
Quexington Nov 2, 2023
83e980e
Merge remote-tracking branch 'origin/long_lived/vault' into quex.all_…
Quexington Nov 2, 2023
3ba8a75
Merge branch 'quex.all_tx_pushing_optional' into quex.rework_spend_cl…
Quexington Nov 2, 2023
008f3ba
Don't autopush txs across RPC (#16314)
Quexington Nov 6, 2023
33a053e
Use TXConfig instead of pending_transactions for coin exclusion in sp…
Quexington Nov 8, 2023
122e28c
Merge commit '33a053e589388defffcca21f0d98a835ecd968ae' into HEAD
Quexington Jan 30, 2024
f3759d2
Merge remote-tracking branch 'origin/main' into quex.no_auto_push
Quexington Jan 30, 2024
dee1b97
merge fixes
Quexington Jan 30, 2024
e6ea806
Inadvertent diffs
Quexington Jan 30, 2024
4a39009
Inadvertent change
Quexington Jan 30, 2024
ee99424
Inadvertent diff.
AmineKhaldi Jan 31, 2024
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
22 changes: 7 additions & 15 deletions chia/pools/pool_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,6 @@ async def create_new_pool_wallet_transaction(
name=spend_bundle.name(),
valid_times=parse_timelock_info(extra_conditions),
)
await standard_wallet.push_transaction(standard_wallet_record)
p2_singleton_puzzle_hash: bytes32 = launcher_id_to_p2_puzzle_hash(
launcher_coin_id, p2_singleton_delay_time, p2_singleton_delayed_ph
)
Expand Down Expand Up @@ -528,17 +527,6 @@ async def generate_fee_transaction(
)
return fee_tx

async def publish_transactions(self, travel_tx: TransactionRecord, fee_tx: Optional[TransactionRecord]) -> None:
# We create two transaction records, one for the pool wallet to keep track of the travel TX, and another
# for the standard wallet to keep track of the fee. However, we will only submit the first one to the
# blockchain, and this one has the fee inside it as well.
# The fee tx, if present, will be added to the DB with no spend_bundle set, which has the effect that it
# will not be sent to full nodes.

await self.wallet_state_manager.add_pending_transaction(travel_tx)
if fee_tx is not None:
await self.wallet_state_manager.add_pending_transaction(dataclasses.replace(fee_tx, spend_bundle=None))

async def generate_travel_transactions(
self, fee: uint64, tx_config: TXConfig
) -> Tuple[TransactionRecord, Optional[TransactionRecord]]:
Expand Down Expand Up @@ -621,6 +609,7 @@ async def generate_travel_transactions(
fee_tx = await self.generate_fee_transaction(fee, tx_config)
assert fee_tx.spend_bundle is not None
signed_spend_bundle = SpendBundle.aggregate([signed_spend_bundle, fee_tx.spend_bundle])
fee_tx = dataclasses.replace(fee_tx, spend_bundle=None)

tx_record = TransactionRecord(
confirmed_at_height=uint32(0),
Expand All @@ -642,7 +631,6 @@ async def generate_travel_transactions(
valid_times=ConditionValidTimes(),
)

await self.publish_transactions(tx_record, fee_tx)
return tx_record, fee_tx

@staticmethod
Expand Down Expand Up @@ -925,7 +913,6 @@ async def claim_pool_rewards(
valid_times=ConditionValidTimes(),
)

await self.publish_transactions(absorb_transaction, fee_tx)
return absorb_transaction, fee_tx

async def new_peak(self, peak_height: uint32) -> None:
Expand Down Expand Up @@ -970,7 +957,12 @@ async def new_peak(self, peak_height: uint32) -> None:
assert self.target_state.relative_lock_height >= self.MINIMUM_RELATIVE_LOCK_HEIGHT
assert self.target_state.pool_url is not None

await self.generate_travel_transactions(self.next_transaction_fee, self.next_tx_config)
travel_tx, fee_tx = await self.generate_travel_transactions(
self.next_transaction_fee, self.next_tx_config
)
await self.wallet_state_manager.add_pending_transaction(travel_tx)
if fee_tx is not None:
await self.wallet_state_manager.add_pending_transaction(fee_tx)

async def have_unconfirmed_transaction(self) -> bool:
unconfirmed: List[TransactionRecord] = await self.wallet_state_manager.tx_store.get_unconfirmed_for_wallet(
Expand Down
12 changes: 11 additions & 1 deletion chia/rpc/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,16 @@ async def rpc_endpoint(self, request: Dict[str, Any], *args, **kwargs) -> Dict[s
):
raise ValueError("Relative timelocks are not currently supported in the RPC")

return await func(self, request, *args, tx_config=tx_config, extra_conditions=extra_conditions, **kwargs)
push: Optional[bool] = request.get("push")

return await func(
self,
request,
*args,
tx_config=tx_config,
extra_conditions=extra_conditions,
**({"push": push} if push is not None else {}),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't looks like the function distinguishes between this argument being passed as True and not being passed at all. wouldn't it look a bit simpler to just say:

Suggested change
**({"push": push} if push is not None else {}),
push = False if push is None else True,

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some cases default to true and some default to false.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah as @AmineKhaldi said, the idea is to omit the push key for the API side default if no value is specified.

**kwargs,
)

return rpc_endpoint
Loading
Loading