Chia-Network / chia-blockchain

Chia blockchain python implementation (full node, farmer, harvester, timelord, and wallet)
Apache License 2.0
10.83k stars 2.02k forks source link

[BUG] Unable to claim SELF_POOLING rewards if coins are sent with diff puzzle hash #7427

Closed wallentx closed 3 years ago

wallentx commented 3 years ago

I am solo farming, but I wanted to go ahead and start making pool-compatible plots. I made a plotnft, and started making plots (madmax) using the contract address from chia plotnft show.

Rather than wait weeks (months?) to win a block SELF_POOLING, only to find that I have no idea how to retrieve it, I decided to send some mojo to my plotnft wallet via a faucet, and test out the chia plotnft claim process.

See transactions here: https://www.chiaexplorer.com/blockchain/address/xch1wt3gthn43yy52d635ke7nv2rmcm048c3lntkxx27y70sqy5rz62qf8qmj3

chia plotnft show Wallet height: 562287 Sync status: Synced Wallet id 2: Current state: SELF_POOLING Current state from block height: 547731 Launcher ID: REDACTED Target address (not for plotting): BLAH Owner public key: BLAH P2 singleton address (pool contract address for plotting): xch1wt3gthn43yy52d635ke7nv2rmcm048c3lntkxx27y70sqy5rz62qf8qmj3 Claimable balance: 6.00212e-07 xch (600212 mojo)

Attempting to do a claim on this presents me with an error:

chia plotnft claim -i 2 Will claim rewards for wallet ID: 2. Error performing operation on Plot NFT -f wallet id: 2: {'error': "{'amount': 500000,\n 'parent_coin_info': '0xb9',\n 'puzzle_hash': '0x72'}", 'success': False}

from debug.log:

2021-07-12T16:20:44.685 wallet chia.rpc.rpc_server : WARNING Error while handling message: Traceback (most recent call last): File "/chia-blockchain/chia/rpc/rpc_server.py", line 81, in inner res_object = await f(request_data) File "/chia-blockchain/chia/rpc/wallet_rpc_api.py", line 1227, in pw_absorb_rewards transaction: TransactionRecord = await wallet.claim_pool_rewards(fee) File "/chia-blockchain/chia/pools/pool_wallet.py", line 761, in claim_pool_rewards coin_to_height_farmed[coin_record.coin] KeyError: Coin(parent_coin_info=<bytes32: 2e9f-BLAH->, puzzle_hash=<bytes32: 72e2-BLAH->, amount=100

Hat tip to @cameroncooper for this:

It appears that the coin sent via faucet the uses a different puzzle than claim is using to spend pool rewards. Starting here: https://github.com/Chia-Network/chia-blockchain/blob/efd401ee35cff76c7fc4d6779c68f72f24fc0217/chia/cmds/plotnft_funcs.py#L330 calls absorb rewards: https://github.com/Chia-Network/chia-blockchain/blob/efd401ee35cff76c7fc4d6779c68f72f24fc0217/chia/rpc/wallet_rpc_api.py#L1217 tries to create a transaction: https://github.com/Chia-Network/chia-blockchain/blob/efd401ee35cff76c7fc4d6779c68f72f24fc0217/chia/pools/pool_wallet.py#L724 and here's the money shot: https://github.com/Chia-Network/chia-blockchain/blob/efd401ee35cff76c7fc4d6779c68f72f24fc0217/chia/pools/pool_puzzles.py#L219

This behavior seems to be the same as https://github.com/Chia-Network/chia-blockchain/issues/7299

If the ability to anonymously send funds from a faucet to a plotnft contract address results in a corrupted pool wallet, I only request that we please nickname this problem #dripgate

emlowe commented 3 years ago

Thanks for this interesting bug report. This doesn't create any permanent corruption of the pool wallet. Chia sent directly to the P2 address are not claimable and ideally shouldn't be shown in the wallet at all. In testing with testnet, the current wallet code will return an error if you have "real" claimable rewards in your pool wallet in this case where you have a mix of claimable and non-claimable (T)XCH. However, this will be fixed in a future release of the wallet such that all truly claimable rewards are claimable while ignoring any other chia in the pooling wallet. Note we plan to make some further fixes to make it harder to get into this state (eg, we will prevent you from sending chia to your own P2 address).

aqk commented 3 years ago

Hey there, just wanted to update about this issue.

The details are complex, but the crux of the matter is that sending money to that address will not work for claiming, unless that coin was a pool reward.

We have several changes in progress to address this. Some involve changing the user interface, and some have to do with claiming. I'll update this issue as we ready PRs for release.

Thank you.

18506711722 commented 3 years ago

If I could, I would like to my xch(Wallet transfer to poolntf).https://github.com/Chia-Network/chia-blockchain/issues/7299

github-actions[bot] commented 3 years ago

This issue has been flagged as stale as there has been no activity on it in 14 days. If this issue is still affecting you and in need of review, please update it to keep it open.

mladentripalo commented 3 years ago

had exactly same problem, after finding proof (on mainnet) i was unable to claim 1.75 part of reward. I have 3 wallets, 2 old ones and one new used for plotNFT. This is how it looked when i entered claim reward...

(venv) kiz@farmer:~$ chia plotnft claim -i 3 Choose wallet key: 1) 3425..... 2) 2296...... 3) 8643...... Enter a number to pick or q to quit: 3

Will claim rewards for wallet ID: 3. Error performing operation on Plot NFT -f 8643....... wallet id: 3: {'error': '3', 'success': False}

other problem is badly written help for "chia plotnft claim -h" ... it doessnt say anywhere that you need to actually provide two wallets... source and destination. Moreover, the -i parameter is ZERO BASED index, while choice given is obviously not zero based. I was at the end, after many tries and frustrations, been able to claim it by changing -i3 to -i2 and using fingerprint of third wallet.

devs should sort this out for ppl who have multiple wallets, and fix -h help please!

emlowe commented 3 years ago

This issue as written was resolved in version 1.2.3