Skip to content
GitLab
About GitLab
GitLab: the DevOps platform
Explore GitLab
Install GitLab
How GitLab compares
Get started
GitLab docs
GitLab Learn
Pricing
Talk to an expert
Help
What's new
4
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Menu
Projects
Groups
Snippets
Sign up now
Login
Sign in / Register
Toggle navigation
Menu
Open sidebar
Flowee
thehub
Commits
45dd785f
Commit
45dd785f
authored
Mar 13, 2021
by
Tom Zander
Browse files
Follow whole-script sizelimit.
Also add unit test for the op_return limits.
parent
a9d3c2ee
Pipeline
#269987458
passed with stages
in 19 minutes and 3 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
libs/server/policy/policy.cpp
View file @
45dd785f
...
...
@@ -70,7 +70,7 @@ bool IsStandard(const CScript &scriptPubKey, Script::TxnOutType &whichType, int
}
else
if
(
whichType
==
Script
::
TX_NULL_DATA
)
{
if
(
!
fAcceptDatacarrier
)
return
false
;
dataUsed
+=
scriptPubKey
.
size
()
-
3
;
// (-1 for OP_RETURN, -2 for the pushdata opcodes)
dataUsed
+=
scriptPubKey
.
size
()
;
}
return
whichType
!=
Script
::
TX_NONSTANDARD
;
...
...
libs/utils/SettingsDefaults.h
View file @
45dd785f
...
...
@@ -34,7 +34,7 @@ constexpr uint32_t DefaultCheckLevel = 3;
constexpr
int32_t
DefaultBlockAcceptSize
=
128000000
;
constexpr
bool
DefaultAcceptDataCarrier
=
true
;
constexpr
int
MaxOpReturnRelay
=
22
0
;
//! bytes
constexpr
int
MaxOpReturnRelay
=
22
3
;
constexpr
bool
DefaultRelayPriority
=
true
;
/** Default for setting that we download and accept blocks only (no transactions, no mempool) */
...
...
testing/bitcoin-protocol/transaction_tests.cpp
View file @
45dd785f
...
...
@@ -334,14 +334,34 @@ void TransactionTests::test_IsStandard()
t
.
vout
[
0
].
scriptPubKey
=
CScript
()
<<
OP_RETURN
<<
ParseHex
(
"04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef3804678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38"
"0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
);
QCOMPARE
(
Settings
::
MaxOpReturnRelay
+
3
,
t
.
vout
[
0
].
scriptPubKey
.
size
());
QCOMPARE
(
Settings
::
MaxOpReturnRelay
,
t
.
vout
[
0
].
scriptPubKey
.
size
());
QVERIFY
(
IsStandardTx
(
t
,
reason
));
// Multiple op-returns.
t
.
vout
.
push_back
(
t
.
vout
.
at
(
0
));
t
.
vout
[
0
].
scriptPubKey
=
CScript
()
<<
OP_RETURN
// 58 + 2 bytes
<<
ParseHex
(
"04678afdb0fe55482719bc3f4cef3804678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38123456"
);
t
.
vout
[
1
].
scriptPubKey
=
CScript
()
<<
OP_RETURN
// 103 + 3 bytes
<<
ParseHex
(
"04678afdb0fe55482719bc3f4cef3804678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38"
"000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
);
QVERIFY
(
IsStandardTx
(
t
,
reason
));
// limit is currently 223
t
.
vout
.
push_back
(
t
.
vout
.
at
(
0
));
t
.
vout
[
2
].
scriptPubKey
=
CScript
()
<<
OP_RETURN
// 57 + 2
<<
ParseHex
(
"04678afdb0fe55482719bc3f4cef3804678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38"
);
QVERIFY
(
IsStandardTx
(
t
,
reason
));
// exactly within limit.
// one byte over limit.
t
.
vout
[
2
].
scriptPubKey
=
t
.
vout
[
1
].
scriptPubKey
;
QCOMPARE
(
IsStandardTx
(
t
,
reason
),
false
);
QCOMPARE
(
reason
,
"oversize-op-return"
);
t
.
vout
.
resize
(
1
);
// MAX_OP_RETURN_RELAY+1-byte TX_NULL_DATA (non-standard)
t
.
vout
[
0
].
scriptPubKey
=
CScript
()
<<
OP_RETURN
<<
ParseHex
(
"04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef3804678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef3800"
"0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
);
QCOMPARE
(
Settings
::
MaxOpReturnRelay
+
4
,
t
.
vout
[
0
].
scriptPubKey
.
size
());
QCOMPARE
(
Settings
::
MaxOpReturnRelay
+
1
,
t
.
vout
[
0
].
scriptPubKey
.
size
());
QVERIFY
(
!
IsStandardTx
(
t
,
reason
));
// Data payload can be encoded in any way...
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment