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

Docker updates to build and run #696

Open
wants to merge 200 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 194 commits
Commits
Show all changes
200 commits
Select commit Hold shift + click to select a range
0446472
clenup of event subscriber
janezpodhostnik Oct 29, 2024
c9d3752
pull start height out of event subscriber
janezpodhostnik Oct 29, 2024
bc3b99b
remove heartbeat interval setting
janezpodhostnik Oct 30, 2024
30fe324
Aggregate and expose EVM-related event payloads
m-Peter Oct 25, 2024
eaf0db2
Implement BlockProvider for block snapshotting
m-Peter Oct 28, 2024
d8e1146
remove traces
janezpodhostnik Oct 30, 2024
9a9604b
removed traces settings from the readme
janezpodhostnik Oct 31, 2024
f12cebc
Add special EVM height handling
janezpodhostnik Nov 1, 2024
0aff71c
split tests
janezpodhostnik Nov 1, 2024
97ba7d7
Simplify added test files
m-Peter Nov 4, 2024
4be3166
Simplify usage of FixedHash field on Block type
m-Peter Nov 4, 2024
72d2891
add register storage
janezpodhostnik Oct 30, 2024
2198eed
register storage fix lookup and remove owner
janezpodhostnik Oct 31, 2024
04a6806
register store add tests
janezpodhostnik Nov 1, 2024
bb847c5
separate delta and index
janezpodhostnik Nov 5, 2024
dc486bc
add more comments
janezpodhostnik Nov 5, 2024
2bfd1eb
address comments
janezpodhostnik Nov 5, 2024
55c2ba7
extract cached register snapshot
janezpodhostnik Nov 6, 2024
5a8de37
Update storage/pebble/register_storage.go
janezpodhostnik Nov 7, 2024
7e56601
add comment
janezpodhostnik Nov 7, 2024
e7030cd
Integrate & incorporate flow-go's onchain package
m-Peter Nov 4, 2024
64d33e0
Implement RemoteCadenceArch type for fetching precompiled calls in co…
m-Peter Nov 4, 2024
18045bf
swap storage
janezpodhostnik Nov 6, 2024
69bba54
Add no-op implementation for RegisterDelta.AllocateSlabIndex
m-Peter Nov 7, 2024
a63925e
Extract method for detecting whether the tracer config is equal to th…
m-Peter Nov 7, 2024
3d981d4
Remove StateDB from BlockExecutor
m-Peter Nov 7, 2024
c3e83ab
Remove out-dated comment regarding precompiles
m-Peter Nov 7, 2024
c2524d7
Move tracer assignment in blockContext method
m-Peter Nov 7, 2024
d7b86ee
Remove receipt return value from BlockExecutor.Run
m-Peter Nov 7, 2024
0071555
Check that txTracer is not nil before getting the result
m-Peter Nov 7, 2024
b74a3ab
use batch to init blocks
janezpodhostnik Nov 7, 2024
e068017
fix db init issue in tests
janezpodhostnik Nov 7, 2024
20f3c2b
Simplify condition in TraceBlockByNumber
m-Peter Nov 7, 2024
5f1f05f
Extract common methods for resolving RPC block tags into a utils file
m-Peter Nov 8, 2024
7ca9956
Move down creation of tracers.Context object
m-Peter Nov 8, 2024
e504092
Move caching of returned data from precompiled call to runCall method
m-Peter Nov 8, 2024
3c8ed31
Change evm height in requester to uint64
m-Peter Nov 8, 2024
11e4b99
Simplify Requester API interface
m-Peter Nov 11, 2024
9576606
Remove dead code from Requester
m-Peter Nov 11, 2024
f91ec40
Remove unused const
m-Peter Nov 11, 2024
2a4444f
Move dryRunScript var to RemoteCadenceArch and bump the gas limit
m-Peter Nov 11, 2024
ec9f40a
Extract replaceAddresses helper function to its own file for re-usabi…
m-Peter Nov 11, 2024
4760f2b
Minor improvements for resolveBlockTag function
m-Peter Nov 11, 2024
0ea0c6f
Simplify Requester initialization from bootstrap
m-Peter Nov 11, 2024
20455c7
Simplify DebugAPI initialization from bootstrap
m-Peter Nov 11, 2024
e0d0150
Move hard-coded values to constants
m-Peter Nov 11, 2024
e1b6506
Minor improvements for DebugAPI
m-Peter Nov 11, 2024
7ad6089
Remove redundant error return value from BlockExecutor constructor
m-Peter Nov 11, 2024
c5083dc
Minor improvements for event ingestion engine
m-Peter Nov 11, 2024
1daf28a
Minor improvements for CallTracerCollector
m-Peter Nov 11, 2024
be3728d
Remove Cadence script caching from Requester
m-Peter Nov 11, 2024
2c663f4
Properly initialize trace call config in debug_traceCall
m-Peter Nov 11, 2024
a0aa458
Add test case for debug_traceTransaction with Cadence arch call
m-Peter Nov 11, 2024
603cd32
Enable Cadence Arch calls for debug_traceCall
m-Peter Nov 11, 2024
b4368e1
Remove unused embed import
m-Peter Nov 12, 2024
b54fb43
Move gas limit for Cadence Arch call to a named constant
m-Peter Nov 12, 2024
fb097d6
Better handling of errors for stored default call traces
m-Peter Nov 12, 2024
dfcfdb0
Storage fixes
janezpodhostnik Nov 7, 2024
4bc7382
remove additional locks
janezpodhostnik Nov 8, 2024
5d29b0b
address review comments
janezpodhostnik Nov 12, 2024
4be38cd
Move eth related types to their own package to avoid import cycle errors
m-Peter Nov 13, 2024
9c069d7
Support state overrides for eth_call & eth_estimateGas
m-Peter Nov 13, 2024
c33b372
Extract the common logic from Call & EstimateGas in dryRunTx helper m…
m-Peter Nov 13, 2024
5c38a0f
batch get events when backfilling
janezpodhostnik Nov 8, 2024
78abedb
cleanup
janezpodhostnik Nov 13, 2024
019fdd2
fix test and bug
janezpodhostnik Nov 13, 2024
2e41206
temp skip test
janezpodhostnik Nov 13, 2024
3bfbe7b
address review comments
janezpodhostnik Nov 13, 2024
99c8faa
unskip tests
janezpodhostnik Nov 14, 2024
a9fe319
Fix wrong block hash value for the 1st EVM block with PrevRandao
m-Peter Nov 19, 2024
1949a0a
Refactor re-execution
janezpodhostnik Nov 14, 2024
7627b4e
Remove transactions mutex
janezpodhostnik Nov 20, 2024
6727d4a
Merge pull request #668 from onflow/janez/remove-transaction-mutex
janezpodhostnik Nov 20, 2024
646c16b
Add debug_flowHeight API endpoint
janezpodhostnik Nov 20, 2024
575017b
update readme
janezpodhostnik Nov 20, 2024
e61ac1c
apply review comments
janezpodhostnik Nov 20, 2024
ca18d33
Handle ingestion of missing EVM.BlockExecuted event in backfill process
m-Peter Nov 19, 2024
a22b951
Add more unit tests for NewSingleBlockEvents & NewMultiBlockEvents me…
m-Peter Nov 20, 2024
0974579
Merge pull request #664 from onflow/mpeter/handle-missing-evm-block-e…
m-Peter Nov 21, 2024
0fff9b1
renamed method
janezpodhostnik Nov 21, 2024
dd2b134
Merge pull request #669 from onflow/janez/flow-block-height
janezpodhostnik Nov 21, 2024
b6d5e55
Use offchain package to create block context
janezpodhostnik Nov 21, 2024
3c3d9e9
update emulator
janezpodhostnik Nov 21, 2024
747a4ad
update dependencies
janezpodhostnik Nov 22, 2024
54a4184
Merge pull request #670 from onflow/janez/update-blocks-provider
zhangchiqing Nov 22, 2024
7d1c55d
update flow-go
janezpodhostnik Nov 25, 2024
10dbeca
update emulator
janezpodhostnik Nov 25, 2024
0de5ef9
Merge pull request #673 from onflow/janez/update-flow-go
janezpodhostnik Nov 25, 2024
39812e5
Use a constant backoff retry strategy for retrieving the Flow transac…
m-Peter Nov 25, 2024
01bb8e7
Merge pull request #672 from onflow/mpeter/update-backoff-retry-strategy
m-Peter Nov 26, 2024
537379c
Cleanup cmd
janezpodhostnik Nov 26, 2024
eb05840
Merge pull request #675 from onflow/janez/switch-to-component
janezpodhostnik Nov 26, 2024
e737742
Rework gas estimation logic to find the lower gas limit at which a tr…
m-Peter Nov 21, 2024
512533d
Add note for binary search algorithm used for EstimateGas
m-Peter Nov 26, 2024
227f57e
Always return error from dry-run with highest allowed gas limit
m-Peter Nov 26, 2024
31ecd72
Remove completely the create_coa.cdc transaction as it is not necessary
m-Peter Nov 26, 2024
d8fa7a2
Fix race for startingBlock field of eth_syncing endpoint
m-Peter Nov 27, 2024
70e7f9e
Fix closing channel twice
janezpodhostnik Nov 27, 2024
c98427b
Merge pull request #680 from onflow/janez/fix-double-channel-closure
janezpodhostnik Nov 27, 2024
565e344
switch to flow-go metrics server
janezpodhostnik Nov 26, 2024
5499cc2
Seperate creating and closing pebbleDB from storage
janezpodhostnik Nov 26, 2024
7286060
Close the AN clients
janezpodhostnik Nov 26, 2024
df1750c
fix tidy
janezpodhostnik Nov 27, 2024
5b77d7b
Change import name
janezpodhostnik Nov 27, 2024
528bd94
Merge pull request #678 from onflow/janez/close-clients
janezpodhostnik Nov 27, 2024
ec3fd4b
Merge pull request #679 from onflow/mpeter/fix-eth-syncing-starting-h…
m-Peter Nov 27, 2024
b57e3e0
Merge pull request #674 from onflow/mpeter/fix-coa-creation-tx
m-Peter Nov 27, 2024
6d11b34
Merge pull request #671 from onflow/mpeter/improve-gas-estimation-logic
m-Peter Nov 27, 2024
15cbe70
Revert "Improve gas estimation logic for `eth_estimateGas`"
peterargue Nov 28, 2024
2825b58
Merge pull request #687 from onflow/revert-671-mpeter/improve-gas-est…
peterargue Nov 28, 2024
3e669d1
Switch from config reference to instance
janezpodhostnik Nov 29, 2024
73ca87e
Merge pull request #689 from onflow/janez/config-instance-2
janezpodhostnik Dec 2, 2024
386044f
Revert "Merge pull request #687 from onflow/revert-671-mpeter/improve…
m-Peter Dec 1, 2024
0e107bf
Fix logical error in eth_estimateGas endpoint
m-Peter Dec 1, 2024
4b32ea8
Merge pull request #690 from onflow/mpeter/fix-gas-estimation-logic
m-Peter Dec 3, 2024
c503c78
add util to extract evm state
zhangchiqing Nov 26, 2024
e18dc70
updat flow-go
zhangchiqing Nov 26, 2024
9d7717c
update go.mod
zhangchiqing Nov 27, 2024
d3c813a
add extract EVM state tests
zhangchiqing Nov 27, 2024
3d9f862
fix replay
zhangchiqing Nov 27, 2024
e919eb8
fix lint
zhangchiqing Nov 27, 2024
6d38717
update tests
zhangchiqing Nov 27, 2024
dabec61
update version
zhangchiqing Nov 27, 2024
51d8b63
update version
zhangchiqing Nov 27, 2024
88f6aaa
update version
zhangchiqing Nov 27, 2024
efd5b1d
update version
zhangchiqing Nov 27, 2024
5248ae4
fix extraction
zhangchiqing Nov 27, 2024
1f74dd8
get account balance
zhangchiqing Nov 27, 2024
d0d687f
print account balance from base view
zhangchiqing Nov 27, 2024
e31bb06
update evm state extraction
zhangchiqing Nov 28, 2024
3a12658
tidy
zhangchiqing Dec 2, 2024
be1f5c1
update version
zhangchiqing Dec 3, 2024
c9eae96
update version
zhangchiqing Dec 5, 2024
467051a
revert changes to ingestion engine
zhangchiqing Dec 5, 2024
96c4472
go mod tidy
zhangchiqing Dec 5, 2024
5495113
fix lint add export evm state to cmd
zhangchiqing Dec 5, 2024
bf84136
fix lint
zhangchiqing Dec 5, 2024
c0bf024
Changes to simplify first time setup and docker usage
franklywatson Dec 5, 2024
bfab77e
Not needed
franklywatson Dec 5, 2024
3b517a0
Enable override
franklywatson Dec 5, 2024
d82dd34
Variable use consistency
franklywatson Dec 5, 2024
8d63c9f
nit
franklywatson Dec 5, 2024
968f54a
Correct image name
franklywatson Dec 5, 2024
1eeb2bf
Detach container by default
franklywatson Dec 5, 2024
dfb48e3
Update README
franklywatson Dec 6, 2024
21ab682
Split guidance into two lines
franklywatson Dec 6, 2024
a540d9c
Merge pull request #683 from onflow/leo/extract-evm-state
zhangchiqing Dec 6, 2024
c93e055
Return empty Logs array when block is empty
m-Peter Dec 6, 2024
b3224f6
Merge pull request #697 from onflow/mpeter/fix-eth-get-logs-response
j1010001 Dec 6, 2024
52e0b17
Use proper variable in E2E test file for logs filtering
m-Peter Dec 6, 2024
334a45f
Account for change made in Dockerfile to add $VERSION
franklywatson Dec 7, 2024
0679ffc
Improve usability and code
franklywatson Dec 7, 2024
3d0973f
Tidyup
franklywatson Dec 7, 2024
40b24a1
Fix mount issue
franklywatson Dec 7, 2024
aa76d88
Fix mount issue
franklywatson Dec 7, 2024
46bbe75
Fix mount issue
franklywatson Dec 7, 2024
61b0977
More troubleshooting mount
franklywatson Dec 7, 2024
a2d1792
More troubleshooting mount
franklywatson Dec 7, 2024
ea3e5cd
Fix for mount
franklywatson Dec 7, 2024
dc9daf2
Fix for mount
franklywatson Dec 7, 2024
7082eec
Resolved mount issue
franklywatson Dec 7, 2024
fdad063
Resolved mount issue
franklywatson Dec 7, 2024
b0207f1
Fix port access from other sources
franklywatson Dec 7, 2024
7e6c63e
Minimize heavy logging
franklywatson Dec 7, 2024
56f8b19
Merge pull request #698 from onflow/mpeter/fix-e2e-test-unused-variable
m-Peter Dec 8, 2024
a8fbdde
WIP updates to README
franklywatson Dec 8, 2024
c52d874
Additions for local docker build docker pull version
franklywatson Dec 8, 2024
03718df
No caching when local build
franklywatson Dec 8, 2024
29bebe3
Couple of changes to test local build
franklywatson Dec 8, 2024
1cc6775
Last tweaks and add redirect to main docs
franklywatson Dec 8, 2024
eb68bfa
Nits and remove traces-gcp-bucket config from options
franklywatson Dec 9, 2024
839e5d3
Added missing metrics-port config
franklywatson Dec 9, 2024
d82f71e
remove dupe
franklywatson Dec 9, 2024
d5b4c75
Fix docker-build-local and docker-run-local targets
franklywatson Dec 9, 2024
756a31b
Handle missing GOARCH for macs
franklywatson Dec 9, 2024
6188ee1
Add OS specific flags to go build
franklywatson Dec 9, 2024
76989f8
Enable GOARCH override if ENV var set
franklywatson Dec 10, 2024
3ed2b21
Support GAS_PRICE configuration and default amount
franklywatson Dec 10, 2024
36afe82
Fixed to make docker-run-local work
franklywatson Dec 10, 2024
9ec01a8
Open access to the right port for emulator
franklywatson Dec 10, 2024
a428439
Revert incorrect config
franklywatson Dec 10, 2024
8a515a3
Simplify variable assignment
franklywatson Dec 10, 2024
9df4d7d
Fix broken make targets for local compilation
franklywatson Dec 10, 2024
3cbe37c
Merge remote-tracking branch 'origin/jp/docker-fixes' into jp/docker-…
franklywatson Dec 10, 2024
ade4766
Fix missing compiler arg for Mac
franklywatson Dec 10, 2024
2425298
Remove duplicate variable setting and add ARCH flag
franklywatson Dec 10, 2024
a5a688d
Remove duplicate entries
franklywatson Dec 10, 2024
b5d6462
Specify host.docker.internal:3569 explicitly for the docker-run-local…
franklywatson Dec 10, 2024
1b2d9a1
Fix emulator startup warning message
franklywatson Dec 10, 2024
272ef11
Not needed
franklywatson Dec 11, 2024
56867b8
Image update to highlight cadence transaction arrow
franklywatson Dec 11, 2024
69770c9
Kill background emulator process before restart
franklywatson Dec 11, 2024
874be8a
Merged changes from feature/local-tx-reexecution branch
franklywatson Dec 11, 2024
407f708
Merged changes from feature/local-tx-reexecution branch
franklywatson Dec 12, 2024
af70a04
Fixed incorrect registry paths
franklywatson Dec 12, 2024
50cfcf3
Typo
franklywatson Dec 12, 2024
fddc38c
Fixes to work with mainnet
franklywatson Dec 12, 2024
bdcb06b
Add system.d example files
franklywatson Dec 12, 2024
68ccadc
Fixed dangling comment line
franklywatson Dec 12, 2024
220105a
Fix missing docker pull
franklywatson Dec 13, 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
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ jobs:
- name: Docker Auth
run: |-
gcloud auth configure-docker ${{ vars.GAR_LOCATION }}-docker.pkg.dev
docker build -t ${{ env.DOCKER_IMAGE_URL }}:${{ steps.set_version.outputs.GATEWAY_VERSION }} --build-arg GATEWAY_VERSION=${{ steps.set_version.outputs.GATEWAY_VERSION }} --file Dockerfile .
docker build --build-arg VERSION="${{ steps.set_version.outputs.GATEWAY_VERSION }}" --build-arg ARCH=amd64 -t ${{ env.DOCKER_IMAGE_URL }}:${{ steps.set_version.outputs.GATEWAY_VERSION }} --file Dockerfile .
docker push ${{ env.DOCKER_IMAGE_URL }}:${{ steps.set_version.outputs.GATEWAY_VERSION }}
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@ tests/e2e-network/node_modules
tests/e2e-network/package-lock.json
db
flow.json
flow*.json
.idea
metrics/data/
7 changes: 4 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

FROM golang:1.22.0 as app-builder

ARG GATEWAY_VERSION="v0.1.0"

# Build the app binary in /app
WORKDIR /app

Expand All @@ -14,8 +12,11 @@ COPY . ./
RUN go mod download
RUN go mod verify

ARG VERSION
ARG ARCH

# Build binary
RUN CGO_ENABLED=1 go build -o bin -ldflags="-X github.com/onflow/flow-evm-gateway/api.Version=${GATEWAY_VERSION}" cmd/main.go
RUN CGO_ENABLED=1 GOOS=linux GOARCH=$ARCH build -o bin -ldflags="-X github.com/onflow/flow-evm-gateway/api.Version=$VERSION" -trimpath cmd/main.go
RUN chmod a+x bin

# RUN APP
Expand Down
175 changes: 151 additions & 24 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,62 @@
# The short Git commit hash
SHORT_COMMIT := $(shell git rev-parse --short HEAD)
BRANCH_NAME:=$(shell git rev-parse --abbrev-ref HEAD | tr '/' '-')
# The Git commit hash
COMMIT := $(shell git rev-parse HEAD)
# The tag of the current commit, otherwise empty
GIT_VERSION := $(shell git describe --tags --abbrev=2 2>/dev/null)
franklywatson marked this conversation as resolved.
Show resolved Hide resolved
CMD_ARGS :=
# ACCESS_NODE_SPORK_HOSTS are comma separated
ACCESS_NODE_SPORK_HOSTS := access-001.devnet51.nodes.onflow.org:9000
EMULATOR_COINBASE := FACF71692421039876a5BB4F10EF7A439D8ef61E
EMULATOR_COA_ADDRESS := f8d6e0586b0a20c7
EMULATOR_COA_KEY := 2619878f0e2ff438d17835c2a4561cb87b4d24d72d12ec34569acd0dd4af7c21
franklywatson marked this conversation as resolved.
Show resolved Hide resolved
UNAME_S := $(shell uname -s)
# Set default values
ARCH :=
OS :=
COMPILER_FLAGS := CGO_ENABLED=1

EMULATOR_ARGS := --flow-network-id=flow-emulator \
--coinbase=$(EMULATOR_COINBASE) \
--coa-address=$(EMULATOR_COA_ADDRESS) \
--coa-key=$(EMULATOR_COA_KEY) \
--wallet-api-key=2619878f0e2ff438d17835c2a4561cb87b4d24d72d12ec34569acd0dd4af7c21 \
--gas-price=0 \
--log-writer=console \
--profiler-enabled=true \
--profiler-port=6060
franklywatson marked this conversation as resolved.
Show resolved Hide resolved
franklywatson marked this conversation as resolved.
Show resolved Hide resolved

# Set VERSION from command line, environment, or default to SHORT_COMMIT
VERSION ?= ${SHORT_COMMIT}

# Set IMAGE_TAG from VERSION if not explicitly set
IMAGE_TAG ?= ${VERSION}
franklywatson marked this conversation as resolved.
Show resolved Hide resolved

# Function to check and append required arguments
define check_and_append
$(if $($(2)),\
$(eval CMD_ARGS += --$(1)=$($(2))),\
$(error ERROR: $(2) ENV variable is required))
endef

# Determine OS and set ARCH
ifeq ($(UNAME_S),Darwin)
OS := macos
ARCH := arm64
$(eval COMPILER_FLAGS += CGO_CFLAGS="-O2 -D__BLST_PORTABLE__")
else ifeq ($(UNAME_S),Linux)
OS := linux
ARCH := amd64
else
$(error Unsupported operating system: $(UNAME_S))
endif
franklywatson marked this conversation as resolved.
Show resolved Hide resolved

# docker container registry
export CONTAINER_REGISTRY := us-west1-docker.pkg.dev/dl-flow-devex-production/development
export DOCKER_BUILDKIT := 1
franklywatson marked this conversation as resolved.
Show resolved Hide resolved
export DATADIR := /data

.PHONY: test
test:
# test all packages
Expand All @@ -20,7 +79,7 @@ check-tidy:

.PHONY: build
build:
CGO_ENABLED=1 go build -o flow-evm-gateway -ldflags="-X github.com/onflow/flow-evm-gateway/api.Version=$(shell git describe --tags --abbrev=0 2>/dev/null || echo 'unknown')" cmd/main.go
$(COMPILER_FLAGS) go build -o flow-evm-gateway -ldflags="-X github.com/onflow/flow-evm-gateway/api.Version=$(IMAGE_TAG)" cmd/main.go
chmod a+x flow-evm-gateway

.PHONY: fix-lint
Expand All @@ -44,37 +103,105 @@ ci: check-tidy test e2e-test

.PHONY: start
start:
go run ./cmd/server/main.go
$(COMPILER_FLAGS) go run ./cmd/main.go

.PHONY: start-local
start-local:
rm -rf db/
rm -rf metrics/data/
go run cmd/main.go run \
--flow-network-id=flow-emulator \
--coinbase=FACF71692421039876a5BB4F10EF7A439D8ef61E \
--coa-address=f8d6e0586b0a20c7 \
--coa-key=2619878f0e2ff438d17835c2a4561cb87b4d24d72d12ec34569acd0dd4af7c21 \
--wallet-api-key=2619878f0e2ff438d17835c2a4561cb87b4d24d72d12ec34569acd0dd4af7c21 \
--coa-resource-create=true \
--gas-price=0 \
--log-writer=console \
--profiler-enabled=true \
--profiler-port=6060
$(COMPILER_FLAGS) go run cmd/main.go run $(EMULATOR_ARGS)
franklywatson marked this conversation as resolved.
Show resolved Hide resolved

# Use this after running `make build`, to test out the binary
.PHONY: start-local-bin
start-local-bin:
rm -rf db/
rm -rf metrics/data/
./flow-evm-gateway run \
--flow-network-id=flow-emulator \
--coinbase=FACF71692421039876a5BB4F10EF7A439D8ef61E \
--coa-address=f8d6e0586b0a20c7 \
--coa-key=2619878f0e2ff438d17835c2a4561cb87b4d24d72d12ec34569acd0dd4af7c21 \
--wallet-api-key=2619878f0e2ff438d17835c2a4561cb87b4d24d72d12ec34569acd0dd4af7c21 \
--coa-resource-create=true \
--gas-price=0 \
--log-writer=console \
--profiler-enabled=true \
--profiler-port=6060
$(COMPILER_FLAGS) go run cmd/main.go run $(EMULATOR_ARGS)

# Build docker image from local sources
.PHONY: docker-build-local
docker-build-local:
ifdef GOARCH
$(eval ARCH=$(GOARCH))
endif
docker build --build-arg ARCH=$(ARCH) --no-cache -f dev/Dockerfile -t "$(CONTAINER_REGISTRY)/evm-gateway:$(COMMIT)" .

# Docker run for local development
.PHONY: docker-run-local
docker-run-local:
@trap 'kill $$(jobs -p)' EXIT
flow emulator -f dev/flow.json &
sleep 3

$(call check_and_append,coinbase,EMULATOR_COINBASE)
$(call check_and_append,coa-address,EMULATOR_COA_ADDRESS)
$(call check_and_append,coa-key,EMULATOR_COA_KEY)

$(eval CMD_ARGS += --flow-network-id=flow-emulator --log-level=debug --gas-price=0 --log-writer=console --profiler-enabled=true --access-node-grpc-host=host.docker.internal:3569)

docker run -p 8545:8545 --add-host=host.docker.internal:host-gateway "$(CONTAINER_REGISTRY)/evm-gateway:$(COMMIT)" $(CMD_ARGS)


# Build docker image for release
.PHONY: docker-build
docker-build:
ifdef GOARCH
$(eval ARCH=$(GOARCH))
endif
docker build --build-arg VERSION="$(VERSION)" --build-arg ARCH=$(ARCH) -f Dockerfile -t "$(CONTAINER_REGISTRY)/evm-gateway:$(IMAGE_TAG)" \
franklywatson marked this conversation as resolved.
Show resolved Hide resolved
--label "git_commit=$(COMMIT)" --label "git_tag=$(IMAGE_TAG)" .

# Install image version from container registry
.PHONY: docker-pull-version
docker-pull-version:
docker pull "$(CONTAINER_REGISTRY)/evm-gateway:$(IMAGE_VERSION)"

# Run GW image
# https://github.com/onflow/flow-evm-gateway?tab=readme-ov-file#configuration-flags
# Requires the following ENV variables:
# - ACCESS_NODE_GRPC_HOST: [access.devnet.nodes.onflow.org:9000 | access.mainnet.nodes.onflow.org:9000]
# - FLOW_NETWORK_ID: [flow-testnet, flow-mainnet]
# - INIT_CADENCE_HEIGHT: [testnet: 211176670, mainnet: 88226267]
# - COINBASE: To be set by the operator. This is an EVM EOA or COA address which is set as the receiver of GW transaction fees (remove 0x prefix)
# - COA_ADDRESS: To be set by the operator. This is a Cadence address which funds gateway operations (remove 0x prefix)
# - COA_KEY: A full weight, private key belonging to operator COA_ADDRESS (remove 0x prefix). NB: For development use only. We recommend using cloud KMS configuration on mainnet
#
# Optional
# - GAS_PRICE: the attoFlow amount
#
# Optional make arguments:
# - DOCKER_RUN_DETACHED: Runs container in detached mode when true
# - DOCKER_HOST_PORT: Sets the exposed container port for the gateway JSON-RPC
# - DOCKER_MOUNT: Sets the host mount point for the EVM data dir
.PHONY: docker-run
docker-run:
$(eval CMD_ARGS :=)
ifdef DOCKER_RUN_DETACHED
$(eval MODE=-d)
endif
ifdef DOCKER_HOST_PORT
$(eval HOST_PORT=$(DOCKER_HOST_PORT))
else
$(eval HOST_PORT=8545)
endif
ifndef GAS_PRICE
$(eval GAS_PRICE=100)
endif
ifdef DOCKER_MOUNT
$(eval MOUNT=--mount type=bind,src="$(DOCKER_MOUNT)",target=$(DATADIR))
$(call check_and_append,database-dir,DATADIR)
endif

$(call check_and_append,access-node-grpc-host,ACCESS_NODE_GRPC_HOST)
$(call check_and_append,flow-network-id,FLOW_NETWORK_ID)
$(call check_and_append,init-cadence-height,INIT_CADENCE_HEIGHT)
$(call check_and_append,coinbase,COINBASE)
$(call check_and_append,coa-address,COA_ADDRESS)
$(call check_and_append,coa-key,COA_KEY)
$(call check_and_append,gas-price,GAS_PRICE)

$(eval CMD_ARGS += --ws-enabled=true --rate-limit=9999999 --rpc-host=0.0.0.0 --log-level=info)
$(call check_and_append,access-node-spork-hosts,ACCESS_NODE_SPORK_HOSTS)

docker run $(MODE) -p $(HOST_PORT):8545 -p 8080:8080 $(MOUNT) "$(CONTAINER_REGISTRY)/evm-gateway:$(IMAGE_TAG)" $(CMD_ARGS)

Loading
Loading