Skip to content

Commit f447cc8

Browse files
authored
Merge branch 'main' into mpeter/track-latest-finalized-block-header
2 parents 54a03bb + 638fe2e commit f447cc8

29 files changed

+251
-200
lines changed

Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,18 @@ OS :=
1919
COMPILER_FLAGS := CGO_ENABLED=1
2020

2121
EMULATOR_ARGS := --flow-network-id=flow-emulator \
22+
--access-node-grpc-host=localhost:3569 \
2223
--coinbase=$(EMULATOR_COINBASE) \
23-
--coa-address=$(EMULATOR_COA_ADDRESS) \
24-
--coa-key=$(EMULATOR_COA_KEY) \
24+
--coa-address=$(EMULATOR_COA_ADDRESS) \
25+
--coa-key=$(EMULATOR_COA_KEY) \
2526
--wallet-api-key=2619878f0e2ff438d17835c2a4561cb87b4d24d72d12ec34569acd0dd4af7c21 \
2627
--gas-price=0 \
2728
--log-writer=console \
2829
--tx-state-validation=local-index \
2930
--profiler-enabled=true \
3031
--profiler-port=6060 \
31-
--ws-enabled=true
32+
--ws-enabled=true \
33+
--coa-tx-lookup-enabled=true
3234

3335
# Set VERSION from command line, environment, or default to SHORT_COMMIT
3436
VERSION ?= $(SHORT_COMMIT)
@@ -168,7 +170,6 @@ docker-pull-version:
168170
# Requires the following ENV variables:
169171
# - ACCESS_NODE_GRPC_HOST: [access.devnet.nodes.onflow.org:9000 | access.mainnet.nodes.onflow.org:9000]
170172
# - FLOW_NETWORK_ID: [flow-testnet, flow-mainnet]
171-
# - INIT_CADENCE_HEIGHT: [testnet: 211176670, mainnet: 85981135]
172173
# - 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)
173174
# - COA_ADDRESS: To be set by the operator. This is a Cadence address which funds gateway operations (remove 0x prefix)
174175
# - 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
@@ -215,7 +216,6 @@ endif
215216

216217
$(call check_and_append,access-node-grpc-host,ACCESS_NODE_GRPC_HOST)
217218
$(call check_and_append,flow-network-id,FLOW_NETWORK_ID)
218-
$(call check_and_append,init-cadence-height,INIT_CADENCE_HEIGHT)
219219
$(call check_and_append,coinbase,COINBASE)
220220
$(call check_and_append,coa-address,COA_ADDRESS)
221221
$(call check_and_append,coa-key,COA_KEY)

README.md

Lines changed: 35 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# EVM Gateway
44

5-
**EVM Gateway enables seamless interaction with EVM on Flow, mirroring the experience of engaging with any other EVM blockchain.**
5+
## EVM Gateway enables seamless interaction with EVM on Flow, mirroring the experience of engaging with any other EVM blockchain
66

77
EVM Gateway implements the Ethereum JSON-RPC API for [EVM on Flow](https://developers.flow.com/evm/about) which conforms to the Ethereum [JSON-RPC specification](https://ethereum.github.io/execution-apis/api-documentation/). The EVM Gateway is tailored for integration with the EVM environment on the Flow blockchain. Rather than implementing the full `geth` stack, the JSON-RPC API available in EVM Gateway is a lightweight implementation that uses Flow's underlying consensus and smart contract language, [Cadence](https://cadence-lang.org/docs/), to handle calls received by the EVM Gateway. For those interested in the underlying implementation details, please refer to the [FLIP #243](https://github.com/onflow/flips/issues/243) (EVM Gateway) and [FLIP #223](https://github.com/onflow/flips/issues/223) (EVM on Flow Core) improvement proposals.
88

@@ -23,7 +23,7 @@ The basic design of the EVM Gateway is as follows:
2323

2424
# Building
2525

26-
**Build from source**
26+
## Build from source
2727

2828
```bash
2929
# Make sure you pull the latest changes before running `make build`
@@ -76,7 +76,7 @@ It is acceptable to create a single Cadence account for the COA and use the EVM
7676

7777
For local development, first install [Flow CLI](https://developers.flow.com/tools/flow-cli/install). The examples below require no configuration and are intended for local development.
7878

79-
**Run from CLI**
79+
### Run from CLI
8080

8181
Before running the gateway locally you need to start the Flow Emulator:
8282

@@ -96,7 +96,7 @@ make start-local
9696
Note that the gateway will be starting from the latest emulator block, so if the emulator is run before any transactions happen in the meantime, the gateway will not fetch those historical blocks & transactions.
9797
This will be improved soon.
9898

99-
**Run with Docker**
99+
### Run with Docker
100100

101101
Using Docker for local development is also supported. The following target builds the current source directory into a docker image
102102

@@ -108,7 +108,7 @@ This target starts the flow emulator and then runs the EVM Gateway using the ima
108108
make docker-run-local
109109
```
110110

111-
**Verify**
111+
## Verify
112112

113113
To verify the service is up and running:
114114

@@ -131,7 +131,7 @@ it should return:
131131
Running against the testnet with a local build can be done by pointing the gateway to the testnet ANs and providing the correct configuration.
132132
Please refer to the configuration section and read through all the configuration flags before proceeding.
133133

134-
**Create Flow account to use for COA**
134+
### Create Flow account to use for COA
135135

136136
If you don't already have a Flow account you will need to create account keys using the following command.
137137

@@ -153,27 +153,23 @@ Signature Algorithm ECDSA_P256
153153
Then visit https://faucet.flow.com/, and use the generated `Public Key`, to create and fund your Flow testnet account.
154154
Make sure to use the Flow address and the `Private Key` for the `--coa-address` & `--coa-key` flags.
155155

156-
**Run local EVM Gateway connected to Testnet**
156+
### Run EVM Gateway connected to Testnet
157157

158158
Below is an example configuration for running against testnet, with a preconfigured testnet account.
159159

160160
```bash
161161
./flow-evm-gateway run \
162+
--access-node-spork-hosts="access-001.devnet51.nodes.onflow.org:9000,access-001.devnet52.nodes.onflow.org:9000" \
162163
--access-node-grpc-host=access.devnet.nodes.onflow.org:9000 \
163-
--access-node-spork-hosts=access-001.devnet51.nodes.onflow.org:9000 \
164164
--flow-network-id=flow-testnet \
165-
--init-cadence-height=211176670 \
166165
--ws-enabled=true \
167166
--coinbase=FACF71692421039876a5BB4F10EF7A439D8ef61E \
168-
--coa-address=62631c28c9fc5a91 \
169-
--coa-key=2892fba444f1d5787739708874e3b01160671924610411ac787ac1379d420f49 \
167+
--coa-address=<16-character hexadecimal address> \
168+
--coa-key=<64-character hexadecimal private key> \
170169
--gas-price=100
171170
```
172171

173-
The `--init-cadence-height` is the Flow block height to start indexing from. To index the full EVM state, from its beginning, the proper value for this flag for testnet is `211176670`. This is the height where the `EVM` contract was first deployed on testnet, and this is where the EVM state starts from.
174-
175172
If you wish to test this out with your own Access Node, simply set `--access-node-grpc-host` to the DNS or IP where it is hosted.
176-
**Note:** You need to make sure that the testnet Access Node which the gateway is connected to has indexed at least up to Flow block height `211176670`.
177173

178174
For the `--gas-price`, feel free to experiment with different values.
179175

@@ -195,16 +191,15 @@ Should return a response similar to:
195191
}
196192
```
197193

198-
**Run local EVM GW docker container connected to Testnet**
194+
### Run local EVM GW docker container connected to Testnet
199195

200-
To use the `make` target to connect a container based gateway instance to testnet requires the following environment variables to be set.
196+
To use the `make` target to connect a container-based gateway instance to testnet requires the following environment variables to be set.
201197

202198
* `ACCESS_NODE_GRPC_HOST`: access.devnet.nodes.onflow.org:9000
203199
* `FLOW_NETWORK_ID`: flow-testnet
204-
* `INIT_CADENCE_HEIGHT`: 211176670
205200
* `COINBASE`: FACF71692421039876a5BB4F10EF7A439D8ef61E
206-
* `COA_ADDRESS`: 62631c28c9fc5a91
207-
* `COA_KEY`: 2892fba444f1d5787739708874e3b01160671924610411ac787ac1379d420f49
201+
* `COA_ADDRESS`: <16-character hexadecimal address>
202+
* `COA_KEY`: <64-character hexadecimal private key>
208203
* `VERSION`: [_repo commit hash or tag version used when building with docker_]
209204

210205
Once set, this target starts the EVM Gateway for the specified image version and connects it to testnet
@@ -217,6 +212,20 @@ make docker-run
217212
Guidance for EVM Gateway node operations including considerations for mainnet, hardware specs, monitoring setup and troubleshooting
218213
can be found in the EVM Gateway [node operations docs](https://developers.flow.com/networks/node-ops/evm-gateway/evm-gateway-setup).
219214

215+
Below is an example configuration for running against mainnet, with a preconfigured mainnet account.
216+
217+
```bash
218+
./flow-evm-gateway run \
219+
--access-node-spork-hosts="access-001.mainnet25.nodes.onflow.org:9000,access-001.mainnet26.nodes.onflow.org:9000" \
220+
--access-node-grpc-host=access.mainnet.nodes.onflow.org:9000 \
221+
--flow-network-id=flow-mainnet \
222+
--ws-enabled=true \
223+
--coinbase=FACF71692421039876a5BB4F10EF7A439D8ef61E \
224+
--coa-address=<16-character hexadecimal address> \
225+
--coa-key=<64-character hexadecimal private key> \
226+
--gas-price=100000000
227+
```
228+
220229
## Configuration Flags
221230

222231
The application can be configured using the following flags at runtime:
@@ -231,7 +240,6 @@ The application can be configured using the following flags at runtime:
231240
| `access-node-spork-hosts` | `""` | Previous spork AN hosts, defined as a comma-separated list (e.g. `"host-1.com,host2.com"`) |
232241
| `flow-network-id` | `flow-emulator` | Flow network ID (options: `flow-emulator`, `flow-testnet`, `flow-mainnet`) |
233242
| `coinbase` | `""` | Coinbase address to use for fee collection |
234-
| `init-cadence-height` | `0` | Cadence block height to start indexing; avoid using on a new network |
235243
| `gas-price` | `1` | Static gas price for EVM transactions |
236244
| `enforce-gas-price` | `true` | Enable enforcing minimum gas price for EVM transactions. When true (default), transactions must specify a gas price greater than or equal to the configured gas price. |
237245
| `coa-address` | `""` | Flow address holding COA account for submitting transactions |
@@ -286,14 +294,15 @@ To connect using Websockets you can use the same DNS names as above but change `
286294
# JSON-RPC API
287295
The EVM Gateway implements APIs according to the Ethereum specification: https://ethereum.org/en/developers/docs/apis/json-rpc/#json-rpc-methods.
288296

289-
**Additional APIs**
290-
- Tracing APIs allows you to fetch execution traces
291-
* `debug_traceTransaction`
292-
* `debug_traceBlockByNumber`
293-
* `debug_traceBlockByHash`
297+
## Additional APIs
298+
- Tracing APIs allow fetching execution traces
299+
* `debug_traceTransaction`
300+
* `debug_traceBlockByNumber`
301+
* `debug_traceBlockByHash`
302+
* `debug_traceCall`
294303
- `debug_flowHeightByBlock` - returns the flow block height for the given EVM block (id or height)
295304

296-
**Unsupported APIs**
305+
## Unsupported APIs
297306
- Wallet APIs: we don't officially support wallet APIs (`eth_accounts`, `eth_sign`, `eth_signTransaction`, `eth_sendTransaction`) due to security
298307
concerns that come with managing the keys on production environments, however, it is possible to configure the gateway to allow these
299308
methods for local development by using a special flag `--wallet-api-key`.

api/pull.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,10 @@ func (api *PullAPI) NewFilter(ctx context.Context, criteria filters.FilterCriter
247247
return "", err
248248
}
249249

250+
if !logs.ValidCriteriaLimits(criteria) {
251+
return "", errs.ErrExceedLogQueryLimit
252+
}
253+
250254
latest, err := api.blocks.LatestEVMHeight()
251255
if err != nil {
252256
return "", err

api/stream.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"github.com/onflow/flow-evm-gateway/config"
1515
ethTypes "github.com/onflow/flow-evm-gateway/eth/types"
1616
"github.com/onflow/flow-evm-gateway/models"
17+
errs "github.com/onflow/flow-evm-gateway/models/errors"
1718
"github.com/onflow/flow-evm-gateway/services/logs"
1819
"github.com/onflow/flow-evm-gateway/storage"
1920
)
@@ -92,6 +93,10 @@ func (s *StreamAPI) NewPendingTransactions(ctx context.Context, fullTx *bool) (*
9293

9394
// Logs creates a subscription that fires for all new log that match the given filter criteria.
9495
func (s *StreamAPI) Logs(ctx context.Context, criteria filters.FilterCriteria) (*rpc.Subscription, error) {
96+
if !logs.ValidCriteriaLimits(criteria) {
97+
return nil, errs.ErrExceedLogQueryLimit
98+
}
99+
95100
return newSubscription(
96101
ctx,
97102
s.logger,

bootstrap/bootstrap.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,15 @@ type Bootstrap struct {
8181
}
8282

8383
func New(config config.Config) (*Bootstrap, error) {
84-
logger := zerolog.New(config.LogWriter).
85-
With().Timestamp().Str("version", api.Version).
86-
Logger().Level(config.LogLevel)
84+
var logger zerolog.Logger
85+
86+
if config.Logger != nil {
87+
logger = *config.Logger
88+
} else {
89+
logger = zerolog.New(config.LogWriter).
90+
With().Timestamp().Str("version", api.Version).
91+
Logger().Level(config.LogLevel)
92+
}
8793

8894
client, err := setupCrossSporkClient(config, logger)
8995
if err != nil {
@@ -143,8 +149,8 @@ func (b *Bootstrap) StartEventIngestion(ctx context.Context) error {
143149

144150
chainID := b.config.FlowNetworkID
145151

146-
// the event subscriber takes the first block to sync from the Access node, which is the block
147-
// after the latest cadence block
152+
// the event subscriber takes the first block to sync from the Access node,
153+
// which is the block after the latest cadence block
148154
nextCadenceHeight := latestCadenceHeight + 1
149155
// Special case when using a local Emulator as Access Node. The Emulator
150156
// always starts at block height 0, so if we try to subscribe at block
@@ -153,7 +159,7 @@ func (b *Bootstrap) StartEventIngestion(ctx context.Context) error {
153159
nextCadenceHeight -= 1
154160
}
155161

156-
// create event subscriber
162+
// create EVM event subscriber
157163
subscriber := ingestion.NewRPCEventSubscriber(
158164
b.logger,
159165
b.client,

config/config.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ const (
3030

3131
// Mainnet height at which the `EVM` system contract was first deployed.
3232
// This is the first height at which the EVM state starts.
33-
MainnetInitCadenceHeight = uint64(85981134)
33+
// reference: https://github.com/onflow/flow/blob/9203b57a04d422360de257bcd92c522a2f51d3b0/sporks.json#L91
34+
MainnetInitCadenceHeight = uint64(85981135)
3435
)
3536

3637
type TxStateValidation string
@@ -80,6 +81,8 @@ type Config struct {
8081
LogLevel zerolog.Level
8182
// LogWriter defines the writer used for logging
8283
LogWriter io.Writer
84+
// Logger if you bring your own
85+
Logger *zerolog.Logger
8386
// RateLimit requests made by the client identified by IP over any protocol (ws/http).
8487
RateLimit uint64
8588
// Address header used to identified clients, usually set by the proxy

go.mod

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ go 1.25.0
44

55
require (
66
github.com/cockroachdb/pebble v1.1.5
7-
github.com/ethereum/go-ethereum v1.16.3
7+
github.com/ethereum/go-ethereum v1.16.4
88
github.com/goccy/go-json v0.10.4
99
github.com/hashicorp/go-multierror v1.1.1
1010
github.com/hashicorp/golang-lru/v2 v2.0.7
1111
github.com/holiman/uint256 v1.3.2
12-
github.com/onflow/atree v0.10.1
13-
github.com/onflow/cadence v1.7.0
14-
github.com/onflow/flow-go v0.43.1-rc.4.0.20250930135247-97f6643af6f8
15-
github.com/onflow/flow-go-sdk v1.8.2
12+
github.com/onflow/atree v0.11.0
13+
github.com/onflow/cadence v1.8.1
14+
github.com/onflow/flow-go v0.43.3-0.20251020174348-b36af5491350
15+
github.com/onflow/flow-go-sdk v1.9.0
1616
github.com/prometheus/client_golang v1.20.5
1717
github.com/rs/cors v1.8.0
1818
github.com/rs/zerolog v1.33.0
@@ -25,7 +25,7 @@ require (
2525
go.uber.org/ratelimit v0.3.1
2626
golang.org/x/exp v0.0.0-20241217172543-b2144cdd0a67
2727
golang.org/x/sync v0.16.0
28-
google.golang.org/grpc v1.75.0
28+
google.golang.org/grpc v1.75.1
2929
)
3030

3131
require (
@@ -58,7 +58,7 @@ require (
5858
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect
5959
github.com/consensys/gnark-crypto v0.18.0 // indirect
6060
github.com/coreos/go-semver v0.3.0 // indirect
61-
github.com/crate-crypto/go-eth-kzg v1.3.0 // indirect
61+
github.com/crate-crypto/go-eth-kzg v1.4.0 // indirect
6262
github.com/crate-crypto/go-ipa v0.0.0-20240724233137-53bbb0ceb27a // indirect
6363
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
6464
github.com/deckarep/golang-set/v2 v2.6.0 // indirect
@@ -71,7 +71,8 @@ require (
7171
github.com/dustin/go-humanize v1.0.1 // indirect
7272
github.com/ef-ds/deque v1.0.4 // indirect
7373
github.com/emicklei/dot v1.6.2 // indirect
74-
github.com/ethereum/c-kzg-4844/v2 v2.1.0 // indirect
74+
github.com/ethereum/c-kzg-4844/v2 v2.1.3 // indirect
75+
github.com/ethereum/go-bigmodexpfix v0.0.0-20250911101455-f9e208c548ab // indirect
7576
github.com/ethereum/go-verkle v0.2.2 // indirect
7677
github.com/felixge/httpsnoop v1.0.4 // indirect
7778
github.com/ferranbt/fastssz v0.1.4 // indirect
@@ -89,7 +90,7 @@ require (
8990
github.com/golang/glog v1.2.5 // indirect
9091
github.com/golang/protobuf v1.5.4 // indirect
9192
github.com/golang/snappy v0.0.5-0.20231225225746-43d5d4cd4e0e // indirect
92-
github.com/google/pprof v0.0.0-20241210010833-40e02aabc2ad // indirect
93+
github.com/google/pprof v0.0.0-20250630185457-6e76a2b096b5 // indirect
9394
github.com/google/s2a-go v0.1.9 // indirect
9495
github.com/google/uuid v1.6.0 // indirect
9596
github.com/googleapis/enterprise-certificate-proxy v0.3.6 // indirect
@@ -152,14 +153,14 @@ require (
152153
github.com/onflow/flow-ft/lib/go/templates v1.0.1 // indirect
153154
github.com/onflow/flow-nft/lib/go/contracts v1.3.0 // indirect
154155
github.com/onflow/flow-nft/lib/go/templates v1.3.0 // indirect
155-
github.com/onflow/flow/protobuf/go/flow v0.4.15 // indirect
156+
github.com/onflow/flow/protobuf/go/flow v0.4.16 // indirect
156157
github.com/onflow/go-ethereum v1.13.4 // indirect
157158
github.com/onflow/sdks v0.6.0-preview.1 // indirect
158159
github.com/onsi/ginkgo v1.16.4 // indirect
159160
github.com/onsi/gomega v1.18.1 // indirect
160161
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect
161162
github.com/pelletier/go-toml/v2 v2.2.1 // indirect
162-
github.com/pierrec/lz4 v2.6.1+incompatible // indirect
163+
github.com/pierrec/lz4/v4 v4.1.22 // indirect
163164
github.com/pion/dtls/v2 v2.2.12 // indirect
164165
github.com/pion/logging v0.2.2 // indirect
165166
github.com/pion/stun/v2 v2.0.0 // indirect
@@ -184,7 +185,7 @@ require (
184185
github.com/spf13/viper v1.15.0 // indirect
185186
github.com/stretchr/objx v0.5.2 // indirect
186187
github.com/subosito/gotenv v1.4.2 // indirect
187-
github.com/supranational/blst v0.3.14 // indirect
188+
github.com/supranational/blst v0.3.16-0.20250831170142-f48500c1fdbe // indirect
188189
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect
189190
github.com/texttheater/golang-levenshtein/levenshtein v0.0.0-20200805054039-cae8b0eaed6c // indirect
190191
github.com/tklauser/go-sysconf v0.3.12 // indirect
@@ -210,7 +211,7 @@ require (
210211
golang.org/x/crypto v0.41.0 // indirect
211212
golang.org/x/net v0.43.0 // indirect
212213
golang.org/x/oauth2 v0.30.0 // indirect
213-
golang.org/x/sys v0.35.0 // indirect
214+
golang.org/x/sys v0.36.0 // indirect
214215
golang.org/x/text v0.28.0 // indirect
215216
golang.org/x/time v0.12.0 // indirect
216217
golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da // indirect

0 commit comments

Comments
 (0)