Skip to content

Commit

Permalink
merge master branch
Browse files Browse the repository at this point in the history
  • Loading branch information
Tarak Ben Youssef committed Oct 21, 2023
2 parents b180269 + 864190c commit 6a42f1e
Show file tree
Hide file tree
Showing 387 changed files with 20,805 additions and 10,602 deletions.
96 changes: 0 additions & 96 deletions .github/workflows/bench.yml

This file was deleted.

13 changes: 8 additions & 5 deletions .github/workflows/builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,15 @@ jobs:

# Provide Google Service Account credentials to Github Action, allowing interaction with the Google Container Registry
# Logging in as github-actions@dl-flow.iam.gserviceaccount.com
- name: Docker login
uses: docker/login-action@v1
- id: auth
uses: google-github-actions/auth@v1
with:
registry: gcr.io
username: _json_key
password: ${{ secrets.GCR_SERVICE_KEY }}
credentials_json: ${{ secrets.GCR_SERVICE_KEY_SECRET }}
- name: Set up Google Cloud SDK
uses: google-github-actions/setup-gcloud@v1
- name: Authenticate docker with gcloud
run: |
gcloud auth configure-docker
- name: Build/Push ${{ matrix.role }} images
env:
Expand Down
13 changes: 8 additions & 5 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@ jobs:
uses: actions/checkout@v2
# Provide Google Service Account credentials to Github Action, allowing interaction with the Google Container Registry
# Logging in as github-actions@dl-flow.iam.gserviceaccount.com
- name: Docker login
uses: docker/login-action@v1
- id: auth
uses: google-github-actions/auth@v1
with:
registry: gcr.io
username: _json_key
password: ${{ secrets.GCR_SERVICE_KEY }}
credentials_json: ${{ secrets.GCR_SERVICE_KEY_SECRET }}
- name: Set up Google Cloud SDK
uses: google-github-actions/setup-gcloud@v1
- name: Authenticate docker with gcloud
run: |
gcloud auth configure-docker
- name: Docker build
run: |
make docker-build-flow
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
uses: golangci/golangci-lint-action@v3
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.51
version: v1.54
args: -v
working-directory: ${{ matrix.dir }}
# https://github.com/golangci/golangci-lint-action/issues/244
Expand Down
14 changes: 8 additions & 6 deletions .github/workflows/tools.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,20 @@ jobs:
- id: auth
uses: google-github-actions/auth@v1
with:
credentials_json: ${{ secrets.GCR_SERVICE_KEY }} # TODO: we need a new key to allow uploads
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: "1.20"
credentials_json: ${{ secrets.GCR_SERVICE_KEY }}
- name: Set up Google Cloud SDK
uses: google-github-actions/setup-gcloud@v1
with:
project_id: flow
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: "1.20"
- name: Checkout repo
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
# to accurately get the version tag
fetch-depth: 0
ref: ${{ inputs.tag }}
- name: Build and upload boot-tools
run: |
Expand Down
19 changes: 15 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,17 @@ cmd/util/util:

.PHONY: update-core-contracts-version
update-core-contracts-version:
# updates the core-contracts version in all of the go.mod files
# usage example: CC_VERSION=0.16.0 make update-core-contracts-version
./scripts/update-core-contracts.sh $(CC_VERSION)
make tidy

.PHONY: update-cadence-version
update-cadence-version:
# updates the cadence version in all of the go.mod files
# usage example: CC_VERSION=0.16.0 make update-cadence-version
./scripts/update-cadence.sh $(CC_VERSION)
make tidy

.PHONY: unittest-main
unittest-main:
Expand Down Expand Up @@ -154,7 +164,7 @@ generate-mocks: install-mock-generators
mockery --name 'ExecutionState' --dir=engine/execution/state --case=underscore --output="engine/execution/state/mock" --outpkg="mock"
mockery --name 'BlockComputer' --dir=engine/execution/computation/computer --case=underscore --output="engine/execution/computation/computer/mock" --outpkg="mock"
mockery --name 'ComputationManager' --dir=engine/execution/computation --case=underscore --output="engine/execution/computation/mock" --outpkg="mock"
mockery --name 'Executor' --dir=engine/execution/computation/query --case=underscore --output="engine/execution/computation/query/mock" --outpkg="mock"
mockery --name '.*' --dir=engine/execution/computation/query --case=underscore --output="engine/execution/computation/query/mock" --outpkg="mock"
mockery --name 'EpochComponentsFactory' --dir=engine/collection/epochmgr --case=underscore --output="engine/collection/epochmgr/mock" --outpkg="mock"
mockery --name 'Backend' --dir=engine/collection/rpc --case=underscore --output="engine/collection/rpc/mock" --outpkg="mock"
mockery --name 'ProviderEngine' --dir=engine/execution/provider --case=underscore --output="engine/execution/provider/mock" --outpkg="mock"
Expand Down Expand Up @@ -196,6 +206,7 @@ generate-mocks: install-mock-generators
mockery --name '.*' --dir=engine/verification/fetcher/ --case=underscore --output="./engine/verification/fetcher/mock" --outpkg="mockfetcher"
mockery --name '.*' --dir=./cmd/util/ledger/reporters --case=underscore --output="./cmd/util/ledger/reporters/mock" --outpkg="mock"
mockery --name 'Storage' --dir=module/executiondatasync/tracker --case=underscore --output="module/executiondatasync/tracker/mock" --outpkg="mocktracker"
mockery --name 'ScriptExecutor' --dir=module/execution --case=underscore --output="module/execution/mock" --outpkg="mock"

#temporarily make insecure/ a non-module to allow mockery to create mocks
mv insecure/go.mod insecure/go2.mod
Expand Down Expand Up @@ -413,7 +424,7 @@ docker-build-ghost-debug:

PHONY: docker-build-bootstrap
docker-build-bootstrap:
docker build -f cmd/Dockerfile --build-arg TARGET=./cmd/bootstrap --build-arg GOARCH=$(GOARCH) --build-arg CGO_FLAG=$(CRYPTO_FLAG) --target production \
docker build -f cmd/Dockerfile --build-arg TARGET=./cmd/bootstrap --build-arg GOARCH=$(GOARCH) --build-arg VERSION=$(IMAGE_TAG) --build-arg CGO_FLAG=$(CRYPTO_FLAG) --target production \
--label "git_commit=${COMMIT}" --label "git_tag=${IMAGE_TAG}" \
-t "$(CONTAINER_REGISTRY)/bootstrap:latest" -t "$(CONTAINER_REGISTRY)/bootstrap:$(SHORT_COMMIT)" -t "$(CONTAINER_REGISTRY)/bootstrap:$(IMAGE_TAG)" .

Expand Down Expand Up @@ -613,7 +624,7 @@ docker-all-tools: tool-util tool-remove-execution-fork

PHONY: docker-build-util
docker-build-util:
docker build -f cmd/Dockerfile --build-arg TARGET=./cmd/util --build-arg GOARCH=$(GOARCH) --build-arg CGO_FLAG=$(CRYPTO_FLAG) --target production \
docker build -f cmd/Dockerfile --build-arg TARGET=./cmd/util --build-arg GOARCH=$(GOARCH) --build-arg VERSION=$(IMAGE_TAG) --build-arg CGO_FLAG=$(CRYPTO_FLAG) --target production \
-t "$(CONTAINER_REGISTRY)/util:latest" -t "$(CONTAINER_REGISTRY)/util:$(SHORT_COMMIT)" -t "$(CONTAINER_REGISTRY)/util:$(IMAGE_TAG)" .

PHONY: tool-util
Expand All @@ -622,7 +633,7 @@ tool-util: docker-build-util

PHONY: docker-build-remove-execution-fork
docker-build-remove-execution-fork:
docker build -f cmd/Dockerfile --ssh default --build-arg TARGET=./cmd/util/cmd/remove-execution-fork --build-arg GOARCH=$(GOARCH) --build-arg CGO_FLAG=$(CRYPTO_FLAG) --target production \
docker build -f cmd/Dockerfile --ssh default --build-arg TARGET=./cmd/util/cmd/remove-execution-fork --build-arg GOARCH=$(GOARCH) --build-arg VERSION=$(IMAGE_TAG) --build-arg CGO_FLAG=$(CRYPTO_FLAG) --target production \
-t "$(CONTAINER_REGISTRY)/remove-execution-fork:latest" -t "$(CONTAINER_REGISTRY)/remove-execution-fork:$(SHORT_COMMIT)" -t "$(CONTAINER_REGISTRY)/remove-execution-fork:$(IMAGE_TAG)" .

PHONY: tool-remove-execution-fork
Expand Down
10 changes: 6 additions & 4 deletions access/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,10 @@ type NetworkParameters struct {

// NodeVersionInfo contains information about node, such as semver, commit, sporkID, protocolVersion, etc
type NodeVersionInfo struct {
Semver string
Commit string
SporkId flow.Identifier
ProtocolVersion uint64
Semver string
Commit string
SporkId flow.Identifier
ProtocolVersion uint64
SporkRootBlockHeight uint64
NodeRootBlockHeight uint64
}
10 changes: 6 additions & 4 deletions access/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,12 @@ func (h *Handler) GetNodeVersionInfo(

return &access.GetNodeVersionInfoResponse{
Info: &entities.NodeVersionInfo{
Semver: nodeVersionInfo.Semver,
Commit: nodeVersionInfo.Commit,
SporkId: nodeVersionInfo.SporkId[:],
ProtocolVersion: nodeVersionInfo.ProtocolVersion,
Semver: nodeVersionInfo.Semver,
Commit: nodeVersionInfo.Commit,
SporkId: nodeVersionInfo.SporkId[:],
ProtocolVersion: nodeVersionInfo.ProtocolVersion,
SporkRootBlockHeight: nodeVersionInfo.SporkRootBlockHeight,
NodeRootBlockHeight: nodeVersionInfo.NodeRootBlockHeight,
},
}, nil
}
Expand Down
98 changes: 98 additions & 0 deletions admin/commands/state_synchronization/execute_script.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
package state_synchronization

import (
"context"
"encoding/json"
"strconv"

"github.com/onflow/flow-go/admin"
"github.com/onflow/flow-go/admin/commands"
"github.com/onflow/flow-go/module/execution"
)

var _ commands.AdminCommand = (*ReadExecutionDataCommand)(nil)

type scriptData struct {
height uint64
script []byte
arguments [][]byte
}

type ExecuteScriptCommand struct {
scriptExecutor execution.ScriptExecutor
}

func (e *ExecuteScriptCommand) Handler(ctx context.Context, req *admin.CommandRequest) (interface{}, error) {
d := req.ValidatorData.(*scriptData)

result, err := e.scriptExecutor.ExecuteAtBlockHeight(context.Background(), d.script, d.arguments, d.height)
if err != nil {
return nil, err
}

return string(result), nil
}

// Validator validates the request.
// Returns admin.InvalidAdminReqError for invalid/malformed requests.
func (e *ExecuteScriptCommand) Validator(req *admin.CommandRequest) error {
input, ok := req.Data.(map[string]interface{})
if !ok {
return admin.NewInvalidAdminReqFormatError("expected map[string]any")
}

heightRaw, ok := input["height"]
if !ok {
return admin.NewInvalidAdminReqFormatError("missing required field 'height")
}

scriptRaw, ok := input["script"]
if !ok {
return admin.NewInvalidAdminReqFormatError("missing required field 'script")
}

argsRaw, ok := input["args"]
if !ok {
return admin.NewInvalidAdminReqFormatError("missing required field 'args")
}

heightStr, ok := heightRaw.(string)
if !ok {
return admin.NewInvalidAdminReqFormatError("'height' must be string")
}

height, err := strconv.ParseUint(heightStr, 10, 64)
if err != nil {
return admin.NewInvalidAdminReqFormatError("'height' must be valid uint64 value", err)
}

scriptStr, ok := scriptRaw.(string)
if !ok {
return admin.NewInvalidAdminReqFormatError("'script' must be string")
}

argsStr, ok := argsRaw.(string)
if !ok {
return admin.NewInvalidAdminReqFormatError("'args' must be string")
}

args := make([][]byte, 0)
err = json.Unmarshal([]byte(argsStr), &args)
if err != nil {
return admin.NewInvalidAdminReqFormatError("'args' not valid JSON", err)
}

req.ValidatorData = &scriptData{
height: height,
script: []byte(scriptStr),
arguments: args,
}

return nil
}

func NewExecuteScriptCommand(scripts execution.ScriptExecutor) commands.AdminCommand {
return &ExecuteScriptCommand{
scripts,
}
}
Loading

0 comments on commit 6a42f1e

Please sign in to comment.