Skip to content

Commit e7f06d8

Browse files
committed
refactor: consolidate rollupsmachine and cartesimachine onto machine
1 parent 85ee681 commit e7f06d8

29 files changed

Lines changed: 1413 additions & 2546 deletions

File tree

cmd/cartesi-rollups-advancer/root/root.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func init() {
7272

7373
Cmd.Flags().StringVar(&machinelogLevel, "machine-log-level", "info",
7474
"Remote Machine log level: trace, debug, info, warning, error, fatal")
75-
cobra.CheckErr(viper.BindPFlag(config.REMOTE_MACHINE_LOG_LEVEL, Cmd.Flags().Lookup("machine-log-level")))
75+
cobra.CheckErr(viper.BindPFlag(config.JSONRPC_MACHINE_LOG_LEVEL, Cmd.Flags().Lookup("machine-log-level")))
7676

7777
// TODO: validate on preRunE
7878
Cmd.PreRunE = func(cmd *cobra.Command, args []string) error {

cmd/cartesi-rollups-node/root/root.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ func init() {
114114

115115
Cmd.Flags().StringVar(&machinelogLevel, "machine-log-level", "info",
116116
"Remote Machine log level: trace, debug, info, warning, error, fatal")
117-
cobra.CheckErr(viper.BindPFlag(config.REMOTE_MACHINE_LOG_LEVEL, Cmd.Flags().Lookup("machine-log-level")))
117+
cobra.CheckErr(viper.BindPFlag(config.JSONRPC_MACHINE_LOG_LEVEL, Cmd.Flags().Lookup("machine-log-level")))
118118

119119
Cmd.Flags().Uint64Var(&maxBlockRange, "max-block-range", 0,
120120
"Maximum number of blocks in a single query. large queries will be split automatically. Zero for unlimited.")

internal/advancer/advancer.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ func Create(ctx context.Context, c *CreateInfo) (*Service, error) {
8383
manager := manager.NewMachineManager(
8484
ctx,
8585
c.Repository,
86-
c.Config.RemoteMachineLogLevel,
8786
s.Logger,
8887
c.Config.FeatureMachineHashCheckEnabled,
8988
)

internal/config/config.go

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import (
1616
"time"
1717

1818
"github.com/cartesi/rollups-node/internal/model"
19-
"github.com/cartesi/rollups-node/pkg/rollupsmachine/cartesimachine"
2019

2120
"github.com/ethereum/go-ethereum/common"
2221
)
@@ -31,14 +30,13 @@ func (r Redacted[T]) String() string {
3130
}
3231

3332
type (
34-
URL = *url.URL
35-
Duration = time.Duration
36-
LogLevel = slog.Level
37-
DefaultBlock = model.DefaultBlock
38-
RedactedString = Redacted[string]
39-
RedactedUint = Redacted[uint32]
40-
MachineLogLevel = cartesimachine.MachineLogLevel
41-
Address = common.Address
33+
URL = *url.URL
34+
Duration = time.Duration
35+
LogLevel = slog.Level
36+
DefaultBlock = model.DefaultBlock
37+
RedactedString = Redacted[string]
38+
RedactedUint = Redacted[uint32]
39+
Address = common.Address
4240
)
4341

4442
// ------------------------------------------------------------------------------------------------
@@ -55,6 +53,22 @@ const (
5553
AuthKindAWS
5654
)
5755

56+
// ------------------------------------------------------------------------------------------------
57+
// JSON-RPC Machine log level
58+
// ------------------------------------------------------------------------------------------------
59+
60+
// MachineLogLevel represents the verbosity level for machine logs
61+
type MachineLogLevel string
62+
63+
const (
64+
MachineLogLevelTrace MachineLogLevel = "trace"
65+
MachineLogLevelDebug MachineLogLevel = "debug"
66+
MachineLogLevelInfo MachineLogLevel = "info"
67+
MachineLogLevelWarn MachineLogLevel = "warn"
68+
MachineLogLevelError MachineLogLevel = "error"
69+
MachineLogLevelFatal MachineLogLevel = "fatal"
70+
)
71+
5872
// ------------------------------------------------------------------------------------------------
5973
// Parsing functions
6074
// ------------------------------------------------------------------------------------------------
@@ -95,7 +109,18 @@ func ToLogLevelFromString(s string) (LogLevel, error) {
95109
}
96110

97111
func ToMachineLogLevelFromString(s string) (MachineLogLevel, error) {
98-
return cartesimachine.ParseMachineLogLevel(s)
112+
var m = map[string]MachineLogLevel{
113+
string(MachineLogLevelTrace): MachineLogLevelTrace,
114+
string(MachineLogLevelDebug): MachineLogLevelDebug,
115+
string(MachineLogLevelInfo): MachineLogLevelInfo,
116+
string(MachineLogLevelWarn): MachineLogLevelWarn,
117+
string(MachineLogLevelError): MachineLogLevelError,
118+
string(MachineLogLevelFatal): MachineLogLevelFatal,
119+
}
120+
if v, ok := m[s]; ok {
121+
return v, nil
122+
}
123+
return "", fmt.Errorf("invalid remote machine log level")
99124
}
100125

101126
func ToAddressFromString(s string) (Address, error) {
@@ -210,6 +235,6 @@ var (
210235
notDefinedRedactedString = func() RedactedString { return RedactedString{""} }
211236
notDefinedRedactedUint = func() RedactedUint { return RedactedUint{0} }
212237
notDefinedURL = func() URL { return &url.URL{} }
213-
notDefinedMachineLogLevel = func() MachineLogLevel { return cartesimachine.MachineLogLevelInfo }
238+
notDefinedMachineLogLevel = func() MachineLogLevel { return MachineLogLevelInfo }
214239
notDefinedAddress = func() Address { return common.Address{} }
215240
)

internal/config/generate/Config.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,9 +325,9 @@ used-by = ["advancer", "node", "cli"]
325325
# Remote Cartesi Machine
326326
#
327327

328-
[machine.CARTESI_REMOTE_MACHINE_LOG_LEVEL]
328+
[machine.CARTESI_JSONRPC_MACHINE_LOG_LEVEL]
329329
default = "info"
330-
go-type = "MachineLogLevel"
330+
go-type = "string"
331331
description = """
332332
Remote Cartesi Machine server log level.
333333
One of "trace", "debug", "info", "warning", "error", "fatal"."""

internal/config/generated.go

Lines changed: 17 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)