The zkevm-config-diff tool extracts default configurations from zkevm components. For zkevm components written in go, it generates the default configurations using the Default() method and writes the configurations to files using the viper.WriteConfigAs() method. Unfortunately, this method doesn't support fields in a go mapstruct very well and will skip some fields if they have a nil value.
For example, here is the result of fmt.Println(viper.AllSettings()) where you can clearly see that some sections of sequencer.streamserver have been ignored like chainId.
On the left, the default sequencer.streamserver section we should get and on the right, the result we get.
This PR removes the need to use viper to write the default configuration file. Instead, it marshals the structure to JSON, normalizes the files with jq and converts them back to TOML using yq.
Description
The
zkevm-config-diff
tool extracts default configurations from zkevm components. For zkevm components written in go, it generates the default configurations using theDefault()
method and writes the configurations to files using theviper.WriteConfigAs()
method. Unfortunately, this method doesn't support fields in a gomapstruct
very well and will skip some fields if they have anil
value.For example, here is the result of
fmt.Println(viper.AllSettings())
where you can clearly see that some sections ofsequencer.streamserver
have been ignored likechainId
.On the left, the default
sequencer.streamserver
section we should get and on the right, the result we get.This PR removes the need to use
viper
to write the default configuration file. Instead, it marshals the structure to JSON, normalizes the files withjq
and converts them back to TOML usingyq
.References (if applicable)
Follow up of #56