config

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2024 License: AGPL-3.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// FlagYes is the flag for yes.
	FlagYes = "yes"
	// FlagCfg is the flag for cfg.
	FlagCfg = "cfg"
	// FlagCustomNetwork is the flag for the custom network file.
	FlagCustomNetwork = "custom-network-file"
	// FlagAmount is the flag for amount.
	FlagAmount = "amount"
	// FlagRemoteMT is the flag for remote-merkletree.
	FlagRemoteMT = "remote-merkletree"
	// FlagComponents is the flag for components.
	FlagComponents = "components"
	// FlagHTTPAPI is the flag for http.api.
	FlagHTTPAPI = "http.api"
	// FlagKeyStorePath is the path of the key store file containing the private key
	// of the account going to sing and approve the tokens.
	FlagKeyStorePath = "key-store-path"
	// FlagPassword is the password needed to decrypt the key store
	FlagPassword = "password"
	// FlagMigrations is the flag for migrations.
	FlagMigrations = "migrations"
	// FlagOutputFile is the flag for the output file
	FlagOutputFile = "output"
	// FlagMaxAmount is the flag to avoid to use the flag FlagAmount
	FlagMaxAmount = "max-amount"
	// 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 = "cdk_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 = `` /* 1215-byte string literal not displayed */

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

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

DefaultValues is the default configuration

View Source
const DefaultVars = `
PathRWData = "/tmp/cdk"
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 added in v0.3.1

func RemoveQuotesForVars(data string) string

func RemoveTypeMarks added in v0.3.1

func RemoveTypeMarks(data string) string

func SaveConfigToFile added in v0.3.1

func SaveConfigToFile(cfg *Config, saveConfigPath string) error

func SaveDataToFile added in v0.3.1

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
	// Configuration of the aggregator
	Aggregator aggregator.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
	// Configuration of the sequence sender service
	SequenceSender sequencesender.Config
	// 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 added in v0.3.1

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

Load loads the configuration

type ConfigRender added in v0.3.1

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 added in v0.3.1

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

func (*ConfigRender) GetUnresolvedVars added in v0.3.1

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 added in v0.3.1

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

GetVars returns the vars in template

func (*ConfigRender) Merge added in v0.3.1

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

func (*ConfigRender) ReadTemplateAdnDefinedValues added in v0.3.1

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 added in v0.3.1

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

- Merge all files - Resolve all variables inside

func (*ConfigRender) ResolveCycle added in v0.3.1

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 added in v0.3.1

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

type DeprecatedField added in v0.3.1

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

type DeprecatedFieldsError added in v0.3.1

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 added in v0.3.1

func NewErrDeprecatedFields() *DeprecatedFieldsError

func (*DeprecatedFieldsError) AddDeprecatedField added in v0.3.1

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

func (*DeprecatedFieldsError) Error added in v0.3.1

func (e *DeprecatedFieldsError) Error() string

type FileData added in v0.3.1

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