Skip to content

Commit

Permalink
Merge pull request #4827 from onflow/petera/update-exec-data-namespace
Browse files Browse the repository at this point in the history
[Access] update execution data protobuf to new namespace
  • Loading branch information
peterargue authored Oct 17, 2023
2 parents d953312 + a02f7b8 commit 6f13b8f
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 23 deletions.
6 changes: 3 additions & 3 deletions engine/access/state_stream/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package state_stream
import (
"github.com/rs/zerolog"

"github.com/onflow/flow/protobuf/go/flow/executiondata"

"github.com/onflow/flow-go/engine"
"github.com/onflow/flow-go/model/flow"
"github.com/onflow/flow-go/module/component"
Expand All @@ -12,8 +14,6 @@ import (
"github.com/onflow/flow-go/module/irrecoverable"
"github.com/onflow/flow-go/storage"
"github.com/onflow/flow-go/utils/logging"

access "github.com/onflow/flow/protobuf/go/flow/executiondata"
)

// Engine exposes the server with the state stream API.
Expand Down Expand Up @@ -63,7 +63,7 @@ func NewEng(
}).
Build()

access.RegisterExecutionDataAPIServer(server.Server, e.handler)
executiondata.RegisterExecutionDataAPIServer(server.Server, e.handler)

return e, nil
}
Expand Down
15 changes: 9 additions & 6 deletions engine/access/state_stream/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import (
"sync/atomic"

"github.com/onflow/flow/protobuf/go/flow/execution"
access "github.com/onflow/flow/protobuf/go/flow/executiondata"
executiondata "github.com/onflow/flow/protobuf/go/flow/executiondata"
"github.com/onflow/flow/protobuf/go/flow/executiondata"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"

Expand Down Expand Up @@ -36,7 +35,7 @@ func NewHandler(api API, chain flow.Chain, conf EventFilterConfig, maxGlobalStre
return h
}

func (h *Handler) GetExecutionDataByBlockID(ctx context.Context, request *access.GetExecutionDataByBlockIDRequest) (*access.GetExecutionDataByBlockIDResponse, error) {
func (h *Handler) GetExecutionDataByBlockID(ctx context.Context, request *executiondata.GetExecutionDataByBlockIDRequest) (*executiondata.GetExecutionDataByBlockIDResponse, error) {
blockID, err := convert.BlockID(request.GetBlockId())
if err != nil {
return nil, status.Errorf(codes.InvalidArgument, "could not convert block ID: %v", err)
Expand All @@ -59,10 +58,10 @@ func (h *Handler) GetExecutionDataByBlockID(ctx context.Context, request *access
return nil, status.Errorf(codes.Internal, "could not convert execution data event payloads to JSON: %v", err)
}

return &access.GetExecutionDataByBlockIDResponse{BlockExecutionData: message}, nil
return &executiondata.GetExecutionDataByBlockIDResponse{BlockExecutionData: message}, nil
}

func (h *Handler) SubscribeExecutionData(request *access.SubscribeExecutionDataRequest, stream access.ExecutionDataAPI_SubscribeExecutionDataServer) error {
func (h *Handler) SubscribeExecutionData(request *executiondata.SubscribeExecutionDataRequest, stream executiondata.ExecutionDataAPI_SubscribeExecutionDataServer) error {
// check if the maximum number of streams is reached
if h.streamCount.Load() >= h.maxStreams {
return status.Errorf(codes.ResourceExhausted, "maximum number of streams reached")
Expand Down Expand Up @@ -117,7 +116,7 @@ func (h *Handler) SubscribeExecutionData(request *access.SubscribeExecutionDataR
}
}

func (h *Handler) SubscribeEvents(request *access.SubscribeEventsRequest, stream access.ExecutionDataAPI_SubscribeEventsServer) error {
func (h *Handler) SubscribeEvents(request *executiondata.SubscribeEventsRequest, stream executiondata.ExecutionDataAPI_SubscribeEventsServer) error {
// check if the maximum number of streams is reached
if h.streamCount.Load() >= h.maxStreams {
return status.Errorf(codes.ResourceExhausted, "maximum number of streams reached")
Expand Down Expand Up @@ -184,3 +183,7 @@ func (h *Handler) SubscribeEvents(request *access.SubscribeEventsRequest, stream
}
}
}

func (h *Handler) GetRegisterValues(ctx context.Context, request *executiondata.GetRegisterValuesRequest) (*executiondata.GetRegisterValuesResponse, error) {
return nil, status.Error(codes.Unimplemented, "not implemented")
}
10 changes: 5 additions & 5 deletions engine/access/state_stream/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"google.golang.org/grpc"

jsoncdc "github.com/onflow/cadence/encoding/json"
access "github.com/onflow/flow/protobuf/go/flow/executiondata"
"github.com/onflow/flow/protobuf/go/flow/executiondata"

"github.com/onflow/flow-go/engine/access/state_stream"
ssmock "github.com/onflow/flow-go/engine/access/state_stream/mock"
Expand All @@ -30,7 +30,7 @@ func TestExecutionDataStream(t *testing.T) {
defer cancel()

api := ssmock.NewAPI(t)
stream := makeStreamMock[access.SubscribeExecutionDataRequest, access.SubscribeExecutionDataResponse](ctx)
stream := makeStreamMock[executiondata.SubscribeExecutionDataRequest, executiondata.SubscribeExecutionDataResponse](ctx)
sub := state_stream.NewSubscription(1)

// generate some events with a payload to include
Expand All @@ -52,7 +52,7 @@ func TestExecutionDataStream(t *testing.T) {
wg.Add(1)
go func() {
wg.Done()
err := h.SubscribeExecutionData(&access.SubscribeExecutionDataRequest{}, stream)
err := h.SubscribeExecutionData(&executiondata.SubscribeExecutionDataRequest{}, stream)
require.NoError(t, err)
t.Log("subscription closed")
}()
Expand Down Expand Up @@ -117,7 +117,7 @@ func TestEventStream(t *testing.T) {
defer cancel()

api := ssmock.NewAPI(t)
stream := makeStreamMock[access.SubscribeEventsRequest, access.SubscribeEventsResponse](ctx)
stream := makeStreamMock[executiondata.SubscribeEventsRequest, executiondata.SubscribeEventsResponse](ctx)
sub := state_stream.NewSubscription(1)

// generate some events with a payload to include
Expand All @@ -139,7 +139,7 @@ func TestEventStream(t *testing.T) {
wg.Add(1)
go func() {
wg.Done()
err := h.SubscribeEvents(&access.SubscribeEventsRequest{}, stream)
err := h.SubscribeEvents(&executiondata.SubscribeEventsRequest{}, stream)
require.NoError(t, err)
t.Log("subscription closed")
}()
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ require (
github.com/onflow/flow-core-contracts/lib/go/templates v1.2.3
github.com/onflow/flow-go-sdk v0.41.10
github.com/onflow/flow-go/crypto v0.24.9
github.com/onflow/flow/protobuf/go/flow v0.3.2-0.20230915140723-432828f7afb9
github.com/onflow/flow/protobuf/go/flow v0.3.2-0.20231017162044-5d0f9b6dfdb2
github.com/onflow/go-bitswap v0.0.0-20230703214630-6d3db958c73d
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58
github.com/pierrec/lz4 v2.6.1+incompatible
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1328,8 +1328,8 @@ github.com/onflow/flow-go/crypto v0.24.9/go.mod h1:fqCzkIBBMRRkciVrvW21rECKq1oD7
github.com/onflow/flow-nft/lib/go/contracts v1.1.0 h1:rhUDeD27jhLwOqQKI/23008CYfnqXErrJvc4EFRP2a0=
github.com/onflow/flow-nft/lib/go/contracts v1.1.0/go.mod h1:YsvzYng4htDgRB9sa9jxdwoTuuhjK8WYWXTyLkIigZY=
github.com/onflow/flow/protobuf/go/flow v0.2.2/go.mod h1:gQxYqCfkI8lpnKsmIjwtN2mV/N2PIwc1I+RUK4HPIc8=
github.com/onflow/flow/protobuf/go/flow v0.3.2-0.20230915140723-432828f7afb9 h1:IGDANryEVnuVAlDZDzNLMMUui9lbwS04KE70C0HXkFw=
github.com/onflow/flow/protobuf/go/flow v0.3.2-0.20230915140723-432828f7afb9/go.mod h1:NA2pX2nw8zuaxfKphhKsk00kWLwfd+tv8mS23YXO4Sk=
github.com/onflow/flow/protobuf/go/flow v0.3.2-0.20231017162044-5d0f9b6dfdb2 h1:PvDTPiMYERXeuEPDSuF67Lm+dG9soy3tMOO6VtRcKwM=
github.com/onflow/flow/protobuf/go/flow v0.3.2-0.20231017162044-5d0f9b6dfdb2/go.mod h1:NA2pX2nw8zuaxfKphhKsk00kWLwfd+tv8mS23YXO4Sk=
github.com/onflow/go-bitswap v0.0.0-20230703214630-6d3db958c73d h1:QcOAeEyF3iAUHv21LQ12sdcsr0yFrJGoGLyCAzYYtvI=
github.com/onflow/go-bitswap v0.0.0-20230703214630-6d3db958c73d/go.mod h1:GCPpiyRoHncdqPj++zPr9ZOYBX4hpJ0pYZRYqSE8VKk=
github.com/onflow/sdks v0.5.0 h1:2HCRibwqDaQ1c9oUApnkZtEAhWiNY2GTpRD5+ftdkN8=
Expand Down
2 changes: 1 addition & 1 deletion insecure/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ require (
github.com/onflow/flow-ft/lib/go/contracts v0.7.0 // indirect
github.com/onflow/flow-go-sdk v0.41.10 // indirect
github.com/onflow/flow-nft/lib/go/contracts v1.1.0 // indirect
github.com/onflow/flow/protobuf/go/flow v0.3.2-0.20230915140723-432828f7afb9 // indirect
github.com/onflow/flow/protobuf/go/flow v0.3.2-0.20231017162044-5d0f9b6dfdb2 // indirect
github.com/onflow/go-bitswap v0.0.0-20230703214630-6d3db958c73d // indirect
github.com/onflow/sdks v0.5.0 // indirect
github.com/onflow/wal v0.0.0-20230529184820-bc9f8244608d // indirect
Expand Down
4 changes: 2 additions & 2 deletions insecure/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1302,8 +1302,8 @@ github.com/onflow/flow-go/crypto v0.24.9/go.mod h1:fqCzkIBBMRRkciVrvW21rECKq1oD7
github.com/onflow/flow-nft/lib/go/contracts v1.1.0 h1:rhUDeD27jhLwOqQKI/23008CYfnqXErrJvc4EFRP2a0=
github.com/onflow/flow-nft/lib/go/contracts v1.1.0/go.mod h1:YsvzYng4htDgRB9sa9jxdwoTuuhjK8WYWXTyLkIigZY=
github.com/onflow/flow/protobuf/go/flow v0.2.2/go.mod h1:gQxYqCfkI8lpnKsmIjwtN2mV/N2PIwc1I+RUK4HPIc8=
github.com/onflow/flow/protobuf/go/flow v0.3.2-0.20230915140723-432828f7afb9 h1:IGDANryEVnuVAlDZDzNLMMUui9lbwS04KE70C0HXkFw=
github.com/onflow/flow/protobuf/go/flow v0.3.2-0.20230915140723-432828f7afb9/go.mod h1:NA2pX2nw8zuaxfKphhKsk00kWLwfd+tv8mS23YXO4Sk=
github.com/onflow/flow/protobuf/go/flow v0.3.2-0.20231017162044-5d0f9b6dfdb2 h1:PvDTPiMYERXeuEPDSuF67Lm+dG9soy3tMOO6VtRcKwM=
github.com/onflow/flow/protobuf/go/flow v0.3.2-0.20231017162044-5d0f9b6dfdb2/go.mod h1:NA2pX2nw8zuaxfKphhKsk00kWLwfd+tv8mS23YXO4Sk=
github.com/onflow/go-bitswap v0.0.0-20230703214630-6d3db958c73d h1:QcOAeEyF3iAUHv21LQ12sdcsr0yFrJGoGLyCAzYYtvI=
github.com/onflow/go-bitswap v0.0.0-20230703214630-6d3db958c73d/go.mod h1:GCPpiyRoHncdqPj++zPr9ZOYBX4hpJ0pYZRYqSE8VKk=
github.com/onflow/sdks v0.5.0 h1:2HCRibwqDaQ1c9oUApnkZtEAhWiNY2GTpRD5+ftdkN8=
Expand Down
2 changes: 1 addition & 1 deletion integration/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ require (
github.com/onflow/flow-go-sdk v0.41.10
github.com/onflow/flow-go/crypto v0.24.9
github.com/onflow/flow-go/insecure v0.0.0-00010101000000-000000000000
github.com/onflow/flow/protobuf/go/flow v0.3.2-0.20230915140723-432828f7afb9
github.com/onflow/flow/protobuf/go/flow v0.3.2-0.20231017162044-5d0f9b6dfdb2
github.com/plus3it/gorecurcopy v0.0.1
github.com/prometheus/client_golang v1.14.0
github.com/prometheus/client_model v0.4.0
Expand Down
4 changes: 2 additions & 2 deletions integration/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1446,8 +1446,8 @@ github.com/onflow/flow-go/crypto v0.24.9/go.mod h1:fqCzkIBBMRRkciVrvW21rECKq1oD7
github.com/onflow/flow-nft/lib/go/contracts v1.1.0 h1:rhUDeD27jhLwOqQKI/23008CYfnqXErrJvc4EFRP2a0=
github.com/onflow/flow-nft/lib/go/contracts v1.1.0/go.mod h1:YsvzYng4htDgRB9sa9jxdwoTuuhjK8WYWXTyLkIigZY=
github.com/onflow/flow/protobuf/go/flow v0.2.2/go.mod h1:gQxYqCfkI8lpnKsmIjwtN2mV/N2PIwc1I+RUK4HPIc8=
github.com/onflow/flow/protobuf/go/flow v0.3.2-0.20230915140723-432828f7afb9 h1:IGDANryEVnuVAlDZDzNLMMUui9lbwS04KE70C0HXkFw=
github.com/onflow/flow/protobuf/go/flow v0.3.2-0.20230915140723-432828f7afb9/go.mod h1:NA2pX2nw8zuaxfKphhKsk00kWLwfd+tv8mS23YXO4Sk=
github.com/onflow/flow/protobuf/go/flow v0.3.2-0.20231017162044-5d0f9b6dfdb2 h1:PvDTPiMYERXeuEPDSuF67Lm+dG9soy3tMOO6VtRcKwM=
github.com/onflow/flow/protobuf/go/flow v0.3.2-0.20231017162044-5d0f9b6dfdb2/go.mod h1:NA2pX2nw8zuaxfKphhKsk00kWLwfd+tv8mS23YXO4Sk=
github.com/onflow/go-bitswap v0.0.0-20230703214630-6d3db958c73d h1:QcOAeEyF3iAUHv21LQ12sdcsr0yFrJGoGLyCAzYYtvI=
github.com/onflow/go-bitswap v0.0.0-20230703214630-6d3db958c73d/go.mod h1:GCPpiyRoHncdqPj++zPr9ZOYBX4hpJ0pYZRYqSE8VKk=
github.com/onflow/nft-storefront/lib/go/contracts v0.0.0-20221222181731-14b90207cead h1:2j1Unqs76Z1b95Gu4C3Y28hzNUHBix7wL490e61SMSw=
Expand Down

0 comments on commit 6f13b8f

Please sign in to comment.