A more general implementation of Lamport's Byzantine Consensus algorithm in Python

Marton Trencseni - Tue 12 August 2025 • Tagged with lamport, byzantine, generals, python, flask, distributed

This follow-up factors Lamport’s Byzantine Generals algorithm into a generalized class that's independent of I/O and payloads. Any node can initiate a round (be "king"), values can be arbitrary strings, and multiple rounds can run concurrently.

Continue reading

Lamport's Byzantine Generals algorithm in Python

Marton Trencseni - Wed 30 July 2025 • Tagged with lamport, byzantine, generals, python, flask, distributed

I discuss Lamport's Byzantine Generals problem and why it requires a total of N≥3M+1 nodes with M malicious nodes, and then implement the solution using Python with HTTP Flask servers.

Continue reading

Exploring Lamport's Bakery algorithm in Python

Marton Trencseni - Fri 11 July 2025 • Tagged with lamport, bakery, python, flask, distributed

This post shows how to implement Lamport’s Bakery algorithm with Python HTTP Flask servers. The Python code is short and readable, helping newcomers grasp the algorithm’s logic without the syntactic overhead of C++. The asynchronous HTTP flow also generates plenty of overlap between workers, so the need for mutual exclusion is obvious. Exposing the variables through REST endpoints enables observation of ticket picking and critical section entry in real time, potentially making the flow of the algorithm easier to understand.

Continue reading

Exploring Lamport's Bakery algorithm in C++20

Marton Trencseni - Sun 06 July 2025 • Tagged with lamport, bakery, c++

I explore Lamport’s Bakery algorithm and show how a naive C++20 implementation breaks on weak memory models, how to fix it with std::atomic, and how to implement bounded tickets.

Continue reading