@@ -522,13 +522,10 @@ func feeCredit(txgroup []transactions.SignedTxnWithAD, minFee uint64) uint64 {
522522
523523// NewInnerEvalParams creates an EvalParams to be used while evaluating an inner group txgroup
524524func NewInnerEvalParams (txg []transactions.SignedTxnWithAD , caller * EvalContext ) * EvalParams {
525- minAvmVersion := computeMinAvmVersion (txg )
526- // Can't happen currently, since earliest inner callable version is higher
527- // than any minimum imposed otherwise. But is correct to inherit a stronger
528- // restriction from above, in case of future restriction.
529- if minAvmVersion < caller .minAvmVersion {
530- minAvmVersion = caller .minAvmVersion
531- }
525+ minAvmVersion := max (computeMinAvmVersion (txg ), caller .minAvmVersion )
526+ // caller.AvmVersion can't exceed the computed value currently, since earliest
527+ // inner callable version is higher than any minimum imposed otherwise. But is
528+ // correct to inherit a stronger restriction from above, in case of future restriction.
532529
533530 // Unlike NewEvalParams, do not add fee credit here. opTxSubmit has already done so.
534531
@@ -1638,10 +1635,7 @@ func (cx *EvalContext) step() error {
16381635 if len (cx .Stack ) == 0 {
16391636 stackString = "<empty stack>"
16401637 } else {
1641- num := 1
1642- if len (spec .Return .Types ) > 1 {
1643- num = len (spec .Return .Types )
1644- }
1638+ num := max (len (spec .Return .Types ), 1 )
16451639 // check for nil error here, because we might not return
16461640 // values if we encounter an error in the opcode
16471641 if err == nil {
@@ -3238,10 +3232,7 @@ func (cx *EvalContext) txnFieldToStack(stxn *transactions.SignedTxnWithAD, fs *t
32383232 return sv , fmt .Errorf ("invalid ApprovalProgramPages index %d" , arrayFieldIdx )
32393233 }
32403234 first := arrayFieldIdx * maxStringSize
3241- last := first + maxStringSize
3242- if last > uint64 (len (txn .ApprovalProgram )) {
3243- last = uint64 (len (txn .ApprovalProgram ))
3244- }
3235+ last := min (first + maxStringSize , uint64 (len (txn .ApprovalProgram )))
32453236 sv .Bytes = txn .ApprovalProgram [first :last ]
32463237 case NumClearStateProgramPages :
32473238 sv .Uint = uint64 (basics .DivCeil (len (txn .ClearStateProgram ), maxStringSize ))
@@ -3251,10 +3242,7 @@ func (cx *EvalContext) txnFieldToStack(stxn *transactions.SignedTxnWithAD, fs *t
32513242 return sv , fmt .Errorf ("invalid ClearStateProgramPages index %d" , arrayFieldIdx )
32523243 }
32533244 first := arrayFieldIdx * maxStringSize
3254- last := first + maxStringSize
3255- if last > uint64 (len (txn .ClearStateProgram )) {
3256- last = uint64 (len (txn .ClearStateProgram ))
3257- }
3245+ last := min (first + maxStringSize , uint64 (len (txn .ClearStateProgram )))
32583246 sv .Bytes = txn .ClearStateProgram [first :last ]
32593247 case RekeyTo :
32603248 sv .Bytes = txn .RekeyTo [:]
0 commit comments