-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
cryptonote_core: tx verif util to collect transp amt commitments #11088
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
Open
j-berman
wants to merge
1
commit into
monero-project:master
Choose a base branch
from
j-berman:transp-amt-coms
base: master
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.
Open
Changes from all commits
Commits
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
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -42,6 +42,28 @@ | |
|
|
||
| using namespace cryptonote; | ||
|
|
||
| static void collect_transparent_amount_commitments_static( | ||
| const std::vector<std::reference_wrapper<const transaction>> &tx_refs, | ||
| std::unordered_map<uint64_t, rct::key> &transparent_amount_commitments_inout) | ||
| { | ||
| // Note: we do not clear transparent_amount_commitments_inout because it may be a rolling cache | ||
|
|
||
| for (const std::reference_wrapper<const transaction> &tx_ref : tx_refs) | ||
| { | ||
| const transaction &tx = tx_ref.get(); | ||
|
|
||
| // We only need commitments for transparent amounts, which are tx version 1 || coinbase txs | ||
| if (tx.version > 1 && !cryptonote::is_coinbase(tx)) | ||
| continue; | ||
| for (const auto &tx_out : tx.vout) | ||
| { | ||
| const uint64_t amount = tx_out.amount; | ||
| if (transparent_amount_commitments_inout.find(amount) == transparent_amount_commitments_inout.end()) | ||
| transparent_amount_commitments_inout[amount] = rct::zeroCommitVartime(amount); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // Do RCT expansion, then do post-expansion sanity checks, then do full non-semantics verification. | ||
| static bool expand_tx_and_ver_rct_non_sem(transaction& tx, const rct::ctkeyM& mix_ring) | ||
| { | ||
|
|
@@ -315,6 +337,46 @@ static bool ver_non_input_consensus_templated(TxForwardIt tx_begin, TxForwardIt | |
| namespace cryptonote | ||
| { | ||
|
|
||
| std::vector<std::reference_wrapper<const transaction>> collect_transparent_amount_commitments( | ||
| const transaction &miner_tx, | ||
| const std::vector<std::pair<transaction, blobdata>> &tx_pairs, | ||
| std::unordered_map<uint64_t, rct::key> &transparent_amount_commitments_inout) | ||
| { | ||
| std::vector<std::reference_wrapper<const transaction>> tx_refs; | ||
| tx_refs.reserve(1 + tx_pairs.size()); | ||
| tx_refs.push_back(std::cref(miner_tx)); | ||
| for (const auto &tx : tx_pairs) | ||
| tx_refs.push_back(std::cref(tx.first)); | ||
| collect_transparent_amount_commitments_static(tx_refs, transparent_amount_commitments_inout); | ||
| return tx_refs; | ||
| } | ||
|
|
||
| std::vector<std::reference_wrapper<const transaction>> collect_transparent_amount_commitments( | ||
| const transaction &miner_tx, | ||
| const std::vector<transaction> &txs, | ||
| std::unordered_map<uint64_t, rct::key> &transparent_amount_commitments_inout) | ||
|
Comment on lines
+354
to
+357
Collaborator
Author
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. |
||
| { | ||
| std::vector<std::reference_wrapper<const transaction>> tx_refs; | ||
| tx_refs.reserve(1 + txs.size()); | ||
| tx_refs.push_back(std::cref(miner_tx)); | ||
| for (const auto &tx : txs) | ||
| tx_refs.push_back(std::cref(tx)); | ||
| collect_transparent_amount_commitments_static(tx_refs, transparent_amount_commitments_inout); | ||
| return tx_refs; | ||
| } | ||
|
|
||
| std::vector<std::reference_wrapper<const transaction>> collect_transparent_amount_commitments( | ||
| const std::unordered_map<crypto::hash, std::pair<transaction, blobdata>> &txs_by_txid, | ||
| std::unordered_map<uint64_t, rct::key> &transparent_amount_commitments_inout) | ||
|
Comment on lines
+368
to
+370
Collaborator
Author
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. |
||
| { | ||
| std::vector<std::reference_wrapper<const transaction>> tx_refs; | ||
| tx_refs.reserve(txs_by_txid.size()); | ||
| for (const auto &tx_pair : txs_by_txid) | ||
| tx_refs.push_back(std::cref(tx_pair.second.first)); | ||
| collect_transparent_amount_commitments_static(tx_refs, transparent_amount_commitments_inout); | ||
| return tx_refs; | ||
| } | ||
|
|
||
| uint64_t get_transaction_weight_limit(const uint8_t hf_version) | ||
| { | ||
| // from v8, limit a tx to 50% of the minimum block weight | ||
|
|
||
This file contains hidden or 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
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.
Sample caller: https://github.com/seraphis-migration/monero/blob/3f159b13e000ca9f0906599c9c5fd9c13f55233c/src/cryptonote_core/blockchain.cpp#L4858-L4859