{"id":32618014,"url":"https://github.com/timyiu478/ben-or-consensus","last_synced_at":"2025-10-30T17:50:48.789Z","repository":{"id":318811147,"uuid":"1062636928","full_name":"timyiu478/ben-or-consensus","owner":"timyiu478","description":"A Ben-Or’s protocol for Binary Asynchronous Agreement ","archived":false,"fork":false,"pushed_at":"2025-10-15T04:50:52.000Z","size":21373,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-15T15:49:07.434Z","etag":null,"topics":["asychronous-network","ben-or","consensus-algorithm","fault-tolerance","random"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/timyiu478.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-23T14:16:12.000Z","updated_at":"2025-10-15T04:50:56.000Z","dependencies_parsed_at":"2025-10-16T06:00:02.696Z","dependency_job_id":"ed180048-eb8e-4ec2-ae9c-336540f145c1","html_url":"https://github.com/timyiu478/ben-or-consensus","commit_stats":null,"previous_names":["timyiu478/ben-or-consensus"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/timyiu478/ben-or-consensus","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timyiu478%2Fben-or-consensus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timyiu478%2Fben-or-consensus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timyiu478%2Fben-or-consensus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timyiu478%2Fben-or-consensus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/timyiu478","download_url":"https://codeload.github.com/timyiu478/ben-or-consensus/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timyiu478%2Fben-or-consensus/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281853675,"owners_count":26573095,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-30T02:00:06.501Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asychronous-network","ben-or","consensus-algorithm","fault-tolerance","random"],"created_at":"2025-10-30T17:50:47.959Z","updated_at":"2025-10-30T17:50:48.778Z","avatar_url":"https://github.com/timyiu478.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## The Ben-Or decentralized consensus algorithm\n\nThe *Ben-Or consensus algorithm* is making use of **randomness** to create consensus in a asynchronous network with eventual liveness guarantee.\n\nThis repository contains my TypeScript implementation of the Ben-Or consensus algorithm, designed to run on a single machine. It's for anyone looking to learn more about this algorithm from a hands-on perspective.\n\n---\n\n## Example Run\n\nExample Configuration:\n\n```\n?: no init value\nH: Non-Faulty\nF: Faulty\nNodes:          F F F F H H H H H H\nInit Values:    1 1 1 1 ? 1 0 1 0 1\n```\n\nRun:\n\n![assets/example_run.gif](assets/example_run.gif)\n\nSee [start.ts](src/start.ts) for the details\n\n---\n\n## How to test the code \n\n1. Run the unit tests with the command `yarn test` and see how the implementation performs against the given tests\n1. Modify the `start.ts` file with the parameters you'd like, launch the network manually with `yarn start` and see the results\n\n---\n\n## Algorithm Details\n\n### Intuition of the algorithm\n\n1. At first every process proposes their input value. \n1. After that, they propose random values.\n1. **When enough processes propose the same value, the value is chosen.**\n1. Eventually, that will happen!\n\n### Setup\n\n1. Protocol proceeds in **asynchronous rounds**, where each round has **two** phases.\n    1. In the first phase of a round, each node tries to identify a value supported by a majority in order to propose that for the second phase.\n    1. In the second phase (the decision phase), a node finalizes its decision if it finds the same value proposed by at least *f+1* nodes. \n1. For each phase, processes broadcast their input values and wait for *n - f* messages from the other processes.\n1. Each message is tagged with the round and phase number. (And messages can be resent to deal with a lossy network. But once a message is sent, that value is **locked** in for that process for that phase/round.)\n\n### Guarantees\n\n1. Deterministic Safety by majority intersection\n1. Termination with probability 1\n\n### Pros and Cons \n\nPros:\n\n1. Processes without input values start by proposing *⊥*\n\nCons:\n\n1. Performance is not predictable.\n1. Convergence can still take multiple rounds.\n1. Amount of communication needed is potentially high.\n\n### Assumptions\n\n1. Node Failure Mode: crash-stop start from round 0 \n1. Message sent will eventually be received in arbitrary order; No message lost \n\n### REST API\n\n- Nodes listen to request on the port defined by `BASE_NODE_PORT` + nodeId, which for the basic configuration, means that node #0 will have the port 3000, #1 the port 3001, etc,\n- Nodes always start with an initial state that is provided as a parameter of the `node` function,\n- Nodes communicate through POST HTTP request with the `/message` route which you should implement,\n- Nodes should start the algorithm when they receive a GET HTTP request to the `/start` route,\n- if the `/stop` GET HTTP route is called on a node, it should stop any activity (this is to prevent any errors in the tests),\n\n---\n\n## References\n\n1. Asynchronous Agreement Part Two: Ben-Or's protocol - https://decentralizedthoughts.github.io/2022-03-30-asynchronous-agreement-part-two-ben-ors-protocol/\n1. Lecture CSE2 G20 Randomized consensus - https://courses.cs.washington.edu/courses/cse452/19sp/slides/l13-benor.pdf\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimyiu478%2Fben-or-consensus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftimyiu478%2Fben-or-consensus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimyiu478%2Fben-or-consensus/lists"}