Skip to content

Commit 44fde73

Browse files
committed
Comments.
1 parent 4323d53 commit 44fde73

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

include/bitcoin/system/impl/chain/operation.ipp

+9-3
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,12 @@ constexpr bool operation::is_counted(opcode code) NOEXCEPT
202202
// (2) they are not evaluated during script execution.
203203
// (3) they are only conditionally successful (tapscript).
204204
// (4) renaming them would lose important historical context.
205+
// Regarding op_verif and op_vernotif, it seems that these were not promoted
206+
// because authors failed to recognize that following their demotion from
207+
// conditionals, these codes became unconditionally invalid, just as others.
208+
// Regarding reserved_255, there is no good reason to have left this reserved,
209+
// as op_return already provides that operation, but it's likely the authors
210+
// felt it exhibits special benavior as the highest value code (it does not).
205211
constexpr bool operation::is_success(opcode code) NOEXCEPT
206212
{
207213
constexpr auto op_187 = opcode::reserved_187;
@@ -211,8 +217,8 @@ constexpr bool operation::is_success(opcode code) NOEXCEPT
211217
{
212218
case opcode::reserved_80:
213219
case opcode::op_ver:
214-
////case opcode::op_verif: // stays invalid
215-
////case opcode::op_vernotif: // stays invalid
220+
////case opcode::op_verif: // stays invalid (why)
221+
////case opcode::op_vernotif: // stays invalid (why)
216222
////case opcode::op_return: // stays reserved
217223
case opcode::op_cat:
218224
case opcode::op_substr:
@@ -232,7 +238,7 @@ constexpr bool operation::is_success(opcode code) NOEXCEPT
232238
case opcode::op_lshift:
233239
case opcode::op_rshift:
234240
////case opcode::reserved_186: // checksigadd subsumes
235-
////case opcode::reserved_255: // stays reserved
241+
////case opcode::reserved_255: // stays reserved (why)
236242
return true;
237243
default:
238244
return code >= op_187 && code <= op_254;

include/bitcoin/system/impl/machine/program.ipp

+6-1
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ program(const transaction& tx, const input_iterator& input,
107107
// Same as segwit but with with budget and unstripped bip342 flag.
108108
// Sigop budget is 50 plus size of prefixed serialized witness [bip342].
109109
// Budget is initialized add1(50) to make it zero-based, avoiding signed type.
110+
// This program is never used to construct another, so masked flags_ never mix.
110111
TEMPLATE
111112
inline CLASS::
112113
program(const transaction& tx, const input_iterator& input,
@@ -173,11 +174,15 @@ initialize() const NOEXCEPT
173174
if (bip342 && script_->is_prevalid())
174175
return error::prevalid_script;
175176

176-
// Fail if last op underflow, lower priority than easy [bip342].
177+
// Fail if last op underflow, lower priority than success codes [bip342].
177178
if (script_->is_underflow())
178179
return error::invalid_script;
179180

180181
// Fail if any op invalid (invalid codes reduced in tapscript).
182+
// Should be after underflow check since underflow is also an invalid op.
183+
// Promoted success codes are not reachable here due to is_prevalid above.
184+
// So only op_verif/op_vernotif (unpromoted invalids) are caught here for
185+
// tapscript, otherwise is_prevalid bypassed and all invalids caught here.
181186
if (script_->is_prefail())
182187
return error::prefail_script;
183188

0 commit comments

Comments
 (0)