Skip to content

Commit

Permalink
Always count spent complexity for internal invokes. (#855)
Browse files Browse the repository at this point in the history
Test adjusted.
  • Loading branch information
alexeykiselev authored Aug 10, 2022
1 parent 1e38538 commit 56259d4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions pkg/ride/functions_proto.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ func performInvoke(invocation invocation, env environment, args ...rideType) (ri
return nil, EvaluationErrorPush(err, "%s at '%s' function '%s' with arguments %v", invocation.name(), recipient.Address.String(), fn, arguments)
}

ws.totalComplexity += res.Complexity()

err = ws.smartAppendActions(res.ScriptActions(), env, &localActionsCountValidator)
if err != nil {
if GetEvaluationErrorType(err) == Undefined {
Expand All @@ -239,8 +241,6 @@ func performInvoke(invocation invocation, env environment, args ...rideType) (ri
env.setNewDAppAddress(proto.WavesAddress(callerAddress))
env.setInvocation(oldInvocationParam)

ws.totalComplexity += res.Complexity()

if res.userResult() == nil {
return rideUnit{}, nil
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/state/invoke_applier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ func TestFailedInvokeApplicationComplexityAfterRideV6(t *testing.T) {
// This transaction reaches data entries size limit (16 KB) after reaching 1000 complexity limit
fcSizeLimitAfterComplexityLimit := proto.FunctionCall{Name: "keyvalue", Arguments: []proto.Argument{&proto.IntegerArgument{Value: 99}, &proto.StringArgument{Value: strings.Repeat("0", 200)}}}
// This transaction reaches data entries size limit (16 KB) before reaching 1000 complexity limit
fcSizeLimitBeforeComplexityLimit := proto.FunctionCall{Name: "keyvalue", Arguments: []proto.Argument{&proto.IntegerArgument{Value: 11}, &proto.StringArgument{Value: strings.Repeat("0", 2000)}}}
fcSizeLimitBeforeComplexityLimit := proto.FunctionCall{Name: "keyvalue", Arguments: []proto.Argument{&proto.IntegerArgument{Value: 10}, &proto.StringArgument{Value: strings.Repeat("0", 2000)}}}
tests := []invokeApplierTestData{
{ // No error, no failure - transaction applied
payments: []proto.ScriptPayment{},
Expand Down

0 comments on commit 56259d4

Please sign in to comment.