Skip to content

Commit

Permalink
Merge pull request #4693 from onflow/tarak/blst-update-blst
Browse files Browse the repository at this point in the history
[Crypto] update BLST version
  • Loading branch information
tarakby authored Sep 13, 2023
2 parents e478781 + 633f152 commit 6fb9707
Show file tree
Hide file tree
Showing 301 changed files with 9,457 additions and 6,258 deletions.
2 changes: 1 addition & 1 deletion CodingConventions.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ happy path is either
Therefore, changing the set of specified sentinel errors is generally considered a breaking API change.


2. **All errors beyond the specified, benign sentinel errors ere considered unexpected failures, i.e. a symptom for potential state corruption.**
2. **All errors beyond the specified, benign sentinel errors are considered unexpected failures, i.e. a symptom of potential state corruption.**
* We employ a fundamental principle of [High Assurance Software Engineering](https://www.researchgate.net/publication/228563190_High_Assurance_Software_Development),
where we treat everything beyond the known benign errors as critical failures. In unexpected failure cases, we assume that the vertex's in-memory state has been
broken and proper functioning is no longer guaranteed. The only safe route of recovery is to restart the vertex from a previously persisted, safe state.
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ generate-mocks: install-mock-generators
mockery --name '(Connector|PingInfoProvider)' --dir=network/p2p --case=underscore --output="./network/mocknetwork" --outpkg="mocknetwork"
$(CGO_FLAG) mockgen -destination=storage/mocks/storage.go -package=mocks github.com/onflow/flow-go/storage Blocks,Headers,Payloads,Collections,Commits,Events,ServiceEvents,TransactionResults
$(CGO_FLAG) mockgen -destination=module/mocks/network.go -package=mocks github.com/onflow/flow-go/module Local,Requester
$(CGO_FLAG) mockgen -destination=network/mocknetwork/mock_network.go -package=mocknetwork github.com/onflow/flow-go/network Network
$(CGO_FLAG) mockgen -destination=network/mocknetwork/mock_network.go -package=mocknetwork github.com/onflow/flow-go/network EngineRegistry
mockery --name='.*' --dir=integration/benchmark/mocksiface --case=underscore --output="integration/benchmark/mock" --outpkg="mock"
mockery --name=ExecutionDataStore --dir=module/executiondatasync/execution_data --case=underscore --output="./module/executiondatasync/execution_data/mock" --outpkg="mock"
mockery --name=Downloader --dir=module/executiondatasync/execution_data --case=underscore --output="./module/executiondatasync/execution_data/mock" --outpkg="mock"
Expand Down
124 changes: 42 additions & 82 deletions cmd/access/node_builder/access_node_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,15 @@ import (
"github.com/onflow/flow-go/network/p2p/conduit"
"github.com/onflow/flow-go/network/p2p/connection"
"github.com/onflow/flow-go/network/p2p/dht"
"github.com/onflow/flow-go/network/p2p/middleware"
"github.com/onflow/flow-go/network/p2p/p2pbuilder"
p2pconfig "github.com/onflow/flow-go/network/p2p/p2pbuilder/config"
"github.com/onflow/flow-go/network/p2p/p2pnet"
"github.com/onflow/flow-go/network/p2p/subscription"
"github.com/onflow/flow-go/network/p2p/tracer"
"github.com/onflow/flow-go/network/p2p/translator"
"github.com/onflow/flow-go/network/p2p/unicast/protocols"
relaynet "github.com/onflow/flow-go/network/relay"
"github.com/onflow/flow-go/network/slashing"
"github.com/onflow/flow-go/network/topology"
"github.com/onflow/flow-go/network/validator"
"github.com/onflow/flow-go/state/protocol"
Expand Down Expand Up @@ -137,7 +138,7 @@ type AccessNodeConfig struct {
type PublicNetworkConfig struct {
// NetworkKey crypto.PublicKey // TODO: do we need a different key for the public network?
BindAddress string
Network network.Network
Network network.EngineRegistry
Metrics module.NetworkMetrics
}

Expand Down Expand Up @@ -386,7 +387,7 @@ func (builder *FlowAccessNodeBuilder) buildFollowerEngine() *FlowAccessNodeBuild

builder.FollowerEng, err = followereng.NewComplianceLayer(
node.Logger,
node.Network,
node.EngineRegistry,
node.Me,
node.Metrics.Engine,
node.Storage.Headers,
Expand All @@ -410,7 +411,7 @@ func (builder *FlowAccessNodeBuilder) buildSyncEngine() *FlowAccessNodeBuilder {
sync, err := synceng.New(
node.Logger,
node.Metrics.Engine,
node.Network,
node.EngineRegistry,
node.Me,
node.State,
node.Storage.Blocks,
Expand Down Expand Up @@ -513,7 +514,7 @@ func (builder *FlowAccessNodeBuilder) BuildExecutionDataRequester() *FlowAccessN
}

var err error
bs, err = node.Network.RegisterBlobService(channels.ExecutionDataService, ds, opts...)
bs, err = node.EngineRegistry.RegisterBlobService(channels.ExecutionDataService, ds, opts...)
if err != nil {
return nil, fmt.Errorf("could not register blob service: %w", err)
}
Expand Down Expand Up @@ -794,46 +795,6 @@ func (builder *FlowAccessNodeBuilder) extraFlags() {
})
}

// initNetwork creates the network.Network implementation with the given metrics, middleware, initial list of network
// participants and topology used to choose peers from the list of participants. The list of participants can later be
// updated by calling network.SetIDs.
func (builder *FlowAccessNodeBuilder) initNetwork(nodeID module.Local,
networkMetrics module.NetworkCoreMetrics,
middleware network.Middleware,
topology network.Topology,
receiveCache *netcache.ReceiveCache,
) (*p2p.Network, error) {
// creates network instance
net, err := p2p.NewNetwork(&p2p.NetworkConfig{
Logger: builder.Logger,
Codec: cborcodec.NewCodec(),
Me: nodeID,
MiddlewareFactory: func() (network.Middleware, error) { return builder.Middleware, nil },
Topology: topology,
SubscriptionManager: subscription.NewChannelSubscriptionManager(middleware),
Metrics: networkMetrics,
IdentityProvider: builder.IdentityProvider,
ReceiveCache: receiveCache,
ConduitFactory: conduit.NewDefaultConduitFactory(),
SporkId: builder.SporkID,
AlspCfg: &alspmgr.MisbehaviorReportManagerConfig{
Logger: builder.Logger,
SpamRecordCacheSize: builder.FlowConfig.NetworkConfig.AlspConfig.SpamRecordCacheSize,
SpamReportQueueSize: builder.FlowConfig.NetworkConfig.AlspConfig.SpamReportQueueSize,
DisablePenalty: builder.FlowConfig.NetworkConfig.AlspConfig.DisablePenalty,
HeartBeatInterval: builder.FlowConfig.NetworkConfig.AlspConfig.HearBeatInterval,
AlspMetrics: builder.Metrics.Network,
NetworkType: network.PublicNetwork,
HeroCacheMetricsFactory: builder.HeroCacheMetricsFactory(),
},
})
if err != nil {
return nil, fmt.Errorf("could not initialize network: %w", err)
}

return net, nil
}

func publicNetworkMsgValidators(log zerolog.Logger, idProvider module.IdentityProvider, selfID flow.Identifier) []network.MessageValidator {
return []network.MessageValidator{
// filter out messages sent by this node itself
Expand All @@ -860,7 +821,7 @@ func (builder *FlowAccessNodeBuilder) InitIDProviders() {
// The following wrapper allows to disallow-list byzantine nodes via an admin command:
// the wrapper overrides the 'Ejected' flag of disallow-listed nodes to true
disallowListWrapper, err := cache.NewNodeDisallowListWrapper(idCache, node.DB, func() network.DisallowListNotificationConsumer {
return builder.Middleware
return builder.NetworkUnderlay
})
if err != nil {
return fmt.Errorf("could not initialize NodeBlockListWrapper: %w", err)
Expand All @@ -879,7 +840,7 @@ func (builder *FlowAccessNodeBuilder) InitIDProviders() {
filter.And(
filter.HasRole(flow.RoleConsensus),
filter.Not(filter.HasNodeID(node.Me.NodeID())),
p2p.NotEjectedFilter,
p2pnet.NotEjectedFilter,
),
builder.IdentityProvider,
)
Expand Down Expand Up @@ -924,14 +885,14 @@ func (builder *FlowAccessNodeBuilder) Initialize() error {
func (builder *FlowAccessNodeBuilder) enqueueRelayNetwork() {
builder.Component("relay network", func(node *cmd.NodeConfig) (module.ReadyDoneAware, error) {
relayNet := relaynet.NewRelayNetwork(
node.Network,
node.EngineRegistry,
builder.AccessNodeConfig.PublicNetworkConfig.Network,
node.Logger,
map[channels.Channel]channels.Channel{
channels.ReceiveBlocks: channels.PublicReceiveBlocks,
},
)
node.Network = relayNet
node.EngineRegistry = relayNet
return relayNet, nil
})
}
Expand Down Expand Up @@ -1164,7 +1125,7 @@ func (builder *FlowAccessNodeBuilder) Build() (cmd.Node, error) {
builder.RequestEng, err = requester.New(
node.Logger,
node.Metrics.Engine,
node.Network,
node.EngineRegistry,
node.Me,
node.State,
channels.RequestCollections,
Expand All @@ -1177,7 +1138,7 @@ func (builder *FlowAccessNodeBuilder) Build() (cmd.Node, error) {

builder.IngestEng, err = ingestion.New(
node.Logger,
node.Network,
node.EngineRegistry,
node.State,
node.Me,
builder.RequestEng,
Expand Down Expand Up @@ -1289,11 +1250,6 @@ func (builder *FlowAccessNodeBuilder) enqueuePublicNetworkInit() {
}).
Component("public network", func(node *cmd.NodeConfig) (module.ReadyDoneAware, error) {
msgValidators := publicNetworkMsgValidators(node.Logger.With().Bool("public", true).Logger(), node.IdentityProvider, builder.NodeID)

middleware := builder.initMiddleware(builder.NodeID, builder.PublicNetworkConfig.Metrics, publicLibp2pNode, msgValidators...)

// topology returns empty list since peers are not known upfront
top := topology.EmptyTopology{}
receiveCache := netcache.NewHeroReceiveCache(builder.FlowConfig.NetworkConfig.NetworkReceivedMessageCacheSize,
builder.Logger,
metrics.NetworkReceiveCacheMetricsFactory(builder.HeroCacheMetricsFactory(), network.PublicNetwork))
Expand All @@ -1303,11 +1259,39 @@ func (builder *FlowAccessNodeBuilder) enqueuePublicNetworkInit() {
return nil, fmt.Errorf("could not register networking receive cache metric: %w", err)
}

net, err := builder.initNetwork(builder.Me, builder.PublicNetworkConfig.Metrics, middleware, top, receiveCache)
net, err := p2pnet.NewNetwork(&p2pnet.NetworkConfig{
Logger: builder.Logger.With().Str("module", "public-network").Logger(),
Libp2pNode: publicLibp2pNode,
Codec: cborcodec.NewCodec(),
Me: builder.Me,
Topology: topology.EmptyTopology{}, // topology returns empty list since peers are not known upfront
Metrics: builder.PublicNetworkConfig.Metrics,
BitSwapMetrics: builder.Metrics.Bitswap,
IdentityProvider: builder.IdentityProvider,
ReceiveCache: receiveCache,
ConduitFactory: conduit.NewDefaultConduitFactory(),
SporkId: builder.SporkID,
UnicastMessageTimeout: p2pnet.DefaultUnicastTimeout,
IdentityTranslator: builder.IDTranslator,
AlspCfg: &alspmgr.MisbehaviorReportManagerConfig{
Logger: builder.Logger,
SpamRecordCacheSize: builder.FlowConfig.NetworkConfig.AlspConfig.SpamRecordCacheSize,
SpamReportQueueSize: builder.FlowConfig.NetworkConfig.AlspConfig.SpamReportQueueSize,
DisablePenalty: builder.FlowConfig.NetworkConfig.AlspConfig.DisablePenalty,
HeartBeatInterval: builder.FlowConfig.NetworkConfig.AlspConfig.HearBeatInterval,
AlspMetrics: builder.Metrics.Network,
NetworkType: network.PublicNetwork,
HeroCacheMetricsFactory: builder.HeroCacheMetricsFactory(),
},
SlashingViolationConsumerFactory: func(adapter network.ConduitAdapter) network.ViolationsConsumer {
return slashing.NewSlashingViolationsConsumer(builder.Logger, builder.Metrics.Network, adapter)
},
}, p2pnet.WithMessageValidators(msgValidators...))
if err != nil {
return nil, err
return nil, fmt.Errorf("could not initialize network: %w", err)
}

builder.NetworkUnderlay = net
builder.AccessNodeConfig.PublicNetworkConfig.Network = net

node.Logger.Info().Msgf("network will run on address: %s", builder.PublicNetworkConfig.BindAddress)
Expand Down Expand Up @@ -1407,27 +1391,3 @@ func (builder *FlowAccessNodeBuilder) initPublicLibp2pNode(networkKey crypto.Pri

return libp2pNode, nil
}

// initMiddleware creates the network.Middleware implementation with the libp2p factory function, metrics, peer update
// interval, and validators. The network.Middleware is then passed into the initNetwork function.
func (builder *FlowAccessNodeBuilder) initMiddleware(nodeID flow.Identifier,
networkMetrics module.NetworkSecurityMetrics,
libp2pNode p2p.LibP2PNode,
validators ...network.MessageValidator,
) network.Middleware {
logger := builder.Logger.With().Bool("staked", false).Logger()
mw := middleware.NewMiddleware(&middleware.Config{
Logger: logger,
Libp2pNode: libp2pNode,
FlowId: nodeID,
BitSwapMetrics: builder.Metrics.Bitswap,
SporkId: builder.SporkID,
UnicastMessageTimeout: middleware.DefaultUnicastTimeout,
IdTranslator: builder.IDTranslator,
Codec: builder.CodecFactory(),
},
middleware.WithMessageValidators(validators...), // use default identifier provider
)
builder.Middleware = mw
return builder.Middleware
}
16 changes: 8 additions & 8 deletions cmd/collection/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ func main() {

followerEng, err = followereng.NewComplianceLayer(
node.Logger,
node.Network,
node.EngineRegistry,
node.Me,
node.Metrics.Engine,
node.Storage.Headers,
Expand All @@ -359,7 +359,7 @@ func main() {
sync, err := consync.New(
node.Logger,
node.Metrics.Engine,
node.Network,
node.EngineRegistry,
node.Me,
node.State,
node.Storage.Blocks,
Expand All @@ -378,7 +378,7 @@ func main() {
Component("ingestion engine", func(node *cmd.NodeConfig) (module.ReadyDoneAware, error) {
ing, err = ingest.New(
node.Logger,
node.Network,
node.EngineRegistry,
node.State,
node.Metrics.Engine,
node.Metrics.Mempool,
Expand Down Expand Up @@ -416,7 +416,7 @@ func main() {
return provider.New(
node.Logger,
node.Metrics.Engine,
node.Network,
node.EngineRegistry,
node.Me,
node.State,
collectionRequestQueue,
Expand All @@ -432,7 +432,7 @@ func main() {
Component("pusher engine", func(node *cmd.NodeConfig) (module.ReadyDoneAware, error) {
push, err = pusher.New(
node.Logger,
node.Network,
node.EngineRegistry,
node.State,
node.Metrics.Engine,
colMetrics,
Expand Down Expand Up @@ -479,7 +479,7 @@ func main() {

complianceEngineFactory, err := factories.NewComplianceEngineFactory(
node.Logger,
node.Network,
node.EngineRegistry,
node.Me,
colMetrics,
node.Metrics.Engine,
Expand All @@ -500,7 +500,7 @@ func main() {
syncFactory, err := factories.NewSyncEngineFactory(
node.Logger,
node.Metrics.Engine,
node.Network,
node.EngineRegistry,
node.Me,
)
if err != nil {
Expand Down Expand Up @@ -554,7 +554,7 @@ func main() {

messageHubFactory := factories.NewMessageHubFactory(
node.Logger,
node.Network,
node.EngineRegistry,
node.Me,
node.Metrics.Engine,
node.State,
Expand Down
14 changes: 7 additions & 7 deletions cmd/consensus/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ func main() {
node.Metrics.Engine,
node.Metrics.Mempool,
sealingTracker,
node.Network,
node.EngineRegistry,
node.Me,
node.Storage.Headers,
node.Storage.Payloads,
Expand All @@ -480,7 +480,7 @@ func main() {
receiptRequester, err = requester.New(
node.Logger,
node.Metrics.Engine,
node.Network,
node.EngineRegistry,
node.Me,
node.State,
channels.RequestReceiptsByBlockID,
Expand Down Expand Up @@ -511,7 +511,7 @@ func main() {

e, err := matching.NewEngine(
node.Logger,
node.Network,
node.EngineRegistry,
node.Me,
node.Metrics.Engine,
node.Metrics.Mempool,
Expand Down Expand Up @@ -544,7 +544,7 @@ func main() {
ing, err := ingestion.New(
node.Logger,
node.Metrics.Engine,
node.Network,
node.EngineRegistry,
node.Me,
core,
)
Expand Down Expand Up @@ -823,7 +823,7 @@ func main() {
messageHub, err := message_hub.NewMessageHub(
createLogger(node.Logger, node.RootChainID),
node.Metrics.Engine,
node.Network,
node.EngineRegistry,
node.Me,
comp,
hot,
Expand All @@ -842,7 +842,7 @@ func main() {
sync, err := synceng.New(
node.Logger,
node.Metrics.Engine,
node.Network,
node.EngineRegistry,
node.Me,
node.State,
node.Storage.Blocks,
Expand Down Expand Up @@ -872,7 +872,7 @@ func main() {
// exchange private DKG messages
messagingEngine, err := dkgeng.NewMessagingEngine(
node.Logger,
node.Network,
node.EngineRegistry,
node.Me,
dkgBrokerTunnel,
node.Metrics.Mempool,
Expand Down
Loading

0 comments on commit 6fb9707

Please sign in to comment.