mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-11-23 19:33:28 +01:00
Merge pull request #8784
5900ed3
Add a size limit for tx_extra in tx pool (tevador)
This commit is contained in:
commit
225e5ba571
@ -53,6 +53,7 @@ namespace cryptonote
|
|||||||
bool m_overspend;
|
bool m_overspend;
|
||||||
bool m_fee_too_low;
|
bool m_fee_too_low;
|
||||||
bool m_too_few_outputs;
|
bool m_too_few_outputs;
|
||||||
|
bool m_tx_extra_too_big;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct block_verification_context
|
struct block_verification_context
|
||||||
|
@ -206,6 +206,11 @@
|
|||||||
|
|
||||||
#define DNS_BLOCKLIST_LIFETIME (86400 * 8)
|
#define DNS_BLOCKLIST_LIFETIME (86400 * 8)
|
||||||
|
|
||||||
|
//The limit is enough for the mandatory transaction content with 16 outputs (547 bytes),
|
||||||
|
//a custom tag (1 byte) and up to 32 bytes of custom data for each recipient.
|
||||||
|
// (1+32) + (1+1+16*32) + (1+16*32) = 1060
|
||||||
|
#define MAX_TX_EXTRA_SIZE 1060
|
||||||
|
|
||||||
// New constants are intended to go here
|
// New constants are intended to go here
|
||||||
namespace config
|
namespace config
|
||||||
{
|
{
|
||||||
|
@ -437,6 +437,8 @@ namespace cryptonote
|
|||||||
if (!sort_tx_extra(tx.extra, tx.extra))
|
if (!sort_tx_extra(tx.extra, tx.extra))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
CHECK_AND_ASSERT_MES(tx.extra.size() <= MAX_TX_EXTRA_SIZE, false, "TX extra size (" << tx.extra.size() << ") is greater than max allowed (" << MAX_TX_EXTRA_SIZE << ")");
|
||||||
|
|
||||||
//check money
|
//check money
|
||||||
if(summary_outs_money > summary_inputs_money )
|
if(summary_outs_money > summary_inputs_money )
|
||||||
{
|
{
|
||||||
|
@ -219,6 +219,15 @@ namespace cryptonote
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t tx_extra_size = tx.extra.size();
|
||||||
|
if (!kept_by_block && tx_extra_size > MAX_TX_EXTRA_SIZE)
|
||||||
|
{
|
||||||
|
LOG_PRINT_L1("transaction tx-extra is too big: " << tx_extra_size << " bytes, the limit is: " << MAX_TX_EXTRA_SIZE);
|
||||||
|
tvc.m_verifivation_failed = true;
|
||||||
|
tvc.m_tx_extra_too_big = true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// if the transaction came from a block popped from the chain,
|
// if the transaction came from a block popped from the chain,
|
||||||
// don't check if we have its key images as spent.
|
// don't check if we have its key images as spent.
|
||||||
// TODO: Investigate why not?
|
// TODO: Investigate why not?
|
||||||
|
@ -1275,6 +1275,8 @@ namespace cryptonote
|
|||||||
add_reason(reason, "fee too low");
|
add_reason(reason, "fee too low");
|
||||||
if ((res.too_few_outputs = tvc.m_too_few_outputs))
|
if ((res.too_few_outputs = tvc.m_too_few_outputs))
|
||||||
add_reason(reason, "too few outputs");
|
add_reason(reason, "too few outputs");
|
||||||
|
if ((res.tx_extra_too_big = tvc.m_tx_extra_too_big))
|
||||||
|
add_reason(reason, "tx-extra too big");
|
||||||
const std::string punctuation = reason.empty() ? "" : ": ";
|
const std::string punctuation = reason.empty() ? "" : ": ";
|
||||||
if (tvc.m_verifivation_failed)
|
if (tvc.m_verifivation_failed)
|
||||||
{
|
{
|
||||||
|
@ -88,7 +88,7 @@ namespace cryptonote
|
|||||||
// advance which version they will stop working with
|
// advance which version they will stop working with
|
||||||
// Don't go over 32767 for any of these
|
// Don't go over 32767 for any of these
|
||||||
#define CORE_RPC_VERSION_MAJOR 3
|
#define CORE_RPC_VERSION_MAJOR 3
|
||||||
#define CORE_RPC_VERSION_MINOR 11
|
#define CORE_RPC_VERSION_MINOR 12
|
||||||
#define MAKE_CORE_RPC_VERSION(major,minor) (((major)<<16)|(minor))
|
#define MAKE_CORE_RPC_VERSION(major,minor) (((major)<<16)|(minor))
|
||||||
#define CORE_RPC_VERSION MAKE_CORE_RPC_VERSION(CORE_RPC_VERSION_MAJOR, CORE_RPC_VERSION_MINOR)
|
#define CORE_RPC_VERSION MAKE_CORE_RPC_VERSION(CORE_RPC_VERSION_MAJOR, CORE_RPC_VERSION_MINOR)
|
||||||
|
|
||||||
@ -592,6 +592,7 @@ namespace cryptonote
|
|||||||
bool fee_too_low;
|
bool fee_too_low;
|
||||||
bool too_few_outputs;
|
bool too_few_outputs;
|
||||||
bool sanity_check_failed;
|
bool sanity_check_failed;
|
||||||
|
bool tx_extra_too_big;
|
||||||
|
|
||||||
BEGIN_KV_SERIALIZE_MAP()
|
BEGIN_KV_SERIALIZE_MAP()
|
||||||
KV_SERIALIZE_PARENT(rpc_access_response_base)
|
KV_SERIALIZE_PARENT(rpc_access_response_base)
|
||||||
@ -606,6 +607,7 @@ namespace cryptonote
|
|||||||
KV_SERIALIZE(fee_too_low)
|
KV_SERIALIZE(fee_too_low)
|
||||||
KV_SERIALIZE(too_few_outputs)
|
KV_SERIALIZE(too_few_outputs)
|
||||||
KV_SERIALIZE(sanity_check_failed)
|
KV_SERIALIZE(sanity_check_failed)
|
||||||
|
KV_SERIALIZE(tx_extra_too_big)
|
||||||
END_KV_SERIALIZE_MAP()
|
END_KV_SERIALIZE_MAP()
|
||||||
};
|
};
|
||||||
typedef epee::misc_utils::struct_init<response_t> response;
|
typedef epee::misc_utils::struct_init<response_t> response;
|
||||||
|
Loading…
Reference in New Issue
Block a user