github.com/koko1123/flow-go-1@v0.29.6/Makefile (about)

     1  # The short Git commit hash
     2  SHORT_COMMIT := $(shell git rev-parse --short HEAD)
     3  # The Git commit hash
     4  COMMIT := $(shell git rev-parse HEAD)
     5  # The tag of the current commit, otherwise empty
     6  VERSION := $(shell git describe --tags --abbrev=2 --match "v*" --match "secure-cadence*" 2>/dev/null)
     7  
     8  # By default, this will run all tests in all packages, but we have a way to override this in CI so that we can
     9  # dynamically split up CI jobs into smaller jobs that can be run in parallel
    10  GO_TEST_PACKAGES := ./...
    11  
    12  # Image tag: if image tag is not set, set it with version (or short commit if empty)
    13  ifeq (${IMAGE_TAG},)
    14  IMAGE_TAG := ${VERSION}
    15  endif
    16  
    17  ifeq (${IMAGE_TAG},)
    18  IMAGE_TAG := ${SHORT_COMMIT}
    19  endif
    20  
    21  IMAGE_TAG_NO_NETGO := $(IMAGE_TAG)-without_netgo
    22  
    23  # Name of the cover profile
    24  COVER_PROFILE := coverage.txt
    25  # Disable go sum database lookup for private repos
    26  GOPRIVATE=github.com/dapperlabs/*
    27  # OS
    28  UNAME := $(shell uname)
    29  
    30  # Used when building within docker
    31  GOARCH := $(shell go env GOARCH)
    32  
    33  # The location of the k8s YAML files
    34  K8S_YAMLS_LOCATION_STAGING=./k8s/staging
    35  
    36  # docker container registry
    37  export CONTAINER_REGISTRY := gcr.io/flow-container-registry
    38  export DOCKER_BUILDKIT := 1
    39  
    40  # setup the crypto package under the GOPATH: needed to test packages importing flow-go/crypto
    41  .PHONY: crypto_setup_gopath
    42  crypto_setup_gopath:
    43  	bash crypto_setup.sh
    44  
    45  cmd/collection/collection:
    46  	go build -o cmd/collection/collection cmd/collection/main.go
    47  
    48  cmd/util/util:
    49  	go build -o cmd/util/util --tags relic cmd/util/main.go
    50  
    51  ############################################################################################
    52  # CAUTION: DO NOT MODIFY THESE TARGETS! DOING SO WILL BREAK THE FLAKY TEST MONITOR
    53  
    54  .PHONY: unittest-main
    55  unittest-main:
    56  	# test all packages with Relic library enabled
    57  	go test $(if $(VERBOSE),-v,) -coverprofile=$(COVER_PROFILE) -covermode=atomic $(if $(RACE_DETECTOR),-race,) $(if $(JSON_OUTPUT),-json,) $(if $(NUM_RUNS),-count $(NUM_RUNS),) --tags relic $(GO_TEST_PACKAGES)
    58  
    59  .PHONY: install-mock-generators
    60  install-mock-generators:
    61  	cd ${GOPATH}; \
    62      go install github.com/vektra/mockery/v2@v2.13.1; \
    63      go install github.com/golang/mock/mockgen@v1.3.1;
    64  
    65  .PHONY: install-tools
    66  install-tools: crypto_setup_gopath check-go-version install-mock-generators
    67  	cd ${GOPATH}; \
    68  	go install github.com/golang/protobuf/protoc-gen-go@v1.3.2; \
    69  	go install github.com/uber/prototool/cmd/prototool@v1.9.0; \
    70  	go install github.com/gogo/protobuf/protoc-gen-gofast@latest; \
    71  	go install golang.org/x/tools/cmd/stringer@master;
    72  
    73  .PHONY: verify-mocks
    74  verify-mocks: generate-mocks
    75  	git diff --exit-code
    76  
    77  ############################################################################################
    78  
    79  .PHONY: emulator-norelic-check
    80  emulator-norelic-check:
    81  	# test the fvm package compiles with Relic library disabled (required for the emulator build)
    82  	cd ./fvm && go test ./... -run=NoTestHasThisPrefix
    83  
    84  .PHONY: fuzz-fvm
    85  fuzz-fvm:
    86  	# run fuzz tests in the fvm package
    87  	cd ./fvm && go test -fuzz=Fuzz -run ^$$ --tags relic
    88  
    89  .PHONY: test
    90  test: verify-mocks unittest-main
    91  
    92  .PHONY: integration-test
    93  integration-test: docker-build-flow
    94  	$(MAKE) -C integration integration-test
    95  
    96  .PHONY: benchmark
    97  benchmark: docker-build-flow
    98  	$(MAKE) -C integration benchmark
    99  
   100  .PHONY: coverage
   101  coverage:
   102  ifeq ($(COVER), true)
   103  	# Cover summary has to produce cover.json
   104  	COVER_PROFILE=$(COVER_PROFILE) ./cover-summary.sh
   105  	# file has to be called index.html
   106  	gocov-html cover.json > index.html
   107  	# coverage.zip will automatically be picked up by teamcity
   108  	zip coverage.zip index.html
   109  endif
   110  
   111  .PHONY: generate-openapi
   112  generate-openapi:
   113  	swagger-codegen generate -l go -i https://raw.githubusercontent.com/onflow/flow/master/openapi/access.yaml -D packageName=models,modelDocs=false,models -o engine/access/rest/models;
   114  	go fmt ./engine/access/rest/models
   115  
   116  .PHONY: generate
   117  generate: generate-proto generate-mocks generate-fvm-env-wrappers
   118  
   119  .PHONY: generate-proto
   120  generate-proto:
   121  	prototool generate protobuf
   122  
   123  .PHONY: generate-fvm-env-wrappers
   124  generate-fvm-env-wrappers:
   125  	go run ./fvm/environment/generate-wrappers fvm/environment/parse_restricted_checker.go
   126  
   127  .PHONY: generate-mocks
   128  generate-mocks: install-mock-generators
   129  	mockery --name '(Connector|PingInfoProvider)' --dir=network/p2p --case=underscore --output="./network/mocknetwork" --outpkg="mocknetwork"
   130  	mockgen -destination=storage/mocks/storage.go -package=mocks github.com/onflow/flow-go/storage Blocks,Headers,Payloads,Collections,Commits,Events,ServiceEvents,TransactionResults
   131  	mockgen -destination=module/mocks/network.go -package=mocks github.com/onflow/flow-go/module Local,Requester
   132  	mockgen -destination=network/mocknetwork/mock_network.go -package=mocknetwork github.com/onflow/flow-go/network Network
   133  	mockery --name='.*' --dir=integration/benchmark/mocksiface --case=underscore --output="integration/benchmark/mock" --outpkg="mock"
   134  	mockery --name=ExecutionDataStore --dir=module/executiondatasync/execution_data --case=underscore --output="./module/executiondatasync/execution_data/mock" --outpkg="mock"
   135  	mockery --name=Downloader --dir=module/executiondatasync/execution_data --case=underscore --output="./module/executiondatasync/execution_data/mock" --outpkg="mock"
   136  	mockery --name 'ExecutionDataRequester' --dir=module/state_synchronization --case=underscore --output="./module/state_synchronization/mock" --outpkg="state_synchronization"
   137  	mockery --name 'ExecutionState' --dir=engine/execution/state --case=underscore --output="engine/execution/state/mock" --outpkg="mock"
   138  	mockery --name 'BlockComputer' --dir=engine/execution/computation/computer --case=underscore --output="engine/execution/computation/computer/mock" --outpkg="mock"
   139  	mockery --name 'ComputationManager' --dir=engine/execution/computation --case=underscore --output="engine/execution/computation/mock" --outpkg="mock"
   140  	mockery --name 'EpochComponentsFactory' --dir=engine/collection/epochmgr --case=underscore --output="engine/collection/epochmgr/mock" --outpkg="mock"
   141  	mockery --name 'Backend' --dir=engine/collection/rpc --case=underscore --output="engine/collection/rpc/mock" --outpkg="mock"
   142  	mockery --name 'ProviderEngine' --dir=engine/execution/provider --case=underscore --output="engine/execution/provider/mock" --outpkg="mock"
   143  	(cd ./crypto && mockery --name 'PublicKey' --case=underscore --output="../module/mock" --outpkg="mock")
   144  	mockery --name '.*' --dir=state/cluster --case=underscore --output="state/cluster/mock" --outpkg="mock"
   145  	mockery --name '.*' --dir=module --case=underscore --tags="relic" --output="./module/mock" --outpkg="mock"
   146  	mockery --name '.*' --dir=module/mempool --case=underscore --output="./module/mempool/mock" --outpkg="mempool"
   147  	mockery --name '.*' --dir=module/component --case=underscore --output="./module/component/mock" --outpkg="component"
   148  	mockery --name '.*' --dir=network --case=underscore --output="./network/mocknetwork" --outpkg="mocknetwork"
   149  	mockery --name '.*' --dir=storage --case=underscore --output="./storage/mock" --outpkg="mock"
   150  	mockery --name '.*' --dir="state/protocol" --case=underscore --output="state/protocol/mock" --outpkg="mock"
   151  	mockery --name '.*' --dir="state/protocol/events" --case=underscore --output="./state/protocol/events/mock" --outpkg="mock"
   152  	mockery --name '.*' --dir=engine/execution/computation/computer --case=underscore --output="./engine/execution/computation/computer/mock" --outpkg="mock"
   153  	mockery --name '.*' --dir=engine/execution/state --case=underscore --output="./engine/execution/state/mock" --outpkg="mock"
   154  	mockery --name '.*' --dir=engine/consensus --case=underscore --output="./engine/consensus/mock" --outpkg="mock"
   155  	mockery --name '.*' --dir=engine/consensus/approvals --case=underscore --output="./engine/consensus/approvals/mock" --outpkg="mock"
   156  	rm -rf ./fvm/environment/mock
   157  	mockery --name '.*' --dir=fvm/environment --case=underscore --output="./fvm/environment/mock" --outpkg="mock"
   158  	mockery --name '.*' --dir=ledger --case=underscore --output="./ledger/mock" --outpkg="mock"
   159  	mockery --name 'ViolationsConsumer' --dir=network/slashing --case=underscore --output="./network/mocknetwork" --outpkg="mocknetwork"
   160  	mockery --name '.*' --dir=network/p2p/ --case=underscore --output="./network/p2p/mock" --outpkg="mockp2p"
   161  	mockery --name 'Vertex' --dir="./module/forest" --case=underscore --output="./module/forest/mock" --outpkg="mock"
   162  	mockery --name '.*' --dir="./consensus/hotstuff" --case=underscore --output="./consensus/hotstuff/mocks" --outpkg="mocks"
   163  	mockery --name '.*' --dir="./engine/access/wrapper" --case=underscore --output="./engine/access/mock" --outpkg="mock"
   164  	mockery --name 'API' --dir="./access" --case=underscore --output="./access/mock" --outpkg="mock"
   165  	mockery --name 'API' --dir="./engine/protocol" --case=underscore --output="./engine/protocol/mock" --outpkg="mock"
   166  	mockery --name 'API' --dir="./engine/access/state_stream" --case=underscore --output="./engine/access/state_stream/mock" --outpkg="mock"
   167  	mockery --name 'ConnectionFactory' --dir="./engine/access/rpc/backend" --case=underscore --output="./engine/access/rpc/backend/mock" --outpkg="mock"
   168  	mockery --name 'IngestRPC' --dir="./engine/execution/ingestion" --case=underscore --tags relic --output="./engine/execution/ingestion/mock" --outpkg="mock"
   169  	mockery --name '.*' --dir=model/fingerprint --case=underscore --output="./model/fingerprint/mock" --outpkg="mock"
   170  	mockery --name 'ExecForkActor' --structname 'ExecForkActorMock' --dir=module/mempool/consensus/mock/ --case=underscore --output="./module/mempool/consensus/mock/" --outpkg="mock"
   171  	mockery --name '.*' --dir=engine/verification/fetcher/ --case=underscore --output="./engine/verification/fetcher/mock" --outpkg="mockfetcher"
   172  	mockery --name '.*' --dir=./cmd/util/ledger/reporters --case=underscore --output="./cmd/util/ledger/reporters/mock" --outpkg="mock"
   173  	mockery --name 'Storage' --dir=module/executiondatasync/tracker --case=underscore --output="module/executiondatasync/tracker/mock" --outpkg="mocktracker"
   174  
   175  	#temporarily make insecure/ a non-module to allow mockery to create mocks
   176  	mv insecure/go.mod insecure/go2.mod
   177  	mockery --name '.*' --dir=insecure/ --case=underscore --output="./insecure/mock"  --outpkg="mockinsecure"
   178  	mv insecure/go2.mod insecure/go.mod
   179  
   180  # this ensures there is no unused dependency being added by accident
   181  .PHONY: tidy
   182  tidy:
   183  	go mod tidy -v
   184  	cd integration; go mod tidy -v
   185  	cd crypto; go mod tidy -v
   186  	cd cmd/testclient; go mod tidy -v
   187  	cd insecure; go mod tidy -v
   188  	git diff --exit-code
   189  
   190  .PHONY: lint
   191  lint: tidy
   192  	# revive -config revive.toml -exclude storage/ledger/trie ./...
   193  	golangci-lint run -v --build-tags relic ./...
   194  
   195  .PHONY: fix-lint
   196  fix-lint:
   197  	# revive -config revive.toml -exclude storage/ledger/trie ./...
   198  	golangci-lint run -v --build-tags relic --fix ./...
   199  
   200  # Runs unit tests with different list of packages as passed by CI so they run in parallel
   201  .PHONY: ci
   202  ci: install-tools test
   203  
   204  # Runs integration tests
   205  .PHONY: ci-integration
   206  ci-integration: crypto_setup_gopath
   207  	$(MAKE) -C integration ci-integration-test
   208  
   209  # Runs benchmark tests
   210  # NOTE: we do not need `docker-build-flow` as this is run as a separate step
   211  # on Teamcity
   212  .PHONY: ci-benchmark
   213  ci-benchmark: install-tools
   214  	$(MAKE) -C integration ci-benchmark
   215  
   216  # Runs unit tests, test coverage, lint in Docker (for mac)
   217  .PHONY: docker-ci
   218  docker-ci:
   219  	docker run --env RACE_DETECTOR=$(RACE_DETECTOR) --env COVER=$(COVER) --env JSON_OUTPUT=$(JSON_OUTPUT) \
   220  		-v /run/host-services/ssh-auth.sock:/run/host-services/ssh-auth.sock -e SSH_AUTH_SOCK="/run/host-services/ssh-auth.sock" \
   221  		-v "$(CURDIR)":/go/flow -v "/tmp/.cache":"/root/.cache" -v "/tmp/pkg":"/go/pkg" \
   222  		-w "/go/flow" "$(CONTAINER_REGISTRY)/golang-cmake:v0.0.7" \
   223  		make ci
   224  
   225  # Runs integration tests in Docker  (for mac)
   226  .PHONY: docker-ci-integration
   227  docker-ci-integration:
   228  	rm -rf crypto/relic
   229  	docker run \
   230  		--env DOCKER_API_VERSION='1.39' \
   231  		--network host \
   232  		-v "$(CURDIR)":/go/flow -v "/tmp/.cache":"/root/.cache" -v "/tmp/pkg":"/go/pkg" \
   233  		-v /tmp:/tmp \
   234  		-v /var/run/docker.sock:/var/run/docker.sock \
   235  		-v /run/host-services/ssh-auth.sock:/run/host-services/ssh-auth.sock -e SSH_AUTH_SOCK="/run/host-services/ssh-auth.sock" \
   236  		-w "/go/flow" "$(CONTAINER_REGISTRY)/golang-cmake:v0.0.7" \
   237  		make ci-integration
   238  
   239  .PHONY: docker-build-collection
   240  docker-build-collection:
   241  	docker build -f cmd/Dockerfile  --build-arg TARGET=./cmd/collection --build-arg COMMIT=$(COMMIT)  --build-arg VERSION=$(IMAGE_TAG) --build-arg GOARCH=$(GOARCH) --target production \
   242  		--label "git_commit=${COMMIT}" --label "git_tag=${IMAGE_TAG}" \
   243  		-t "$(CONTAINER_REGISTRY)/collection:latest" -t "$(CONTAINER_REGISTRY)/collection:$(SHORT_COMMIT)" -t "$(CONTAINER_REGISTRY)/collection:$(IMAGE_TAG)" .
   244  
   245  .PHONY: docker-build-collection-without-netgo
   246  docker-build-collection-without-netgo:
   247  	docker build -f cmd/Dockerfile  --build-arg TAGS=relic --build-arg TARGET=./cmd/collection --build-arg COMMIT=$(COMMIT)  --build-arg VERSION=$(IMAGE_TAG_NO_NETGO) --build-arg GOARCH=$(GOARCH) --target production \
   248  		--label "git_commit=${COMMIT}" --label "git_tag=$(IMAGE_TAG_NO_NETGO)" -t "$(CONTAINER_REGISTRY)/collection:$(IMAGE_TAG_NO_NETGO)" .
   249  
   250  .PHONY: docker-build-collection-debug
   251  docker-build-collection-debug:
   252  	docker build -f cmd/Dockerfile  --build-arg TARGET=./cmd/collection --build-arg COMMIT=$(COMMIT)  --build-arg VERSION=$(IMAGE_TAG) --build-arg GOARCH=$(GOARCH) --target debug \
   253  		-t "$(CONTAINER_REGISTRY)/collection-debug:latest" -t "$(CONTAINER_REGISTRY)/collection-debug:$(SHORT_COMMIT)" -t "$(CONTAINER_REGISTRY)/collection-debug:$(IMAGE_TAG)" .
   254  
   255  .PHONY: docker-build-consensus
   256  docker-build-consensus:
   257  	docker build -f cmd/Dockerfile  --build-arg TARGET=./cmd/consensus --build-arg COMMIT=$(COMMIT)  --build-arg VERSION=$(IMAGE_TAG) --build-arg GOARCH=$(GOARCH) --target production \
   258  		--label "git_commit=${COMMIT}" --label "git_tag=${IMAGE_TAG}" \
   259  		-t "$(CONTAINER_REGISTRY)/consensus:latest" -t "$(CONTAINER_REGISTRY)/consensus:$(SHORT_COMMIT)" -t "$(CONTAINER_REGISTRY)/consensus:$(IMAGE_TAG)" .
   260  
   261  .PHONY: docker-build-consensus-without-netgo
   262  docker-build-consensus-without-netgo:
   263  	docker build -f cmd/Dockerfile  --build-arg TAGS=relic --build-arg TARGET=./cmd/consensus --build-arg COMMIT=$(COMMIT)  --build-arg VERSION=$(IMAGE_TAG_NO_NETGO) --build-arg GOARCH=$(GOARCH) --target production \
   264  		--label "git_commit=${COMMIT}" --label "git_tag=$(IMAGE_TAG_NO_NETGO)" -t "$(CONTAINER_REGISTRY)/consensus:$(IMAGE_TAG_NO_NETGO)" .
   265  
   266  .PHONY: docker-build-consensus-debug
   267  docker-build-consensus-debug:
   268  	docker build -f cmd/Dockerfile  --build-arg TARGET=./cmd/consensus --build-arg COMMIT=$(COMMIT)  --build-arg VERSION=$(IMAGE_TAG) --build-arg GOARCH=$(GOARCH) --target debug \
   269  		-t "$(CONTAINER_REGISTRY)/consensus-debug:latest" -t "$(CONTAINER_REGISTRY)/consensus-debug:$(SHORT_COMMIT)" -t "$(CONTAINER_REGISTRY)/consensus-debug:$(IMAGE_TAG)" .
   270  
   271  .PHONY: docker-build-execution
   272  docker-build-execution:
   273  	docker build -f cmd/Dockerfile  --build-arg TARGET=./cmd/execution --build-arg COMMIT=$(COMMIT)  --build-arg VERSION=$(IMAGE_TAG) --build-arg GOARCH=$(GOARCH) --target production \
   274  		--label "git_commit=${COMMIT}" --label "git_tag=${IMAGE_TAG}" \
   275  		-t "$(CONTAINER_REGISTRY)/execution:latest" -t "$(CONTAINER_REGISTRY)/execution:$(SHORT_COMMIT)" -t "$(CONTAINER_REGISTRY)/execution:$(IMAGE_TAG)" .
   276  
   277  .PHONY: docker-build-execution-without-netgo
   278  docker-build-execution-without-netgo:
   279  	docker build -f cmd/Dockerfile  --build-arg TAGS=relic --build-arg TARGET=./cmd/execution --build-arg COMMIT=$(COMMIT)  --build-arg VERSION=$(IMAGE_TAG_NO_NETGO) --build-arg GOARCH=$(GOARCH) --target production \
   280  		--label "git_commit=${COMMIT}" --label "git_tag=$(IMAGE_TAG_NO_NETGO)" -t "$(CONTAINER_REGISTRY)/execution:$(IMAGE_TAG_NO_NETGO)" .
   281  
   282  .PHONY: docker-build-execution-debug
   283  docker-build-execution-debug:
   284  	docker build -f cmd/Dockerfile  --build-arg TARGET=./cmd/execution --build-arg COMMIT=$(COMMIT)  --build-arg VERSION=$(IMAGE_TAG) --build-arg GOARCH=$(GOARCH) --target debug \
   285  		-t "$(CONTAINER_REGISTRY)/execution-debug:latest" -t "$(CONTAINER_REGISTRY)/execution-debug:$(SHORT_COMMIT)" -t "$(CONTAINER_REGISTRY)/execution-debug:$(IMAGE_TAG)" .
   286  
   287  # build corrupt execution node for BFT testing
   288  .PHONY: docker-build-execution-corrupt
   289  docker-build-execution-corrupt:
   290  	# temporarily make insecure/ a non-module to allow Docker to use corrupt builders there
   291  	./insecure/cmd/mods_override.sh
   292  	docker build -f cmd/Dockerfile  --build-arg TARGET=./insecure/cmd/execution --build-arg COMMIT=$(COMMIT)  --build-arg VERSION=$(IMAGE_TAG) --build-arg GOARCH=$(GOARCH) --target production \
   293  		--label "git_commit=${COMMIT}" --label "git_tag=${IMAGE_TAG}" \
   294  		-t "$(CONTAINER_REGISTRY)/execution-corrupted:latest" -t "$(CONTAINER_REGISTRY)/execution-corrupted:$(SHORT_COMMIT)" -t "$(CONTAINER_REGISTRY)/execution-corrupted:$(IMAGE_TAG)" .
   295  	./insecure/cmd/mods_restore.sh
   296  
   297  .PHONY: docker-build-verification
   298  docker-build-verification:
   299  	docker build -f cmd/Dockerfile  --build-arg TARGET=./cmd/verification --build-arg COMMIT=$(COMMIT)  --build-arg VERSION=$(IMAGE_TAG) --build-arg GOARCH=$(GOARCH) --target production \
   300  		--label "git_commit=${COMMIT}" --label "git_tag=${IMAGE_TAG}" \
   301  		-t "$(CONTAINER_REGISTRY)/verification:latest" -t "$(CONTAINER_REGISTRY)/verification:$(SHORT_COMMIT)" -t "$(CONTAINER_REGISTRY)/verification:$(IMAGE_TAG)" .
   302  
   303  .PHONY: docker-build-verification-without-netgo
   304  docker-build-verification-without-netgo:
   305  	docker build -f cmd/Dockerfile  --build-arg TAGS=relic --build-arg TARGET=./cmd/verification --build-arg COMMIT=$(COMMIT)  --build-arg VERSION=$(IMAGE_TAG_NO_NETGO) --build-arg GOARCH=$(GOARCH) --target production \
   306  		--label "git_commit=${COMMIT}" --label "git_tag=$(IMAGE_TAG_NO_NETGO)" -t "$(CONTAINER_REGISTRY)/verification:$(IMAGE_TAG_NO_NETGO)" .
   307  
   308  .PHONY: docker-build-verification-debug
   309  docker-build-verification-debug:
   310  	docker build -f cmd/Dockerfile  --build-arg TARGET=./cmd/verification --build-arg COMMIT=$(COMMIT)  --build-arg VERSION=$(IMAGE_TAG) --build-arg GOARCH=$(GOARCH) --target debug \
   311  		-t "$(CONTAINER_REGISTRY)/verification-debug:latest" -t "$(CONTAINER_REGISTRY)/verification-debug:$(SHORT_COMMIT)" -t "$(CONTAINER_REGISTRY)/verification-debug:$(IMAGE_TAG)" .
   312  
   313  # build corrupt verification node for BFT testing
   314  .PHONY: docker-build-verification-corrupt
   315  docker-build-verification-corrupt:
   316  	# temporarily make insecure/ a non-module to allow Docker to use corrupt builders there
   317  	./insecure/cmd/mods_override.sh
   318  	docker build -f cmd/Dockerfile  --build-arg TARGET=./insecure/cmd/verification --build-arg COMMIT=$(COMMIT)  --build-arg VERSION=$(IMAGE_TAG) --build-arg GOARCH=$(GOARCH) --target production \
   319  		--label "git_commit=${COMMIT}" --label "git_tag=${IMAGE_TAG}" \
   320  		-t "$(CONTAINER_REGISTRY)/verification-corrupted:latest" -t "$(CONTAINER_REGISTRY)/verification-corrupted:$(SHORT_COMMIT)" -t "$(CONTAINER_REGISTRY)/verification-corrupted:$(IMAGE_TAG)" .
   321  	./insecure/cmd/mods_restore.sh
   322  
   323  .PHONY: docker-build-access
   324  docker-build-access:
   325  	docker build -f cmd/Dockerfile  --build-arg TARGET=./cmd/access --build-arg COMMIT=$(COMMIT)  --build-arg VERSION=$(IMAGE_TAG) --build-arg GOARCH=$(GOARCH) --target production \
   326  		--label "git_commit=${COMMIT}" --label "git_tag=${IMAGE_TAG}" \
   327  		-t "$(CONTAINER_REGISTRY)/access:latest" -t "$(CONTAINER_REGISTRY)/access:$(SHORT_COMMIT)" -t "$(CONTAINER_REGISTRY)/access:$(IMAGE_TAG)" .
   328  
   329  .PHONY: docker-build-access-without-netgo
   330  docker-build-access-without-netgo:
   331  	docker build -f cmd/Dockerfile  --build-arg TAGS=relic --build-arg TARGET=./cmd/access --build-arg COMMIT=$(COMMIT)  --build-arg VERSION=$(IMAGE_TAG_NO_NETGO) --build-arg GOARCH=$(GOARCH) --target production \
   332  		--label "git_commit=${COMMIT}" --label "git_tag=$(IMAGE_TAG_NO_NETGO)" -t "$(CONTAINER_REGISTRY)/access:$(IMAGE_TAG_NO_NETGO)" .
   333  
   334  .PHONY: docker-build-access-debug
   335  docker-build-access-debug:
   336  	docker build -f cmd/Dockerfile  --build-arg TARGET=./cmd/access  --build-arg COMMIT=$(COMMIT) --build-arg VERSION=$(IMAGE_TAG) --build-arg GOARCH=$(GOARCH) --target debug \
   337  		-t "$(CONTAINER_REGISTRY)/access-debug:latest" -t "$(CONTAINER_REGISTRY)/access-debug:$(SHORT_COMMIT)" -t "$(CONTAINER_REGISTRY)/access-debug:$(IMAGE_TAG)" .
   338  
   339  # build corrupt access node for BFT testing
   340  .PHONY: docker-build-access-corrupt
   341  docker-build-access-corrupt:
   342  	#temporarily make insecure/ a non-module to allow Docker to use corrupt builders there
   343  	./insecure/cmd/mods_override.sh
   344  	docker build -f cmd/Dockerfile  --build-arg TARGET=./insecure/cmd/access --build-arg COMMIT=$(COMMIT)  --build-arg VERSION=$(IMAGE_TAG) --build-arg GOARCH=$(GOARCH) --target production \
   345  		--label "git_commit=${COMMIT}" --label "git_tag=${IMAGE_TAG}" \
   346  		-t "$(CONTAINER_REGISTRY)/access-corrupted:latest" -t "$(CONTAINER_REGISTRY)/access-corrupted:$(SHORT_COMMIT)" -t "$(CONTAINER_REGISTRY)/access-corrupted:$(IMAGE_TAG)" .
   347  	./insecure/cmd/mods_restore.sh
   348  
   349  .PHONY: docker-build-observer
   350  docker-build-observer:
   351  	docker build -f cmd/Dockerfile --build-arg TARGET=./cmd/observer --build-arg COMMIT=$(COMMIT) --build-arg VERSION=$(IMAGE_TAG) --build-arg GOARCH=$(GOARCH) --target production \
   352  		--label "git_commit=${COMMIT}" --label "git_tag=${IMAGE_TAG}" \
   353  		-t "$(CONTAINER_REGISTRY)/observer:latest" -t "$(CONTAINER_REGISTRY)/observer:$(SHORT_COMMIT)" -t "$(CONTAINER_REGISTRY)/observer:$(IMAGE_TAG)" .
   354  
   355  .PHONY: docker-build-observer-without-netgo
   356  docker-build-observer-without-netgo:
   357  	docker build -f cmd/Dockerfile  --build-arg TAGS=relic --build-arg TARGET=./cmd/observer --build-arg COMMIT=$(COMMIT)  --build-arg VERSION=$(IMAGE_TAG_NO_NETGO) --build-arg GOARCH=$(GOARCH) --target production \
   358  		--label "git_commit=${COMMIT}" --label "git_tag=$(IMAGE_TAG_NO_NETGO)" -t "$(CONTAINER_REGISTRY)/observer:$(IMAGE_TAG_NO_NETGO)" .
   359  
   360  
   361  .PHONY: docker-build-ghost
   362  docker-build-ghost:
   363  	docker build -f cmd/Dockerfile  --build-arg TARGET=./cmd/ghost --build-arg COMMIT=$(COMMIT)  --build-arg VERSION=$(IMAGE_TAG) --build-arg GOARCH=$(GOARCH) --target production \
   364  		--label "git_commit=${COMMIT}" --label "git_tag=${IMAGE_TAG}" \
   365  		-t "$(CONTAINER_REGISTRY)/ghost:latest" -t "$(CONTAINER_REGISTRY)/ghost:$(SHORT_COMMIT)" -t "$(CONTAINER_REGISTRY)/ghost:$(IMAGE_TAG)" .
   366  
   367  .PHONY: docker-build-ghost-debug
   368  docker-build-ghost-debug:
   369  	docker build -f cmd/Dockerfile  --build-arg TARGET=./cmd/ghost --build-arg COMMIT=$(COMMIT)  --build-arg VERSION=$(IMAGE_TAG) --build-arg GOARCH=$(GOARCH) --target debug \
   370  		-t "$(CONTAINER_REGISTRY)/ghost-debug:latest" -t "$(CONTAINER_REGISTRY)/ghost-debug:$(SHORT_COMMIT)" -t "$(CONTAINER_REGISTRY)/ghost-debug:$(IMAGE_TAG)" .
   371  
   372  PHONY: docker-build-bootstrap
   373  docker-build-bootstrap:
   374  	docker build -f cmd/Dockerfile  --build-arg TARGET=./cmd/bootstrap --build-arg GOARCH=$(GOARCH) --target production \
   375  		--label "git_commit=${COMMIT}" --label "git_tag=${IMAGE_TAG}" \
   376  		-t "$(CONTAINER_REGISTRY)/bootstrap:latest" -t "$(CONTAINER_REGISTRY)/bootstrap:$(SHORT_COMMIT)" -t "$(CONTAINER_REGISTRY)/bootstrap:$(IMAGE_TAG)" .
   377  
   378  PHONY: tool-bootstrap
   379  tool-bootstrap: docker-build-bootstrap
   380  	docker container create --name bootstrap $(CONTAINER_REGISTRY)/bootstrap:latest;docker container cp bootstrap:/bin/app ./bootstrap;docker container rm bootstrap
   381  
   382  .PHONY: docker-build-bootstrap-transit
   383  docker-build-bootstrap-transit:
   384  	docker build -f cmd/Dockerfile  --build-arg TARGET=./cmd/bootstrap/transit --build-arg COMMIT=$(COMMIT)  --build-arg VERSION=$(VERSION) --build-arg GOARCH=$(GOARCH) --no-cache \
   385  	    --target production  \
   386  		-t "$(CONTAINER_REGISTRY)/bootstrap-transit:latest" -t "$(CONTAINER_REGISTRY)/bootstrap-transit:$(SHORT_COMMIT)" -t "$(CONTAINER_REGISTRY)/bootstrap-transit:$(IMAGE_TAG)" .
   387  
   388  PHONY: tool-transit
   389  tool-transit: docker-build-bootstrap-transit
   390  	docker container create --name transit $(CONTAINER_REGISTRY)/bootstrap-transit:latest;docker container cp transit:/bin/app ./transit;docker container rm transit
   391  
   392  .PHONY: docker-build-loader
   393  docker-build-loader:
   394  	docker build -f ./integration/benchmark/cmd/manual/Dockerfile --build-arg TARGET=./benchmark/cmd/manual --target production \
   395  		--label "git_commit=${COMMIT}" --label "git_tag=${IMAGE_TAG}" \
   396  		-t "$(CONTAINER_REGISTRY)/loader:latest" -t "$(CONTAINER_REGISTRY)/loader:$(SHORT_COMMIT)" -t "$(CONTAINER_REGISTRY)/loader:$(IMAGE_TAG)" .
   397  
   398  .PHONY: docker-build-flow
   399  docker-build-flow: docker-build-collection docker-build-consensus docker-build-execution docker-build-verification docker-build-access docker-build-observer docker-build-ghost
   400  
   401  .PHONY: docker-build-flow-without-netgo
   402  docker-build-flow-without-netgo: docker-build-collection-without-netgo docker-build-consensus-without-netgo docker-build-execution-without-netgo docker-build-verification-without-netgo docker-build-access-without-netgo docker-build-observer-without-netgo
   403  
   404  .PHONY: docker-build-flow-corrupt
   405  docker-build-flow-corrupt: docker-build-execution-corrupt docker-build-verification-corrupt docker-build-access-corrupt
   406  
   407  .PHONY: docker-build-benchnet
   408  docker-build-benchnet: docker-build-flow docker-build-loader
   409  
   410  .PHONY: docker-push-collection
   411  docker-push-collection:
   412  	docker push "$(CONTAINER_REGISTRY)/collection:$(SHORT_COMMIT)"
   413  	docker push "$(CONTAINER_REGISTRY)/collection:$(IMAGE_TAG)"
   414  
   415  .PHONY: docker-push-collection-without-netgo
   416  docker-push-collection-without-netgo:
   417  	docker push "$(CONTAINER_REGISTRY)/collection:$(IMAGE_TAG_NO_NETGO)"
   418  
   419  .PHONY: docker-push-collection-latest
   420  docker-push-collection-latest: docker-push-collection
   421  	docker push "$(CONTAINER_REGISTRY)/collection:latest"
   422  
   423  .PHONY: docker-push-consensus
   424  docker-push-consensus:
   425  	docker push "$(CONTAINER_REGISTRY)/consensus:$(SHORT_COMMIT)"
   426  	docker push "$(CONTAINER_REGISTRY)/consensus:$(IMAGE_TAG)"
   427  
   428  .PHONY: docker-push-consensus-without-netgo
   429  docker-push-consensus-without-netgo:
   430  	docker push "$(CONTAINER_REGISTRY)/consensus:$(IMAGE_TAG_NO_NETGO)"
   431  
   432  .PHONY: docker-push-consensus-latest
   433  docker-push-consensus-latest: docker-push-consensus
   434  	docker push "$(CONTAINER_REGISTRY)/consensus:latest"
   435  
   436  .PHONY: docker-push-execution
   437  docker-push-execution:
   438  	docker push "$(CONTAINER_REGISTRY)/execution:$(SHORT_COMMIT)"
   439  	docker push "$(CONTAINER_REGISTRY)/execution:$(IMAGE_TAG)"
   440  
   441  .PHONY: docker-push-execution-without-netgo
   442  docker-push-execution-without-netgo:
   443  	docker push "$(CONTAINER_REGISTRY)/execution:$(IMAGE_TAG_NO_NETGO)"
   444  
   445  .PHONY: docker-push-execution-latest
   446  docker-push-execution-latest: docker-push-execution
   447  	docker push "$(CONTAINER_REGISTRY)/execution:latest"
   448  
   449  .PHONY: docker-push-verification
   450  docker-push-verification:
   451  	docker push "$(CONTAINER_REGISTRY)/verification:$(SHORT_COMMIT)"
   452  	docker push "$(CONTAINER_REGISTRY)/verification:$(IMAGE_TAG)"
   453  
   454  .PHONY: docker-push-verification-without-netgo
   455  docker-push-verification-without-netgo:
   456  	docker push "$(CONTAINER_REGISTRY)/verification:$(IMAGE_TAG_NO_NETGO)"
   457  
   458  .PHONY: docker-push-verification-latest
   459  docker-push-verification-latest: docker-push-verification
   460  	docker push "$(CONTAINER_REGISTRY)/verification:latest"
   461  
   462  .PHONY: docker-push-access
   463  docker-push-access:
   464  	docker push "$(CONTAINER_REGISTRY)/access:$(SHORT_COMMIT)"
   465  	docker push "$(CONTAINER_REGISTRY)/access:$(IMAGE_TAG)"
   466  
   467  .PHONY: docker-push-access-without-netgo
   468  docker-push-access-without-netgo:
   469  	docker push "$(CONTAINER_REGISTRY)/access:$(IMAGE_TAG_NO_NETGO)"
   470  
   471  .PHONY: docker-push-access-latest
   472  docker-push-access-latest: docker-push-access
   473  	docker push "$(CONTAINER_REGISTRY)/access:latest"
   474  
   475  .PHONY: docker-push-observer
   476  docker-push-observer:
   477  	docker push "$(CONTAINER_REGISTRY)/observer:$(SHORT_COMMIT)"
   478  	docker push "$(CONTAINER_REGISTRY)/observer:$(IMAGE_TAG)"
   479  
   480  .PHONY: docker-push-observer-without-netgo
   481  docker-push-observer-without-netgo:
   482  	docker push "$(CONTAINER_REGISTRY)/observer:$(IMAGE_TAG_NO_NETGO)"
   483  
   484  .PHONY: docker-push-observer-latest
   485  docker-push-observer-latest: docker-push-observer
   486  	docker push "$(CONTAINER_REGISTRY)/observer:latest"
   487  
   488  .PHONY: docker-push-ghost
   489  docker-push-ghost:
   490  	docker push "$(CONTAINER_REGISTRY)/ghost:$(SHORT_COMMIT)"
   491  	docker push "$(CONTAINER_REGISTRY)/ghost:$(IMAGE_TAG)"
   492  
   493  .PHONY: docker-push-ghost-latest
   494  docker-push-ghost-latest: docker-push-ghost
   495  	docker push "$(CONTAINER_REGISTRY)/ghost:latest"
   496  
   497  .PHONY: docker-push-loader
   498  docker-push-loader:
   499  	docker push "$(CONTAINER_REGISTRY)/loader:$(SHORT_COMMIT)"
   500  	docker push "$(CONTAINER_REGISTRY)/loader:$(IMAGE_TAG)"
   501  
   502  .PHONY: docker-push-loader-latest
   503  docker-push-loader-latest: docker-push-loader
   504  	docker push "$(CONTAINER_REGISTRY)/loader:latest"
   505  
   506  .PHONY: docker-push-flow
   507  docker-push-flow: docker-push-collection docker-push-consensus docker-push-execution docker-push-verification docker-push-access docker-push-observer
   508  
   509  .PHONY: docker-push-flow-without-netgo
   510  docker-push-flow-without-netgo: docker-push-collection-without-netgo docker-push-consensus-without-netgo docker-push-execution-without-netgo docker-push-verification-without-netgo docker-push-access-without-netgo docker-push-observer-without-netgo
   511  
   512  .PHONY: docker-push-flow-latest
   513  docker-push-flow-latest: docker-push-collection-latest docker-push-consensus-latest docker-push-execution-latest docker-push-verification-latest docker-push-access-latest docker-push-observer-latest
   514  
   515  .PHONY: docker-push-benchnet
   516  docker-push-benchnet: docker-push-flow docker-push-loader
   517  
   518  .PHONY: docker-push-benchnet-latest
   519  docker-push-benchnet-latest: docker-push-flow-latest docker-push-loader-latest
   520  
   521  .PHONY: docker-run-collection
   522  docker-run-collection:
   523  	docker run -p 8080:8080 -p 3569:3569 "$(CONTAINER_REGISTRY)/collection:latest" --nodeid 1234567890123456789012345678901234567890123456789012345678901234 --entries collection-1234567890123456789012345678901234567890123456789012345678901234@localhost:3569=1000
   524  
   525  .PHONY: docker-run-consensus
   526  docker-run-consensus:
   527  	docker run -p 8080:8080 -p 3569:3569 "$(CONTAINER_REGISTRY)/consensus:latest" --nodeid 1234567890123456789012345678901234567890123456789012345678901234 --entries consensus-1234567890123456789012345678901234567890123456789012345678901234@localhost:3569=1000
   528  
   529  .PHONY: docker-run-execution
   530  docker-run-execution:
   531  	docker run -p 8080:8080 -p 3569:3569 "$(CONTAINER_REGISTRY)/execution:latest" --nodeid 1234567890123456789012345678901234567890123456789012345678901234 --entries execution-1234567890123456789012345678901234567890123456789012345678901234@localhost:3569=1000
   532  
   533  .PHONY: docker-run-verification
   534  docker-run-verification:
   535  	docker run -p 8080:8080 -p 3569:3569 "$(CONTAINER_REGISTRY)/verification:latest" --nodeid 1234567890123456789012345678901234567890123456789012345678901234 --entries verification-1234567890123456789012345678901234567890123456789012345678901234@localhost:3569=1000
   536  
   537  .PHONY: docker-run-access
   538  docker-run-access:
   539  	docker run -p 9000:9000 -p 3569:3569 -p 8080:8080  -p 8000:8000 "$(CONTAINER_REGISTRY)/access:latest" --nodeid 1234567890123456789012345678901234567890123456789012345678901234 --entries access-1234567890123456789012345678901234567890123456789012345678901234@localhost:3569=1000
   540  
   541  .PHONY: docker-run-observer
   542  docker-run-observer:
   543  	docker run -p 9000:9000 -p 3569:3569 -p 8080:8080  -p 8000:8000 "$(CONTAINER_REGISTRY)/observer:latest" --nodeid 1234567890123456789012345678901234567890123456789012345678901234 --entries observer-1234567890123456789012345678901234567890123456789012345678901234@localhost:3569=1000
   544  
   545  .PHONY: docker-run-ghost
   546  docker-run-ghost:
   547  	docker run -p 9000:9000 -p 3569:3569 "$(CONTAINER_REGISTRY)/ghost:latest" --nodeid 1234567890123456789012345678901234567890123456789012345678901234 --entries ghost-1234567890123456789012345678901234567890123456789012345678901234@localhost:3569=1000
   548  
   549  PHONY: docker-all-tools
   550  docker-all-tools: tool-util tool-remove-execution-fork
   551  
   552  PHONY: docker-build-util
   553  docker-build-util:
   554  	docker build -f cmd/Dockerfile --build-arg TARGET=./cmd/util --build-arg GOARCH=$(GOARCH) --target production \
   555  		-t "$(CONTAINER_REGISTRY)/util:latest" -t "$(CONTAINER_REGISTRY)/util:$(SHORT_COMMIT)" -t "$(CONTAINER_REGISTRY)/util:$(IMAGE_TAG)" .
   556  
   557  PHONY: tool-util
   558  tool-util: docker-build-util
   559  	docker container create --name util $(CONTAINER_REGISTRY)/util:latest;docker container cp util:/bin/app ./util;docker container rm util
   560  
   561  PHONY: docker-build-remove-execution-fork
   562  docker-build-remove-execution-fork:
   563  	docker build -f cmd/Dockerfile --ssh default --build-arg TARGET=./cmd/util/cmd/remove-execution-fork --build-arg GOARCH=$(GOARCH) --target production \
   564  		-t "$(CONTAINER_REGISTRY)/remove-execution-fork:latest" -t "$(CONTAINER_REGISTRY)/remove-execution-fork:$(SHORT_COMMIT)" -t "$(CONTAINER_REGISTRY)/remove-execution-fork:$(IMAGE_TAG)" .
   565  
   566  PHONY: tool-remove-execution-fork
   567  tool-remove-execution-fork: docker-build-remove-execution-fork
   568  	docker container create --name remove-execution-fork $(CONTAINER_REGISTRY)/remove-execution-fork:latest;docker container cp remove-execution-fork:/bin/app ./remove-execution-fork;docker container rm remove-execution-fork
   569  
   570  .PHONY: check-go-version
   571  check-go-version:
   572  	@bash -c '\
   573  		MINGOVERSION=1.18; \
   574  		function ver { printf "%d%03d%03d%03d" $$(echo "$$1" | tr . " "); }; \
   575  		GOVER=$$(go version | sed -rne "s/.* go([0-9.]+).*/\1/p" ); \
   576  		if [ "$$(ver $$GOVER)" -lt "$$(ver $$MINGOVERSION)" ]; then \
   577  			echo "go $$GOVER is too old. flow-go only supports go $$MINGOVERSION and up."; \
   578  			exit 1; \
   579  		fi; \
   580  		'
   581  
   582  #----------------------------------------------------------------------
   583  # CD COMMANDS
   584  #----------------------------------------------------------------------
   585  
   586  .PHONY: deploy-staging
   587  deploy-staging: update-deployment-image-name-staging apply-staging-files monitor-rollout
   588  
   589  # Staging YAMLs must have 'staging' in their name.
   590  .PHONY: apply-staging-files
   591  apply-staging-files:
   592  	kconfig=$$(uuidgen); \
   593  	echo "$$KUBECONFIG_STAGING" > $$kconfig; \
   594  	files=$$(find ${K8S_YAMLS_LOCATION_STAGING} -type f \( --name "*.yml" -or --name "*.yaml" \)); \
   595  	echo "$$files" | xargs -I {} kubectl --kubeconfig=$$kconfig apply -f {}
   596  
   597  # Deployment YAMLs must have 'deployment' in their name.
   598  .PHONY: update-deployment-image-name-staging
   599  update-deployment-image-name-staging: CONTAINER=flow-test-net
   600  update-deployment-image-name-staging:
   601  	@files=$$(find ${K8S_YAMLS_LOCATION_STAGING} -type f \( --name "*.yml" -or --name "*.yaml" \) | grep deployment); \
   602  	for file in $$files; do \
   603  		patched=`openssl rand -hex 8`; \
   604  		node=`echo "$$file" | grep -oP 'flow-\K\w+(?=-node-deployment.yml)'`; \
   605  		kubectl patch -f $$file -p '{"spec":{"template":{"spec":{"containers":[{"name":"${CONTAINER}","image":"$(CONTAINER_REGISTRY)/'"$$node"':${IMAGE_TAG}"}]}}}}`' --local -o yaml > $$patched; \
   606  		mv -f $$patched $$file; \
   607  	done
   608  
   609  .PHONY: monitor-rollout
   610  monitor-rollout:
   611  	kconfig=$$(uuidgen); \
   612  	echo "$$KUBECONFIG_STAGING" > $$kconfig; \
   613  	kubectl --kubeconfig=$$kconfig rollout status statefulsets.apps flow-collection-node-v1; \
   614  	kubectl --kubeconfig=$$kconfig rollout status statefulsets.apps flow-consensus-node-v1; \
   615  	kubectl --kubeconfig=$$kconfig rollout status statefulsets.apps flow-execution-node-v1; \
   616  	kubectl --kubeconfig=$$kconfig rollout status statefulsets.apps flow-verification-node-v1