Skip to content

Commit

Permalink
ci(halo): enable RPCs for docker (#2036)
Browse files Browse the repository at this point in the history
Enable all `halo` RPCs inside docker containers. Operators can then
control accessibility via bind mounts only.

Also, serve CosmosRPC BEFORE starting cometbft to improve using them for
health checks.

issue: none
  • Loading branch information
corverroos authored Oct 2, 2024
1 parent 564fb09 commit abbfa2e
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 31 deletions.
12 changes: 6 additions & 6 deletions halo/app/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,17 +193,17 @@ func Start(ctx context.Context, cfg Config) (<-chan error, func(context.Context)
}
}()

log.Info(ctx, "Starting CometBFT", "listeners", cmtNode.Listeners())

if err := cmtNode.Start(); err != nil {
return nil, nil, errors.Wrap(err, "start comet node")
}

clientCtx := app.ClientContext(ctx).WithClient(rpcClient).WithHomeDir(cfg.HomeDir)
if err := startRPCServers(ctx, cfg, app, sdkLogger, metrics, asyncAbort, clientCtx); err != nil {
return nil, nil, err
}

log.Info(ctx, "Starting CometBFT")

if err := cmtNode.Start(); err != nil {
return nil, nil, errors.Wrap(err, "start comet node")
}

go monitorCometForever(ctx, cfg.Network, rpcClient, cmtNode.ConsensusReactor().WaitSync, cfg.DataDir())
go monitorEVMForever(ctx, cfg, engineCl)

Expand Down
1 change: 1 addition & 0 deletions halo/cmd/cometconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ func DefaultCometConfig(homeDir string) cfg.Config {
conf.ProxyApp = "" // Only support built-in ABCI app supported.
conf.ABCI = "" // Only support built-in ABCI app supported.
conf.Consensus.TimeoutPropose = time.Second // Mitigate slow blocks when proposer inactive (default=3s).
conf.RPC.ListenAddress = "tcp://0.0.0.0:26657" // Halo always run inside docker

return *conf
}
Expand Down
6 changes: 3 additions & 3 deletions halo/cmd/testdata/TestCLIReference_rollback.golden
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ Usage:
halo rollback [flags]

Flags:
--api-address string Address defines the API server to listen on (default "tcp://localhost:1317")
--api-enable Enable defines if the API server should be enabled.
--api-address string Address defines the API server to listen on (default "tcp://0.0.0.0:1317")
--api-enable Enable defines if the API server should be enabled. (default true)
--app-db-backend string The type of database for application and snapshots databases (default "goleveldb")
--engine-endpoint string An EVM execution client Engine API http endpoint
--engine-jwt-file string The path to the Engine API JWT file
--evm-build-delay duration Minimum delay between triggering and fetching a EVM payload build (default 600ms)
--evm-build-optimistic Enables optimistic building of EVM payloads on previous block finalize (default true)
--grpc-address string Address defines the GRPC server to listen on (default "localhost:9090")
--grpc-address string Address defines the GRPC server to listen on (default "0.0.0.0:9090")
--grpc-enable Enable defines if the GRPC server should be enabled. (default true)
--hard Remove last block as well as state
-h, --help help for rollback
Expand Down
6 changes: 3 additions & 3 deletions halo/cmd/testdata/TestCLIReference_run.golden
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ Usage:
halo run [flags]

Flags:
--api-address string Address defines the API server to listen on (default "tcp://localhost:1317")
--api-enable Enable defines if the API server should be enabled.
--api-address string Address defines the API server to listen on (default "tcp://0.0.0.0:1317")
--api-enable Enable defines if the API server should be enabled. (default true)
--app-db-backend string The type of database for application and snapshots databases (default "goleveldb")
--engine-endpoint string An EVM execution client Engine API http endpoint
--engine-jwt-file string The path to the Engine API JWT file
--evm-build-delay duration Minimum delay between triggering and fetching a EVM payload build (default 600ms)
--evm-build-optimistic Enables optimistic building of EVM payloads on previous block finalize (default true)
--grpc-address string Address defines the GRPC server to listen on (default "localhost:9090")
--grpc-address string Address defines the GRPC server to listen on (default "0.0.0.0:9090")
--grpc-enable Enable defines if the GRPC server should be enabled. (default true)
-h, --help help for run
--home string The application home directory containing config and data (default "./halo")
Expand Down
8 changes: 4 additions & 4 deletions halo/cmd/testdata/TestRunCmd_defaults.golden
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
},
"UnsafeSkipUpgrades": null,
"SDKAPI": {
"Enable": false,
"Address": "tcp://localhost:1317"
"Enable": true,
"Address": "tcp://0.0.0.0:1317"
},
"SDKGRPC": {
"Enable": true,
"Address": "localhost:9090"
"Address": "0.0.0.0:9090"
},
"Comet": {
"Version": "0.38.12",
Expand All @@ -42,7 +42,7 @@
"FilterPeers": false,
"RPC": {
"RootDir": "./halo",
"ListenAddress": "tcp://127.0.0.1:26657",
"ListenAddress": "tcp://0.0.0.0:26657",
"CORSAllowedOrigins": [],
"CORSAllowedMethods": [
"HEAD",
Expand Down
8 changes: 4 additions & 4 deletions halo/cmd/testdata/TestRunCmd_flags.golden
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
},
"UnsafeSkipUpgrades": null,
"SDKAPI": {
"Enable": false,
"Address": "tcp://localhost:1317"
"Enable": true,
"Address": "tcp://0.0.0.0:1317"
},
"SDKGRPC": {
"Enable": true,
"Address": "localhost:9090"
"Address": "0.0.0.0:9090"
},
"Comet": {
"Version": "0.38.12",
Expand All @@ -42,7 +42,7 @@
"FilterPeers": false,
"RPC": {
"RootDir": "foo",
"ListenAddress": "tcp://127.0.0.1:26657",
"ListenAddress": "tcp://0.0.0.0:26657",
"CORSAllowedOrigins": [],
"CORSAllowedMethods": [
"HEAD",
Expand Down
6 changes: 3 additions & 3 deletions halo/cmd/testdata/TestRunCmd_json_files.golden
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
},
"UnsafeSkipUpgrades": null,
"SDKAPI": {
"Enable": false,
"Enable": true,
"Address": "api/json"
},
"SDKGRPC": {
"Enable": true,
"Address": "localhost:9090"
"Address": "0.0.0.0:9090"
},
"Comet": {
"Version": "0.38.12",
Expand All @@ -42,7 +42,7 @@
"FilterPeers": false,
"RPC": {
"RootDir": "testinput/input2",
"ListenAddress": "tcp://127.0.0.1:26657",
"ListenAddress": "tcp://0.0.0.0:26657",
"CORSAllowedOrigins": [],
"CORSAllowedMethods": [
"HEAD",
Expand Down
2 changes: 1 addition & 1 deletion halo/cmd/testdata/TestRunCmd_toml_files.golden
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
},
"UnsafeSkipUpgrades": null,
"SDKAPI": {
"Enable": false,
"Enable": true,
"Address": "api/toml"
},
"SDKGRPC": {
Expand Down
11 changes: 7 additions & 4 deletions halo/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,15 @@ const (
defaultDBBackend = db.GoLevelDBBackend
defaultEVMBuildDelay = time.Millisecond * 600 // 100ms longer than geth's --miner.recommit=500ms.
defaultEVMBuildOptimistic = true

defaultAPIEnable = true // Halo runs in docker, so enabled via port mapping
defaultAPIAddress = "tcp://0.0.0.0:1317" // Halo runs inside docker
defaultGRPCEnable = true // Halo runs in docker, so enabled via port mapping
defaultGRPCAddress = "0.0.0.0:9090" // Halo runs inside docker
)

// DefaultConfig returns the default halo config.
func DefaultConfig() Config {
sdkConfig := srvconfig.DefaultConfig()

return Config{
HomeDir: DefaultHomeDir,
Network: "", // No default
Expand All @@ -60,8 +63,8 @@ func DefaultConfig() Config {
EVMBuildDelay: defaultEVMBuildDelay,
EVMBuildOptimistic: defaultEVMBuildOptimistic,
Tracer: tracer.DefaultConfig(),
SDKAPI: RPCConfig{Enable: sdkConfig.API.Enable, Address: sdkConfig.API.Address},
SDKGRPC: RPCConfig{Enable: sdkConfig.GRPC.Enable, Address: sdkConfig.GRPC.Address},
SDKAPI: RPCConfig{Enable: defaultAPIEnable, Address: defaultAPIAddress},
SDKGRPC: RPCConfig{Enable: defaultGRPCEnable, Address: defaultGRPCAddress},
}
}

Expand Down
6 changes: 3 additions & 3 deletions halo/config/testdata/default_halo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ unsafe-skip-upgrades = [1,2,3]
[api]

# Enable defines if the API server should be enabled.
enable = false
enable = true

# Address defines the API server to listen on.
address = "tcp://localhost:1317"
address = "tcp://0.0.0.0:1317"

###############################################################################
### Cosmos SDK gRPC Configuration ###
Expand All @@ -92,7 +92,7 @@ address = "tcp://localhost:1317"
enable = true

# Address defines the gRPC server address to bind to.
address = "localhost:9090"
address = "0.0.0.0:9090"

#######################################################################
### X-Chain ###
Expand Down

0 comments on commit abbfa2e

Please sign in to comment.