Skip to content

Commit 7fb3409

Browse files
Merge branch 'master' into janez/flaky-test-fixes
2 parents 061b012 + e240bbc commit 7fb3409

61 files changed

Lines changed: 2870 additions & 957 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Changelog
2+
3+
Release notes and version history for flow-go are tracked via GitHub Releases:
4+
5+
- https://github.com/onflow/flow-go/releases
6+
7+
For user-facing changes per version, see the Releases page. Each release page contains the tag, release notes, and links to the associated commits and milestones.

CITATION.cff

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
cff-version: 1.2.0
2+
message: "If you use flow-go in your research or reference it in a publication, please cite it as below."
3+
title: "flow-go: Flow Network Reference Implementation in Go"
4+
abstract: "flow-go is the Go reference implementation of the Flow network, a Layer 1 proof-of-stake blockchain. It implements HotStuff consensus, a multi-role node architecture (Access, Collection, Consensus, Execution, Verification), the Flow Virtual Machine, ledger, networking, and cryptography subsystems."
5+
authors:
6+
- name: "Flow Foundation"
7+
website: "https://flow.com"
8+
repository-code: "https://github.com/onflow/flow-go"
9+
url: "https://flow.com"
10+
license: AGPL-3.0-only
11+
type: software
12+
keywords:
13+
- flow
14+
- flow-network
15+
- blockchain
16+
- layer-1
17+
- proof-of-stake
18+
- consensus
19+
- hotstuff
20+
- byzantine-fault-tolerance
21+
- cadence
22+
- smart-contracts
23+
- reference-implementation
24+
- distributed-systems
25+
- go

README.md

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,22 @@
1-
# Flow [![GoDoc](https://godoc.org/github.com/onflow/flow-go?status.svg)](https://godoc.org/github.com/onflow/flow-go)
1+
# flow-go — Flow Network Reference Implementation in Go
22

3-
Flow is a fast, secure, and developer-friendly blockchain built to support the next generation of games, apps and the
4-
digital assets that power them. Read more about it [here](https://github.com/onflow/flow).
3+
[![GoDoc](https://godoc.org/github.com/onflow/flow-go?status.svg)](https://godoc.org/github.com/onflow/flow-go)
4+
[![License: AGPL v3](https://img.shields.io/badge/License-AGPL_v3-blue.svg)](https://www.gnu.org/licenses/agpl-3.0)
5+
[![Release](https://img.shields.io/github/v/release/onflow/flow-go)](https://github.com/onflow/flow-go/releases)
6+
[![Discord](https://img.shields.io/badge/Discord-Flow-7289DA?logo=discord&logoColor=white)](https://discord.gg/flow)
7+
[![Built on Flow](https://img.shields.io/badge/Built_on-Flow-00EF8B)](https://flow.com)
8+
9+
Reference implementation of the [Flow network](https://flow.com) 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.
10+
11+
## TL;DR
12+
13+
- **What:** flow-go is the Go reference implementation of the Flow network, a Layer 1 proof-of-stake blockchain.
14+
- **Who it's for:** protocol contributors, node operators, and teams building infrastructure on or adjacent to Flow.
15+
- **Why use it:** canonical source of truth for Flow consensus (HotStuff), multi-role architecture, Cadence VM integration, and Flow EVM.
16+
- **Status:** see [Releases](https://github.com/onflow/flow-go/releases) for the latest version. Live on mainnet.
17+
- **License:** AGPL-3.0
18+
- **Related repos:** [cadence](https://github.com/onflow/cadence) (language) · [flow-cli](https://github.com/onflow/flow-cli) (CLI) · [fcl-js](https://github.com/onflow/fcl-js) (JS client) · [flow-go-sdk](https://github.com/onflow/flow-go-sdk) (Go client)
19+
- The reference Go implementation for the Flow network, open-sourced since 2019.
520

621
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
722
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
@@ -192,3 +207,35 @@ type StateMachineEventsTelemetryFactory interface {
192207
config:
193208
dir: "state/protocol/protocol_state/mock"
194209
```
210+
211+
## FAQ
212+
213+
### What is flow-go?
214+
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.
215+
216+
### How does flow-go differ from the Cadence repo?
217+
flow-go is the **protocol / node** implementation. [`onflow/cadence`](https://github.com/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.
218+
219+
### What are the five node roles in Flow?
220+
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.
221+
222+
### Which Go version does flow-go require?
223+
Go 1.25 or later. See the [Installation](#installation) section for the full environment setup.
224+
225+
### Where is the consensus algorithm implemented?
226+
Under [`/consensus/hotstuff`](/consensus/hotstuff). HotStuff is the BFT consensus family used by Flow.
227+
228+
### How do I run a local Flow network?
229+
See the [Local Network Guide](/integration/localnet/README.md) for a full local multi-role network suitable for integration testing.
230+
231+
### Where do I report a security issue?
232+
See [SECURITY.md](/SECURITY.md) for the responsible disclosure policy.
233+
234+
## About Flow
235+
236+
This repo is the Go reference implementation of the [Flow network](https://flow.com), a Layer 1 blockchain built for consumer applications, AI Agents, and DeFi at scale.
237+
238+
- Developer docs: https://developers.flow.com
239+
- Cadence language: https://cadence-lang.org
240+
- Community: [Flow Discord](https://discord.gg/flow) · [Flow Forum](https://forum.flow.com)
241+
- Governance: [Flow Improvement Proposals](https://github.com/onflow/flips)

cmd/access/node_builder/access_node_builder.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1763,6 +1763,10 @@ func (builder *FlowAccessNodeBuilder) extraFlags() {
17631763
return errors.New("execution-data-indexing-enabled must be set if store-tx-result-error-messages is enabled")
17641764
}
17651765

1766+
if builder.stateStreamConf.MaxGlobalStreams == 0 {
1767+
return errors.New("state-stream-global-max-streams must be greater than 0")
1768+
}
1769+
17661770
return nil
17671771
})
17681772
}

cmd/observer/node_builder/observer_builder.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -945,6 +945,10 @@ func (builder *ObserverServiceBuilder) extraFlags() {
945945
return errors.New("rest-max-request-size must be greater than 0")
946946
}
947947

948+
if builder.stateStreamConf.MaxGlobalStreams == 0 {
949+
return errors.New("state-stream-global-max-streams must be greater than 0")
950+
}
951+
948952
return nil
949953
})
950954
}

cmd/scaffold.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ import (
5656
netcache "github.com/onflow/flow-go/network/cache"
5757
"github.com/onflow/flow-go/network/channels"
5858
"github.com/onflow/flow-go/network/converter"
59+
"github.com/onflow/flow-go/network/message"
5960
"github.com/onflow/flow-go/network/p2p"
6061
p2pbuilder "github.com/onflow/flow-go/network/p2p/builder"
6162
p2pbuilderconfig "github.com/onflow/flow-go/network/p2p/builder/config"
@@ -691,6 +692,13 @@ func (fnb *FlowNodeBuilder) InitFlowNetworkWithConduitFactory(
691692
SlashingViolationConsumerFactory: func(adapter network.ConduitAdapter) network.ViolationsConsumer {
692693
return slashing.NewSlashingViolationsConsumer(fnb.Logger, fnb.Metrics.Network, adapter)
693694
},
695+
UnicastStreamAuthorizer: func() func(flow.Role, flow.Role) bool {
696+
if fnb.ObserverMode {
697+
// observer mode uses public network where peers are not authorized based on role
698+
return message.AlwaysAuthorizedUnicastSenderRole
699+
}
700+
return nil // use default (IsAuthorizedUnicastSenderRole)
701+
}(),
694702
}, networkOptions...)
695703
if err != nil {
696704
return nil, fmt.Errorf("could not initialize network: %w", err)

cmd/util/cmd/checkpoint-collect-stats/cmd.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ import (
1919

2020
"github.com/onflow/flow-go/cmd/util/ledger/reporters"
2121
"github.com/onflow/flow-go/cmd/util/ledger/util"
22+
"github.com/onflow/flow-go/fvm/environment"
2223
"github.com/onflow/flow-go/fvm/evm/emulator/state"
23-
"github.com/onflow/flow-go/fvm/evm/handler"
2424
"github.com/onflow/flow-go/ledger"
2525
"github.com/onflow/flow-go/ledger/common/pathfinder"
2626
"github.com/onflow/flow-go/ledger/complete"
@@ -465,9 +465,9 @@ func getRegisterType(key ledger.Key) string {
465465
return "account storage ID"
466466
case state.CodesStorageIDKey:
467467
return "code storage ID"
468-
case handler.BlockStoreLatestBlockKey:
468+
case environment.BlockStoreLatestBlockKey:
469469
return "latest block"
470-
case handler.BlockStoreLatestBlockProposalKey:
470+
case environment.BlockStoreLatestBlockProposalKey:
471471
return "latest block proposal"
472472
}
473473

cmd/util/cmd/inspect-token-movements/cmd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func run(*cobra.Command, []string) {
8181
}()
8282

8383
// Create the token changes inspector with default search tokens for this chain
84-
inspector := inspection.NewTokenChangesInspector(inspection.DefaultTokenDiffSearchTokens(chain, true), chainID)
84+
inspector := inspection.NewTokenChangesInspector(inspection.DefaultTokenDiffSearchTokens(chain), chainID)
8585

8686
var from, to uint64
8787

cmd/util/cmd/verify_execution_result/cmd.go

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,27 +88,58 @@ func run(*cobra.Command, []string) {
8888
lg.Info().Msgf("look for 'could not verify' in the log for any mismatch, or try again with --stop_on_mismatch true to stop on first mismatch")
8989
}
9090

91+
var totalStats verifier.BlockVerificationStats
92+
9193
if flagFromTo != "" {
9294
from, to, err := parseFromTo(flagFromTo)
9395
if err != nil {
9496
lg.Fatal().Err(err).Msg("could not parse from_to")
9597
}
9698

9799
lg.Info().Msgf("verifying range from %d to %d", from, to)
98-
err = verifier.VerifyRange(lockManager, from, to, chainID, flagDatadir, flagChunkDataPackDir, flagWorkerCount, flagStopOnMismatch, flagtransactionFeesDisabled, flagScheduledTransactionsEnabled)
100+
totalStats, err = verifier.VerifyRange(
101+
lockManager,
102+
from,
103+
to,
104+
chainID,
105+
flagDatadir,
106+
flagChunkDataPackDir,
107+
flagWorkerCount,
108+
flagStopOnMismatch,
109+
flagtransactionFeesDisabled,
110+
flagScheduledTransactionsEnabled,
111+
)
99112
if err != nil {
100113
lg.Fatal().Err(err).Msgf("could not verify range from %d to %d", from, to)
101114
}
102-
lg.Info().Msgf("finished verified range from %d to %d", from, to)
115+
lg.Info().Msgf("finished verifying range from %d to %d", from, to)
103116
} else {
104117
lg.Info().Msgf("verifying last %d sealed blocks", flagLastK)
105-
err := verifier.VerifyLastKHeight(lockManager, flagLastK, chainID, flagDatadir, flagChunkDataPackDir, flagWorkerCount, flagStopOnMismatch, flagtransactionFeesDisabled, flagScheduledTransactionsEnabled)
118+
var err error
119+
totalStats, err = verifier.VerifyLastKHeight(
120+
lockManager,
121+
flagLastK,
122+
chainID,
123+
flagDatadir,
124+
flagChunkDataPackDir,
125+
flagWorkerCount,
126+
flagStopOnMismatch,
127+
flagtransactionFeesDisabled,
128+
flagScheduledTransactionsEnabled,
129+
)
106130
if err != nil {
107131
lg.Fatal().Err(err).Msg("could not verify last k height")
108132
}
109133

110-
lg.Info().Msgf("finished verified last %d sealed blocks", flagLastK)
134+
lg.Info().Msgf("finished verifying last %d sealed blocks", flagLastK)
111135
}
136+
137+
lg.Info().Msgf("matching chunks: %d/%d. matching transactions: %d/%d",
138+
totalStats.MatchedChunkCount,
139+
totalStats.MatchedChunkCount+totalStats.MismatchedChunkCount,
140+
totalStats.MatchedTransactionCount,
141+
totalStats.MatchedTransactionCount+totalStats.MismatchedTransactionCount,
142+
)
112143
}
113144

114145
func parseFromTo(fromTo string) (from, to uint64, err error) {

context7.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"url": "https://context7.com/onflow/flow-go",
3+
"public_key": "pk_EZ8p3YOFzJRKvdNkXGanl"
4+
}

0 commit comments

Comments
 (0)