flow-go

module
v0.38.0-preview.0.0.10 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: AGPL-3.0

README

Flow GoDoc

Flow is a fast, secure, and developer-friendly blockchain built to support the next generation of games, apps and the digital assets that power them. Read more about it here.

Table of Contents

Getting started

Documentation

You can find an overview of the Flow architecture on the documentation website.

Development on Flow is divided into work streams. Each work stream has a home directory containing high-level documentation for the stream, as well as links to documentation for relevant components used by that work stream.

The following table lists all work streams and links to their home directory and documentation:

Work Stream Home directory
Access Node /cmd/access
Collection Node /cmd/collection
Consensus Node /cmd/consensus
Execution Node /cmd/execution
Verification Node /cmd/verification
Observer Service /cmd/observer
HotStuff /consensus/hotstuff
Storage /storage
Ledger /ledger
Networking /network
Cryptography /crypto

Installation

  • Clone this repository

  • Install Go (Flow requires Go 1.22 and later)

  • Install Docker, which is used for running a local network and integration tests

  • Make sure the GOPATH and GOBIN environment variables are set, and GOBIN is added to your path:

    export GOPATH=$(go env GOPATH)
    export GOBIN=$GOPATH/bin
    export PATH=$PATH:$GOBIN
    

    Add these to your shell profile to persist them for future runs.

  • Then, run the following command:

    make install-tools
    

At this point, you should be ready to build, test, and run Flow! 🎉

Development Workflow

Testing

Flow has a unit test suite and an integration test suite. Unit tests for a module live within the module they are testing. Integration tests live in integration/tests.

Run the unit test suite:

make test

Run the integration test suite:

make integration-test
Building

The recommended way to build and run Flow for local development is using Docker.

Build a Docker image for all nodes:

make docker-native-build-flow

Build a Docker image for a particular node role (replace $ROLE with collection, consensus, etc.):

make docker-native-build-$ROLE
Building a binary for the access node

Build the binary for an access node that can be run directly on the machine without using Docker.

make docker-native-build-access-binary

this builds a binary for Linux/x86_64 machine.

The make command will generate a binary called flow_access_node

Importing the module

When importing the github.com/onflow/flow-go module in your Go project, testing or building your project may require setting extra Go flags because the module requires cgo. In particular, CGO_ENABLED must be set to 1 if cgo isn't enabled by default. This constraint comes from the underlying cryptography library. Refer to the crypto repository build for more details.

Local Network

A local version of the network can be run for manual testing and integration. See the Local Network Guide for instructions.

Code Generation

Generated code is kept up to date in the repository, so should be committed whenever it changes.

Run all code generators:

make generate

Generate protobuf stubs:

make generate-proto

Generate OpenAPI schema models:

make generate-openapi

Generate mocks used for unit tests:

make generate-mocks

Directories

Path Synopsis
Package admin is a reverse proxy.
Package admin is a reverse proxy.
cmd
bootstrap/cmd
contains CLI logic that can exit the program and read/write files.
contains CLI logic that can exit the program and read/write files.
bootstrap/run
contains reusable logic that does not know about a CLI.
contains reusable logic that does not know about a CLI.
build
Package build contains information about the build that injected at build-time.
Package build contains information about the build that injected at build-time.
testclient Module
hotstuff/cruisectl
Package cruisectl implements a "cruise control" system for Flow by adjusting nodes' latest ProposalTiming in response to changes in the measured view rate and target epoch switchover time.
Package cruisectl implements a "cruise control" system for Flow by adjusting nodes' latest ProposalTiming in response to changes in the measured view rate and target epoch switchover time.
crypto module
access/rest/common/models
* Access API * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: 1.0.0 * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
* Access API * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: 1.0.0 * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
access/rest/http/models
* Access API * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: 1.0.0 * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
* Access API * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: 1.0.0 * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
collection/ingest
Package ingest implements an engine for receiving transactions that need to be packaged into a collection.
Package ingest implements an engine for receiving transactions that need to be packaged into a collection.
collection/pusher
Package pusher implements an engine for providing access to resources held by the collection node, including collections, collection guarantees, and transactions.
Package pusher implements an engine for providing access to resources held by the collection node, including collections, collection guarantees, and transactions.
collection/rpc
Package rpc implements accepting transactions into the system.
Package rpc implements accepting transactions into the system.
common/grpc/compressor/deflate
Package deflate implements and registers the DEFLATE compressor during initialization.
Package deflate implements and registers the DEFLATE compressor during initialization.
fvm
evm
systemcontracts
Package systemcontracts stores canonical address locations for all system smart contracts and service events.
Package systemcontracts stores canonical address locations for all system smart contracts and service events.
insecure module
integration module
common/pathfinder
Package pathfinder computes the trie storage path for any given key/value pair
Package pathfinder computes the trie storage path for any given key/value pair
model
bootstrap
Package bootstrap defines canonical models and encoding for bootstrapping.
Package bootstrap defines canonical models and encoding for bootstrapping.
cluster
Package cluster contains models related to collection node cluster consensus.
Package cluster contains models related to collection node cluster consensus.
dkg
dkg
Package dkg implements a controller that manages the lifecycle of a Joint Feldman DKG node, as well as a broker that enables the controller to communicate with other nodes
Package dkg implements a controller that manages the lifecycle of a Joint Feldman DKG node, as well as a broker that enables the controller to communicate with other nodes
id
mocknetwork
Package mocknetwork is a generated GoMock package.
Package mocknetwork is a generated GoMock package.
p2p
p2p/node
Package p2pnode encapsulates the libp2p library
Package p2pnode encapsulates the libp2p library
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
tools
test_monitor/common
Package common has helper / utility functions used by all levels of flaky test monitor.
Package common has helper / utility functions used by all levels of flaky test monitor.
utils
binstat
Package binstat implements file based code statistics in bins.
Package binstat implements file based code statistics in bins.
dsl
io
rand
Package rand is a wrapper around `crypto/rand` that uses the system RNG underneath to extract secure entropy.
Package rand is a wrapper around `crypto/rand` that uses the system RNG underneath to extract secure entropy.

Jump to

Keyboard shortcuts

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