Chia-Network / pool-reference

Reference python implementation of Chia pool operations for pool operators
Apache License 2.0
439 stars 197 forks source link

Odd bug collecting pool reward #265

Closed tommy4111 closed 2 years ago

tommy4111 commented 2 years ago

I'm trying to debug an odd behavior in collect_pool_rewards_loop() where once node height reaches the confirmation_security_threshold, get_coin_records_by_puzzle_hashes() can't find any coin_records.

Note, on testnet, everything works fine. On mainnet it's reproducible:

coin_records: List[CoinRecord] = await self.node_rpc_client.get_coin_records_by_puzzle_hashes(
    scan_phs,
    include_spent_coins=False,
    start_height=self.scan_start_height,
)
self.log.info(
    f"Scanning for block rewards from {self.scan_start_height} to {peak_height}. "
    f"Found: {len(coin_records)}"
)

Blocks found at 1404718, and finds nothing by the time we wait for 32 confirmations from 1125582 to 1404750. Logs: 2022-01-10 15:45:24 | Scanning for block rewards from 1125582 to 1404742. Found: 1 2022-01-10 15:46:24 | Scanning for block rewards from 1125582 to 1404744. Found: 1 2022-01-10 15:47:24 | Scanning for block rewards from 1125582 to 1404746. Found: 1 2022-01-10 15:48:24 | Scanning for block rewards from 1125582 to 1404750. Found: 0 2022-01-10 15:49:24 | Scanning for block rewards from 1125582 to 1404756. Found: 0 2022-01-10 15:50:24 | Scanning for block rewards from 1125582 to 1404758. Found: 0 2022-01-10 15:51:24 | Scanning for block rewards from 1125582 to 1404761. Found: 0

So since we can't find any coin_records, it skips over absorbing the coin. The pool's wallet do see the coins:

{'confirmed_wallet_balance': 3500000000000, 'max_send_amount': 3500000000000, 'pending_change': 0, 'pending_coin_removal_count': 0, 'spendable_balance': 3500000000000, 'unconfirmed_wallet_balance': 3500000000000, 'unspent_coin_count': 3, 'wallet_id': 1}

Thanks

FazendaPool commented 2 years ago

this behaviour is explained by include_spent_coins=False, as soon as the coin is spent you can no longer find it.

tommy4111 commented 2 years ago

include_spent_coins

Right, I just don't see where it is spent.

mariano54 commented 2 years ago

This is not a bug. The coin is being spent by someone. Either the user is spending it or you have 2 pools running.