-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
fixNonFungibleTokensV1_2
: Multiple bug fixes for XLS-20 NFTs
#4417
Conversation
@ximinez @intelliot I noticed the
|
I don't think |
// After this amendment, if any payment would cause a non-IOU-issuer to | ||
// have a negative balance, or an IOU-issuer to have a positive balance in | ||
// their own currency, we know that something went wrong. This was | ||
// originally found in the context of IOU transfer fees. Since there are | ||
// several payouts in this tx, just confirm that the end state is OK. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: negative balances are not a problem. Trustlines are bi-directional, and the issuer might have configured the trustline so that you can go into debt. The problem is a balance that exceeds the limit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(@ledhed2222 wrote this comment here)
@ledhed2222 if it makes sense to you, could you clarify this comment? You can do so in a new PR, with feature/nft-fixes
as the base branch.
(or, you can push a commit on feature/nft-fixes
, if permissions allow. Either way is fine)
NonFungibleTokensV1_2
: Multiple bug fixes for XLS-20 NFTs
Just as a note, some of the the commit messages on this pull request do not follow guidelines we've been following for a long time. Here's the source of the guidelines we've followed in the past: https://cbea.ms/git-commit/ Specifically, we've requested that line lengths on commit messages be limited to 72 characters or so. We haven't always been great at enforcing that, but it has been a guideline. I understand that expectations change over time. So if unlimited line lengths is the new norm, then so be it. But I thought ya'll should be aware that it is a change. |
NonFungibleTokensV1_2
: Multiple bug fixes for XLS-20 NFTsfixNonFungibleTokensV1_2
: Multiple bug fixes for XLS-20 NFTs
Yeah I think this is something we should enforce before PR merge in the future. Since this existing feature branch going into develop, I think preserving the message to be easily referenced to its original PR might have some value, but we should enforce this char limit going forward |
It's a good guideline, but writing good (short) commit messages is extremely difficult, and I wouldn't hold up the release just for that. To take a specific example, how would you rewrite It is the worst offender and I would be in favor of shortening it with a simple rebase before merging it into |
First line is 68 characters long. (And I'd drop |
@intelliot, there are two guidelines I'm noticing:
You're noting a place where we broke the first of these guidelines. 50 characters is really hard. I tend to target 60 characters. For the case you pointer out I might suggest that we don't need all of those detail in the subject line. We can put additional details in the body:
These guidelines are hard. Even native English speaking programmers tend to not be great writers. Placing these constraints on non-native-English speakers is even harder. But the guidelines do help a great deal with the legibility of the log. |
To make it easier to navigate between the commit history and the relevant PRs, I'd like to include the PR # in the subject. Also, I believe putting the
(Unfortunately, that is now 75 characters.) I like @scottschurr 's suggestion, with the addition of the relevant issue/PR:
The issue/PR #s are helpful as they allow readers to easily find discussions and rationale related to the change. |
I'll do that cleanup to remove |
@kennyzlei Given you're rebasing anyway, and given that we would like to merge this PR as multiple commits (not a single squashed commit), feel free to rebase on top of the current HEAD of |
7fdd93e
to
05602af
Compare
@intelliot @scottschurr @ximinez just rebased and fixed up commit messages, ready for review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have not reviewed the code itself, but I confirmed that this is a feature branch whose individual commits were previously approved by trusted reviewers.
(Scott S is reviewing) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like what I'd expect.
48ec19d
to
2ec7471
Compare
* Allow offers to be removable * Delete sell offers first Signed-off-by: Shawn Xie <[email protected]>
Fixes 3 issues: In the following scenario, an account cannot perform NFTokenAcceptOffer even though it should be allowed to: - BROKER has < S - ALICE offers to sell token for S - BOB offers to buy token for > S - BROKER tries to bridge the two offers This currently results in `tecINSUFFICIENT_FUNDS`, but should not because BROKER is not spending any funds in this transaction, beyond the transaction fee. When trading an NFT using IOUs, and when the issuer of the IOU has any non-zero value set for TransferFee on their account via AccountSet (not a TransferFee on the NFT), and when the sale amount is equal to the total balance of that IOU that the buyer has, the resulting balance for the issuer of the IOU will become positive. This means that the buyer of the NFT was supposed to have caused a certain amount of IOU to be burned. That amount was unable to be burned because the buyer couldn't cover it. This results in the buyer owing this amount back to the issuer. In a real world scenario, this is appropriate and can be settled off-chain. Currency issuers could not make offers for NFTs using their own currency, receiving `tecINSUFFICIENT_FUNDS` if they tried to do so. With this fix, they are now able to buy/sell NFTs using their own currency.
Fixes #4374 It was possible for a broker to combine a sell and a buy offer from an account that already owns an NFT. Such brokering extracts money from the NFT owner and provides no benefit in return. With this amendment, the code detects when a broker is returning an NFToken to its initial owner and prohibits the transaction. This forbids a broker from selling an NFToken to the account that already owns the token. This fixes a bug in the original implementation of XLS-20. Thanks to @nixer89 for suggesting this fix.
…4399) Without this amendment, for NFTs using broker mode, if the sell offer contains a destination and that destination is the buyer account, anyone can broker the transaction. Also, if a buy offer contains a destination and that destination is the seller account, anyone can broker the transaction. This is not ideal and is misleading. Instead, with this amendment: If you set a destination, that destination needs to be the account settling the transaction. So, the broker must be the destination if they want to settle. If the buyer is the destination, then the buyer must accept the sell offer, as you cannot broker your own offers. If users want their offers open to the public, then they should not set a destination. On the other hand, if users want to limit who can settle the offers, then they would set a destination. Unit tests: 1. The broker cannot broker a destination offer to the buyer and the buyer must accept the sell offer. (0 transfer) 2. If the broker is the destination, the broker will take the difference. (broker mode)
2ec7471
to
ac78b7a
Compare
High Level Overview of Change
Proposal to merge feature branch
feature/nft-fixes
todevelop
branchContext of Change
Introduce a new amendment,
fixNonFungibleTokensV1_2
which is a combination of bug fixes that have been individually merged intofeature/nft-fixes
through the pull request process:NonFungibleTokensV1_2
amendment) #4346Each individual pull request contains details on the bugs they intend to fix
Type of Change