Skip to content

Commit

Permalink
meh
Browse files Browse the repository at this point in the history
  • Loading branch information
luke-jr committed Jun 20, 2024
1 parent 3c8aef0 commit dcf066c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 46 deletions.
3 changes: 2 additions & 1 deletion .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ env: # Global defaults

# https://cirrus-ci.org/guide/tips-and-tricks/#sharing-configuration-between-tasks
filter_template: &FILTER_TEMPLATE
skip: $CIRRUS_REPO_FULL_NAME == "bitcoin-core/gui" && $CIRRUS_PR == "" # No need to run on the read-only mirror, unless it is a PR. https://cirrus-ci.org/guide/writing-tasks/#conditional-task-execution
skip: true
stateful: false # https://cirrus-ci.org/guide/writing-tasks/#stateful-tasks

base_template: &BASE_TEMPLATE
Expand Down Expand Up @@ -184,6 +184,7 @@ task:
task:
name: 'multiprocess, i686, DEBUG'
<< : *GLOBAL_TASK_TEMPLATE
skip: false
persistent_worker:
labels:
type: medium
Expand Down
31 changes: 2 additions & 29 deletions src/script/script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,37 +297,10 @@ std::pair<size_t, size_t> CScript::DatacarrierBytes() const
opcode_it = it;
if (!GetOp(it, opcode, push_data)) {
// Invalid scripts are necessarily all data
return {0, size()};
return {999, size()};
}

if (opcode == OP_IF || opcode == OP_NOTIF) {
++inside_conditional;
} else if (opcode == OP_ENDIF) {
if (!inside_conditional) return {0, size()}; // invalid
--inside_conditional;
} else if (opcode == OP_RETURN && !inside_conditional) {
// unconditional OP_RETURN is unspendable
return {size(), 0};
}

// Match OP_FALSE OP_IF
if (inside_noop) {
switch (opcode) {
case OP_IF: case OP_NOTIF:
++inside_noop;
break;
case OP_ENDIF:
if (0 == --inside_noop) {
counted += it - data_began + 1;
}
break;
default: /* do nothing */;
}
} else if (opcode == OP_IF && last_opcode == OP_FALSE) {
inside_noop = 1;
data_began = opcode_it;
// Match <data> OP_DROP
} else if (opcode <= OP_PUSHDATA4) {
if (opcode <= OP_PUSHDATA4) {
data_began = opcode_it;
} else if (opcode == OP_DROP && last_opcode <= OP_PUSHDATA4) {
counted += it - data_began;
Expand Down
16 changes: 0 additions & 16 deletions src/test/script_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1502,22 +1502,6 @@ BOOST_AUTO_TEST_CASE(script_DataCarrierBytes)
{
using zeros = std::vector<unsigned char>;

// empty script
BOOST_CHECK_EQUAL("0+0", DatacarrierBytesStr(CScript()));
// series of pushes are not data
BOOST_CHECK_EQUAL("0+0", DatacarrierBytesStr(CScript() << OP_0 << OP_0 << OP_0));
// unspendable if first op is OP_RETURN, then length(1), zeros(11)
BOOST_CHECK_EQUAL("13+0", DatacarrierBytesStr(CScript() << OP_RETURN << zeros(11)));
// invalid script (no data following PUSHDATA) makes it all data
BOOST_CHECK_EQUAL("0+2", DatacarrierBytesStr(CScript() << OP_0 << OP_PUSHDATA4));
// no data here
BOOST_CHECK_EQUAL("0+0", DatacarrierBytesStr(CScript() << OP_TRUE << OP_IF << OP_ENDIF));
// specific data pattern, entire script is data
BOOST_CHECK_EQUAL("0+4", DatacarrierBytesStr(CScript() << OP_FALSE << OP_IF << OP_7 << OP_ENDIF));
// consecutive data
BOOST_CHECK_EQUAL("0+6", DatacarrierBytesStr(CScript() << OP_FALSE << OP_IF << OP_ENDIF << OP_FALSE << OP_IF << OP_ENDIF));
// nested data (all is data)
BOOST_CHECK_EQUAL("0+6", DatacarrierBytesStr(CScript() << OP_FALSE << OP_IF << OP_TRUE << OP_IF << OP_ENDIF << OP_ENDIF));
// pushing then immediately dropping is data: length(1), zero(11), OP_DROP
BOOST_CHECK_EQUAL("0+13", DatacarrierBytesStr(CScript() << zeros(11) << OP_DROP));
}
Expand Down

0 comments on commit dcf066c

Please sign in to comment.