Server Authority Studio Beta - Insights from Engineers!

BindToSimulation tries REALLY HARD to maintain the requested frequency regardless of server frame rate. This does mean that it may fire multiple times a frame.

There are going to be some cases where during EXTREME perf issues we drop this below the requested frequency.

1 Like

How do you deal with floating-point inaccuracies and other non-deterministic logic in the simulation? I believe the ‘number’ type in Luau is just a double behind the scenes. I would expect this to cause a ton of minor client mispredictions, causing constant rollbacks. Will we need to maintain determinism in our simulation logic? Or rather, is it even feasible to write deterministic simulation logic currently?

1 Like

Thank you for writing about this stuff, though. It’s always super insightful seeing the decision-making behind crafting this engine :grinning_face_with_smiling_eyes:

1 Like

We don’t think we’ll ever be able to completely remove non-determinism in the engine, so mispredictions should always be expected. In theory a misprediction shouldn’t necessarily be noticeable by the user if the resimulation is good enough.

That being said, this is why Mechanisms right now are not ideal for current state of Server Authority, we still have some work to do in order to reduce mispredictions and non-determinism.

5 Likes

@Khanovich Thank you for your help and transparency on this Server Authority issue. I’ve read several of your messages and agree with many of them, especially your desire to make people understand why streaming became necessary. What I understand is that it’s a security measure for players with low-cost hardware, and as we know, good internet is easier to get than hardware, so I agree that streaming can help in most cases.

I only have one question, as I’m not understanding it very well, perhaps because it’s new and I don’t have many examples of its use. How can I perform a Tween with the player in a script on the server and have them also perform the Tween on the client? BindToSimulation seems like a loop, but how do I replicate it only once? Is there a function for this, or would it have to be done through a RemoteEvent?

Example:
ServerTween = Tween(HumanoidRootPart):Play()
RandomFunctionToReplication()
– Hey client, replicate this: ServerTween
end

I hope you understood the question.

1 Like

Next generation replication is intriguing. It sounds like there is some CPU overhead, but does this mean that it can also effectively reduce network load?

This would be huge because I feel it’s been a longstanding issue for a long time, with many games opting to forcibly replicate player characters at the cost of immense recv.

1 Like

Well, I’ve spent the last few days testing the feature (I requested and waited a long time for it). I believe that in terms of “Usefulness” it’s doing what it should, which is to make the player’s character controlled and validated by the server. There’s no need for more or less than that.

The advantages of this feature are:

  • Fluidity in the client, compared to using it without it. (Even with SetNetworkOwner(nil))

  • Rollback in the client in case of poor synchronization.

  • Most importantly, explorers no longer have control over the CHARACTER. #1

What should be observed:

  • We don’t need the game to go through an absurd and immense authority to the server, as if everything needed to be replicated. What we need is only control of the client character. #2

  • Need for improvements in standard synchronization, because many times the character on the server is in one location and the client, even after several seconds, does not receive the synchronization.

  • Anchored controls are not replicated correctly with BindToSimulation. (I had to use a RemoteEvent to signal correctly)

#1 - Developers need to learn how to protect themselves from exploiters in their games, but our difficulty has always been controlling the client character, as it was seen as an authority.

#2 - We don’t need the entire game controlled by the server, as developers need to learn how to adopt security measures, so giving us only what was beyond our control is fine. I don’t see the need to insert internal debounces in call functions like RemoteEvent or proximity buttons; leave that to us.

I suggest including some simulation mechanisms, such as Tween, because it’s not replicated in the function, however, it’s still possible to work around the situation using other methods, but I make this request because the community is used to using Tween.

In short, thank you for the tool, because what I really saw as a security problem was the client controlling the character as it pleased, and now it’s not anymore. Good work to the whole team, and I hope you continue to improve this feature.

5 Likes

Hoping to see more improvements with the input action system interactions. I’m finding out that the server will eat up your inputs if a misprediction occurs and will force a button boolean to be true, even when it’s not pressed (also, some way to tell how hard a button has been pressed would be nice, but that’s a feature for IAS).

Other than that, I am absolutely loving this new API. I’m building a lightweight platform fighter specifically for it, and I can’t wait to show it off :smiley:

7 Likes

Really appreciate you writing this post, it helped me understand the new system a lot better.

I think the site linked in the original post provides a good example of one of the core server authority issues, in that server updates will always be old if data is updated too frequently: Server reconciliation

I’ve been playtesting the Server Authority Laser Tag place and have run into character motion issues a couple of times that seemed to me like this issue.

I’m assuming something like this is already built into the physics/networking system so if physics instances are constantly being updated they aren’t old?

But at the same time, from the developer side, I think the point of BindToSimulation is to modify the physics as things happen, so I’m not sure if theres a way to figure out events that have happened to an instance since the ‘new server replication’ within BindToSimulation and reapply them in a similar way?

This might address the above, but with attributes being used to store data, is the best way to achieve something like this to do what the article suggests and add an attribute to the instance that’s a sequential update number that both client and server can update as necessary? Then the client could reapply changes after the current sequenceId via BindToSimulation?

But then, if the client does need to reconcile via BindToSimulation, does it offer any way to know what the current simulation step is, or would that need to be tracked by attributes as well?

I think I might be confused about the intersection of what is ‘automated’ so that ‘it just works’ and what developers might have to do themselves.

3 Likes

I noticed that when I fire a remote event on input, the remote event arrives faster than the input action’s replication.
I assume this is intentional to make sure the input arrives on the server at a consistent delay, but does the same delay apply to all other replication? or is it just input actions? and what happens if the input arrives slower than the delay?
Also, will there ever be a way to know that this delay is? I feel like it would be very useful to a lot of people.
Also also, how does the engine determine what this delay should be? This one is just for curiosity’s sake.

2 Likes

Unfortunately, currently there is no real synchronization between RemoteEvents and Inputs/Other Data Replication when “NextGenerationReplication” is enabled.

They are independent of each other, and RemoteEvents are mostly synchronized with things like Instances streaming in and other remote events.

The World State (Properties on Streamed in Instances) + Inputs are synchronized with each other.

4 Likes

Looking forward for how-to tutorials to learn how to properly implement abilities that affect movement, since it’s very difficult to code them currently. Trying to make a slide ability but it continues to roll back after it ends, so I can’t really get it to work.

The open-sourced server authority experiences (i.e. racing, soccer, laser tag) don’t help in learning how to properly implement movement abilities. This also goes for basic stats like speed boosts, slowness, and movelock.

2 Likes

SAuthModifyDefaultAvatar.rbxl (68.8 KB)

Not sure if this is helpful, but this place contains an avatar that I added a “Boost” and “Sprint” ability to. To use the “Sprint” you hold shift, and to use the boost you jump and press “V” and it will propel you in a direction of your momentum.

This should work with Server Authority On or Off (if you have the other Server Authority-required features enabled.)

The key here is how you hook things up to run on Client and Server correctly, which we realize is more complex than desired…

Hope this helps.

2 Likes

Any updates on animations? They’re still kind of janky with server authority. One of my friends is still having trouble with them even when their experience has been built with server authority in mind.

2 Likes

In progress. Current Studio Beta, animations just don’t work with prediction, so if you have any simulation state or gameplay crucial state with animations it will not work at all. (This is super easy to repro on a default avatar and walking into a wall)

This is one of our top priorities to fix, but it requires re-writing how animations work internally in Roblox, which is why it’s taking some time.

6 Likes

Nice to hear that there’s still progress and work on it. Things have been silent for a while, so you start to get curious.

That aside, will this internal change ever be released as a standalone update or will it come out as a SA exclusive?

3 Likes

rate my own server authority gng:

Folder setup

ServerScriptService
 ├─ ServerAuthority.server.lua
 └─ Authority
     ├─ Validator.lua
     ├─ RateLimiter.lua
     └─ PlayerState.lua
ReplicatedStorage
 └─ Remotes
     └─ ActionEvent (RemoteEvent)

RateLimiter.lua

Basic per-player throttling. Cheap, effective, boring (which is good).

local RateLimiter = {}
RateLimiter.__index = RateLimiter

function RateLimiter.new(limit, window)
	return setmetatable({
		limit = limit,
		window = window,
		calls = {}
	}, RateLimiter)
end

function RateLimiter:Allow(player)
	local now = os.clock()
	local record = self.calls[player] or {count = 0, reset = now + self.window}

	if now > record.reset then
		record.count = 0
		record.reset = now + self.window
	end

	record.count += 1
	self.calls[player] = record

	return record.count <= self.limit
end

function RateLimiter:Cleanup(player)
	self.calls[player] = nil
end

return RateLimiter

PlayerState.lua

Server-owned truth. Clients never write to this.

local PlayerState = {}

local states = {}

function PlayerState.Init(player)
	states[player] = {
		Health = 100,
		Position = Vector3.zero,
		LastValidCFrame = nil,
	}
end

function PlayerState.Get(player)
	return states[player]
end

function PlayerState.Remove(player)
	states[player] = nil
end

return PlayerState

Validator.lua

This is where exploits go to die.

local Validator = {}

local MAX_DISTANCE = 20 -- studs per update

function Validator.ValidPlayer(player)
	return player and player:IsA("Player") and player.Character
end

function Validator.ValidMovement(player, newCFrame, state)
	if not state.LastValidCFrame then
		state.LastValidCFrame = newCFrame
		return true
	end

	local delta = (newCFrame.Position - state.LastValidCFrame.Position).Magnitude
	if delta > MAX_DISTANCE then
		return false
	end

	state.LastValidCFrame = newCFrame
	return true
end

function Validator.ValidAction(action)
	return typeof(action) == "string"
end

return Validator

ServerAuthority.server.lua

This is the actual authority. The server decides everything.

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local ActionEvent = ReplicatedStorage.Remotes.ActionEvent

local RateLimiter = require(script.Authority.RateLimiter)
local Validator = require(script.Authority.Validator)
local PlayerState = require(script.Authority.PlayerState)

local actionLimiter = RateLimiter.new(10, 1) -- 10 actions per second

Players.PlayerAdded:Connect(function(player)
	PlayerState.Init(player)
end)

Players.PlayerRemoving:Connect(function(player)
	PlayerState.Remove(player)
	actionLimiter:Cleanup(player)
end)

ActionEvent.OnServerEvent:Connect(function(player, payload)
	if not Validator.ValidPlayer(player) then return end
	if not actionLimiter:Allow(player) then
		warn("Rate limit hit:", player)
		return
	end

	local state = PlayerState.Get(player)
	if not state then return end

	-- Example payload:
	-- {action = "Move", cframe = CFrame}

	if not Validator.ValidAction(payload.action) then return end

	if payload.action == "Move" then
		if typeof(payload.cframe) ~= "CFrame" then return end

		if not Validator.ValidMovement(player, payload.cframe, state) then
			warn("Invalid movement:", player)
			return
		end

		player.Character:PivotTo(payload.cframe)
	end

	-- Extend here:
	-- Combat
	-- Abilities
	-- Inventory
end)

Client rule (important)

Clients request, servers decide.

Bad client:

character:PivotTo(cframe)

Correct client:

ActionEvent:FireServer({
	action = "Move",
	cframe = cframe
})
8 Likes

I really appreciate the full transparency and honesty when it comes to the rationale behind the engineering and technical decisions for server authority. It’s something we’d love to see more of, thank you.

I have a question regarding custom physics for character controllers. Currently, I’ve finished implementing a custom character controller that handles position integration, collision detection, and resolution. (The collision resolution code is a bit messy due to the lack of margins for spherecasts hopefully margins will be available soon.), the physics uses luau + vector/cframe math only.

I was wondering whether it’s practical and realistic to try to make this work with the new authority system, or with Roblox in general. I’ve always shied away from more “low-level” custom systems because I viewed them as impractical due to engine limitations, but I’m starting to reconsider it. I was hoping you could provide some feedback on this (some engineering wisdom perhaps).

It would also be great if you could share some guidelines to help me decide whether it’s practical to build something from scratch in Roblox Studio, or if it’s better to use the built-in tools and hack my way through them to achieve the behavior I need.

7 Likes

please reconsider the 50-character limit for string attributes, for my use-case i was storing a set-once, read-once attribute that looked like this

:setattribute("t", httpservice:jsonencode({
	instancekey = httpservice:generateguid(false);
	peerindex = 1;
	activitykey = "activity"
})) --- approx 93 characters, depends on len of activitykey

and because of this limit, i had to completely forgo using httpservice and dictionaries and now use a shallow formatted string that now looks like this

:setattribute("t", string.format("%d!%d!%s", 1, 1, httpservice:generateguid(false))) --- 40 characters

… which, although optimized for space, flies dangerously close to the 50 character limit

6 Likes

Torque.Torque currently cannot be set in BindToSimulation callbacks. Please change this!

4 Likes