Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
11ec5fb
Move config default log level from comet to rollkit
randygrok Mar 4, 2025
7ab7387
Use instrumentation config from rollkit
randygrok Mar 4, 2025
7cab9e5
refactor: Migrate instrumentation config from CometBFT to Rollkit
randygrok Mar 4, 2025
726e153
refactor: Update node configuration to use Viper and remove CometBFT …
randygrok Mar 4, 2025
d01c738
Merge remote-tracking branch 'origin/feature/exec_api' into feature/c…
randygrok Mar 4, 2025
a0819f9
refactor: Remove proxy_app configuration in node commands
randygrok Mar 4, 2025
ede2690
refactor: Remove ABCI transport configuration flags
randygrok Mar 4, 2025
90096e7
refactor: Update P2P configuration to use 'p2p.laddr' instead of 'p2p…
randygrok Mar 4, 2025
d719600
refactor: Remove commented-out code and unused configurations in run_…
randygrok Mar 4, 2025
5fa72f2
refactor: Remove P2P external address configuration
randygrok Mar 4, 2025
3b97a57
Merge branch 'feature/exec_api' into feature/config-comet
randygrok Mar 5, 2025
31007ea
remove duplicated rollkit config
randygrok Mar 5, 2025
ec9add9
Merge branch 'feature/config-comet' of github.xm233.cn-randy:rollkit/rollk…
randygrok Mar 5, 2025
2d99233
remove duplicate
randygrok Mar 5, 2025
2e53815
Markdown lint
randygrok Mar 5, 2025
08746a5
use default nodeRollkit
randygrok Mar 5, 2025
01f5412
Add conditionals to viper load
randygrok Mar 5, 2025
9892f0e
fix default url
randygrok Mar 5, 2025
7f57d49
fix units
randygrok Mar 5, 2025
b2fca53
update code
randygrok Mar 5, 2025
1feddf3
update docs
randygrok Mar 5, 2025
dfd8f01
remove links
randygrok Mar 5, 2025
48aaf04
fix files mdbook
randygrok Mar 5, 2025
2af5c65
fix dockerfile
randygrok Mar 5, 2025
75efbc8
add test coverage
randygrok Mar 5, 2025
7e1b2b9
fix lint errors
randygrok Mar 5, 2025
6319f6e
remove old comment
randygrok Mar 5, 2025
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
15 changes: 7 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## prep the base image.
#
FROM golang as base
FROM golang AS base

RUN apt update && \
apt-get install -y \
Expand All @@ -9,21 +9,20 @@ RUN apt update && \
curl

# enable faster module downloading.
ENV GOPROXY https://proxy.golang.org
ENV GOPROXY=https://proxy.golang.org

## builder stage.
#
FROM base as builder
FROM base AS builder

WORKDIR /rollkit

# cache dependencies.
COPY ./go.mod .
COPY ./go.sum .
RUN go mod download

# Copiar todo el código fuente primero
COPY . .

# Ahora descargar las dependencias
RUN go mod download

RUN make install

## prep the final image.
Expand Down
66 changes: 24 additions & 42 deletions cmd/rollkit/commands/run_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@ import (
"net"
"net/url"
"os"
"path/filepath"
"syscall"
"time"

"cosmossdk.io/log"
cmtcmd "github.com/cometbft/cometbft/cmd/cometbft/commands"
cometconf "github.com/cometbft/cometbft/config"
cometcli "github.com/cometbft/cometbft/libs/cli"
cometos "github.com/cometbft/cometbft/libs/os"
cometnode "github.com/cometbft/cometbft/node"
cometp2p "github.com/cometbft/cometbft/p2p"
cometprivval "github.com/cometbft/cometbft/privval"
comettypes "github.com/cometbft/cometbft/types"
Expand Down Expand Up @@ -44,9 +43,6 @@ import (
)

var (
// initialize the config with the cometBFT defaults
config = cometconf.DefaultConfig()

// initialize the rollkit node configuration
nodeConfig = rollconf.DefaultNodeConfig

Expand Down Expand Up @@ -98,16 +94,19 @@ func NewRunNodeCmd() *cobra.Command {
return initFiles()
},
RunE: func(cmd *cobra.Command, args []string) error {
genDocProvider := cometnode.DefaultGenesisDocProviderFunc(config)
genDocProvider := RollkitGenesisDocProviderFunc(nodeConfig)
genDoc, err := genDocProvider()
if err != nil {
return err
}
nodeKey, err := cometp2p.LoadOrGenNodeKey(config.NodeKeyFile())
nodeKeyFile := filepath.Join(nodeConfig.RootDir, "config", "node_key.json")
nodeKey, err := cometp2p.LoadOrGenNodeKey(nodeKeyFile)
if err != nil {
return err
}
pval := cometprivval.LoadOrGenFilePV(config.PrivValidatorKeyFile(), config.PrivValidatorStateFile())
privValidatorKeyFile := filepath.Join(nodeConfig.RootDir, "config", "priv_validator_key.json")
privValidatorStateFile := filepath.Join(nodeConfig.RootDir, "data", "priv_validator_state.json")
pval := cometprivval.LoadOrGenFilePV(privValidatorKeyFile, privValidatorStateFile)
p2pKey, err := rolltypes.GetNodeKey(nodeKey)
if err != nil {
return err
Expand All @@ -117,17 +116,6 @@ func NewRunNodeCmd() *cobra.Command {
return err
}

// default to socket connections for remote clients
if len(config.ABCI) == 0 {
config.ABCI = "socket"
}

// get the node configuration
rollconf.GetNodeConfig(&nodeConfig, config)
if err := rollconf.TranslateAddresses(&nodeConfig); err != nil {
return err
}

// initialize the metrics
metrics := node.DefaultMetricsProvider(rollconf.DefaultInstrumentationConfig())

Expand Down Expand Up @@ -186,11 +174,6 @@ func NewRunNodeCmd() *cobra.Command {

logger.Info("Executor address", "address", nodeConfig.ExecutorAddress)

// use noop proxy app by default
if !cmd.Flags().Lookup("proxy_app").Changed {
config.ProxyApp = "noop"
}

// Create a cancellable context for the node
ctx, cancel := context.WithCancel(cmd.Context())
defer cancel() // Ensure context is cancelled when command exits
Expand Down Expand Up @@ -325,7 +308,6 @@ func addNodeFlags(cmd *cobra.Command) {
// Add cometBFT flags
cmtcmd.AddNodeFlags(cmd)

cmd.Flags().String("transport", config.ABCI, "specify abci transport (socket | grpc)")
cmd.Flags().Bool("ci", false, "run node for ci testing")

// Add Rollkit flags
Expand Down Expand Up @@ -413,8 +395,8 @@ func tryStartMockExecutorServerGRPC(listenAddress string) (*grpc.Server, error)
// note that such a change would also require changing the cosmos-sdk
func initFiles() error {
// Generate the private validator config files
cometprivvalKeyFile := config.PrivValidatorKeyFile()
cometprivvalStateFile := config.PrivValidatorStateFile()
cometprivvalKeyFile := filepath.Join(nodeConfig.RootDir, "config", "priv_validator_key.json")
cometprivvalStateFile := filepath.Join(nodeConfig.RootDir, "data", "priv_validator_state.json")
var pv *cometprivval.FilePV
if cometos.FileExists(cometprivvalKeyFile) {
pv = cometprivval.LoadFilePV(cometprivvalKeyFile, cometprivvalStateFile)
Expand All @@ -428,7 +410,7 @@ func initFiles() error {
}

// Generate the node key config files
nodeKeyFile := config.NodeKeyFile()
nodeKeyFile := filepath.Join(nodeConfig.RootDir, "config", "node_key.json")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need node key?

if cometos.FileExists(nodeKeyFile) {
logger.Info("Found node key", "path", nodeKeyFile)
} else {
Expand All @@ -439,7 +421,7 @@ func initFiles() error {
}

// Generate the genesis file
genFile := config.GenesisFile()
genFile := filepath.Join(nodeConfig.RootDir, "config", "genesis.json")
if cometos.FileExists(genFile) {
logger.Info("Found genesis file", "path", genFile)
} else {
Expand Down Expand Up @@ -478,15 +460,10 @@ func parseConfig(cmd *cobra.Command) error {
return err
}
}
config.RootDir = home
nodeConfig.RootDir = home

// Validate the root directory
cometconf.EnsureRoot(config.RootDir)

// Validate the config
if err := config.ValidateBasic(); err != nil {
return fmt.Errorf("error in config file: %w", err)
}
rollconf.EnsureRoot(nodeConfig.RootDir)

// Parse the flags
if err := parseFlags(cmd); err != nil {
Expand All @@ -503,7 +480,7 @@ func parseFlags(cmd *cobra.Command) error {
}

// unmarshal viper into config
err := v.Unmarshal(&config, func(c *mapstructure.DecoderConfig) {
err := v.Unmarshal(&nodeConfig, func(c *mapstructure.DecoderConfig) {
c.TagName = "mapstructure"
c.DecodeHook = mapstructure.ComposeDecodeHookFunc(
mapstructure.StringToTimeDurationHookFunc(),
Expand All @@ -514,15 +491,20 @@ func parseFlags(cmd *cobra.Command) error {
return fmt.Errorf("unable to decode command flags into config: %w", err)
}

// special handling for the p2p external address, due to inconsistencies in mapstructure and flag name
if cmd.Flags().Lookup("p2p.external-address").Changed {
config.P2P.ExternalAddress = viper.GetString("p2p.external-address")
}

// handle rollkit node configuration
if err := nodeConfig.GetViperConfig(v); err != nil {
return fmt.Errorf("unable to decode command flags into nodeConfig: %w", err)
}

return nil
}

// RollkitGenesisDocProviderFunc returns a function that loads the GenesisDoc from the filesystem
// using nodeConfig instead of config.
func RollkitGenesisDocProviderFunc(nodeConfig rollconf.NodeConfig) func() (*comettypes.GenesisDoc, error) {
return func() (*comettypes.GenesisDoc, error) {
// Construct the genesis file path using rootify
genFile := filepath.Join(nodeConfig.RootDir, "config", "genesis.json")
return comettypes.GenesisDocFromFile(genFile)
}
}
Loading