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

[Bug] Cancelling 1 of 3 offers for the same NFT does not visually cancel all offers, nor does it update true status until offers expire #2563

Open
OverActiveBladderSystem opened this issue Dec 23, 2024 · 8 comments
Assignees
Labels
bug Something isn't working

Comments

@OverActiveBladderSystem

What happened?

In this example I created 3 expiring offers for the same NFT, each offer requesting a different asset type.

When cancelling 1 of 3 offers on blockchain, none of the offers showed up as "cancelled" in the GUI despite all 3 offers disappearing almost immediately on Dexie's website, only the offer we selected to cancel has changed its status in the GUI to "pending cancel" but remained in pending status until the offer time expired an hour later.

(The other two offers showed no status change in the GUI until each of them reached their expiration time individually)

Photo 1 shows the active offers waiting to be accepted or expire
Screenshot (10)

Photo 2 shows all the offers we made appear on Dexie
Screenshot (2498)

Photo 3 shows we attempt to cancel one of the offers on chain
Screenshot (11)

Photo 4 shows the "pending cancel" status of the offer we selected
Screenshot (12)

Photo 5 shows all the offers we made have been removed from Dexie
Screenshot (2499)

Photo 6 shows the "pending cancel" status remains after 30 minutes waiting
Screenshot (13)

Photo 7 shows the offers have "expired" only after waiting the entire 60 minutes
Screenshot (14)

Version

2.5.0

What platform are you using?

Windows

What ui mode are you using?

GUI

Relevant log output or stacktrace

No response

@OverActiveBladderSystem OverActiveBladderSystem added the bug Something isn't working label Dec 23, 2024
@Chia-Network Chia-Network deleted a comment Dec 24, 2024
Copy link
Contributor

github-actions bot commented Jan 7, 2025

'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.'

@ChiaMineJP
Copy link
Contributor

I tried to reproduce but in my testnet environment but I couldn't.
It's possible that your GUI client stopped syncing in some time and missed to catch the cancelling data from blockchain at the time.

Here is my recording which shows that my GUI client successfully cancelled an offer at almost the same time as Dexie.

Screen.Recording.2025-01-09.at.1.39.16.mov

@ChiaMineJP ChiaMineJP self-assigned this Jan 8, 2025
@wjblanke
Copy link
Contributor

wjblanke commented Jan 8, 2025

Izumi does the 3 offers at the same time matter? Thanks for looking into this!

@OverActiveBladderSystem
Copy link
Author

OverActiveBladderSystem commented Jan 9, 2025

Izumi does the 3 offers at the same time matter? Thanks for looking into this!

This may be it...

I retested with the same NFT, I first tried with a single offer, it worked as expected just as in the video above. (You can see the one cancelled offer in the photo below)

Next I tried with multiple offers that all showed up on Dexie. I cancel on chain 1 of 3 offers and its status changes to pending cancel, but it fails to actually show as cancelled despite all 3 offers being removed from Dexie. Now I wait for the timer to expire. (The log file indicates the cancel was accepted by the full node and eventually the wallet removes the old NFT coin and adds the new NFT coin, so the underlying system recognizes the cancel and receipt of the coin back)

Screenshot (2654)

After waiting for the timer to expire on 2 of the 3 offers, they show up as "expired" rather than the "cancelled" we expect.

Screenshot (2658)

The one offer still remains pending accept because I forgot to change the default expiration timer for the test, but it shows the on chain cancel does not visually get reflected despite the offers being cancelled and removed from Dexie.

So I decide to see what happens if I try to cancel that 7 day offer, its status does not change after trying to cancel it, I check the log file to see if anything happened within and see an error message, I assume because the wallet knows the offer has been cancelled and can no longer spend that coin to cancel it now?

Attached is a log showing the wallet recognizes the NFT coin change but does not reflect it in the GUI when 3 offers for the same asset exist, as well as the error received when trying to cancel the 7 day offer because that coin no longer exists.
three-offers-dont-cancel.txt

(edited)
I am adding an extended version of the log showing all the actions, the single offer being successful, and the 3 offers that failed to act as expected, just in case there is some additional information that may lead to discovering where the issue is.
three-offers-dont-cancel-extended-log-2.txt

@ChiaMineJP
Copy link
Contributor

@wjblanke @OverActiveBladderSystem
Sorry for missing the point. I'll search the root cause for this issue.

@ChiaMineJP
Copy link
Contributor

I managed to reproduce this issue and it seems complicated than expected.
Still searching for the root cause for now.

@ChiaMineJP
Copy link
Contributor

I've searched for trade_record table in wallet/db/blockchain_wallet_v2_xxx.sqlite and found that the statuses of relavant records match the GUI. (1 pending cancel trade record and 2 pending accept records)
So this is likely an issue of chia-blockchain, not chia-blockchain-gui.
I'll further look into the code.

@ChiaMineJP
Copy link
Contributor

ChiaMineJP commented Jan 12, 2025

I found that the primary issues are:

  1. Canceling an offer with a NFT in offering-side does not set PENDING_CANCEL status for trades which also offers the same NFT.
  • This is because current wallet implementation updates trade status by trade_id and not by coins being spent.
  1. Confirming cancellation does not set CANCELLED status to the trade records.
  • I understood the root cause. I'll desribe it in the following paragraph.

Why cancelling multiple NFT offers doesn't work

When confirming the offer cancellation, which means the offering NFT coin was spent but requesting coins were not created, trade_records wallet db table would be like:

trade_id status
offer1 PENDING_ACCEPT
offer2 PENDING_ACCEPT
offer3 PENDING_CANCEL

(This inconsistent statuses is caused by issue 1. above.)

Then look at the code below. This code is executed when monitoring coin state has been changed.
For example, the offering coin is spent to cancel.
https://github.com/Chia-Network/chia-blockchain/blob/2.5.0/chia/wallet/trade_manager.py#L154
image

The target trade whose status is expected to be set to CANCELLED is acquired by self.get_trade_by_coin(coin_state.coin).
This is the problem.
When this is executed, it gets offer1 in the above table.
offer1's status is PENDING_ACCEPT.
When offer is cancelled, its status must be PENDING_CANCEL according to
https://github.com/Chia-Network/chia-blockchain/blob/2.5.0/chia/wallet/trade_manager.py#L204
image

So the current implementation misses to recognize offer cancellation for NFT.
I'll prepare a PR to fix this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants