go-algorand

module
v0.0.0-...-548b26a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 15, 2025 License: AGPL-3.0

README

go-algorand

Branch Build Status
rel/stable CircleCI
rel/beta CircleCI
rel/nightly CircleCI

Algorand's official implementation in Go.

Algorand is a permissionless, pure proof-of-stake blockchain that delivers decentralization, scalability, security, and transaction finality.

Getting Started

Visit our developer website for the most up-to-date information about using and installing the Algorand platform.

Building from Source

Development is done using the Go Programming Language. The Go version is specified in the project's go.mod file. This document assumes you have a functioning environment set up. If you need assistance setting up an environment, please visit the official Go documentation website.

Linux / OSX

We currently strive to support Debian-based distributions, with Ubuntu 20.04 as our official release target. Building on Arch Linux also works well. Our core engineering team uses Linux and OSX, so both environments are well-supported for development.

OSX Only: Homebrew (brew) must be installed before continuing. Here are the installation requirements.

Initial Environment Setup
git clone https://github.com/algorand/go-algorand
cd go-algorand
./scripts/configure_dev.sh
./scripts/buildtools/install_buildtools.sh

At this point, you are ready to build go-algorand. We use make and have several targets to automate common tasks.

Build
make install
Test
# Unit tests
make test

# Integration tests
make integration
Style and Checks
make fmt
make lint
make fix
make vet

Alternatively, run:

make sanity

Running a Node

Once the software is built, you'll find binaries in ${GOPATH}/bin, and a data directory will be initialized at ~/.algorand. Start your node with:

${GOPATH}/bin/goal node start -d ~/.algorand

Use:

${GOPATH}/bin/carpenter -d ~/.algorand

to see activity. Refer to the developer website for instructions on using different tools.

Providing Your Own Data Directory

You can run a node out of other directories than ~/.algorand and join networks other than mainnet. Just make a new directory and copy the genesis.json file for the network into it. For example:

mkdir ~/testnet_data
cp installer/genesis/testnet/genesis.json ~/testnet_data/genesis.json
${GOPATH}/bin/goal node start -d ~/testnet_data

Genesis files for mainnet, testnet, and betanet can be found in installer/genesis/.

Contributing

Please refer to our CONTRIBUTING document.

Project Layout

go-algorand is organized into various subsystems and packages:

Core

Provides core functionality to the algod and kmd daemons, as well as other tools and commands:

  • crypto: Contains the cryptographic constructions used for hashing, signatures, and VRFs. It also includes Algorand-specific details about spending keys, protocol keys, one-time-use signing keys, and how they relate to each other.
  • config: Holds configuration parameters, including those used locally by the node and those that must be agreed upon by the protocol.
  • data: Defines various types used throughout the codebase.
    • basics: Holds basic types such as MicroAlgos, account data, and addresses.
    • account: Defines accounts, including "root" accounts (which can spend money) and "participation" accounts (which can participate in the agreement protocol).
    • transactions: Defines transactions that accounts can issue against the Algorand state, including standard payments and participation key registration transactions.
    • bookkeeping: Defines blocks, which are batches of transactions atomically committed to Algorand.
    • pools: Implements the transaction pool, holding transactions seen by a node in memory before they are proposed in a block.
    • committee: Implements the credentials that authenticate a participating account's membership in the agreement protocol.
  • ledger (README): Contains the Algorand Ledger state machine, which holds the sequence of blocks. The Ledger executes the state transitions resulting from applying these blocks. It answers queries on blocks (e.g., what transactions were in the last committed block?) and on accounts (e.g., what is my balance?).
  • protocol: Declares constants used to identify protocol versions, tags for routing network messages, and prefixes for domain separation of cryptographic inputs. It also implements the canonical encoder.
  • network: Contains the code for participating in a mesh network based on WebSockets. It maintains connections to some number of peers, (optionally) accepts connections from peers, sends point-to-point and broadcast messages, and receives messages, routing them to various handler code (e.g., agreement/gossip/network.go registers three handlers).
    • rpcs: Contains the HTTP RPCs used by algod processes to query one another.
  • agreement (README): Contains the agreement service, which implements Algorand's Byzantine Agreement protocol. This protocol allows participating accounts to quickly confirm blocks in a fork-safe manner, provided that sufficient account stake is correctly executing the protocol.
  • node: Integrates the components above and handles initialization and shutdown. It provides queries into these components.
Daemon

Contains the two daemons that provide Algorand clients with services:

  • daemon/algod: Holds the algod daemon, which implements a participating node. algod allows a node to participate in the agreement protocol, submit and confirm transactions, and view the state of the Algorand Ledger.
    • daemon/algod/api (README): The REST interface used for interactions with algod.
  • daemon/kmd (README): Holds the kmd daemon, which allows a node to sign transactions. Since kmd is separate from algod, it enables a user to sign transactions on an air-gapped computer.
Interfacing

Enables developers to interface with the Algorand system:

  • cmd: Contains the primary commands defining entry points into the system.
    • cmd/catchupsrv (README): A tool to assist with processing historic blocks on a new node.
  • libgoal: Exports a Go interface useful for developers of Algorand clients.
  • tools (README): Various tools and utilities that don’t have a better place to go.
  • tools/debug: Holds secondary commands that assist developers during debugging.
  • tools/misc (README): Small tools that are handy in a pinch.
Deployment

Helps Algorand developers deploy networks of their own:

  • nodecontrol
  • docker
  • commandandcontrol (README): A tool to automate a network of algod instances.
  • components
  • netdeploy
Utilities

Provides utilities for the various components:

  • logging: A wrapper around logrus.
  • util: Contains a variety of utilities, including a codec, a SQLite wrapper, a goroutine pool, a timer interface, node metrics, and more.
Test
  • test (README): Contains end-to-end tests and utilities for the above components.

License

Please see the COPYING_FAQ for details on how to apply our license.

Copyright (C) 2019-2025, Algorand Inc.

Directories

Path Synopsis
Package agreement implements Algorand's agreement protocol, which enables all nodes to consistently update the state of the system.
Package agreement implements Algorand's agreement protocol, which enables all nodes to consistently update the state of the system.
agreementtest
Package agreementtest produces useful functions for testing code.
Package agreementtest produces useful functions for testing code.
gossip
Package gossip adapts the interface of network.GossipNode to agreement.Network.
Package gossip adapts the interface of network.GossipNode to agreement.Network.
cmd
algofix
Fix finds Go programs that use old APIs and rewrites them to use newer ones.
Fix finds Go programs that use old APIs and rewrites them to use newer ones.
dbgen
dbgen -i <inputfile> -o <outputfile> -p <pkgname> -n <funcname> generates an installation function for a sqlite3 database schema installation.
dbgen -i <inputfile> -o <outputfile> -p <pkgname> -n <funcname> generates an installation function for a sqlite3 database schema installation.
goal
Code generated by bundle_genesis_json.sh.
Code generated by bundle_genesis_json.sh.
incorporate
incorporate builds a genesis JSON file from a CSV file.
incorporate builds a genesis JSON file from a CSV file.
kmd
tealdbg
Code generated during build process.
Code generated during build process.
components
secp256k1
Package secp256k1 wraps the bitcoin secp256k1 C library.
Package secp256k1 wraps the bitcoin secp256k1 C library.
daemon
algod/api/server
Package server Algod REST API.
Package server Algod REST API.
algod/api/server/v2/generated/data
Package data provides primitives to interact with the openapi HTTP API.
Package data provides primitives to interact with the openapi HTTP API.
algod/api/server/v2/generated/experimental
Package experimental provides primitives to interact with the openapi HTTP API.
Package experimental provides primitives to interact with the openapi HTTP API.
algod/api/server/v2/generated/model
Package model provides primitives to interact with the openapi HTTP API.
Package model provides primitives to interact with the openapi HTTP API.
algod/api/server/v2/generated/nonparticipating/private
Package private provides primitives to interact with the openapi HTTP API.
Package private provides primitives to interact with the openapi HTTP API.
algod/api/server/v2/generated/nonparticipating/public
Package public provides primitives to interact with the openapi HTTP API.
Package public provides primitives to interact with the openapi HTTP API.
algod/api/server/v2/generated/participating/private
Package private provides primitives to interact with the openapi HTTP API.
Package private provides primitives to interact with the openapi HTTP API.
algod/api/server/v2/generated/participating/public
Package public provides primitives to interact with the openapi HTTP API.
Package public provides primitives to interact with the openapi HTTP API.
algod/api/spec/common
Package common defines models exposed by algod rest api
Package common defines models exposed by algod rest api
algod/api/spec/v2
Package v2 defines models exposed by algod rest api
Package v2 defines models exposed by algod rest api
kmd
kmd/api
Package api for KMD HTTP API
Package api for KMD HTTP API
kmd/lib/kmdapi
Code generated by bundle_swagger_json.sh, along with swagger.json.
Code generated by bundle_swagger_json.sh, along with swagger.json.
internal
logspec
Package logspec specifies the data format of event log statements.
Package logspec specifies the data format of event log statements.
p2p
Package node is the Algorand node itself, with functions exposed to the frontend
Package node is the Algorand node itself, with functions exposed to the frontend
shared
pingpong
Package pingpong provides a transaction generating utility for performance testing.
Package pingpong provides a transaction generating utility for performance testing.
test
commandandcontrol/cc_agent
cc_agent starts agent process on algod host
cc_agent starts agent process on algod host
tools
debug/carpenter
carpenter builds meaningful patterns out of raw Algorand logs
carpenter builds meaningful patterns out of raw Algorand logs
debug/chopper
chopper compares raw Algorand logs for matching catchpoint (balance trie) roots and labels
chopper compares raw Algorand logs for matching catchpoint (balance trie) roots and labels
debug/coroner
coroner performs post-mortem autospies on Algorand nodes
coroner performs post-mortem autospies on Algorand nodes
debug/genconsensusconfig
doberman will tell you when there's something wrong with the system
doberman will tell you when there's something wrong with the system
debug/logfilter
logfilter buffer go test output and make sure to limit the output to only the error-related stuff.
logfilter buffer go test output and make sure to limit the output to only the error-related stuff.
network/dnssec
Package dnssec provides net.Resolver-compatible methods for DNSSEC.
Package dnssec provides net.Resolver-compatible methods for DNSSEC.
teal/algotmpl
algotmpl is a command-line tool which provides documentation and fills out templates for users.
algotmpl is a command-line tool which provides documentation and fills out templates for users.
teal/dkey/dsign
dsign creates keys for signing data in LogicSig scripts.
dsign creates keys for signing data in LogicSig scripts.
x-repo-types Module
bloom
Package bloom implements Bloom filters.
Package bloom implements Bloom filters.
db
Package db defines database utility functions.
Package db defines database utility functions.
metrics
Package metrics provides a metric logging wrappers for Prometheus server.
Package metrics provides a metric logging wrappers for Prometheus server.
s3
tar
timers
Package timers provides a Clock abstraction useful for simulating timeouts.
Package timers provides a Clock abstraction useful for simulating timeouts.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL