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

cryptonote_core: misc v17 consensus rules #9751

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/blockchain_utilities/blockchain_import.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,9 @@ int check_flush(cryptonote::core &core, std::vector<block_complete_entry> &block
for(auto& tx_blob: block_entry.txs)
{
tx_verification_context tvc = AUTO_VAL_INIT(tvc);
core.handle_incoming_tx(tx_blob, tvc, relay_method::block, true);
CHECK_AND_ASSERT_THROW_MES(tx_blob.prunable_hash == crypto::null_hash,
"block entry must not contain pruned txs");
core.handle_incoming_tx(tx_blob.blob, tvc, relay_method::block, true);
if(tvc.m_verifivation_failed)
{
cryptonote::transaction transaction;
Expand All @@ -189,8 +191,9 @@ int check_flush(cryptonote::core &core, std::vector<block_complete_entry> &block
// process block

block_verification_context bvc = {};
pool_supplement ps{};

core.handle_incoming_block(block_entry.block, pblocks.empty() ? NULL : &pblocks[blockidx++], bvc, false); // <--- process block
core.handle_incoming_block(block_entry.block, pblocks.empty() ? NULL : &pblocks[blockidx++], bvc, ps, false); // <--- process block

if(bvc.m_verifivation_failed)
{
Expand Down
14 changes: 14 additions & 0 deletions src/cryptonote_basic/cryptonote_format_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ namespace cryptonote
CHECK_AND_ASSERT_MES(r, false, "Failed to parse transaction from blob");
CHECK_AND_ASSERT_MES(expand_transaction_1(tx, false), false, "Failed to expand transaction data");
tx.invalidate_hashes();
tx.set_blob_size(tx_blob.size());
//TODO: validate tx

return get_transaction_hash(tx, tx_hash);
Expand Down Expand Up @@ -497,6 +498,19 @@ namespace cryptonote
return get_transaction_weight(tx, blob_size);
}
//---------------------------------------------------------------
uint64_t get_transaction_blob_size(const transaction& tx)
{
if (!tx.is_blob_size_valid())
{
const cryptonote::blobdata tx_blob = tx_to_blob(tx);
tx.set_blob_size(tx_blob.size());
}

CHECK_AND_ASSERT_THROW_MES(tx.is_blob_size_valid(), "BUG: blob size valid not set");

return tx.blob_size;
}
//---------------------------------------------------------------
bool get_tx_fee(const transaction& tx, uint64_t & fee)
{
if (tx.version > 1)
Expand Down
1 change: 1 addition & 0 deletions src/cryptonote_basic/cryptonote_format_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ namespace cryptonote
uint64_t get_transaction_weight(const transaction &tx);
uint64_t get_transaction_weight(const transaction &tx, size_t blob_size);
uint64_t get_pruned_transaction_weight(const transaction &tx);
uint64_t get_transaction_blob_size(const transaction& tx);

bool check_money_overflow(const transaction& tx);
bool check_outs_overflow(const transaction& tx);
Expand Down
3 changes: 2 additions & 1 deletion src/cryptonote_basic/verification_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ namespace cryptonote
bool m_marked_as_orphaned;
bool m_already_exists;
bool m_partial_block_reward;
bool m_bad_pow; // if bad pow, bad peer outright for DoS protection
bool m_bad_pow; // if bad pow, ban peer outright for DoS protection
bool m_missing_txs; // set if, during verif, we don't have all the necessary txs available
};
}
4 changes: 4 additions & 0 deletions src/cryptonote_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@
#define HF_VERSION_BULLETPROOF_PLUS 15
#define HF_VERSION_VIEW_TAGS 15
#define HF_VERSION_2021_SCALING 15
#define HF_VERSION_FCMP 17
#define HF_VERSION_REJECT_UNLOCK_TIME 17
#define HF_VERSION_REJECT_LARGE_EXTRA 17
#define HF_VERSION_REJECT_UNMIXABLE_V1 17

#define PER_KB_FEE_QUANTIZATION_DECIMALS 8
#define CRYPTONOTE_SCALING_2021_FEE_ROUNDING_PLACES 2
Expand Down
Loading
Loading