-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
feat: Versionable CompressedCoin #1628
Merged
Merged
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift click to select a range
27026d2
Versionable CompressedCoin
bvrooman b3b0990
Merge branch 'master' into bvrooman/feat/versionable-compressed-coin
db1cfd8
Update CHANGELOG.md
bvrooman e918e74
Merge branch 'bvrooman/feat/versionable-compressed-coin' of https://g…
bvrooman 721db43
Impl default only in test
bvrooman e27aa8a
Merge branch 'master' into bvrooman/feat/versionable-compressed-coin
bvrooman 2968ae0
Use explicit v1 over default
bvrooman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
Versionable CompressedCoin
- Loading branch information
commit 27026d2833251562835c57f365404b0929fd7705
There are no files selected for viewing
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1007,9 1007,9 @@ where | |
| Input::CoinPredicate(CoinPredicate { utxo_id, .. }) => { | ||
if let Some(coin) = db.storage::<Coins>().get(utxo_id)? { | ||
let coin_mature_height = coin | ||
.tx_pointer | ||
.tx_pointer() | ||
.block_height() | ||
.saturating_add(*coin.maturity) | ||
.saturating_add(**coin.maturity()) | ||
.into(); | ||
if block_height < coin_mature_height { | ||
return Err(TransactionValidityError::CoinHasNotMatured( | ||
|
@@ -1192,7 1192,7 @@ where | |
db, *utxo_id, *owner, *amount, *asset_id, *maturity, | ||
options, | ||
)?; | ||
*tx_pointer = coin.tx_pointer; | ||
*tx_pointer = *coin.tx_pointer(); | ||
} | ||
Input::Contract(Contract { | ||
ref mut utxo_id, | ||
|
@@ -1240,7 1240,7 @@ where | |
db, *utxo_id, *owner, *amount, *asset_id, *maturity, | ||
options, | ||
)?; | ||
if tx_pointer != &coin.tx_pointer { | ||
if tx_pointer != coin.tx_pointer() { | ||
return Err(ExecutorError::InvalidTransactionOutcome { | ||
transaction_id: tx_id, | ||
}) | ||
|
@@ -1371,13 1371,12 @@ where | |
.map(Cow::into_owned) | ||
} else { | ||
// if utxo validation is disabled, just assign this new input to the original block | ||
Ok(CompressedCoin { | ||
owner, | ||
amount, | ||
asset_id, | ||
maturity, | ||
tx_pointer: Default::default(), | ||
}) | ||
let mut coin = CompressedCoin::default(); | ||
coin.set_owner(owner); | ||
coin.set_amount(amount); | ||
coin.set_asset_id(asset_id); | ||
coin.set_maturity(maturity); | ||
Ok(coin) | ||
} | ||
} | ||
|
||
|
@@ -1508,13 1507,12 @@ where | |
// This is because variable or transfer outputs won't have any value | ||
// if there's a revert or panic and shouldn't be added to the utxo set. | ||
if *amount > Word::MIN { | ||
let coin = CompressedCoin { | ||
owner: *to, | ||
amount: *amount, | ||
asset_id: *asset_id, | ||
maturity: 0u32.into(), | ||
tx_pointer: TxPointer::new(block_height, tx_idx), | ||
}; | ||
let mut coin = CompressedCoin::default(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oops, missed this! |
||
coin.set_owner(*to); | ||
coin.set_amount(*amount); | ||
coin.set_asset_id(*asset_id); | ||
coin.set_maturity(0u32.into()); | ||
coin.set_tx_pointer(TxPointer::new(block_height, tx_idx)); | ||
|
||
if db.storage::<Coins>().insert(&utxo_id, &coin)?.is_some() { | ||
return Err(ExecutorError::OutputAlreadyExists) | ||
|
Oops, something went wrong.
Oops, something went wrong.
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.
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.
Here we also want to use
V1
explicitly