diff --git a/core/vm/validate.go b/core/vm/validate.go index 11987f677e..5cce0cb004 100644 --- a/core/vm/validate.go +++ b/core/vm/validate.go @@ -120,10 +120,8 @@ func validateCode(code []byte, section int, container *Container, jt *JumpTable, if arg >= len(container.Types) { return nil, fmt.Errorf("%w: arg %d, last %d, pos %d", ErrInvalidSectionArgument, arg, len(container.Types), i) } - // TODO check if that is actually a problem - // JUMPF operand must point to a code section with equal or fewer number of outputs as the section in which it resides, or to a section with 0x80 as outputs (non-returning) - if container.Types[arg].Output > container.Types[section].Output { - return nil, fmt.Errorf("%w: arg %d, last %d, pos %d", ErrInvalidSectionArgument, arg, len(container.Types), i) + if container.Types[arg].Output != 0x80 && container.Types[arg].Output > container.Types[section].Output { + return nil, fmt.Errorf("%w: arg %d, last %d, pos %d", ErrInvalidNumberOfOutputs, arg, len(container.Types), i) } visitedCode[arg] = struct{}{} case op == DATALOADN: diff --git a/core/vm/validate_linear.go b/core/vm/validate_linear.go index b1fc092296..85cec10897 100644 --- a/core/vm/validate_linear.go +++ b/core/vm/validate_linear.go @@ -82,9 +82,6 @@ func validateControlFlow2(code []byte, section int, metadata []*FunctionMetadata return 0, fmt.Errorf("%w: at pos %d", ErrStackUnderflow{stackLen: have, required: want}, pos) } } else { - if metadata[section].Output < newSection.Output { - return 0, fmt.Errorf("%w: at pos %d", ErrInvalidNumberOfOutputs, pos) - } if currentBounds.max != currentBounds.min { return 0, fmt.Errorf("%w: max %d, min %d, at pos %d", ErrInvalidNumberOfOutputs, currentBounds.max, currentBounds.min, pos) }