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

Don't autopush txs across RPC #16314

Merged
merged 5 commits into from
Nov 6, 2023
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.
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 @@ -622,6 +610,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 @@ -643,7 +632,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 @@ -926,7 +914,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 @@ -971,7 +958,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 @@ -79,6 +79,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 {}),
**kwargs,
)

return rpc_endpoint
Loading