-
Notifications
You must be signed in to change notification settings - Fork 10
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
Use flow-go Components for composing #682
base: feature/local-tx-reexecution
Are you sure you want to change the base?
Use flow-go Components for composing #682
Conversation
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
1d626c7
to
a2386c1
Compare
33d6278
to
67136f9
Compare
9e3947b
to
50d77d2
Compare
2121836
to
a746c82
Compare
bootstrap/bootstrap.go
Outdated
DB *pebble.DB | ||
Client *requester.CrossSporkClient | ||
Storages *Storages | ||
// Signer is used for signing flow transactions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Signer is used for signing flow transactions |
bootstrap/bootstrap.go
Outdated
func (fnb *EVMGatewayNodeBuilder) apiServerComponent(cfg config.Config) (module.ReadyDoneAware, error) { | ||
log := fnb.Logger | ||
|
||
log.Info().Msg("bootstrap starting Metrics server") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log.Info().Msg("bootstrap starting Metrics server") | |
log.Info().Msg("bootstrap starting API server") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice 👏 👏 👏
87a1102
to
453f201
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for making this consistent with flow-go. will make it much easier to reason with.
a general comment about the component usage. In some places you used a component manager, and in others you wrote your own. I'm OK with custom handling where it's easier, but I think we should avoid non-idempotent Ready/Done methods
server *http.Server | ||
endpoint string | ||
|
||
startupCompleted chan struct{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about using a component manager here? I think we should stick to the idempotent Ready()
/Done()
pattern.
}() | ||
|
||
<-ready | ||
startGateway(t, ctx, cfg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the previous version waited for Run
to be called. should we wait for Ready()
here?
|
||
node, err := builder.Build() | ||
if err != nil { | ||
builder.Logger.Fatal().Err(err).Send() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
builder.Logger.Fatal().Err(err).Send() | |
builder.Logger.Fatal().Err(err).Msg("failed to build node") |
case <-done: | ||
log.Info().Msg("done, shutting down") | ||
if err := builder.Initialize(); err != nil { | ||
builder.Logger.Fatal().Err(err).Send() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
builder.Logger.Fatal().Err(err).Send() | |
builder.Logger.Fatal().Err(err).Msg("failed to initialize node") |
return nil | ||
}) | ||
|
||
return err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return err | |
return nil |
} | ||
fnb.Logger.Info().Msg("database has been closed") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this belongs in the db shutdown callback
fnb.Component("API Server", fnb.apiServerComponent) | ||
fnb.Component("Event Ingestion Engine", fnb.eventIngestionEngineComponent) | ||
fnb.Component("Metrics Server", fnb.metricsServerComponent) | ||
fnb.Component("Profiler Server", fnb.profilerServerComponent) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: put profiles and metrics first so we can capture debug data during startup
Uint64("start-cadence-height", latestCadenceHeight). | ||
Uint64("latest-cadence-height", latestCadenceBlock.Height). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these names are confusing. consider renaming
} | ||
if events.Err != nil { | ||
return fmt.Errorf( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why don't we need to handle this error anymore?
Closes: onflow/flow-go#6776
Depends on: onflow/flow-go#6769
Description
Use flow-go component model and node framework to compose the Gatway and handle shutdown.
Main advantage is that the re-use of the component management system from flow-go automatically gives us nicer error handling an resource closing on error. To use the error handling, just make sure to use
irrecoverable.SignalerContext.Throw(err)
for any unexpected error. This will start the shutdown procedure and properly release all resources.Changes:
api/profiler.go
is now a componentapi/server.go
is now a componentbootstrap/bootstrap.go
is changed a lot and is modeled afterflow-go
ExecutionNodeBuilder
bootstrap/utils.go
were moved intoservices/requester/key_store_component.go
which is a component that handles the keystore. It should have aClose
for the KMS client, but the KMS client is currently not aio.Closer
(which should be addresses)cmd/run/cmd.go
was simplified because the startup logic is now actually inflow-go
models/engine.go
was removed because its no longer neededmodels/stream.go
was converted into a component. This lets it force shutdown the gateway in case of an error inNotify
services/ingestion/engine.go
is now component. In case of errors in events processing it shuts down the node.This depends on onflow/flow-go#6769
For contributor use:
master
branchFiles changed
in the Github PR explorer