Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Access] Add compatible range to Node Version Info endpoint #6294

Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
1b29583
Updated protobuf version, added compatible range to rpc NodeVersionIn…
UlyanaAndrukhiv Aug 5, 2024
030fdb9
Updated backend for NodeVersionInfo, updated rpc handler
UlyanaAndrukhiv Aug 5, 2024
b3d9086
Updated REST endpoint
UlyanaAndrukhiv Aug 5, 2024
afbdcc0
Updated functional test for REST endpoint
UlyanaAndrukhiv Aug 5, 2024
0578781
Updated test
UlyanaAndrukhiv Aug 5, 2024
7d91f26
Updated backend stream transaction test according to changes
UlyanaAndrukhiv Aug 5, 2024
cfcbe4a
Added additional test case for NodeVersionInfo endpoint
UlyanaAndrukhiv Aug 5, 2024
ce0af54
Merge branch 'master' into UlyanaAndrukhiv/6248-compatible-range-to-n…
UlyanaAndrukhiv Aug 6, 2024
1cb26f9
Updated naming according to comment
UlyanaAndrukhiv Aug 6, 2024
9d1648a
Merge branch 'UlyanaAndrukhiv/6248-compatible-range-to-node-version' …
UlyanaAndrukhiv Aug 6, 2024
d88140d
Merge branch 'master' into UlyanaAndrukhiv/6248-compatible-range-to-n…
UlyanaAndrukhiv Aug 8, 2024
69e5d4d
Merge branch 'master' into UlyanaAndrukhiv/6248-compatible-range-to-n…
UlyanaAndrukhiv Aug 9, 2024
e465fdf
Merge branch 'master' into UlyanaAndrukhiv/6248-compatible-range-to-n…
UlyanaAndrukhiv Aug 9, 2024
f7ac659
Updated protobuf and REST versions, moved NodeVersionInfo to model/fl…
UlyanaAndrukhiv Aug 12, 2024
b3fafd3
Merge branch 'UlyanaAndrukhiv/6248-compatible-range-to-node-version' …
UlyanaAndrukhiv Aug 12, 2024
d617224
Merge branch 'master' into UlyanaAndrukhiv/6248-compatible-range-to-n…
UlyanaAndrukhiv Aug 12, 2024
b8471a6
Added lint to integration makefile
UlyanaAndrukhiv Aug 12, 2024
3df9a49
Updated flow-emulator version
UlyanaAndrukhiv Aug 12, 2024
e236969
Merge branch 'master' into UlyanaAndrukhiv/6248-compatible-range-to-n…
UlyanaAndrukhiv Aug 12, 2024
f8a6fc0
Merged with master
UlyanaAndrukhiv Aug 13, 2024
e62d36a
Merge branch 'UlyanaAndrukhiv/6248-compatible-range-to-node-version' …
UlyanaAndrukhiv Aug 13, 2024
0534243
Merge branch 'master' into UlyanaAndrukhiv/6248-compatible-range-to-n…
UlyanaAndrukhiv Aug 15, 2024
b62c43e
Merge branch 'master' into UlyanaAndrukhiv/6248-compatible-range-to-n…
UlyanaAndrukhiv Aug 16, 2024
6155655
Updated protobuf version
UlyanaAndrukhiv Aug 16, 2024
55d2c54
Merge branch 'UlyanaAndrukhiv/6248-compatible-range-to-node-version' …
UlyanaAndrukhiv Aug 16, 2024
22e8b04
Fixed convertion from CompatibleRange to protobuf message
UlyanaAndrukhiv Aug 16, 2024
cc044be
Updated flow-emulator version
UlyanaAndrukhiv Aug 16, 2024
88f3ffe
Updated start height getter logic
UlyanaAndrukhiv Aug 19, 2024
532189e
Merged 2 methods
UlyanaAndrukhiv Aug 19, 2024
5c65f14
Updated EndHeight according to comment
UlyanaAndrukhiv Aug 19, 2024
f0e08af
Removed duplicate implementation
UlyanaAndrukhiv Aug 19, 2024
84ec98e
Added test for CompatibleRangeToMessage
UlyanaAndrukhiv Aug 19, 2024
1304a20
Merge branch 'master' into UlyanaAndrukhiv/6248-compatible-range-to-n…
UlyanaAndrukhiv Aug 20, 2024
0200350
Merge branch 'master' into UlyanaAndrukhiv/6248-compatible-range-to-n…
UlyanaAndrukhiv Aug 21, 2024
e7bf591
Merge branch 'master' of github.com:The-K-R-O-K/flow-go into UlyanaAn…
UlyanaAndrukhiv Aug 26, 2024
b2cb768
Mergerd with master
UlyanaAndrukhiv Aug 26, 2024
834529e
Updated flow-emulator version
UlyanaAndrukhiv Aug 26, 2024
3187556
Merge branch 'master' into UlyanaAndrukhiv/6248-compatible-range-to-n…
UlyanaAndrukhiv Aug 27, 2024
50dcd73
Moved NodeVersionInfo to access module
UlyanaAndrukhiv Aug 27, 2024
7fee253
Updated flow-emulator version
UlyanaAndrukhiv Aug 27, 2024
7b26083
Removed replace for flow-emulator
UlyanaAndrukhiv Aug 28, 2024
28604da
Merge branch 'master' into UlyanaAndrukhiv/6248-compatible-range-to-n…
UlyanaAndrukhiv Aug 28, 2024
00eae08
Merged with master
UlyanaAndrukhiv Aug 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions access/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
type API interface {
Ping(ctx context.Context) error
GetNetworkParameters(ctx context.Context) NetworkParameters
GetNodeVersionInfo(ctx context.Context) (*NodeVersionInfo, error)
GetNodeVersionInfo(ctx context.Context) (*flow.NodeVersionInfo, error)

GetLatestBlockHeader(ctx context.Context, isSealed bool) (*flow.Header, flow.BlockStatus, error)
GetBlockHeaderByHeight(ctx context.Context, height uint64) (*flow.Header, flow.BlockStatus, error)
Expand Down Expand Up @@ -263,13 +263,3 @@ func MessageToTransactionResult(message *access.TransactionResultResponse) *Tran
type NetworkParameters struct {
ChainID flow.ChainID
}

// NodeVersionInfo contains information about node, such as semver, commit, sporkID, protocolVersion, etc
type NodeVersionInfo struct {
Semver string
Commit string
SporkId flow.Identifier
ProtocolVersion uint64
SporkRootBlockHeight uint64
NodeRootBlockHeight uint64
}
1 change: 1 addition & 0 deletions access/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ func (h *Handler) GetNodeVersionInfo(
ProtocolVersion: nodeVersionInfo.ProtocolVersion,
SporkRootBlockHeight: nodeVersionInfo.SporkRootBlockHeight,
NodeRootBlockHeight: nodeVersionInfo.NodeRootBlockHeight,
CompatibleRange: convert.CompatibleRangeToMessage(nodeVersionInfo.CompatibleRange),
},
}, nil
}
Expand Down
10 changes: 5 additions & 5 deletions access/mock/api.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions cmd/access/node_builder/access_node_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ type FlowAccessNodeBuilder struct {
ExecutionDataPruner *pruner.Pruner
ExecutionDatastoreManager edstorage.DatastoreManager
ExecutionDataTracker tracker.Storage
versionControl *version.VersionControl
VersionControl *version.VersionControl

// The sync engine participants provider is the libp2p peer store for the access node
// which is not available until after the network has started.
Expand Down Expand Up @@ -978,7 +978,7 @@ func (builder *FlowAccessNodeBuilder) BuildExecutionSyncComponents() *FlowAccess
builder.programCacheSize > 0,
)

err = builder.ScriptExecutor.Initialize(builder.ExecutionIndexer, scripts, builder.versionControl)
err = builder.ScriptExecutor.Initialize(builder.ExecutionIndexer, scripts, builder.VersionControl)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -1813,8 +1813,8 @@ func (builder *FlowAccessNodeBuilder) Build() (cmd.Node, error) {
// VersionControl needs to consume BlockFinalized events.
node.ProtocolEvents.AddConsumer(versionControl)

builder.versionControl = versionControl
versionControlDependable.Init(builder.versionControl)
builder.VersionControl = versionControl
versionControlDependable.Init(builder.VersionControl)

return versionControl, nil
}).
Expand Down Expand Up @@ -1921,6 +1921,7 @@ func (builder *FlowAccessNodeBuilder) Build() (cmd.Node, error) {
TxResultQueryMode: txResultQueryMode,
TxResultsIndex: builder.TxResultsIndex,
LastFullBlockHeight: lastFullBlockHeight,
VersionControl: builder.VersionControl,
})
if err != nil {
return nil, fmt.Errorf("could not initialize backend: %w", err)
Expand Down
9 changes: 5 additions & 4 deletions cmd/observer/node_builder/observer_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ type ObserverServiceBuilder struct {
ExecutionIndexerCore *indexer.IndexerCore
TxResultsIndex *index.TransactionResultsIndex
IndexerDependencies *cmd.DependencyList
versionControl *version.VersionControl
VersionControl *version.VersionControl

ExecutionDataDownloader execution_data.Downloader
ExecutionDataRequester state_synchronization.ExecutionDataRequester
Expand Down Expand Up @@ -1513,7 +1513,7 @@ func (builder *ObserverServiceBuilder) BuildExecutionSyncComponents() *ObserverS
builder.programCacheSize > 0,
)

err = builder.ScriptExecutor.Initialize(builder.ExecutionIndexer, scripts, builder.versionControl)
err = builder.ScriptExecutor.Initialize(builder.ExecutionIndexer, scripts, builder.VersionControl)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -1854,8 +1854,8 @@ func (builder *ObserverServiceBuilder) enqueueRPCServer() {
// VersionControl needs to consume BlockFinalized events.
node.ProtocolEvents.AddConsumer(versionControl)

builder.versionControl = versionControl
versionControlDependable.Init(builder.versionControl)
builder.VersionControl = versionControl
versionControlDependable.Init(builder.VersionControl)

return versionControl, nil
})
Expand Down Expand Up @@ -1930,6 +1930,7 @@ func (builder *ObserverServiceBuilder) enqueueRPCServer() {
builder.stateStreamConf.ResponseLimit,
builder.stateStreamConf.ClientSendBufferSize,
),
VersionControl: builder.VersionControl,
}

if builder.localServiceAPIEnabled {
Expand Down
5 changes: 0 additions & 5 deletions engine/access/handle_irrecoverable_state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,7 @@ func (suite *IrrecoverableStateTestSuite) SetupTest() {
suite.state = protocol.NewState(suite.T())
suite.snapshot = protocol.NewSnapshot(suite.T())

rootHeader := unittest.BlockHeaderFixture()
params := protocol.NewParams(suite.T())
params.On("SporkID").Return(unittest.IdentifierFixture(), nil)
params.On("ProtocolVersion").Return(uint(unittest.Uint64InRange(10, 30)), nil)
params.On("SporkRootBlockHeight").Return(rootHeader.Height, nil)
params.On("SealedRoot").Return(rootHeader, nil)

suite.epochQuery = protocol.NewEpochQuery(suite.T())
suite.state.On("Sealed").Return(suite.snapshot, nil).Maybe()
Expand Down
15 changes: 15 additions & 0 deletions engine/access/rest/models/model_compatible_range.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* 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)
*/
package models

// A compatible version range.
type CompatibleRange struct {
StartHeight string `json:"start_height"`
EndHeight string `json:"end_height"`
}
13 changes: 7 additions & 6 deletions engine/access/rest/models/model_node_version_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
package models

type NodeVersionInfo struct {
Semver string `json:"semver"`
Commit string `json:"commit"`
SporkId string `json:"spork_id"`
ProtocolVersion string `json:"protocol_version"`
SporkRootBlockHeight string `json:"spork_root_block_height"`
NodeRootBlockHeight string `json:"node_root_block_height"`
Semver string `json:"semver"`
Commit string `json:"commit"`
SporkId string `json:"spork_id"`
ProtocolVersion string `json:"protocol_version"`
SporkRootBlockHeight string `json:"spork_root_block_height"`
NodeRootBlockHeight string `json:"node_root_block_height"`
CompatibleRange *CompatibleRange `json:"compatible_range,omitempty"`
}
11 changes: 9 additions & 2 deletions engine/access/rest/models/node_version_info.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
package models

import (
"github.com/onflow/flow-go/access"
"github.com/onflow/flow-go/engine/access/rest/util"
"github.com/onflow/flow-go/model/flow"
)

func (t *NodeVersionInfo) Build(params *access.NodeVersionInfo) {
func (t *NodeVersionInfo) Build(params *flow.NodeVersionInfo) {
t.Semver = params.Semver
t.Commit = params.Commit
t.SporkId = params.SporkId.String()
t.ProtocolVersion = util.FromUint(params.ProtocolVersion)
t.SporkRootBlockHeight = util.FromUint(params.SporkRootBlockHeight)
t.NodeRootBlockHeight = util.FromUint(params.NodeRootBlockHeight)

if params.CompatibleRange != nil {
t.CompatibleRange = &CompatibleRange{
StartHeight: util.FromUint(params.CompatibleRange.StartHeight),
EndHeight: util.FromUint(params.CompatibleRange.EndHeight),
}
}
}
26 changes: 21 additions & 5 deletions engine/access/rest/routes/node_version_info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
mocktestify "github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"

"github.com/onflow/flow-go/access"
"github.com/onflow/flow-go/access/mock"
"github.com/onflow/flow-go/cmd/build"
"github.com/onflow/flow-go/model/flow"
"github.com/onflow/flow-go/utils/unittest"
)

Expand All @@ -28,13 +28,19 @@ func TestGetNodeVersionInfo(t *testing.T) {
t.Run("get node version info", func(t *testing.T) {
req := getNodeVersionInfoRequest(t)

params := &access.NodeVersionInfo{
nodeRootBlockHeight := unittest.Uint64InRange(10_000, 100_000)

params := &flow.NodeVersionInfo{
Semver: build.Version(),
Commit: build.Commit(),
SporkId: unittest.IdentifierFixture(),
ProtocolVersion: unittest.Uint64InRange(10, 30),
SporkRootBlockHeight: unittest.Uint64InRange(1000, 10_000),
NodeRootBlockHeight: unittest.Uint64InRange(10_000, 100_000),
NodeRootBlockHeight: nodeRootBlockHeight,
CompatibleRange: &flow.CompatibleRange{
StartHeight: nodeRootBlockHeight,
EndHeight: uint64(0),
},
}

backend.Mock.
Expand All @@ -48,21 +54,31 @@ func TestGetNodeVersionInfo(t *testing.T) {
})
}

func nodeVersionInfoExpectedStr(nodeVersionInfo *access.NodeVersionInfo) string {
func nodeVersionInfoExpectedStr(nodeVersionInfo *flow.NodeVersionInfo) string {
compatibleRange := fmt.Sprintf(`"compatible_range": {
"start_height": "%d",
"end_height": "%d"
}`,
nodeVersionInfo.CompatibleRange.StartHeight,
nodeVersionInfo.CompatibleRange.EndHeight,
)

return fmt.Sprintf(`{
"semver": "%s",
"commit": "%s",
"spork_id": "%s",
"protocol_version": "%d",
"spork_root_block_height": "%d",
"node_root_block_height": "%d"
"node_root_block_height": "%d",
%s
}`,
nodeVersionInfo.Semver,
nodeVersionInfo.Commit,
nodeVersionInfo.SporkId.String(),
nodeVersionInfo.ProtocolVersion,
nodeVersionInfo.SporkRootBlockHeight,
nodeVersionInfo.NodeRootBlockHeight,
compatibleRange,
)
}

Expand Down
47 changes: 31 additions & 16 deletions engine/access/rpc/backend/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/onflow/flow-go/engine/access/rpc/connection"
"github.com/onflow/flow-go/engine/access/subscription"
"github.com/onflow/flow-go/engine/common/rpc"
"github.com/onflow/flow-go/engine/common/version"
"github.com/onflow/flow-go/fvm/blueprints"
"github.com/onflow/flow-go/model/flow"
"github.com/onflow/flow-go/model/flow/filter"
Expand Down Expand Up @@ -81,9 +82,9 @@ type Backend struct {
executionReceipts storage.ExecutionReceipts
connFactory connection.ConnectionFactory

// cache the response to GetNodeVersionInfo since it doesn't change
nodeInfo *access.NodeVersionInfo
BlockTracker subscription.BlockTracker
BlockTracker subscription.BlockTracker
stateParams protocol.Params
versionControl *version.VersionControl
}

type Params struct {
Expand Down Expand Up @@ -119,6 +120,7 @@ type Params struct {
TxResultQueryMode IndexQueryMode
TxResultsIndex *index.TransactionResultsIndex
LastFullBlockHeight *counters.PersistentStrictMonotonicCounter
VersionControl *version.VersionControl
}

var _ TransactionErrorMessage = (*Backend)(nil)
Expand Down Expand Up @@ -162,9 +164,6 @@ func New(params Params) (*Backend, error) {
}
systemTxID := systemTx.ID()

// initialize node version info
nodeInfo := getNodeVersionInfo(params.State.Params())

transactionsLocalDataProvider := &TransactionsLocalDataProvider{
state: params.State,
collections: params.Collections,
Expand Down Expand Up @@ -243,7 +242,8 @@ func New(params Params) (*Backend, error) {
executionReceipts: params.ExecutionReceipts,
connFactory: params.ConnFactory,
chainID: params.ChainID,
nodeInfo: nodeInfo,
stateParams: params.State.Params(),
versionControl: params.VersionControl,
}

txValidator, err := configureTransactionValidator(params.State, params.ChainID, params.ScriptExecutor, params.CheckPayerBalance)
Expand Down Expand Up @@ -343,26 +343,41 @@ func (b *Backend) Ping(ctx context.Context) error {
}

// GetNodeVersionInfo returns node version information such as semver, commit, sporkID, protocolVersion, etc
func (b *Backend) GetNodeVersionInfo(_ context.Context) (*access.NodeVersionInfo, error) {
return b.nodeInfo, nil
func (b *Backend) GetNodeVersionInfo(_ context.Context) (*flow.NodeVersionInfo, error) {
return b.getNodeVersionInfo(), nil
UlyanaAndrukhiv marked this conversation as resolved.
Show resolved Hide resolved
}

// getNodeVersionInfo returns the NodeVersionInfo for the node.
// Since these values are static while the node is running, it is safe to cache.
func getNodeVersionInfo(stateParams protocol.Params) *access.NodeVersionInfo {
sporkID := stateParams.SporkID()
protocolVersion := stateParams.ProtocolVersion()
sporkRootBlockHeight := stateParams.SporkRootBlockHeight()
func (b *Backend) getNodeVersionInfo() *flow.NodeVersionInfo {
sporkID := b.stateParams.SporkID()
protocolVersion := b.stateParams.ProtocolVersion()
sporkRootBlockHeight := b.stateParams.SporkRootBlockHeight()

nodeRootBlockHeader := b.stateParams.SealedRoot()

nodeRootBlockHeader := stateParams.SealedRoot()
var compatibleRange *flow.CompatibleRange

// Version control feature could be disabled
if b.versionControl != nil {
compatibleRange = &flow.CompatibleRange{
StartHeight: b.versionControl.StartHeight(),
EndHeight: b.versionControl.EndHeight(),
}

// StartHeight is the root block if there is no start boundary in the current spork
if compatibleRange.StartHeight == version.NoHeight {
compatibleRange.StartHeight = nodeRootBlockHeader.Height
}
UlyanaAndrukhiv marked this conversation as resolved.
Show resolved Hide resolved
}

nodeInfo := &access.NodeVersionInfo{
nodeInfo := &flow.NodeVersionInfo{
Semver: build.Version(),
Commit: build.Commit(),
SporkId: sporkID,
ProtocolVersion: uint64(protocolVersion),
SporkRootBlockHeight: sporkRootBlockHeight,
NodeRootBlockHeight: nodeRootBlockHeader.Height,
CompatibleRange: compatibleRange,
}

return nodeInfo
Expand Down
4 changes: 2 additions & 2 deletions engine/access/rpc/backend/backend_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ func (b *backendNetwork) GetNetworkParameters(_ context.Context) access.NetworkP
}
}

func (b *backendNetwork) GetNodeVersionInfo(_ context.Context) (*access.NodeVersionInfo, error) {
UlyanaAndrukhiv marked this conversation as resolved.
Show resolved Hide resolved
func (b *backendNetwork) GetNodeVersionInfo(_ context.Context) (*flow.NodeVersionInfo, error) {
stateParams := b.state.Params()
sporkId := stateParams.SporkID()
protocolVersion := stateParams.ProtocolVersion()

return &access.NodeVersionInfo{
return &flow.NodeVersionInfo{
Semver: build.Version(),
Commit: build.Commit(),
SporkId: sporkId,
Expand Down
Loading
Loading