From b88d77aec5e7bef5305a668d15031351c0548b4d Mon Sep 17 00:00:00 2001 From: glozow Date: Thu, 11 Feb 2021 09:50:42 -0800 Subject: [policy] Define packages Define the Package type as an alias for a vector of transactions for now. Add PackageValidationResult, similar to TxValidationResult and BlockValidationResult for package-wide errors that cannot be reported within a single transaction result, such as having too many transactions in the package. We can update the concept of what a package is and have different logic for packages vs lists of transactions in the future, e.g. for package relay. --- src/policy/packages.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/policy/packages.h (limited to 'src/policy') diff --git a/src/policy/packages.h b/src/policy/packages.h new file mode 100644 index 0000000000..60aafb6d74 --- /dev/null +++ b/src/policy/packages.h @@ -0,0 +1,29 @@ +// Copyright (c) 2021 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_POLICY_PACKAGES_H +#define BITCOIN_POLICY_PACKAGES_H + +#include +#include + +#include + +/** A "reason" why a package was invalid. It may be that one or more of the included + * transactions is invalid or the package itself violates our rules. + * We don't distinguish between consensus and policy violations right now. + */ +enum class PackageValidationResult { + PCKG_RESULT_UNSET = 0, //!< Initial value. The package has not yet been rejected. + PCKG_POLICY, //!< The package itself is invalid (e.g. too many transactions). + PCKG_TX, //!< At least one tx is invalid. +}; + +/** A package is an ordered list of transactions. The transactions cannot conflict with (spend the + * same inputs as) one another. */ +using Package = std::vector; + +class PackageValidationState : public ValidationState {}; + +#endif // BITCOIN_POLICY_PACKAGES_H -- cgit v1.2.3 From ae8e6df709ff3d52b8e9918e09cacb64f83ae379 Mon Sep 17 00:00:00 2001 From: glozow Date: Mon, 5 Apr 2021 11:13:27 -0700 Subject: [policy] limit package sizes Maximum number of transactions allowed in a package is 25, equal to the default mempool descendant limit: if a package has more transactions than this, either it would fail default mempool descendant limit or the transactions don't all have a dependency relationship (but then they shouldn't be in a package together). Same rationale for 101KvB virtual size package limit. Note that these policies are only used in test accepts so far. --- src/policy/packages.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/policy') diff --git a/src/policy/packages.h b/src/policy/packages.h index 60aafb6d74..4b1463dcb3 100644 --- a/src/policy/packages.h +++ b/src/policy/packages.h @@ -10,6 +10,11 @@ #include +/** Default maximum number of transactions in a package. */ +static constexpr uint32_t MAX_PACKAGE_COUNT{25}; +/** Default maximum total virtual size of transactions in a package in KvB. */ +static constexpr uint32_t MAX_PACKAGE_SIZE{101}; + /** A "reason" why a package was invalid. It may be that one or more of the included * transactions is invalid or the package itself violates our rules. * We don't distinguish between consensus and policy violations right now. -- cgit v1.2.3