From d0e7b3ee8e5d746dadeda4185fc2a4d83580137c Mon Sep 17 00:00:00 2001 From: Ardit Marku Date: Thu, 26 Sep 2024 16:12:55 +0300 Subject: [PATCH 1/8] Remove obsolete key files for previewnet/migration networks --- Dockerfile | 2 -- migration-keys.json | 22 ---------------------- previewnet-keys.json | 22 ---------------------- 3 files changed, 46 deletions(-) delete mode 100644 migration-keys.json delete mode 100644 previewnet-keys.json diff --git a/Dockerfile b/Dockerfile index d6c385b47..941290189 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,8 +27,6 @@ WORKDIR /flow-evm-gateway RUN apt-get update && apt-get install ca-certificates -y COPY --from=app-builder /app/bin /flow-evm-gateway/app -COPY --from=app-builder /app/previewnet-keys.json /flow-evm-gateway/previewnet-keys.json -COPY --from=app-builder /app/migration-keys.json /flow-evm-gateway/migration-keys.json EXPOSE 8545 diff --git a/migration-keys.json b/migration-keys.json deleted file mode 100644 index a477a452c..000000000 --- a/migration-keys.json +++ /dev/null @@ -1,22 +0,0 @@ -[ -"1b5c3a19ea37dc1f84ee842c9a5b094289e4ee65be559f3e71d8ae5618e81582", -"9ec5349b20ecf67de909e8195475842e117858ccba3fa82a087dd0e9b6cb8368", -"0c4745c00c22205a7980ef3cf9ae866cc7c533b21e87955b0952d086ab437268", -"5f52dad479356e8c510b7c7cf439d0a5749254f8d84d8dcb9f96a1f7ddaaf852", -"8726ab6a7d3b0cb182db7c9b795526d2d92c3addef2108a71e84ced5c705f0f9", -"6434f64c58086a9bdcb675aed34c4dea9e8be22c45f1043dde3cb3a2b5f651c5", -"c5cd55e69566561f6e057775623f834ce5bbb959821de72421b101baf069d100", -"66b21ff0b20692342415478020a753f314901c0dea20503a19e7d2b741b07d38", -"c2fae3e8cde2f5e11b46b9598d8a8f6cd6705992e28dbc77d550b69967e8db50", -"4b2485674d337f8f30762fea3eaffa7d51ca174bee8ab42a4598830da056e117", -"b7cf8e834028e8ed02c52ca453f7f77b69d99afd5c8c33a8a50a3dfd47e4760e", -"74b8539868a77fae05a7c371bf7c8aba525bc6cf8932f331c390d6f543101de3", -"6b0406beff2eb64ebe475900b7643c0c7067712dcda1cfd425e9d6dff687fc12", -"85d16e1c0b1155bc8a472ce1ee831fa84167cd81175870aa56d681a29a223ad4", -"84695c80cc57989b66adfd7def2f893a2861be9ba67032781620197363eb27de", -"c94fa3421a023786b949fab2b5999ddf86fecf9399bc8b9fbe0ff87480f56f4d", -"7400f5b415abc79c2fe20465a3a777be6e25301ecc9998f74c1ee9808681a7cb", -"446bdfac76bfe7f28e62c39f144a5ec7ace1c817f72f17f8dc56091bbb0c71af", -"ea5f76027a4107a1274ccac9ba81fabb0bc2e4166ec4f4eae9023aaff7302904", -"e882f3c46edb9a136c4ee473ce31c31d98287aa52e9873b117fc6e4ce1191cca" -] diff --git a/previewnet-keys.json b/previewnet-keys.json deleted file mode 100644 index a477a452c..000000000 --- a/previewnet-keys.json +++ /dev/null @@ -1,22 +0,0 @@ -[ -"1b5c3a19ea37dc1f84ee842c9a5b094289e4ee65be559f3e71d8ae5618e81582", -"9ec5349b20ecf67de909e8195475842e117858ccba3fa82a087dd0e9b6cb8368", -"0c4745c00c22205a7980ef3cf9ae866cc7c533b21e87955b0952d086ab437268", -"5f52dad479356e8c510b7c7cf439d0a5749254f8d84d8dcb9f96a1f7ddaaf852", -"8726ab6a7d3b0cb182db7c9b795526d2d92c3addef2108a71e84ced5c705f0f9", -"6434f64c58086a9bdcb675aed34c4dea9e8be22c45f1043dde3cb3a2b5f651c5", -"c5cd55e69566561f6e057775623f834ce5bbb959821de72421b101baf069d100", -"66b21ff0b20692342415478020a753f314901c0dea20503a19e7d2b741b07d38", -"c2fae3e8cde2f5e11b46b9598d8a8f6cd6705992e28dbc77d550b69967e8db50", -"4b2485674d337f8f30762fea3eaffa7d51ca174bee8ab42a4598830da056e117", -"b7cf8e834028e8ed02c52ca453f7f77b69d99afd5c8c33a8a50a3dfd47e4760e", -"74b8539868a77fae05a7c371bf7c8aba525bc6cf8932f331c390d6f543101de3", -"6b0406beff2eb64ebe475900b7643c0c7067712dcda1cfd425e9d6dff687fc12", -"85d16e1c0b1155bc8a472ce1ee831fa84167cd81175870aa56d681a29a223ad4", -"84695c80cc57989b66adfd7def2f893a2861be9ba67032781620197363eb27de", -"c94fa3421a023786b949fab2b5999ddf86fecf9399bc8b9fbe0ff87480f56f4d", -"7400f5b415abc79c2fe20465a3a777be6e25301ecc9998f74c1ee9808681a7cb", -"446bdfac76bfe7f28e62c39f144a5ec7ace1c817f72f17f8dc56091bbb0c71af", -"ea5f76027a4107a1274ccac9ba81fabb0bc2e4166ec4f4eae9023aaff7302904", -"e882f3c46edb9a136c4ee473ce31c31d98287aa52e9873b117fc6e4ce1191cca" -] From 1df7bf429d45cb115e9536545847004e6f03b4b7 Mon Sep 17 00:00:00 2001 From: Ardit Marku Date: Thu, 26 Sep 2024 16:45:22 +0300 Subject: [PATCH 2/8] Remove non-existent configuration flags from README --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index edbec0880..c3a3299b1 100644 --- a/README.md +++ b/README.md @@ -180,7 +180,6 @@ The application can be configured using the following flags at runtime: | `ws-enabled` | `false` | Enable websocket connections | | `access-node-grpc-host` | `localhost:3569` | Host to the flow access node gRPC API | | `access-node-spork-hosts` | `""` | Previous spork AN hosts, defined as a comma-separated list (e.g. `"host-1.com,host2.com"`) | -| `evm-network-id` | `testnet ` | EVM network ID (options: `testnet`, `mainnet`) | | `flow-network-id` | `flow-emulator` | Flow network ID (options: `flow-emulator`, `flow-testnet`, `flow-mainnet`) | | `coinbase` | `""` | Coinbase address to use for fee collection | | `init-cadence-height` | `0` | Cadence block height to start indexing; avoid using on a new network | @@ -204,7 +203,6 @@ The application can be configured using the following flags at runtime: | `wallet-api-key` | `""` | ECDSA private key for wallet APIs (local/testing use only) | | `filter-expiry` | `5m` | Expiry time for idle filters | | `traces-gcp-bucket` | `""` | GCP bucket name for transaction traces | -| `prometheus-config-file-path`| `./metrics/prometheus.yml` | Path to the Prometheus configuration file | | `index-only` | `false` | Run in index-only mode, allowing state queries and indexing but no transaction sending | | `profiler-enabled` | `false` | Enable the pprof profiler server | | `profiler-host` | `localhost` | Host for the pprof profiler | From 0056128296a16b541885f1e17939af038a2787ec Mon Sep 17 00:00:00 2001 From: Ardit Marku Date: Mon, 30 Sep 2024 09:40:03 +0300 Subject: [PATCH 3/8] Add the EVM GW version to log lines --- bootstrap/bootstrap.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bootstrap/bootstrap.go b/bootstrap/bootstrap.go index 5d4a2f17c..cf3845932 100644 --- a/bootstrap/bootstrap.go +++ b/bootstrap/bootstrap.go @@ -57,7 +57,8 @@ type Bootstrap struct { func New(config *config.Config) (*Bootstrap, error) { logger := zerolog.New(config.LogWriter). - With().Timestamp().Logger().Level(config.LogLevel) + With().Timestamp().Str("version", api.Version). + Logger().Level(config.LogLevel) client, err := setupCrossSporkClient(config, logger) if err != nil { From 5ba3dfadff8d2ae04ee5abfad580233f8415da7a Mon Sep 17 00:00:00 2001 From: Ardit Marku Date: Mon, 30 Sep 2024 18:19:35 +0300 Subject: [PATCH 4/8] Update CODEOWNERS file --- .github/CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 1a98e0538..30e615a83 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1 +1 @@ -* @sideninja @peterargue @m-Peter +* @janezpodhostnik @peterargue @m-Peter From b89212c2d42bdc2b9ea5e528e4b3ccd2623b16da Mon Sep 17 00:00:00 2001 From: Janez Podhostnik Date: Mon, 30 Sep 2024 16:19:20 +0200 Subject: [PATCH 5/8] Add engine type to startup logs --- bootstrap/bootstrap.go | 20 ++++++++++++-------- go.mod | 2 +- go.sum | 4 ++-- tests/go.mod | 2 +- tests/go.sum | 4 ++-- 5 files changed, 18 insertions(+), 14 deletions(-) diff --git a/bootstrap/bootstrap.go b/bootstrap/bootstrap.go index 5d4a2f17c..e575e6b07 100644 --- a/bootstrap/bootstrap.go +++ b/bootstrap/bootstrap.go @@ -136,7 +136,7 @@ func (b *Bootstrap) StartEventIngestion(ctx context.Context) error { b.collector, ) - startEngine(ctx, b.events, l) + StartEngine(ctx, b.events, l) return nil } @@ -160,7 +160,7 @@ func (b *Bootstrap) StartTraceDownloader(ctx context.Context) error { b.collector, ) - startEngine(ctx, b.traces, l) + StartEngine(ctx, b.traces, l) return nil } @@ -373,23 +373,27 @@ func (b *Bootstrap) StopProfilerServer() { } } -// startEngine starts provided engine and panics if there are startup errors. -func startEngine( +// StartEngine starts provided engine and panics if there are startup errors. +func StartEngine( ctx context.Context, engine models.Engine, logger zerolog.Logger, ) { - logger.Info().Msg("starting engine") + l := logger.With().Type("engine", engine).Logger() + + l.Info().Msg("starting engine") + start := time.Now() go func() { err := engine.Run(ctx) if err != nil { - logger.Error().Err(err).Msg("engine failed to run") - panic(err) + l.Fatal().Err(err).Msg("engine failed to run") } }() <-engine.Ready() - logger.Info().Msg("engine started successfully") + l.Info(). + Dur("duration", time.Since(start)). + Msg("engine started successfully") } // setupCrossSporkClient sets up a cross-spork AN client. diff --git a/go.mod b/go.mod index d07f78302..eddaa4fb1 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,7 @@ require ( github.com/onflow/go-ethereum v1.14.7 github.com/prometheus/client_golang v1.18.0 github.com/rs/cors v1.8.0 - github.com/rs/zerolog v1.31.0 + github.com/rs/zerolog v1.33.0 github.com/samber/slog-zerolog v1.0.0 github.com/sethvargo/go-limiter v1.0.0 github.com/sethvargo/go-retry v0.2.3 diff --git a/go.sum b/go.sum index ef9529840..b89ccea28 100644 --- a/go.sum +++ b/go.sum @@ -1988,8 +1988,8 @@ github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= github.com/rs/cors v1.8.0 h1:P2KMzcFwrPoSjkF1WLRPsp3UMLyql8L4v9hQpVeK5so= github.com/rs/cors v1.8.0/go.mod h1:EBwu+T5AvHOcXwvZIkQFjUN6s8Czyqw12GL/Y0tUyRM= github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= -github.com/rs/zerolog v1.31.0 h1:FcTR3NnLWW+NnTwwhFWiJSZr4ECLpqCm6QsEnyvbV4A= -github.com/rs/zerolog v1.31.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= +github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8= +github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= github.com/russross/blackfriday v1.5.2 h1:HyvC0ARfnZBqnXwABFeSZHpKvJHJJfPz81GNueLj0oo= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= diff --git a/tests/go.mod b/tests/go.mod index da7a4bbe5..d142132e3 100644 --- a/tests/go.mod +++ b/tests/go.mod @@ -11,7 +11,7 @@ require ( github.com/onflow/flow-go v0.37.10 github.com/onflow/flow-go-sdk v1.0.0-preview.56 github.com/onflow/go-ethereum v1.14.7 - github.com/rs/zerolog v1.31.0 + github.com/rs/zerolog v1.33.0 github.com/stretchr/testify v1.9.0 ) diff --git a/tests/go.sum b/tests/go.sum index 6d4239c4a..6004cfde9 100644 --- a/tests/go.sum +++ b/tests/go.sum @@ -2264,8 +2264,8 @@ github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= github.com/rs/cors v1.8.0 h1:P2KMzcFwrPoSjkF1WLRPsp3UMLyql8L4v9hQpVeK5so= github.com/rs/cors v1.8.0/go.mod h1:EBwu+T5AvHOcXwvZIkQFjUN6s8Czyqw12GL/Y0tUyRM= github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= -github.com/rs/zerolog v1.31.0 h1:FcTR3NnLWW+NnTwwhFWiJSZr4ECLpqCm6QsEnyvbV4A= -github.com/rs/zerolog v1.31.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= +github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8= +github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= github.com/russross/blackfriday v1.5.2 h1:HyvC0ARfnZBqnXwABFeSZHpKvJHJJfPz81GNueLj0oo= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= From 0fd21da185bebda397c057c53aebda670f258057 Mon Sep 17 00:00:00 2001 From: Janez Podhostnik Date: Mon, 30 Sep 2024 17:56:19 +0200 Subject: [PATCH 6/8] add goimports linter --- .golangci.toml | 4 ++++ models/sequential_height_test.go | 3 ++- services/requester/rotation_signer_test.go | 5 +++-- 3 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 .golangci.toml diff --git a/.golangci.toml b/.golangci.toml new file mode 100644 index 000000000..84ff36767 --- /dev/null +++ b/.golangci.toml @@ -0,0 +1,4 @@ +[linters] +enable = [ + "goimports", +] \ No newline at end of file diff --git a/models/sequential_height_test.go b/models/sequential_height_test.go index c762c71f4..0f0b17954 100644 --- a/models/sequential_height_test.go +++ b/models/sequential_height_test.go @@ -1,9 +1,10 @@ package models import ( - "github.com/stretchr/testify/require" "math" "testing" + + "github.com/stretchr/testify/require" ) func TestSequentialHeight(t *testing.T) { diff --git a/services/requester/rotation_signer_test.go b/services/requester/rotation_signer_test.go index 792001915..ed9a621bf 100644 --- a/services/requester/rotation_signer_test.go +++ b/services/requester/rotation_signer_test.go @@ -2,12 +2,13 @@ package requester import ( "fmt" + "sync" + "testing" + "github.com/onflow/flow-go-sdk/crypto" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "golang.org/x/exp/maps" - "sync" - "testing" ) func Test_KeyRotation(t *testing.T) { From 5d7352f6b77ed53a9f9a66b2c1a2011eef4e0f8f Mon Sep 17 00:00:00 2001 From: Janez Podhostnik Date: Mon, 30 Sep 2024 20:53:49 +0200 Subject: [PATCH 7/8] Refactor engine status --- models/engine.go | 6 +++--- services/ingestion/engine.go | 19 +++++-------------- services/traces/engine.go | 20 ++++++++------------ 3 files changed, 16 insertions(+), 29 deletions(-) diff --git a/models/engine.go b/models/engine.go index 4e2ade6cf..edb328689 100644 --- a/models/engine.go +++ b/models/engine.go @@ -30,15 +30,15 @@ func NewEngineStatus() *EngineStatus { } } -func (e *EngineStatus) IsReady() <-chan struct{} { +func (e *EngineStatus) Ready() <-chan struct{} { return e.ready } -func (e *EngineStatus) IsStopped() <-chan struct{} { +func (e *EngineStatus) Stopped() <-chan struct{} { return e.stop } -func (e *EngineStatus) IsDone() <-chan struct{} { +func (e *EngineStatus) Done() <-chan struct{} { return e.done } diff --git a/services/ingestion/engine.go b/services/ingestion/engine.go index de463a15b..2a9792933 100644 --- a/services/ingestion/engine.go +++ b/services/ingestion/engine.go @@ -31,6 +31,8 @@ var _ models.Engine = &Engine{} // it will just overwrite the current indexed data. Idempotency is an important // requirement of the implementation of this engine. type Engine struct { + *models.EngineStatus + subscriber EventSubscriber store *pebble.Storage blocks storage.BlockIndexer @@ -39,7 +41,6 @@ type Engine struct { accounts storage.AccountIndexer log zerolog.Logger evmLastHeight *models.SequentialHeight - status *models.EngineStatus blocksPublisher *models.Publisher logsPublisher *models.Publisher collector metrics.Collector @@ -60,6 +61,8 @@ func NewEventIngestionEngine( log = log.With().Str("component", "ingestion").Logger() return &Engine{ + EngineStatus: models.NewEngineStatus(), + subscriber: subscriber, store: store, blocks: blocks, @@ -67,24 +70,12 @@ func NewEventIngestionEngine( transactions: transactions, accounts: accounts, log: log, - status: models.NewEngineStatus(), blocksPublisher: blocksPublisher, logsPublisher: logsPublisher, collector: collector, } } -// Ready signals when the engine has started. -func (e *Engine) Ready() <-chan struct{} { - return e.status.IsReady() -} - -// Done signals when the engine has stopped. -func (e *Engine) Done() <-chan struct{} { - // return e.status.IsDone() - return nil -} - // Stop the engine. func (e *Engine) Stop() { // todo @@ -113,7 +104,7 @@ func (e *Engine) Run(ctx context.Context) error { e.log.Info().Uint64("start-cadence-height", latestCadence).Msg("starting ingestion") - e.status.MarkReady() + e.MarkReady() for events := range e.subscriber.Subscribe(ctx, latestCadence) { if events.Err != nil { diff --git a/services/traces/engine.go b/services/traces/engine.go index 45cf4daf6..fd51dfece 100644 --- a/services/traces/engine.go +++ b/services/traces/engine.go @@ -27,8 +27,9 @@ var _ models.Engine = &Engine{} // listens for new transaction events and then downloads and index the // traces from the transaction execution. type Engine struct { + *models.EngineStatus + logger zerolog.Logger - status *models.EngineStatus blocksPublisher *models.Publisher blocks storage.BlockIndexer traces storage.TraceIndexer @@ -46,7 +47,8 @@ func NewTracesIngestionEngine( collector metrics.Collector, ) *Engine { return &Engine{ - status: models.NewEngineStatus(), + EngineStatus: models.NewEngineStatus(), + logger: logger.With().Str("component", "trace-ingestion").Logger(), blocksPublisher: blocksPublisher, blocks: blocks, @@ -56,11 +58,13 @@ func NewTracesIngestionEngine( } } +// Run the engine. +// TODO: use the context to stop the engine. func (e *Engine) Run(ctx context.Context) error { // subscribe to new blocks e.blocksPublisher.Subscribe(e) - e.status.MarkReady() + e.MarkReady() return nil } @@ -148,13 +152,5 @@ func (e *Engine) Error() <-chan error { } func (e *Engine) Stop() { - e.status.MarkStopped() -} - -func (e *Engine) Done() <-chan struct{} { - return e.status.IsDone() -} - -func (e *Engine) Ready() <-chan struct{} { - return e.status.IsReady() + e.MarkStopped() } From 38481bb9b6785910294f23175848c8c62df251c7 Mon Sep 17 00:00:00 2001 From: Janez Podhostnik Date: Mon, 30 Sep 2024 21:22:56 +0200 Subject: [PATCH 8/8] Change codeowners --- .github/CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 30e615a83..98382d5de 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1 +1 @@ -* @janezpodhostnik @peterargue @m-Peter +* @janezpodhostnik @peterargue @m-Peter @zhangchiqing @ramtinms \ No newline at end of file