SCROLL FOR THE DEFINITIONTRUSTEDTRUCKSN 52.52° / E 13.40°
01DefinitionDistributed Systems Engineering Standard
An atomic CPU and distributed memory instruction used to achieve lock-free synchronization and prevent split-brain race conditions.
01 / CANONICAL DEFINITION
What it means.
Compare-And-Swap (CAS) is an atomic primitive comparing the contents of a memory location with a given value, modifying it to a new value only if the current value matches the expected value. If another writer modified it first, the operation fails cleanly.
02 / ROLE IN TRUSTEDTRUCKS
Where it is used.
Enforces strict linearizable nonce allocation in the transaction pipeline. Lua scripts in Redis check the version token before incrementing nonces, preventing race conditions across multi-pod API servers.
03 / TECHNICAL SPECIFICATION
Lua script: `if current_version == expected_version then update() else fail()`. Prevents nonce reuse and signer deadlock.
04 / WHAT IT MUST NOT IMPLY
Read it carefully.
CAS prevents split-brain writes; it does not protect against external RPC timeouts on the downstream blockchain node.