opencbdc-tx

A transaction processor for a hypothetical, general-purpose, central bank digital currency

https://github.com/mit-dci/opencbdc-tx

Science Score: 62.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
    6 of 26 committers (23.1%) from academic institutions
  • Institutional organization owner
    Organization mit-dci has institutional domain (dci.mit.edu)
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (13.2%) to scientific vocabulary
Last synced: 6 months ago · JSON representation ·

Repository

A transaction processor for a hypothetical, general-purpose, central bank digital currency

Basic Info
  • Host: GitHub
  • Owner: mit-dci
  • License: other
  • Language: C++
  • Default Branch: trunk
  • Homepage:
  • Size: 1.21 MB
Statistics
  • Stars: 913
  • Watchers: 59
  • Forks: 204
  • Open Issues: 89
  • Releases: 0
Created over 4 years ago · Last pushed 12 months ago
Metadata Files
Readme Changelog Contributing License Code of conduct Citation

README.md


CI Status Contributor Covenant MIT License GitHub Stars

Introduction

OpenCBDC is a technical research project focused on answering open questions surrounding central bank digital currencies (CBDCs).

This repository includes the core transaction processor for a hypothetical, general purpose central bank digital currency (CBDC). Initially, this work was derived from Project Hamilton (a collaboration between the MIT Digital Currency Initiative (DCI) and the Federal Reserve Bank of Boston (FRBB)).

For higher-level conceptual explanations, as well as findings and conclusions related to this code, see our research paper.

Initially, we focused our work on achieving high transaction throughput, low latency, and resilience against multiple geographical datacenter outages without significant downtime or any data loss. The design decisions we made to achieve these goals will help inform policy makers around the world about the spectrum of tradeoffs and available options for CBDC design.

News

If there are significant changes to the repository that may require manual downstream intervention (or other important updates), we will make a NEWS post.

Architecture

We have explored several architectures under two broad categories as follows:

UHS-Based Transaction Processor

We explored two system architectures for transaction settlement based on an unspent transaction output (UTXO) data model and transaction format. Both architectures implement the same schema representing an unspent hash set (UHS) abstraction. One architecture provides linearizability of transactions, whereas the other only provides serializability. By relaxing the ordering constraint, the peak transaction throughput supported by the system scales horizontally with the number of nodes, but the transaction history is unavailable making the system harder to audit retroactively. Both architectures handle multiple geo-distributed datacenter outages with a recovery time objective (RTO) of under ten seconds and a recovery point objective (RPO) of zero.

There are two UHS-based architectures as follows:

  1. "Atomizer" architecture
    • Materializes a total ordering of all transactions settled by the system in a linear sequence of batches.
    • Requires vertical scaling as peak transaction throughput is limited by the performance of a single system component.
    • Maximum demonstrated throughput ~170K transactions per second.
    • Geo-replicated latency <2 seconds.
  2. "Two-phase commit" architecture
    • Transaction history is not materialized and only a relative ordering is assigned between directly related transactions.
    • Combines two-phase commit (2PC) and conservative two-phase locking (C2PL) to create a system without a single bottlenecked component where peak transaction throughput scales horizontally with the number of nodes.
    • Maximum demonstrated throughput ~1.7M transactions per second.
    • Geo-replicated latency <1 second.

Read the 2PC & Atomizer architecture guide for a detailed description of the system components and implementation of each architecture.

Parallel Architecture for Scalably Executing smart Contracts ("PArSEC")

We built a system with a generic virtual machine layer that is capable of performing parallel executions of smart contracts.

The architecture is composed of two layers:

  1. A distributed key-value data store with ACID database properties
    • This back-end data store is not constrained to any type of data and is agnostic to the execution later.
  2. A generic virtual machine layer that executes programs (i.e. smart contracts) and uses the distributed key-value data store to record state
    • This computation layer defines the data models and transaction semantics.
    • We have implemented the Ethereum Virtual Machine EVM and a Lua based virtual machine as two working examples.
  • This architecture enables parallel execution of smart contracts which can be scaled horizontally where keys are independent.
  • Unmodified smart contracts from the Ethereum ecosystem can be deployed directly onto our EVM implementation.

Read the PArSEC Architecture Guide for more details.

Contributing and Discussion

You can join the OpenCBDC mailing list to receive updates from technical working groups and learn more about our work. If you would like to join our technical discussions and help workshop proposals, you can join our Zulip chat.

For more information on how to contribute, please see our Contribution Guide!

If you want to dive straight in, take a look at our issue tracker's list of good first issues.

Setup

If you would like to install OpenCBDC and run it on your local machine, follow the steps below:

Get the Code

  1. Install Git
  2. Clone the repository (including the submodules using: --recurse-submodules)

console $ git clone --recurse-submodules https://github.com/mit-dci/opencbdc-tx

Setup the build environment

Use these directions if you would like to build the source code on your machine. Alternatively, if you just want to run the system, skip to the Run the Code section below.

  1. Setup the build-environment

Note that this script is just a convenience to install system-wide dependencies we expect. As a result, it uses the system package manager, requires sudo, and should only be run once. console # ./scripts/install-build-tools.sh Note: Running Homebrew as root on mac via shell script is not supported, so run without sudo and when prompted, enter the root password. console $ ./scripts/install-build-tools.sh

  1. Setup project dependencies

This script builds and installs a local copy of several build-dependencies that are not widely packaged. Because the installation is done in a user-specific location (./prefix by default) rather than a system-wide one, you do not need root permission to run the script. Additionally, if you want to remove the installed build-dependencies or restart the installation process, you can safely delete the prefix directory and rerun this script. console $ ./scripts/setup-dependencies.sh 1. Run the build script console $ ./scripts/build.sh

macOS

Note that if you have not already installed the xcode cli tools you will need to:

```console

xcode-select --install

```

Documentation

Github Pages hosts the official copy of the OpenCBDC API Reference.

This reference is housed in an external repository.

Running the Code

UHS-based Architectures (2PC & Atomizer)

See the 2PC & Atomizer User Guide

PArSEC Architecture

See the PArSEC User Guide

Testing

Users can verify the setup by running both unit/integration and end-to-end tests on OpenCBDC.

Unit and Integration Tests

Running the tests:

  1. Build all Docker images

console $ ./scripts/build-docker.sh 1. Run Unit and Integration Tests

console $ docker run -ti opencbdc-tx-builder ./scripts/test.sh

E2E Testing with Kubernetes

Requirements

  • Go (go test library used to run tests)
  • Minikube
  • Helm
  • Kubectl

Running the tests:

console $ ./scripts/build-docker.sh

console $ ./scripts/test-e2e-minikube.sh

Review results and logs at testruns/<testrun-uuid>/

Linting

General

This script checks for newlines at the end of all tracked git files except images. Then it runs clang-format and clang-tidy on .cpp files in the following directories: src, tests, cmake-tests, tools.

console $ ./scripts/lint.sh

Python

Lint all python files according to ruleset defined in .pylintrc. Optional code quality value >= 5.0 and <= 10.0 can be entered as a threshold of failure.

console $ ./scripts/pylint.sh 8.0

Virtual Environment for Python

./scripts/install-build-tools.sh creates a virtual environemnt.
Once run, follow these steps to run python code.

  1. Activate the virtual environment which has the required python version and packages installed. console $ source ./scripts/activate-venv.sh

  2. Run python code console (.py_venv) $ python ./scripts/<script_name>.py

  3. Exit the virtual environment console (.py_venv) $ deactivate

Owner

  • Name: The MIT Digital Currency Initiative @ Media Lab
  • Login: mit-dci
  • Kind: organization
  • Location: Cambridge, MA

Citation (CITATION.cff)

cff-version: 1.2.0
message: "If you use this software, please cite it as below."
authors:
  - name: "The OpenCBDC Development Team"
    website: https://github.com/mit-dci/opencbdc-tx
type: software
repository-code: https://github.com/mit-dci/opencbdc-tx
license: "MIT"
license-url: https://github.com/mit-dci/opencbdc-tx/blob/trunk/COPYING
preferred-citation:
  type: conference-paper
  authors:
    - given-names: "James"
      family-names: "Lovejoy"
      affiliation: Federal Reserve Bank of Boston
    - given-names: "Cory"
      family-names: "Fields"
      affiliation: MIT Media Lab
    - given-names: "Madars"
      family-names: "Virza"
      affiliation: MIT Media Lab
    - given-names: "Kevin"
      family-names: "Karwaski"
      affiliation: Federal Reserve Bank of Boston
    - given-names: "Anders"
      family-names: "Brownworth"
      affiliation: Federal Reserve Bank of Boston
    - given-names: "Neha"
      family-names: "Narula"
      affiliation: MIT Media Lab
  title: "Hamilton: A High-Performance Transaction Processor for Central Bank Digital Currencies"
  year: 2023
  conference:
    name: "20th USENIX Symposium on Networked System Design and Implementation (NSDI 23)"
    year: 2023
    city: "Boston, MA"
    country: "US"
  start: 901
  end: 915
  publisher:
    name: "USENIX Association"
  url: "https://www.usenix.org/system/files/nsdi23-lovejoy.pdf"

GitHub Events

Total
  • Issues event: 5
  • Watch event: 27
  • Issue comment event: 8
  • Push event: 4
  • Pull request review comment event: 2
  • Pull request event: 11
  • Pull request review event: 6
  • Fork event: 7
Last Year
  • Issues event: 5
  • Watch event: 27
  • Issue comment event: 8
  • Push event: 4
  • Pull request review comment event: 2
  • Pull request event: 11
  • Pull request review event: 6
  • Fork event: 7

Committers

Last synced: 9 months ago

All Time
  • Total Commits: 227
  • Total Committers: 26
  • Avg Commits per committer: 8.731
  • Development Distribution Score (DDS): 0.692
Past Year
  • Commits: 22
  • Committers: 5
  • Avg Commits per committer: 4.4
  • Development Distribution Score (DDS): 0.636
Top Committers
Name Email Commits
James Lovejoy j****1@g****m 70
Alexander Jung 1****m 31
Michael Maurer m****i@n****u 31
Michael L. Szulczewski m****i@m****g 22
Sam Stuewe s****e@m****u 19
Gert-Jaap Glasbergen g****p@w****m 10
Morgan Rockett m****t@t****u 7
Jonathan Allen j****n@b****g 5
eolesinski e****4@c****u 5
Kyle Crawshaw k****w@g****m 3
Yiannis Karavas y****s@m****g 2
paparuch p****h@0****m 2
Anders Brownworth a****b@e****m 2
Chris Desch c****h@g****m 2
Duc M. Trinh d****h@g****m 2
Jon Wiggins me@j****g 2
Madars Virza m****s@m****u 2
davidmag854 4****4 2
Cory Fields c****-@c****m 1
Dave Bryson d****b@m****g 1
Douglas K. G. Araujo d****o@g****m 1
Hendrik T Tan 2****n 1
Josh Soref j****f 1
Enriko Chavez e****o@m****u 1
nicol-ii n****9@g****m 1
ryoungblom r****m@g****m 1

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 54
  • Total pull requests: 54
  • Average time to close issues: 2 months
  • Average time to close pull requests: 2 months
  • Total issue authors: 21
  • Total pull request authors: 20
  • Average comments per issue: 2.65
  • Average comments per pull request: 2.31
  • Merged pull requests: 33
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 6
  • Average time to close issues: N/A
  • Average time to close pull requests: about 19 hours
  • Issue authors: 0
  • Pull request authors: 3
  • Average comments per issue: 0
  • Average comments per pull request: 0.67
  • Merged pull requests: 2
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • HalosGhost (20)
  • rockett-m (8)
  • davebryson (6)
  • metalicjames (5)
  • madars (4)
  • narula (3)
  • dmtrinh (3)
  • SpencerC (3)
  • maurermi (3)
  • tanqiwen (2)
  • UrsaEli (2)
  • temucin (2)
  • llsuperpositionll (1)
  • wadagso-gertjaap (1)
  • youngseoka (1)
Pull Request Authors
  • metalicjames (19)
  • maurermi (14)
  • HalosGhost (14)
  • rockett-m (13)
  • eolesinski (7)
  • dmtrinh (5)
  • wadagso-gertjaap (4)
  • nicol-ii (4)
  • davebryson (3)
  • jallen-frb (2)
  • kylecrawshaw (2)
  • amar-4006 (2)
  • anders94 (2)
  • david8544 (2)
  • cdesch (2)
Top Labels
Issue Labels
fix/bug (21) enhancement/refactor (11) topic/hardening-security (10) enhancement/feature (10) topic/architecture (9) difficulty/02-low (9) feedback/question (9) difficulty/01-good-first-issue (9) enhancement/build-system (8) enhancement/optimization (7) feedback/proposal (7) difficulty/03-medium (6) enhancement/testing (4) enhancement/documentation (4) topic/privacy (3) feedback/logistics (3) status/on-hold (2) closed/cannot-reproduce (1) closed/duplicate (1) status/needs-triage (1) status/in-progress (1) closed/needs-information (1) difficulty/04-high (1) topic/programmability (1) topic/user-experience (1)
Pull Request Labels
fix/bug (3) enhancement/build-system (1)

Dependencies

.github/workflows/ci.yml actions
  • actions/checkout v2 composite
  • actions/upload-artifact v2 composite
.github/workflows/docker-merge.yml actions
  • actions/checkout v3 composite
  • docker/build-push-action v2 composite
  • docker/login-action v1 composite
  • docker/metadata-action v3 composite
  • docker/setup-buildx-action v1 composite
  • docker/setup-qemu-action v1 composite
.github/workflows/docker-pull.yml actions
  • actions/checkout v3 composite
  • tj-actions/changed-files v32 composite
.github/workflows/docker-push.yml actions
  • actions/checkout v3 composite
.github/workflows/pages.yml actions
  • actions/checkout v2 composite
  • mattnotmitt/doxygen-action edge composite
  • peaceiris/actions-gh-pages v3 composite
Dockerfile docker
  • $BASE_IMAGE latest build
  • $IMAGE_VERSION latest build
docker-compose-2pc.yml docker
  • opencbdc-tx-twophase latest
docker-compose-atomizer.yml docker
  • opencbdc-tx-atomizer latest
docker-compose-prebuilt-2pc.yml docker
  • ghcr.io/mit-dci/opencbdc-tx-twophase latest
docker-compose-prebuilt-atomizer.yml docker
  • ghcr.io/mit-dci/opencbdc-tx-atomizer latest
docker-compose-test-2pc.yml docker
  • opencbdc-tx-twophase latest
docker-compose-test-atomizer.yml docker
  • opencbdc-tx-atomizer latest
scripts/Dockerfile docker
  • ubuntu 20.04 build
charts/tests/go.mod go
  • cloud.google.com/go v0.83.0
  • github.com/aws/aws-sdk-go v1.40.56
  • github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc
  • github.com/cpuguy83/go-md2man/v2 v2.0.0
  • github.com/davecgh/go-spew v1.1.1
  • github.com/docker/spdystream v0.0.0-20181023171402-6480d4af844c
  • github.com/ghodss/yaml v1.0.0
  • github.com/go-errors/errors v1.0.2-0.20180813162953-d98b870cc4e0
  • github.com/go-logr/logr v0.2.0
  • github.com/go-sql-driver/mysql v1.4.1
  • github.com/gogo/protobuf v1.3.2
  • github.com/golang/protobuf v1.5.2
  • github.com/google/gofuzz v1.1.0
  • github.com/google/uuid v1.2.0
  • github.com/googleapis/gnostic v0.4.1
  • github.com/gruntwork-io/go-commons v0.8.0
  • github.com/gruntwork-io/terratest v0.40.20
  • github.com/hashicorp/errwrap v1.0.0
  • github.com/hashicorp/go-multierror v1.1.0
  • github.com/imdario/mergo v0.3.11
  • github.com/jmespath/go-jmespath v0.4.0
  • github.com/json-iterator/go v1.1.11
  • github.com/kelseyhightower/envconfig v1.4.0
  • github.com/mattn/go-zglob v0.0.2-0.20190814121620-e3c945676326
  • github.com/mitchellh/go-homedir v1.1.0
  • github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd
  • github.com/modern-go/reflect2 v1.0.1
  • github.com/pmezard/go-difflib v1.0.0
  • github.com/pquerna/otp v1.2.0
  • github.com/russross/blackfriday/v2 v2.1.0
  • github.com/spf13/pflag v1.0.5
  • github.com/stretchr/testify v1.7.0
  • github.com/urfave/cli v1.22.2
  • golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a
  • golang.org/x/net v0.0.0-20210614182718-04defd469f4e
  • golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c
  • golang.org/x/sys v0.0.0-20220517195934-5e4e11fc645e
  • golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1
  • golang.org/x/text v0.3.6
  • golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e
  • google.golang.org/appengine v1.6.7
  • google.golang.org/protobuf v1.26.0
  • gopkg.in/inf.v0 v0.9.1
  • gopkg.in/yaml.v2 v2.4.0
  • gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
  • k8s.io/api v0.20.6
  • k8s.io/apimachinery v0.20.6
  • k8s.io/client-go v0.20.6
  • k8s.io/klog/v2 v2.4.0
  • k8s.io/utils v0.0.0-20201110183641-67b214c5f920
  • sigs.k8s.io/structured-merge-diff/v4 v4.0.3
  • sigs.k8s.io/yaml v1.2.0
charts/tests/go.sum go
  • 619 dependencies
docker-compose-parsec-test.yml docker
  • opencbdc-tx latest
docker-compose-parsec.yml docker
  • opencbdc-tx-parsec latest
tools/bench/parsec/evm/contracts/package.json npm
  • @openzeppelin/contracts ^4.6.0
  • chai ^4.2.0
  • hardhat ^2.9.5
tools/bench/parsec/evm/contracts/pnpm-lock.yaml npm
  • 300 dependencies