diff --git a/pkg/ride/functions_proto.go b/pkg/ride/functions_proto.go
index c8b2a878e..f00937b5b 100644
--- a/pkg/ride/functions_proto.go
+++ b/pkg/ride/functions_proto.go
@@ -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 {
@@ -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
 	}
diff --git a/pkg/state/invoke_applier_test.go b/pkg/state/invoke_applier_test.go
index 925816c75..233973fc5 100644
--- a/pkg/state/invoke_applier_test.go
+++ b/pkg/state/invoke_applier_test.go
@@ -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{},