diff --git a/scripts/zkevm-config-diff/README.md b/scripts/zkevm-config-diff/README.md index 3e7ddbd2..8c7f0f7c 100644 --- a/scripts/zkevm-config-diff/README.md +++ b/scripts/zkevm-config-diff/README.md @@ -21,23 +21,23 @@ rm -rf ./default-configs/* ./kurtosis-cdk-configs/* 3. Dump default configurations. ```bash -sh zkevm_config.sh dump default ./default-configs +./zkevm_config.sh dump default ./default-configs ``` 4. Dump kurtosis-cdk configurations. ```bash -sh zkevm_config.sh dump kurtosis-cdk ./kurtosis-cdk-configs +./zkevm_config.sh dump kurtosis-cdk ./kurtosis-cdk-configs ``` 5. Compare configurations. You'll find diffs in `./diff`. ```bash -sh zkevm_config.sh compare configs ./default-configs ./kurtosis-cdk-configs +./zkevm_config.sh compare configs ./default-configs ./kurtosis-cdk-configs ``` 6. Compare two specific files. ```bash -sh zkevm_config.sh compare files ./default-configs/cdk-data-availability-config.toml ./kurtosis-cdk-configs/cdk-data-availability-config.toml +./zkevm_config.sh compare files ./default-configs/cdk-data-availability-config.toml ./kurtosis-cdk-configs/cdk-data-availability-config.toml ``` diff --git a/scripts/zkevm-config-diff/dump_zkevm_default_config.go b/scripts/zkevm-config-diff/dump_zkevm_default_config.go index cf405771..35d24fe3 100644 --- a/scripts/zkevm-config-diff/dump_zkevm_default_config.go +++ b/scripts/zkevm-config-diff/dump_zkevm_default_config.go @@ -1,8 +1,10 @@ package main import ( + "encoding/json" "fmt" "os" + "os/exec" "path/filepath" agglayerconfig "github.com/0xPolygon/agglayer/config" @@ -12,8 +14,6 @@ import ( zkevmnodeconfig "github.com/0xPolygonHermez/zkevm-node/config" "log/slog" - - "github.com/spf13/viper" ) type Module string @@ -28,13 +28,13 @@ const ( func main() { // Check if the expected number of command-line arguments is provided. if len(os.Args) != 2 { - fmt.Println("Usage: dump_zkevm_default_config ") + slog.Info("Usage: dump_zkevm_default_config ") os.Exit(1) } directory := os.Args[1] // Dump zkevm components default configurations. - slog.Info(fmt.Sprintf("Dumping current zkevm configurations in %s...", directory)) + slog.Info("Dumping current zkevm configurations", "directory", directory) if err := dumpDefaultConfig(ZkevmNode, directory); err != nil { slog.Error("Unable to dump zkevm-node default config", "err", err) @@ -57,37 +57,43 @@ func main() { func dumpDefaultConfig(module Module, directory string) error { slog.Info("Dumping default config", "module", module) - var defaultConfigFunc func() error + // Create default config. + var cfg interface{} + var err error switch module { case ZkevmNode: - defaultConfigFunc = func() error { - _, err := zkevmnodeconfig.Default() - return err - } + cfg, err = zkevmnodeconfig.Default() case ZkevmAggLayer: - defaultConfigFunc = func() error { - _, err := agglayerconfig.Default() - return err - } + cfg, err = agglayerconfig.Default() case CdkDataAvailability: - defaultConfigFunc = func() error { - _, err := cdkdaconfig.Default() - return err - } + cfg, err = cdkdaconfig.Default() case ZkevmBridgeService: - defaultConfigFunc = func() error { - _, err := zkevmbridgeserviceconfig.Default() - return err - } + cfg, err = zkevmbridgeserviceconfig.Default() default: return fmt.Errorf("unsupported module: %s", module) } - if err := defaultConfigFunc(); err != nil { + if err != nil { return fmt.Errorf("unable to create default config: %v", err) } - filePath := filepath.Join(directory, fmt.Sprintf("%s-config.toml", module)) - if err := viper.WriteConfigAs(filePath); err != nil { - return fmt.Errorf("unable to write default config file: %v", err) + + // Marshal config to JSON. + cfgJson, err := json.Marshal(cfg) + if err != nil { + return fmt.Errorf("unable to marshal config to json: %v", err) + } + + // Transform the JSON config with jq and format it in TOML with yq. + cmd := fmt.Sprintf("echo '%s' | jq 'walk(if type == \"object\" and keys_unsorted == [\"Duration\"] then ((.Duration / 1e9 | tostring) + \"s\") else . end) | del(..|nulls)' | yq -t", cfgJson) + cfgToml, err := exec.Command("bash", "-c", cmd).CombinedOutput() + if err != nil { + return fmt.Errorf("unable to execute jq command: %v", err) + } + + // Save the config in TOML. + fileName := fmt.Sprintf("%s-config.toml", module) + filePath := filepath.Join(directory, fileName) + if err := os.WriteFile(filePath, cfgToml, 0644); err != nil { + return fmt.Errorf("unable to write config to file: %v", err) } return nil } diff --git a/scripts/zkevm-config-diff/go.mod b/scripts/zkevm-config-diff/go.mod index 2ecbb87e..93a986cc 100644 --- a/scripts/zkevm-config-diff/go.mod +++ b/scripts/zkevm-config-diff/go.mod @@ -3,16 +3,15 @@ module zkevm-node-dump-default-config go 1.21.8 // To replace the zkevm-node dependency by cdk-validium-node, follow these steps: -// replace github.com/0xPolygonHermez/zkevm-node => github.com/0xPolygon/cdk-validium-node v0.6.4+cdk.2 +// replace github.com/0xPolygonHermez/zkevm-node => github.com/0xPolygon/cdk-validium-node v0.6.5+cdk // Run go mod tidy. -replace github.com/0xPolygonHermez/zkevm-node => github.com/0xPolygon/cdk-validium-node v0.6.5-0.20240401131830-60a3e2e517c0 +replace github.com/0xPolygonHermez/zkevm-node => github.com/0xPolygon/cdk-validium-node v0.6.6-0.20240411144334-bd59114567b8 require ( - github.com/0xPolygon/agglayer v0.1.1 + github.com/0xPolygon/agglayer v0.1.3 github.com/0xPolygon/cdk-data-availability v0.0.7 github.com/0xPolygonHermez/zkevm-bridge-service v0.4.3-0.20240422135055-48f8b52b09ae github.com/0xPolygonHermez/zkevm-node v0.6.5 - github.com/spf13/viper v1.18.2 ) require ( @@ -128,6 +127,7 @@ require ( github.com/spf13/afero v1.11.0 // indirect github.com/spf13/cast v1.6.0 // indirect github.com/spf13/pflag v1.0.5 // indirect + github.com/spf13/viper v1.18.2 // indirect github.com/status-im/keycard-go v0.2.0 // indirect github.com/stretchr/objx v0.5.2 // indirect github.com/stretchr/testify v1.9.0 // indirect @@ -145,18 +145,17 @@ require ( github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect go.uber.org/multierr v1.10.0 // indirect go.uber.org/zap v1.27.0 // indirect - golang.org/x/crypto v0.20.0 // indirect + golang.org/x/crypto v0.21.0 // indirect golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa // indirect golang.org/x/mod v0.14.0 // indirect - golang.org/x/net v0.21.0 // indirect + golang.org/x/net v0.23.0 // indirect golang.org/x/sync v0.6.0 // indirect - golang.org/x/sys v0.17.0 // indirect - golang.org/x/term v0.17.0 // indirect + golang.org/x/sys v0.18.0 // indirect + golang.org/x/term v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/time v0.5.0 // indirect golang.org/x/tools v0.15.0 // indirect - google.golang.org/genproto v0.0.0-20240125205218-1f4bbc51befe // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20240205150955-31a09d347014 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20240311132316-a219d84964c2 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240304161311-37d4d3c04a78 // indirect google.golang.org/grpc v1.62.1 // indirect google.golang.org/protobuf v1.33.0 // indirect diff --git a/scripts/zkevm-config-diff/go.sum b/scripts/zkevm-config-diff/go.sum index 5864dcc6..53e54096 100644 --- a/scripts/zkevm-config-diff/go.sum +++ b/scripts/zkevm-config-diff/go.sum @@ -37,14 +37,14 @@ cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohl cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -github.com/0xPolygon/agglayer v0.1.1 h1:Hyjlf0RhrCLoTn+D5+FHPxApZxr1W0ueqCUzhq72J00= -github.com/0xPolygon/agglayer v0.1.1/go.mod h1:IHnajBmmyIyMbcZBXQ7rk2xSjJiSLfljx5ZqXR5MxqY= +github.com/0xPolygon/agglayer v0.1.3 h1:bWc+g8AmS4uP92yiETyizCXZOjfBzIezPZzax21LD7E= +github.com/0xPolygon/agglayer v0.1.3/go.mod h1:dxYsQUqPRQ6SC50yr/dXssHvIavNRLdMUUByGC6n1LY= github.com/0xPolygon/cdk-data-availability v0.0.7 h1:i5v2I8uEgHSZ5BjnJs3Dsy1XpKdSvfZbON9D16gSCUg= github.com/0xPolygon/cdk-data-availability v0.0.7/go.mod h1:qF+xt2gYwBab8XPh3fr6pnNUMEJq/32rmJN0D630hmY= github.com/0xPolygon/cdk-rpc v0.0.0-20240412164206-b23522339906 h1:Y0VWnpzb8XqsTOYfCUR7l6UsUrbHs4Jg9i2c7oE7WrA= github.com/0xPolygon/cdk-rpc v0.0.0-20240412164206-b23522339906/go.mod h1:2scWqMMufrQXu7TikDgQ3BsyaKoX8qP26D6E262vSOg= -github.com/0xPolygon/cdk-validium-node v0.6.5-0.20240401131830-60a3e2e517c0 h1:4akMHWX3umOtRRKfFetXoHk/zvpU4ifSUDNdbY2PROg= -github.com/0xPolygon/cdk-validium-node v0.6.5-0.20240401131830-60a3e2e517c0/go.mod h1:8lw5+FBwpIYQoMH9oyyHMQpyawpwiM6mH5kTX57DuJ4= +github.com/0xPolygon/cdk-validium-node v0.6.6-0.20240411144334-bd59114567b8 h1:SDDkncLQ8Bk91A+fEroITUbDNcOh/kfHdkpDfNy0Wk8= +github.com/0xPolygon/cdk-validium-node v0.6.6-0.20240411144334-bd59114567b8/go.mod h1:8lw5+FBwpIYQoMH9oyyHMQpyawpwiM6mH5kTX57DuJ4= github.com/0xPolygonHermez/zkevm-bridge-service v0.4.3-0.20240422135055-48f8b52b09ae h1:7SqriunmR4hNLQdVkRlh9MYgtRwwjJ2201n666LSU9I= github.com/0xPolygonHermez/zkevm-bridge-service v0.4.3-0.20240422135055-48f8b52b09ae/go.mod h1:8pCOG49QDU4G5+Sg2wyyJPws20zhHHfOZWvHvZRoVJA= github.com/0xPolygonHermez/zkevm-data-streamer v0.1.19 h1:wRFA6uF0sqihWKaxKsk+hEkxcQeOU1eKhVzZy90otZ8= @@ -817,8 +817,8 @@ golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.20.0 h1:jmAMJJZXr5KiCw05dfYK9QnqaqKLYXijU23lsEdcQqg= -golang.org/x/crypto v0.20.0/go.mod h1:Xwo95rrVNIoSMx9wa1JroENMToLWn3RNVrTBpLHgZPQ= +golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= +golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -907,8 +907,8 @@ golang.org/x/net v0.0.0-20211008194852-3b03d305991f/go.mod h1:9nx3DQGgdP8bBQD5qx golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220607020251-c690dde0001d/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4= -golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= +golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= +golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1009,14 +1009,14 @@ golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= -golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.0.0-20220722155259-a9ba230a4035/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.17.0 h1:mkTF7LCd6WGJNL3K1Ad7kwxNfYAW6a8a8QqtMblp/4U= -golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= +golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= +golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1179,10 +1179,8 @@ google.golang.org/genproto v0.0.0-20210319143718-93e7006c17a6/go.mod h1:FWY/as6D google.golang.org/genproto v0.0.0-20210402141018-6c239bbf2bb1/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A= google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= google.golang.org/genproto v0.0.0-20210624195500-8bfb893ecb84/go.mod h1:SzzZ/N+nwJDaO1kznhnlzqS8ocJICar6hYhVyhi++24= -google.golang.org/genproto v0.0.0-20240125205218-1f4bbc51befe h1:USL2DhxfgRchafRvt/wYyyQNzwgL7ZiURcozOE/Pkvo= -google.golang.org/genproto v0.0.0-20240125205218-1f4bbc51befe/go.mod h1:cc8bqMqtv9gMOr0zHg2Vzff5ULhhL2IXP4sbcn32Dro= -google.golang.org/genproto/googleapis/api v0.0.0-20240205150955-31a09d347014 h1:x9PwdEgd11LgK+orcck69WVRo7DezSO4VUMPI4xpc8A= -google.golang.org/genproto/googleapis/api v0.0.0-20240205150955-31a09d347014/go.mod h1:rbHMSEDyoYX62nRVLOCc4Qt1HbsdytAYoVwgjiOhF3I= +google.golang.org/genproto/googleapis/api v0.0.0-20240311132316-a219d84964c2 h1:rIo7ocm2roD9DcFIX67Ym8icoGCKSARAiPljFhh5suQ= +google.golang.org/genproto/googleapis/api v0.0.0-20240311132316-a219d84964c2/go.mod h1:O1cOfN1Cy6QEYr7VxtjOyP5AdAuR0aJ/MYZaaof623Y= google.golang.org/genproto/googleapis/rpc v0.0.0-20240304161311-37d4d3c04a78 h1:Xs9lu+tLXxLIfuci70nG4cpwaRC+mRQPUL7LoIeDJC4= google.golang.org/genproto/googleapis/rpc v0.0.0-20240304161311-37d4d3c04a78/go.mod h1:UCOku4NytXMJuLQE5VuqA5lX3PcHCBo8pxNyvkf4xBs= google.golang.org/grpc v1.12.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw=