GNU Affero General Public License v3.0

项目介绍

onflow/flow-go 是一个托管在 GitHub 上的开源项目,主要使用 Go 编写,采用 GNU Affero General Public License v3.0 许可证,目前获得 569 个 Star、214 次 Fork。

仓库全名
onflow/flow-go
开源许可证
GNU Affero General Public License v3.0
Star 数
569
Fork 数
214
未关闭 Issue
272

README 摘要

flow-go — Flow Network Reference Implementation in Go Reference implementation of the Flow network in Go. Flow is a Layer 1 proof-of-stake blockchain built for consumer apps, AI Agents, and DeFi at scale. This repo hosts the node software — consensus, execution, verification, access, and collection roles — and the Cadence VM integration used on mainnet, testnet, and local networks. TL;DR What: flow-go is the Go…

完整内容见 GitHub 原始 README 或本页 。

常见问题

flow-go 用什么语言开发?

主要使用 Go 编写,采用 GNU Affero General Public License v3.0 许可证,目前有 569 个 Star。

flow-go 可以免费商用吗?

仓库标注的许可证为 GNU Affero General Public License v3.0,商用前请先阅读仓库 LICENSE 文件确认授权范围。

如何获取 flow-go 的源码?

可以直接克隆仓库:git clone https://github.com/onflow/flow-go.git;安装与运行步骤见仓库 README。

flow-go 最近还在维护吗?

仓库最近一次更新为 6月26日,当前有 272 个未关闭 Issue;Star 数为 569,可作为社区活跃度的参考。

README

flow-go — Flow Network Reference Implementation in Go

GoDoc License: AGPL v3 Release Discord Built on Flow

Reference implementation of the Flow network in Go. Flow is a Layer 1 proof-of-stake blockchain built for consumer apps, AI Agents, and DeFi at scale. This repo hosts the node software — consensus, execution, verification, access, and collection roles — and the Cadence VM integration used on mainnet, testnet, and local networks.

TL;DR

  • What: flow-go is the Go reference implementation of the Flow network, a Layer 1 proof-of-stake blockchain.
  • Who it’s for: protocol contributors, node operators, and teams building infrastructure on or adjacent to Flow.
  • Why use it: canonical source of truth for Flow consensus (HotStuff), multi-role architecture, Cadence VM integration, and Flow EVM.
  • Status: see Releases for the latest version. Live on mainnet.
  • License: AGPL-3.0
  • Related repos: cadence (language) · flow-cli (CLI) · fcl-js (JS client) · flow-go-sdk (Go client)
  • The reference Go implementation for the Flow network, open-sourced since 2019.

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.26 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

Mocks

We use github.com/vektra/mockery for mocking interfaces within tests. The configuration is in .mockery.yaml.

Adding and updating packages

You can add new packages by their fully qualified name. e.g.

github.com/onflow/flow-go/module/execution:

This will add all interfaces within the module/execution/ (non-recursive).

Mocking functions

Mockery dropped support for generating function mocks. Instead, you can use this pattern:

  1. Create a mock_interfaces directory in the package where the function mock exists.
  2. Add a file that mocks the function. for example, this mocks the `StateMachineEventsTelemetryFactory(candidateView uint64) protocol_state.StateMachineTelemetryConsumer
package mockinterfaces

import "github.com/onflow/flow-go/state/protocol/protocol_state"

// ExecForkActor allows to create a mock for the ExecForkActor callback
type StateMachineEventsTelemetryFactory interface {
	Execute(candidateView uint64) protocol_state.StateMachineTelemetryConsumer
}
  1. Add the package to .mockery.yaml. Note: specify the directory where you want the mock to be placed.
  github.com/onflow/flow-go/state/protocol/protocol_state/mock_interfaces:
    config:
      dir: "state/protocol/protocol_state/mock"

FAQ

What is flow-go?

flow-go is the Go reference implementation of the Flow network — a Layer 1 proof-of-stake blockchain. It implements the node software (Access, Collection, Consensus, Execution, Verification roles), the HotStuff consensus algorithm, ledger, storage, networking, and cryptography subsystems.

How does flow-go differ from the Cadence repo?

flow-go is the protocol / node implementation. onflow/cadence is the Cadence smart contract language (compiler, interpreter, type system). flow-go embeds the Cadence VM to execute transactions, but the language itself is developed in the Cadence repo.

What are the five node roles in Flow?

Access, Collection, Consensus, Execution, and Verification. Each has its own entry point under /cmd/. There is also an Observer service for staking-free read-only access.

Which Go version does flow-go require?

Go 1.26 or later. See the Installation section for the full environment setup.

Where is the consensus algorithm implemented?

Under /consensus/hotstuff. HotStuff is the BFT consensus family used by Flow.

How do I run a local Flow network?

See the Local Network Guide for a full local multi-role network suitable for integration testing.

Where do I report a security issue?

See SECURITY.md for the responsible disclosure policy.

About Flow

This repo is the Go reference implementation of the Flow network, a Layer 1 blockchain built for consumer applications, AI Agents, and DeFi at scale.

评论

暂无评论