You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, OP_RETURN after genesis are handled using a special case error code, ErrOK, which results in some pretty funky and unintuitive code.
So for example, on OP_RETURN, we check to see if we're in a post genesis context, and if we are and aren't in a conditional, we return success():
funcopcodeReturn(op*ParsedOpcode, t*thread) error {
if!t.afterGenesis {
returnerrs.NewError(errs.ErrEarlyReturn, "script returned early")
}
t.earlyReturnAfterGenesis=trueiflen(t.condStack) ==0 {
// Terminate the execution as successful. The remaining of the script does not affect the validity (even in// presence of unbalanced IFs, invalid opcodes etc)returnsuccess()
}
returnnil
}
Then, in the thread executor, when we execute the opcode we check for this special case error:
iferr:=t.executeOpcode(opcode); err!=nil {
ifok:=errs.IsErrorCode(err, errs.ErrOK); ok {
// If returned early, move onto the next scriptt.shiftScript()
returnt.scriptIdx>=len(t.scripts), nil
}
returntrue, err
}
This creates sections in our codebase where an error mightn't actually be an error, and it would be really nice if we could move away from this, even if it was something as simple as a state flag on interpreter.thread.
The text was updated successfully, but these errors were encountered:
Currently,
OP_RETURN
after genesis are handled using a special case error code,ErrOK
, which results in some pretty funky and unintuitive code.So for example, on
OP_RETURN
, we check to see if we're in a post genesis context, and if we are and aren't in a conditional, we returnsuccess()
:Success is just a wrapping for
ErrOK
:Then, in the thread executor, when we execute the opcode we check for this special case error:
This creates sections in our codebase where an error mightn't actually be an error, and it would be really nice if we could move away from this, even if it was something as simple as a state flag on
interpreter.thread
.The text was updated successfully, but these errors were encountered: