Skip to content
TRUSTEDTRUCKS®
Join the network
INFRASTRUCTURE & ARCHITECTURE · TERM 02 OF 67

CAS

Compare-And-Swap (Atomic Optimistic Concurrency)

All terms
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.

05 / RELATED SPECIFICATIONS
  • TT-SPEC-KAFKA-MIGRATION-001
  • TT-SPEC-INGESTION-EXEC-001
02Related3 CONNECTED TERMS
  1. 01GoQuorumGoQuorum Enterprise Permissioned Ethereum BlockchainAn enterprise-grade, permissioned Ethereum-based ledger offering high transaction throughput, privacy domains, and zero-gas execution.Blockchain & Web3
  2. 02EoSExactly-Once SemanticsA distributed messaging guarantee ensuring that each event is processed once and only once, even during network failures.Infrastructure & Architecture
  3. 03SRESite Reliability EngineeringAn engineering discipline applying software engineering practices to infrastructure and operations problems.Infrastructure & Architecture