-
Notifications
You must be signed in to change notification settings - Fork 647
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
Use special container type for token balances #2074
Open
pmconrad
wants to merge
59
commits into
bitshares:develop
Choose a base branch
from
pmconrad:asset_amount
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pmconrad
added
2d Developing
Status indicating currently designing and developing a solution
3c Enhancement
Classification indicating a change to the functionality of the existing imlementation
5a Docs Needed
Status specific to Documentation indicating the need for proper documentation to be added
6 API
Impact flag identifying the application programing interface (API)
labels
Dec 4, 2019
API incompatibilities are (mostly) resolved, tests working, replay working (up to 37M blocks anyway). |
abitmore
reviewed
Dec 28, 2019
// BitShares mainnet has a negative genesis balance of 250M BTS. It stems from the BitShares-1 | ||
// snapshot, and was created in BitShares-1 by someone exploiting an overflow bug. | ||
// This means that there are 250M more BTS in existence than was previously assumed. The -250M BTS | ||
// are added to the total supply colculation, i. e. the total supply is 250M higher than indicated |
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.
Typo colculation
.
abitmore
modified the milestones:
5.0.0 - Protocol Upgrade Release,
5.1.0 - Feature Release
Sep 13, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
2d Developing
Status indicating currently designing and developing a solution
3c Enhancement
Classification indicating a change to the functionality of the existing imlementation
5a Docs Needed
Status specific to Documentation indicating the need for proper documentation to be added
6 API
Impact flag identifying the application programing interface (API)
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR implements an idea originally mentioned by @nathanhourt . His observation was that we use the
asset
type for two fundamentally different concepts, which is inherently dangerous.A real-world analogy for the asset type could be, for example, a slip of paper reading "$ 1.00". The two fundamentally different concepts that match this type are, for example, a price tag in a supermarket on the one hand, and a bank note on the other. The important difference is that the bank note carries value, whereas the price tag only carries information. A consequence of this is, for example, that it is not possible to copy a bank note (or at least strictly forbidden), whereas it is perfectly ok to copy the price tag.
So, in order to model an equivalent for the "bank note" concept, this PR creates a new type
stored_value
. It employs RAII concepts, in the sense that it can only be moved around, not copied.On top of that, this PR implements a simple bookkeeping concept: account balances cannot be created from nothing, nor can they be destroyed into nothing. Every creation or destruction of a balance must have a counterpart in another account. For this, a
stored_debt
type is introduced. Every token balance is issued by astored_debt
, and only astored_debt
can destroy (aka burn) balances. Instances ofstored_debt
andstored_value
can only be destructed successfully if their contained amount is zero. This should ensure that no tokens are lost, and none can be created from nothing, as happened e. g. in #429.Unfortunately, the beauty of the general concept is somewhat undermined by the way in which our database transaction system works. I. e.
undo_db
copies objects, and restores them upon rollback, by copying back the original value. Similarly, things are complicated by API calls returning copies of internal database objects.This PR affects some API changes, i. e. the structure of certain database objects has changed slightly.