Help us shape the future of Go! Take the 2026 Go Developer Survey

config

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 21, 2025 License: AGPL-3.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// FlagCfg is the flag for cfg.
	FlagCfg = "cfg"
	// FlagComponents is the flag for components.
	FlagComponents = "components"
	// FlagSaveConfigPath is the flag to save the final configuration file
	FlagSaveConfigPath = "save-config-path"
	// FlagDisableDefaultConfigVars is the flag to force all variables to be set on config-files
	FlagDisableDefaultConfigVars = "disable-default-config-vars"
	// FlagAllowDeprecatedFields is the flag to allow deprecated fields
	FlagAllowDeprecatedFields = "allow-deprecated-fields"

	EnvVarPrefix       = "CDK"
	ConfigType         = "toml"
	SaveConfigFileName = "aggkit_config.toml"

	DefaultCreationFilePermissions = os.FileMode(0600)
)
View Source
const (

	// LeafTypeBalance specifies that leaf stores Balance
	LeafTypeBalance leafType = 0
	// LeafTypeNonce specifies that leaf stores Nonce
	LeafTypeNonce leafType = 1
	// LeafTypeCode specifies that leaf stores Code
	LeafTypeCode leafType = 2
	// LeafTypeStorage specifies that leaf stores Storage Value
	LeafTypeStorage leafType = 3
	// LeafTypeSCLength specifies that leaf stores Storage Value
	LeafTypeSCLength leafType = 4
)
View Source
const DefaultMandatoryVars = `` /* 1110-byte string literal not displayed */

This values doesnt have a default value because depend on the environment / deployment

View Source
const DefaultValues = `` /* 4769-byte string literal not displayed */

DefaultValues is the default configuration

View Source
const DefaultVars = `
PathRWData = "/tmp/aggkit"
L1URLSyncChunkSize = 100

`

This doesnt below to config, but are the vars used to avoid repetition in config-files

Variables

View Source
var (
	ErrCycleVars                 = fmt.Errorf("cycle vars")
	ErrMissingVars               = fmt.Errorf("missing vars")
	ErrUnsupportedConfigFileType = fmt.Errorf("unsupported config file type")
)

Functions

func RemoveQuotesForVars

func RemoveQuotesForVars(data string) string

func RemoveTypeMarks

func RemoveTypeMarks(data string) string

func SaveConfigToFile

func SaveConfigToFile(cfg *Config, saveConfigPath string) error

func SaveDataToFile

func SaveDataToFile(fullPath, reason string, data []byte) error

Types

type Config

type Config struct {
	// Configuration of the etherman (client for access L1)
	Etherman ethermanconfig.Config
	// Configure Log level for all the services, allow also to store the logs in a file
	Log log.Config
	// Configuration of the genesis of the network. This is used to known the initial state of the network
	NetworkConfig NetworkConfig
	// Common Config that affects all the services
	Common common.Config
	// Configuration of the reorg detector service to be used for the L1
	ReorgDetectorL1 reorgdetector.Config
	// Configuration of the reorg detector service to be used for the L2
	ReorgDetectorL2 reorgdetector.Config
	// Configuration of the aggOracle service
	AggOracle aggoracle.Config
	// Configuration of the L1 Info Treee Sync service
	L1InfoTreeSync l1infotreesync.Config

	// RPC is the config for the RPC server
	RPC jRPC.Config

	// ClaimSponsor is the config for the claim sponsor
	ClaimSponsor claimsponsor.EVMClaimSponsorConfig

	// BridgeL1Sync is the configuration for the synchronizer of the bridge of the L1
	BridgeL1Sync bridgesync.Config

	// BridgeL2Sync is the configuration for the synchronizer of the bridge of the L2
	BridgeL2Sync bridgesync.Config

	// LastGERSync is the config for the synchronizer in charge of syncing the last GER injected on L2.
	// Needed for the bridge service (RPC)
	LastGERSync lastgersync.Config

	// AggSender is the configuration of the agg sender service
	AggSender aggsender.Config
}

Config represents the configuration of the entire CDK Node The file is TOML format

func Load

func Load(ctx *cli.Context) (*Config, error)

Load loads the configuration

func LoadFile

func LoadFile(files []FileData, saveConfigPath string,
	setDefaultVars bool, allowDeprecatedFields bool) (*Config, error)

Load loads the configuration

func LoadFileFromString

func LoadFileFromString(configFileData string, configType string) (*Config, error)

Load loads the configuration

type ConfigRender

type ConfigRender struct {
	// 0: default, 1: specific
	FilesData []FileData
	// Function to resolve environment variables typically: Os.LookupEnv
	LookupEnvFunc     func(key string) (string, bool)
	EnvinormentPrefix string
}

func NewConfigRender

func NewConfigRender(filesData []FileData, envinormentPrefix string) *ConfigRender

func (*ConfigRender) GetUnresolvedVars

func (c *ConfigRender) GetUnresolvedVars(tpl *fasttemplate.Template,
	data map[string]interface{}, useEnv bool) []string

GetUnresolvedVars returns the vars in template that are no on data In this case we don't use environment variables

func (*ConfigRender) GetVars

func (c *ConfigRender) GetVars(configData string) []string

GetVars returns the vars in template

func (*ConfigRender) Merge

func (c *ConfigRender) Merge() (string, error)

func (*ConfigRender) ReadTemplateAdnDefinedValues

func (c *ConfigRender) ReadTemplateAdnDefinedValues(data string) (*fasttemplate.Template,
	map[string]interface{}, error)

The variables in data must be in format template: A={{B}} no A="{{B}}"

func (*ConfigRender) Render

func (c *ConfigRender) Render() (string, error)

- Merge all files - Resolve all variables inside

func (*ConfigRender) ResolveCycle

func (c *ConfigRender) ResolveCycle(partialResolvedConfigData string) (string, error)

ResolveCycle resolve the cycle vars: It iterate to configData, each step must reduce the number of 'vars' if not means that there are cycle vars

func (*ConfigRender) ResolveVars

func (c *ConfigRender) ResolveVars(fullConfigData string) (string, error)

type DeprecatedField

type DeprecatedField struct {
	// If the field name ends with a dot means that match a section
	FieldNamePattern string
	Reason           string
}

type DeprecatedFieldsError

type DeprecatedFieldsError struct {
	// key is the rule and the value is the field's name that matches the rule
	Fields map[DeprecatedField][]string
}

func NewErrDeprecatedFields

func NewErrDeprecatedFields() *DeprecatedFieldsError

func (*DeprecatedFieldsError) AddDeprecatedField

func (e *DeprecatedFieldsError) AddDeprecatedField(fieldName string, rule DeprecatedField)

func (*DeprecatedFieldsError) Error

func (e *DeprecatedFieldsError) Error() string

type FileData

type FileData struct {
	Name    string
	Content string
}

type GenesisFromJSON

type GenesisFromJSON struct {
	// L1: root hash of the genesis block
	Root string `json:"root"`
	// L1: block number of the genesis block
	GenesisBlockNum uint64 `json:"genesisBlockNumber"`
	// L2:  List of states contracts used to populate merkle tree at initial state
	Genesis []genesisAccountFromJSON `json:"genesis"`
	// L1: configuration of the network
	L1Config ethermanconfig.L1Config
}

GenesisFromJSON is the config file for network_custom

type NetworkConfig

type NetworkConfig struct {
	// L1: Configuration related to L1
	L1Config ethermanconfig.L1Config `mapstructure:"L1"`
	// L1: Genesis of the rollup, first block number and root
	Genesis state.Genesis
}

NetworkConfig is the configuration struct for the different environments

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL