Merge pull request #208 from fuwa0529/fix-bp

Fix tx error on testnet2
This commit is contained in:
jw 2019-06-06 08:49:05 -07:00 committed by GitHub
commit 1b96834767
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 13 additions and 7 deletions

View File

@ -146,7 +146,7 @@ namespace cryptonote
if (!base_only) if (!base_only)
{ {
const bool bulletproof = rct::is_rct_bulletproof(rv.type); const bool bulletproof = rct::is_rct_bulletproof(rv.type);
if (bulletproof && rv.type == rct::RCTTypeBulletproof) if (rct::is_rct_new_bulletproof(rv.type))
{ {
if (rv.p.bulletproofs.size() != 1) if (rv.p.bulletproofs.size() != 1)
{ {
@ -415,7 +415,7 @@ namespace cryptonote
const size_t n_outputs = tx.vout.size(); const size_t n_outputs = tx.vout.size();
if (n_outputs <= 2) if (n_outputs <= 2)
return blob_size; return blob_size;
if (rv.type != rct::RCTTypeBulletproof) if (rct::is_rct_old_bulletproof(rv.type))
return blob_size; return blob_size;
const uint64_t bp_base = 368; const uint64_t bp_base = 368;
const size_t n_padded_outputs = rct::n_bulletproof_max_amounts(rv.p.bulletproofs); const size_t n_padded_outputs = rct::n_bulletproof_max_amounts(rv.p.bulletproofs);

View File

@ -808,7 +808,7 @@ namespace cryptonote
if (tx.version >= 2) if (tx.version >= 2)
{ {
rct::rctSig &rv = tx.rct_signatures; rct::rctSig &rv = tx.rct_signatures;
if (rv.type != rct::RCTTypeBulletproof){ if (!rct::is_rct_new_bulletproof(rv.type)){
if (rv.outPk.size() != tx.vout.size()) if (rv.outPk.size() != tx.vout.size())
{ {
LOG_PRINT_L1("WRONG TRANSACTION BLOB, Bad outPk size in tx " << tx_hash << ", rejected"); LOG_PRINT_L1("WRONG TRANSACTION BLOB, Bad outPk size in tx " << tx_hash << ", rejected");

View File

@ -1099,7 +1099,7 @@ namespace rct {
tools::threadpool::waiter waiter; tools::threadpool::waiter waiter;
std::deque<bool> results(bulletproof ? rv.p.bulletproofs.size() : rv.outPk.size(), false); std::deque<bool> results(bulletproof ? rv.p.bulletproofs.size() : rv.outPk.size(), false);
DP("range proofs verified?"); DP("range proofs verified?");
if (bulletproof && rv.type == RCTTypeBulletproof) if (rct::is_rct_new_bulletproof(rv.type))
{ {
for (size_t i = 0; i < rv.p.bulletproofs.size(); i++) for (size_t i = 0; i < rv.p.bulletproofs.size(); i++)
tpool.submit(&waiter, [&, i] { results[i] = verBulletproof(rv.p.bulletproofs[i]); }); tpool.submit(&waiter, [&, i] { results[i] = verBulletproof(rv.p.bulletproofs[i]); });
@ -1232,7 +1232,7 @@ namespace rct {
for (const rctSig *rvp: rvv) for (const rctSig *rvp: rvv)
{ {
const rctSig &rv = *rvp; const rctSig &rv = *rvp;
if (rv.type != RCTTypeBulletproof){ if (!rct::is_rct_new_bulletproof(rv.type)){
if (!proofs.empty() && !verBulletproof_old(proofs)) if (!proofs.empty() && !verBulletproof_old(proofs))
{ {
LOG_PRINT_L1("Aggregate range proof verified failed"); LOG_PRINT_L1("Aggregate range proof verified failed");

View File

@ -251,6 +251,11 @@ namespace rct {
} }
} }
bool is_rct_new_bulletproof(int type)
{
return is_rct_bulletproof(type) && !is_rct_old_bulletproof(type);
}
bool is_rct_borromean(int type) bool is_rct_borromean(int type)
{ {
switch (type) switch (type)

View File

@ -574,6 +574,7 @@ namespace rct {
bool is_rct_simple(int type); bool is_rct_simple(int type);
bool is_rct_bulletproof(int type); bool is_rct_bulletproof(int type);
bool is_rct_old_bulletproof(int type); bool is_rct_old_bulletproof(int type);
bool is_rct_new_bulletproof(int type);
bool is_rct_borromean(int type); bool is_rct_borromean(int type);
static inline const rct::key &pk2rct(const crypto::public_key &pk) { return (const rct::key&)pk; } static inline const rct::key &pk2rct(const crypto::public_key &pk) { return (const rct::key&)pk; }

View File

@ -9177,7 +9177,7 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_2(std::vector<cryp
const bool bulletproof = use_fork_rules(get_bulletproof_fork(), 0); const bool bulletproof = use_fork_rules(get_bulletproof_fork(), 0);
const rct::RCTConfig rct_config { const rct::RCTConfig rct_config {
bulletproof ? rct::RangeProofPaddedBulletproof : rct::RangeProofBorromean, bulletproof ? rct::RangeProofPaddedBulletproof : rct::RangeProofBorromean,
bulletproof ? (use_fork_rules(12, 0) ? 1 : 2) : 0 bulletproof ? (use_fork_rules(HF_VERSION_SMALLER_BP, -10) ? 2 : 1) : 0
}; };
const uint64_t base_fee = get_base_fee(); const uint64_t base_fee = get_base_fee();
@ -9826,7 +9826,7 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_from(const crypton
const bool bulletproof = use_fork_rules(get_bulletproof_fork(), 0); const bool bulletproof = use_fork_rules(get_bulletproof_fork(), 0);
const rct::RCTConfig rct_config { const rct::RCTConfig rct_config {
bulletproof ? rct::RangeProofPaddedBulletproof : rct::RangeProofBorromean, bulletproof ? rct::RangeProofPaddedBulletproof : rct::RangeProofBorromean,
bulletproof ? (use_fork_rules(12, 0) ? 1 : 2) : 0, bulletproof ? (use_fork_rules(HF_VERSION_SMALLER_BP, -10) ? 2 : 1) : 0
}; };
const uint64_t base_fee = get_base_fee(); const uint64_t base_fee = get_base_fee();
const uint64_t fee_multiplier = get_fee_multiplier(priority, get_fee_algorithm()); const uint64_t fee_multiplier = get_fee_multiplier(priority, get_fee_algorithm());