Skip to content

Commit 1d47246

Browse files
authored
Merge branch 'master' into update-bn2-automation
2 parents 0c146e8 + ae79b52 commit 1d47246

File tree

99 files changed

+3944
-2666
lines changed

Some content is hidden

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

99 files changed

+3944
-2666
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ generate-mocks: install-mock-generators
161161
mockery --name '.*' --dir=engine/execution/computation/computer --case=underscore --output="./engine/execution/computation/computer/mock" --outpkg="mock"
162162
mockery --name '.*' --dir=engine/execution/state --case=underscore --output="./engine/execution/state/mock" --outpkg="mock"
163163
mockery --name '.*' --dir=engine/collection --case=underscore --output="./engine/collection/mock" --outpkg="mock"
164+
mockery --name 'complianceCore' --dir=engine/common/follower --exported --case=underscore --output="./engine/common/follower/mock" --outpkg="mock"
164165
mockery --name '.*' --dir=engine/common/follower/cache --case=underscore --output="./engine/common/follower/cache/mock" --outpkg="mock"
165166
mockery --name '.*' --dir=engine/consensus --case=underscore --output="./engine/consensus/mock" --outpkg="mock"
166167
mockery --name '.*' --dir=engine/consensus/approvals --case=underscore --output="./engine/consensus/approvals/mock" --outpkg="mock"

cmd/access/node_builder/access_node_builder.go

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
"github.com/onflow/flow-go/consensus"
2929
"github.com/onflow/flow-go/consensus/hotstuff"
3030
"github.com/onflow/flow-go/consensus/hotstuff/committees"
31+
"github.com/onflow/flow-go/consensus/hotstuff/notifications"
3132
consensuspubsub "github.com/onflow/flow-go/consensus/hotstuff/notifications/pubsub"
3233
"github.com/onflow/flow-go/consensus/hotstuff/signature"
3334
hotstuffvalidator "github.com/onflow/flow-go/consensus/hotstuff/validator"
@@ -39,17 +40,15 @@ import (
3940
"github.com/onflow/flow-go/engine/access/rpc"
4041
"github.com/onflow/flow-go/engine/access/rpc/backend"
4142
"github.com/onflow/flow-go/engine/access/state_stream"
42-
"github.com/onflow/flow-go/engine/common/follower"
4343
followereng "github.com/onflow/flow-go/engine/common/follower"
4444
"github.com/onflow/flow-go/engine/common/requester"
4545
synceng "github.com/onflow/flow-go/engine/common/synchronization"
4646
"github.com/onflow/flow-go/model/flow"
4747
"github.com/onflow/flow-go/model/flow/filter"
4848
"github.com/onflow/flow-go/module"
4949
"github.com/onflow/flow-go/module/blobs"
50-
"github.com/onflow/flow-go/module/buffer"
5150
"github.com/onflow/flow-go/module/chainsync"
52-
"github.com/onflow/flow-go/module/compliance"
51+
modulecompliance "github.com/onflow/flow-go/module/compliance"
5352
"github.com/onflow/flow-go/module/executiondatasync/execution_data"
5453
finalizer "github.com/onflow/flow-go/module/finalizer/consensus"
5554
"github.com/onflow/flow-go/module/id"
@@ -223,7 +222,7 @@ type FlowAccessNodeBuilder struct {
223222
// engines
224223
IngestEng *ingestion.Engine
225224
RequestEng *requester.Engine
226-
FollowerEng *followereng.Engine
225+
FollowerEng *followereng.ComplianceEngine
227226
SyncEng *synceng.Engine
228227
StateStreamEng *state_stream.Engine
229228
}
@@ -319,31 +318,39 @@ func (builder *FlowAccessNodeBuilder) buildFollowerCore() *FlowAccessNodeBuilder
319318

320319
func (builder *FlowAccessNodeBuilder) buildFollowerEngine() *FlowAccessNodeBuilder {
321320
builder.Component("follower engine", func(node *cmd.NodeConfig) (module.ReadyDoneAware, error) {
322-
// initialize cleaner for DB
323-
cleaner := bstorage.NewCleaner(node.Logger, node.DB, builder.Metrics.CleanCollector, flow.DefaultValueLogGCFrequency)
324-
conCache := buffer.NewPendingBlocks()
321+
var heroCacheCollector module.HeroCacheMetrics = metrics.NewNoopCollector()
322+
if node.HeroCacheMetricsEnable {
323+
heroCacheCollector = metrics.FollowerCacheMetrics(node.MetricsRegisterer)
324+
}
325325

326-
followerEng, err := follower.New(
326+
core, err := followereng.NewComplianceCore(
327327
node.Logger,
328-
node.Network,
329-
node.Me,
330-
node.Metrics.Engine,
331328
node.Metrics.Mempool,
332-
cleaner,
333-
node.Storage.Headers,
334-
node.Storage.Payloads,
329+
heroCacheCollector,
330+
builder.FinalizationDistributor,
335331
builder.FollowerState,
336-
conCache,
337332
builder.FollowerCore,
338333
builder.Validator,
339334
builder.SyncCore,
340335
node.Tracer,
341-
follower.WithComplianceOptions(compliance.WithSkipNewProposalsThreshold(builder.ComplianceConfig.SkipNewProposalsThreshold)),
336+
modulecompliance.WithSkipNewProposalsThreshold(node.ComplianceConfig.SkipNewProposalsThreshold),
337+
)
338+
if err != nil {
339+
return nil, fmt.Errorf("could not create follower core: %w", err)
340+
}
341+
342+
builder.FollowerEng, err = followereng.NewComplianceLayer(
343+
node.Logger,
344+
node.Network,
345+
node.Me,
346+
node.Metrics.Engine,
347+
node.Storage.Headers,
348+
builder.Finalized,
349+
core,
342350
)
343351
if err != nil {
344352
return nil, fmt.Errorf("could not create follower engine: %w", err)
345353
}
346-
builder.FollowerEng = followerEng
347354

348355
return builder.FollowerEng, nil
349356
})
@@ -560,10 +567,12 @@ func (builder *FlowAccessNodeBuilder) BuildExecutionDataRequester() *FlowAccessN
560567
}
561568

562569
func FlowAccessNode(nodeBuilder *cmd.FlowNodeBuilder) *FlowAccessNodeBuilder {
570+
dist := consensuspubsub.NewFinalizationDistributor()
571+
dist.AddConsumer(notifications.NewSlashingViolationsConsumer(nodeBuilder.Logger))
563572
return &FlowAccessNodeBuilder{
564573
AccessNodeConfig: DefaultAccessNodeConfig(),
565574
FlowNodeBuilder: nodeBuilder,
566-
FinalizationDistributor: consensuspubsub.NewFinalizationDistributor(),
575+
FinalizationDistributor: dist,
567576
}
568577
}
569578

cmd/bootstrap/run/execution_state.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ func GenerateServiceAccountPrivateKey(seed []byte) (flow.AccountPrivateKey, erro
3232
}, nil
3333
}
3434

35-
// NOTE: this is now unused and should become part of another tool.
3635
func GenerateExecutionState(
3736
dbDir string,
3837
accountKey flow.AccountPublicKey,

cmd/collection/main.go

Lines changed: 36 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"github.com/onflow/flow-go/consensus"
2121
"github.com/onflow/flow-go/consensus/hotstuff"
2222
"github.com/onflow/flow-go/consensus/hotstuff/committees"
23+
"github.com/onflow/flow-go/consensus/hotstuff/notifications"
2324
"github.com/onflow/flow-go/consensus/hotstuff/notifications/pubsub"
2425
"github.com/onflow/flow-go/consensus/hotstuff/pacemaker/timeout"
2526
hotsignature "github.com/onflow/flow-go/consensus/hotstuff/signature"
@@ -37,7 +38,6 @@ import (
3738
"github.com/onflow/flow-go/model/flow"
3839
"github.com/onflow/flow-go/model/flow/filter"
3940
"github.com/onflow/flow-go/module"
40-
"github.com/onflow/flow-go/module/buffer"
4141
builder "github.com/onflow/flow-go/module/builder/collection"
4242
"github.com/onflow/flow-go/module/chainsync"
4343
"github.com/onflow/flow-go/module/epochs"
@@ -50,7 +50,6 @@ import (
5050
badgerState "github.com/onflow/flow-go/state/protocol/badger"
5151
"github.com/onflow/flow-go/state/protocol/blocktimer"
5252
"github.com/onflow/flow-go/state/protocol/events/gadgets"
53-
storagekv "github.com/onflow/flow-go/storage/badger"
5453
)
5554

5655
func main() {
@@ -80,15 +79,14 @@ func main() {
8079
clusterComplianceConfig modulecompliance.Config
8180

8281
pools *epochpool.TransactionPools // epoch-scoped transaction pools
83-
followerBuffer *buffer.PendingBlocks // pending block cache for follower
8482
finalizationDistributor *pubsub.FinalizationDistributor
8583
finalizedHeader *consync.FinalizedHeaderCache
8684

8785
push *pusher.Engine
8886
ing *ingest.Engine
8987
mainChainSyncCore *chainsync.Core
9088
followerCore *hotstuff.FollowerLoop // follower hotstuff logic
91-
followerEng *followereng.Engine
89+
followerEng *followereng.ComplianceEngine
9290
colMetrics module.CollectionMetrics
9391
err error
9492

@@ -173,6 +171,11 @@ func main() {
173171

174172
nodeBuilder.
175173
PreInit(cmd.DynamicStartPreInit).
174+
Module("finalization distributor", func(node *cmd.NodeConfig) error {
175+
finalizationDistributor = pubsub.NewFinalizationDistributor()
176+
finalizationDistributor.AddConsumer(notifications.NewSlashingViolationsConsumer(node.Logger))
177+
return nil
178+
}).
176179
Module("mutable follower state", func(node *cmd.NodeConfig) error {
177180
// For now, we only support state implementations from package badger.
178181
// If we ever support different implementations, the following can be replaced by a type-aware factory
@@ -199,10 +202,6 @@ func main() {
199202
err := node.Metrics.Mempool.Register(metrics.ResourceTransaction, pools.CombinedSize)
200203
return err
201204
}).
202-
Module("pending block cache", func(node *cmd.NodeConfig) error {
203-
followerBuffer = buffer.NewPendingBlocks()
204-
return nil
205-
}).
206205
Module("metrics", func(node *cmd.NodeConfig) error {
207206
colMetrics = metrics.NewCollectionCollector(node.Tracer)
208207
return nil
@@ -251,6 +250,14 @@ func main() {
251250

252251
return validator, err
253252
}).
253+
Component("finalized snapshot", func(node *cmd.NodeConfig) (module.ReadyDoneAware, error) {
254+
finalizedHeader, err = consync.NewFinalizedHeaderCache(node.Logger, node.State, finalizationDistributor)
255+
if err != nil {
256+
return nil, fmt.Errorf("could not create finalized snapshot cache: %w", err)
257+
}
258+
259+
return finalizedHeader, nil
260+
}).
254261
Component("consensus committee", func(node *cmd.NodeConfig) (module.ReadyDoneAware, error) {
255262
// initialize consensus committee's membership state
256263
// This committee state is for the HotStuff follower, which follows the MAIN CONSENSUS Committee
@@ -270,7 +277,6 @@ func main() {
270277
packer := hotsignature.NewConsensusSigDataPacker(mainConsensusCommittee)
271278
// initialize the verifier for the protocol consensus
272279
verifier := verification.NewCombinedVerifier(mainConsensusCommittee, packer)
273-
finalizationDistributor = pubsub.NewFinalizationDistributor()
274280
// creates a consensus follower with noop consumer as the notifier
275281
followerCore, err = consensus.NewFollower(
276282
node.Logger,
@@ -290,45 +296,47 @@ func main() {
290296
return followerCore, nil
291297
}).
292298
Component("follower engine", func(node *cmd.NodeConfig) (module.ReadyDoneAware, error) {
293-
// initialize cleaner for DB
294-
cleaner := storagekv.NewCleaner(node.Logger, node.DB, node.Metrics.CleanCollector, flow.DefaultValueLogGCFrequency)
295-
296299
packer := hotsignature.NewConsensusSigDataPacker(mainConsensusCommittee)
297300
// initialize the verifier for the protocol consensus
298301
verifier := verification.NewCombinedVerifier(mainConsensusCommittee, packer)
299302

300303
validator := validator.New(mainConsensusCommittee, verifier)
301304

302-
followerEng, err = followereng.New(
305+
var heroCacheCollector module.HeroCacheMetrics = metrics.NewNoopCollector()
306+
if node.HeroCacheMetricsEnable {
307+
heroCacheCollector = metrics.FollowerCacheMetrics(node.MetricsRegisterer)
308+
}
309+
310+
core, err := followereng.NewComplianceCore(
303311
node.Logger,
304-
node.Network,
305-
node.Me,
306-
node.Metrics.Engine,
307312
node.Metrics.Mempool,
308-
cleaner,
309-
node.Storage.Headers,
310-
node.Storage.Payloads,
313+
heroCacheCollector,
314+
finalizationDistributor,
311315
followerState,
312-
followerBuffer,
313316
followerCore,
314317
validator,
315318
mainChainSyncCore,
316319
node.Tracer,
317-
followereng.WithComplianceOptions(modulecompliance.WithSkipNewProposalsThreshold(node.ComplianceConfig.SkipNewProposalsThreshold)),
320+
modulecompliance.WithSkipNewProposalsThreshold(node.ComplianceConfig.SkipNewProposalsThreshold),
318321
)
319322
if err != nil {
320-
return nil, fmt.Errorf("could not create follower engine: %w", err)
323+
return nil, fmt.Errorf("could not create follower core: %w", err)
321324
}
322325

323-
return followerEng, nil
324-
}).
325-
Component("finalized snapshot", func(node *cmd.NodeConfig) (module.ReadyDoneAware, error) {
326-
finalizedHeader, err = consync.NewFinalizedHeaderCache(node.Logger, node.State, finalizationDistributor)
326+
followerEng, err = followereng.NewComplianceLayer(
327+
node.Logger,
328+
node.Network,
329+
node.Me,
330+
node.Metrics.Engine,
331+
node.Storage.Headers,
332+
finalizedHeader.Get(),
333+
core,
334+
)
327335
if err != nil {
328-
return nil, fmt.Errorf("could not create finalized snapshot cache: %w", err)
336+
return nil, fmt.Errorf("could not create follower engine: %w", err)
329337
}
330338

331-
return finalizedHeader, nil
339+
return followerEng, nil
332340
}).
333341
Component("main chain sync engine", func(node *cmd.NodeConfig) (module.ReadyDoneAware, error) {
334342

cmd/consensus/main.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"github.com/onflow/flow-go/consensus/hotstuff"
2121
"github.com/onflow/flow-go/consensus/hotstuff/blockproducer"
2222
"github.com/onflow/flow-go/consensus/hotstuff/committees"
23+
"github.com/onflow/flow-go/consensus/hotstuff/notifications"
2324
"github.com/onflow/flow-go/consensus/hotstuff/notifications/pubsub"
2425
"github.com/onflow/flow-go/consensus/hotstuff/pacemaker/timeout"
2526
"github.com/onflow/flow-go/consensus/hotstuff/persister"
@@ -355,6 +356,7 @@ func main() {
355356
}).
356357
Module("finalization distributor", func(node *cmd.NodeConfig) error {
357358
finalizationDistributor = pubsub.NewFinalizationDistributor()
359+
finalizationDistributor.AddConsumer(notifications.NewSlashingViolationsConsumer(nodeBuilder.Logger))
358360
return nil
359361
}).
360362
Module("machine account config", func(node *cmd.NodeConfig) error {
@@ -683,20 +685,17 @@ func main() {
683685
return hot, nil
684686
}).
685687
Component("consensus compliance engine", func(node *cmd.NodeConfig) (module.ReadyDoneAware, error) {
686-
// initialize the entity database accessors
687-
cleaner := bstorage.NewCleaner(node.Logger, node.DB, node.Metrics.CleanCollector, flow.DefaultValueLogGCFrequency)
688-
689688
// initialize the pending blocks cache
690689
proposals := buffer.NewPendingBlocks()
691690

692691
logger := createLogger(node.Logger, node.RootChainID)
693-
complianceCore, err := compliance.NewCore(logger,
692+
complianceCore, err := compliance.NewCore(
693+
logger,
694694
node.Metrics.Engine,
695695
node.Metrics.Mempool,
696696
mainMetrics,
697697
node.Metrics.Compliance,
698698
node.Tracer,
699-
cleaner,
700699
node.Storage.Headers,
701700
node.Storage.Payloads,
702701
mutableState,

cmd/execution/README.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,6 @@ required to trigger this condition is put in place to prevent triggering it in c
6868
happen on unstable networks.
6969
EN keeps track of the highest block it has executed. This is not a Flow protocol feature, and only serves synchronisation needs.
7070

71-
### Execution State syncing
72-
Other execution node is queried for range of missing blocks and hold authority to decide if it's willing (and able) to answer this query.
73-
If so, it sends the `ExecutionStateDelta` which contains all the block data and results of execution.
74-
Currently, this is fully trusted operation, meaning data is applied as-is without any extra checks.
75-
7671
### Missing blocks
7772
If no other EN are available, the block-level synchronisation is started. This requests blocks from consensus nodes, and
7873
incoming blocks are processed as if they were received during normal mode of operation

0 commit comments

Comments
 (0)