config

package
v1.35.0 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2024 License: MIT Imports: 23 Imported by: 8

README

TOML Config

These basic building blocks can be used to create a TOML config file. For example:

import (
    ctf_config "github.com/smartcontractkit/chainlink-testing-framework/config"
	ctf_test_env "github.com/smartcontractkit/chainlink-testing-framework/docker/test_env"
)

type TestConfig struct {
	ChainlinkImage         *ctf_config.ChainlinkImageConfig `toml:"ChainlinkImage"`
	ChainlinkUpgradeImage  *ctf_config.ChainlinkImageConfig `toml:"ChainlinkUpgradeImage"`
	Logging                *ctf_config.LoggingConfig        `toml:"Logging"`
	Network                *ctf_config.NetworkConfig        `toml:"Network"`
	Pyroscope              *ctf_config.PyroscopeConfig      `toml:"Pyroscope"`
	PrivateEthereumNetwork *ctf_test_env.EthereumNetwork    `toml:"PrivateEthereumNetwork"`
}

It's up to the user to provide a way to read the config from file and unmarshal it into the struct. You can check testconfig.go to see one way it could be done..

Validate() should be used to ensure that the config is valid. Some of the building blocks have also a Default() method that can be used to get default values.

Also you might find BytesToAnyTomlStruct(logger zerolog.Logger, filename, configurationName string, target any, content []byte) error utility method useful for unmarshalling TOMLs read from env var or files into a struct

Test Secrets

Test secrets are not stored directly within the TestConfig TOML due to security reasons. Instead, they are passed into TestConfig via environment variables. Below is a list of all available secrets. Set only the secrets required for your specific tests, like so: E2E_TEST_CHAINLINK_IMAGE=qa_ecr_image_url.

Default Secret Loading

By default, secrets are loaded from the ~/.testsecrets dotenv file. Example of a local ~/.testsecrets file:

E2E_TEST_CHAINLINK_IMAGE=qa_ecr_image_url
E2E_TEST_CHAINLINK_UPGRADE_IMAGE=qa_ecr_image_url
E2E_TEST_ARBITRUM_SEPOLIA_WALLET_KEY=wallet_key
All E2E Test Secrets
Secret Env Var Example
Chainlink Image E2E_TEST_CHAINLINK_IMAGE E2E_TEST_CHAINLINK_IMAGE=qa_ecr_image_url
Chainlink Upgrade Image E2E_TEST_CHAINLINK_UPGRADE_IMAGE E2E_TEST_CHAINLINK_UPGRADE_IMAGE=qa_ecr_image_url
Wallet Key per network E2E_TEST_(.+)_WALLET_KEY or E2E_TEST_(.+)_WALLET_KEY_(\d+)$ E2E_TEST_ARBITRUM_SEPOLIA_WALLET_KEY=wallet_key or E2E_TEST_ARBITRUM_SEPOLIA_WALLET_KEY_1=wallet_key_1, E2E_TEST_ARBITRUM_SEPOLIA_WALLET_KEY_2=wallet_key_2 for multiple keys per network
RPC HTTP URL per network E2E_TEST_(.+)_RPC_HTTP_URL or E2E_TEST_(.+)_RPC_HTTP_URL_(\d+)$ E2E_TEST_ARBITRUM_SEPOLIA_RPC_HTTP_URL=url or E2E_TEST_ARBITRUM_SEPOLIA_RPC_HTTP_URL_1=url, E2E_TEST_ARBITRUM_SEPOLIA_RPC_HTTP_URL_2=url for multiple http urls per network
RPC WebSocket URL per network E2E_TEST_(.+)_RPC_WS_URL or E2E_TEST_(.+)_RPC_WS_URL_(\d+)$ E2E_TEST_ARBITRUM_RPC_WS_URL=ws_url or E2E_TEST_ARBITRUM_RPC_WS_URL_1=ws_url_1, E2E_TEST_ARBITRUM_RPC_WS_URL_2=ws_url_2 for multiple ws urls per network
Loki Tenant ID E2E_TEST_LOKI_TENANT_ID E2E_TEST_LOKI_TENANT_ID=tenant_id
Loki Endpoint E2E_TEST_LOKI_ENDPOINT E2E_TEST_LOKI_ENDPOINT=url
Loki Basic Auth E2E_TEST_LOKI_BASIC_AUTH E2E_TEST_LOKI_BASIC_AUTH=token
Loki Bearer Token E2E_TEST_LOKI_BEARER_TOKEN E2E_TEST_LOKI_BEARER_TOKEN=token
Grafana Bearer Token E2E_TEST_GRAFANA_BEARER_TOKEN E2E_TEST_GRAFANA_BEARER_TOKEN=token
Pyroscope Server URL E2E_TEST_PYROSCOPE_SERVER_URL E2E_TEST_PYROSCOPE_SERVER_URL=url
Pyroscope Key E2E_TEST_PYROSCOPE_KEY E2E_TEST_PYROSCOPE_KEY=key
Run GitHub Workflow with Your Test Secrets

By default, GitHub workflows execute with a set of predefined secrets. However, you can use custom secrets by specifying a unique identifier for your secrets when running the gh workflow command.

Steps to Use Custom Secrets
  1. Upload Local Secrets to GitHub Secrets Vault:

    • Install ghsecrets tool: Install the ghsecrets tool to manage GitHub Secrets more efficiently.

      go install github.com/smartcontractkit/chainlink-testing-framework/tools/ghsecrets@latest
      

      If you use asdf, run asdf reshim

    • Upload Secrets: Run ghsecrets set from local core repo to upload the content of your ~/.testsecrets file to the GitHub Secrets Vault and generate a unique identifier (referred to as your_ghsecret_id).

    cd path-to-chainlink-core-repo
    
    ghsecrets set
    

    For more details about ghsecrets, visit https://github.com/smartcontractkit/chainlink-testing-framework/tree/main/tools/ghsecrets#faq

  2. Execute the Workflow with Custom Secrets:

    • To use the custom secrets in your GitHub Actions workflow, pass the -f test_secrets_override_key={your_ghsecret_id} flag when running the gh workflow command.
      gh workflow run <workflow_name> -f test_secrets_override_key={your_ghsecret_id}
      
Default Secrets Handling

If the test_secrets_override_key is not provided, the workflow will default to using the secrets preconfigured in the CI environment.

Creating New Test Secrets in TestConfig

When adding a new secret to the TestConfig, such as a token or other sensitive information, the method ReadConfigValuesFromEnvVars() in config/testconfig.go must be extended to include the new secret. Ensure that the new environment variable starts with the E2E_TEST_ prefix. This prefix is crucial for ensuring that the secret is correctly propagated to Kubernetes tests when using the Remote Runner.

Here’s a quick checklist for adding a new test secret:

  • Add the secret to ~/.testsecrets with the E2E_TEST_ prefix to ensure proper handling.
  • Extend the config/testconfig.go:ReadConfigValuesFromEnvVars() method to load the secret in TestConfig
  • Add the secrets to All E2E Test Secrets table.

Working example

For a full working example making use of all the building blocks see testconfig.go. It provides methods for reading TOML, applying overrides and validating non-empty config blocks. It supports 4 levels of overrides, in order of precedence:

  • BASE64_CONFIG_OVERRIDE env var
  • overrides.toml
  • [product_name].toml
  • default.toml

All you need to do now to get the config is execute func GetConfig(configurationName string, product string) (TestConfig, error). It will first look for folder with file .root_dir and from there it will look for config files in all subfolders, so that you can place the config files in whatever folder(s) work for you. It assumes that all configuration versions for a single product are kept in [product_name].toml under different configuration names (that can represent anything you want: a single test, a test type, a test group, etc).

Overrides of config files are done in a super-simple way. We try to unmarshall consecutive files into the same struct. Since it's all pointer based only not-nil keys are overwritten.

IMPORTANT!

It is required to add overrides.toml to .gitignore in your project, so that you don't accidentally commit it as it might contain secrets.

Network config (and default RPC endpoints)

Some more explanation is needed for the NetworkConfig:

type NetworkConfig struct {
	// list of networks that should be used for testing
	SelectedNetworks []string            `toml:"selected_networks"`
	// map of network name to EVMNetworks where key is network name and value is a pointer to EVMNetwork
	// if not set, it will try to find the network from defined networks in MappedNetworks under known_networks.go
	// it doesn't matter if you use `arbitrum_sepolia` or `ARBITRUM_SEPOLIA` or even `arbitrum_SEPOLIA` as key
	// as all keys will be uppercased when loading the Default config
	EVMNetworks map[string]*blockchain.EVMNetwork `toml:"EVMNetworks,omitempty"`
	// map of network name to ForkConfigs where key is network name and value is a pointer to ForkConfig
	// only used if network fork is needed, if provided, the network will be forked with the given config
	// networkname is fetched first from the EVMNetworks and
	// if not defined with EVMNetworks, it will try to find the network from defined networks in MappedNetworks under known_networks.go
    ForkConfigs map[string]*ForkConfig `toml:"ForkConfigs,omitempty"`
	// map of network name to RPC endpoints where key is network name and value is a list of RPC HTTP endpoints
	RpcHttpUrls      map[string][]string `toml:"RpcHttpUrls"`
	// map of network name to RPC endpoints where key is network name and value is a list of RPC WS endpoints
	RpcWsUrls        map[string][]string `toml:"RpcWsUrls"`
	// map of network name to wallet keys where key is network name and value is a list of private keys (aka funding keys)
	WalletKeys       map[string][]string `toml:"WalletKeys"`
}

func (n *NetworkConfig) Default() error {
    ...
}

Sample TOML config:

selected_networks = ["arbitrum_goerli", "optimism_goerli", "new_network"]

[EVMNetworks.new_network]
evm_name = "new_test_network"
evm_chain_id = 100009
evm_simulated = true
evm_chainlink_transaction_limit = 5000
evm_minimum_confirmations = 1
evm_gas_estimation_buffer = 10000
client_implementation = "Ethereum"
evm_supports_eip1559 = true
evm_default_gas_limit = 6000000

[ForkConfigs.new_network]
url = "ws://localhost:8546"
block_number = 100

[RpcHttpUrls]
arbitrum_goerli = ["https://devnet-2.mt/ABC/rpc/"]
new_network = ["http://localhost:8545"]

[RpcWsUrls]
arbitrum_goerli = ["wss://devnet-2.mt/ABC/ws/"]
new_network = ["ws://localhost:8546"]

[WalletKeys]
arbitrum_goerli = ["1810868fc221b9f50b5b3e0186d8a5f343f892e51ce12a9e818f936ec0b651ed"]
optimism_goerli = ["1810868fc221b9f50b5b3e0186d8a5f343f892e51ce12a9e818f936ec0b651ed"]
new_network = ["ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"]

Whenever you are adding a new EVMNetwork to the config, you can either

  • provide the rpcs and wallet keys in Rpc<Http/Ws>Urls and WalletKeys. Like in the example above, you can see that new_network is added to the selected_networks and EVMNetworks and then the rpcs and wallet keys are provided in RpcHttpUrls, RpcWsUrls and WalletKeys respectively.
  • provide the rpcs and wallet keys in the EVMNetworks itself. Like in the example below, you can see that new_network is added to the selected_networks and EVMNetworks and then the rpcs and wallet keys are provided in EVMNetworks itself.

selected_networks = ["new_network"]

[EVMNetworks.new_network]
evm_name = "new_test_network"
evm_chain_id = 100009
evm_urls = ["ws://localhost:8546"]
evm_http_urls = ["http://localhost:8545"]
evm_keys = ["ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"]
evm_simulated = true
evm_chainlink_transaction_limit = 5000
evm_minimum_confirmations = 1
evm_gas_estimation_buffer = 10000
client_implementation = "Ethereum"
evm_supports_eip1559 = true
evm_default_gas_limit = 6000000

If your config struct looks like that:


type TestConfig struct {
	Network *ctf_config.NetworkConfig `toml:"Network"`
}

then your TOML file should look like that:

[Network]
selected_networks = ["arbitrum_goerli","new_network"]

[Network.EVMNetworks.new_network]
evm_name = "new_test_network"
evm_chain_id = 100009
evm_simulated = true
evm_chainlink_transaction_limit = 5000
evm_minimum_confirmations = 1
evm_gas_estimation_buffer = 10000
client_implementation = "Ethereum"
evm_supports_eip1559 = true
evm_default_gas_limit = 6000000

[Network.RpcHttpUrls]
arbitrum_goerli = ["https://devnet-2.mt/ABC/rpc/"]
new_network = ["http://localhost:8545"]

[Network.RpcWsUrls]
arbitrum_goerli = ["ws://devnet-2.mt/ABC/rpc/"]
new_network = ["ws://localhost:8546"]

[Network.WalletKeys]
arbitrum_goerli = ["1810868fc221b9f50b5b3e0186d8a5f343f892e51ce12a9e818f936ec0b651ed"]
new_network = ["ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"]

If in your product config you want to support case-insensitive network names and map keys remember to run NetworkConfig.UpperCaseNetworkNames() on your config before using it.

Providing custom values in the CI

Up to this point when we wanted to modify some dynamic tests parameters in the CI we would simply set env vars. That approach won't work anymore. The way to go around it is to build a TOML file, base64 it, mask it and then set is as BASE64_CONFIG_OVERRIDE env var that will be read by tests. Here's an example of a working snippet of how that could look:

convert_to_toml_array() {
	local IFS=','
	local input_array=($1)
	local toml_array_format="["

	for element in "${input_array[@]}"; do
		toml_array_format+="\"$element\","
	done

	toml_array_format="${toml_array_format%,}]"
	echo "$toml_array_format"
}

selected_networks=$(convert_to_toml_array "$SELECTED_NETWORKS")
log_targets=$(convert_to_toml_array "$LOGSTREAM_LOG_TARGETS")

if [ -n "$PYROSCOPE_SERVER" ]; then
	pyroscope_enabled=true
else
	pyroscope_enabled=false
fi

if [ -n "$ETH2_EL_CLIENT" ]; then
	execution_layer="$ETH2_EL_CLIENT"
else
	execution_layer="geth"
fi

if [ -n "$TEST_LOG_COLLECT" ]; then
	test_log_collect=true
else
	test_log_collect=false
fi

cat << EOF > config.toml
[Network]
selected_networks=$selected_networks

[ChainlinkImage]
image="$CHAINLINK_IMAGE"
version="$CHAINLINK_VERSION"

[Pyroscope]
enabled=$pyroscope_enabled
server_url="$PYROSCOPE_SERVER"
environment="$PYROSCOPE_ENVIRONMENT"
key_secret="$PYROSCOPE_KEY"

[Logging]
test_log_collect=$test_log_collect
run_id="$RUN_ID"

[Logging.LogStream]
log_targets=$log_targets

[Logging.Loki]
tenant_id="$LOKI_TENANT_ID"
url="$LOKI_URL"
basic_auth_secret="$LOKI_BASIC_AUTH"
bearer_token_secret="$LOKI_BEARER_TOKEN"

[Logging.Grafana]
url="$GRAFANA_URL"
EOF

BASE64_CONFIG_OVERRIDE=$(cat config.toml | base64 -w 0)
echo ::add-mask::$BASE64_CONFIG_OVERRIDE
echo "BASE64_CONFIG_OVERRIDE=$BASE64_CONFIG_OVERRIDE" >> $GITHUB_ENV

These two lines in that very order are super important

BASE64_CONFIG_OVERRIDE=$(cat config.toml | base64 -w 0)
echo ::add-mask::$BASE64_CONFIG_OVERRIDE

::add-mask:: has to be called only after env var has been set to it's final value, otherwise it won't be recognized and masked properly and secrets will be exposed in the logs.

Providing custom values for local execution

For local execution it's best to put custom variables in overrides.toml file.

Providing custom values in k8s

It's easy. All you need to do is:

  • Create TOML file with these values
  • Base64 it: cat your.toml | base64
  • Set the base64 result as BASE64_CONFIG_OVERRIDE environment variable.

BASE64_CONFIG_OVERRIDE will be automatically forwarded to k8s (as long as it is set and available to the test process), when creating the environment programmatically via environment.New().

Quick example:

BASE64_CONFIG_OVERRIDE=$(cat your.toml | base64) go test your-test-that-runs-in-k8s ./file/with/your/test

Not moved to TOML

Not moved to TOML:

  • SLACK_API_KEY
  • SLACK_USER
  • SLACK_CHANNEL
  • TEST_LOG_LEVEL
  • CHAINLINK_ENV_USER
  • DETACH_RUNNER
  • ENV_JOB_IMAGE
  • most of k8s-specific env variables were left untouched

Documentation

Index

Constants

View Source
const (
	E2E_TEST_LOG_COLLECT_ENV                = "E2E_TEST_LOG_COLLECT"
	E2E_TEST_LOGGING_RUN_ID_ENV             = "E2E_TEST_LOGGING_RUN_ID"
	E2E_TEST_LOG_STREAM_LOG_TARGETS_ENV     = "E2E_TEST_LOG_STREAM_LOG_TARGETS"
	E2E_TEST_LOKI_TENANT_ID_ENV             = "E2E_TEST_LOKI_TENANT_ID"
	E2E_TEST_LOKI_ENDPOINT_ENV              = "E2E_TEST_LOKI_ENDPOINT"
	E2E_TEST_LOKI_BASIC_AUTH_ENV            = "E2E_TEST_LOKI_BASIC_AUTH"
	E2E_TEST_LOKI_BEARER_TOKEN_ENV          = "E2E_TEST_LOKI_BEARER_TOKEN" // #nosec G101
	E2E_TEST_GRAFANA_BASE_URL_ENV           = "E2E_TEST_GRAFANA_BASE_URL"
	E2E_TEST_GRAFANA_DASHBOARD_URL_ENV      = "E2E_TEST_GRAFANA_DASHBOARD_URL"
	E2E_TEST_GRAFANA_BEARER_TOKEN_ENV       = "E2E_TEST_GRAFANA_BEARER_TOKEN" // #nosec G101
	E2E_TEST_PYROSCOPE_ENABLED_ENV          = "E2E_TEST_PYROSCOPE_ENABLED"
	E2E_TEST_PYROSCOPE_SERVER_URL_ENV       = "E2E_TEST_PYROSCOPE_SERVER_URL"
	E2E_TEST_PYROSCOPE_KEY_ENV              = "E2E_TEST_PYROSCOPE_KEY"
	E2E_TEST_PYROSCOPE_ENVIRONMENT_ENV      = "E2E_TEST_PYROSCOPE_ENVIRONMENT"
	E2E_TEST_CHAINLINK_IMAGE_ENV            = "E2E_TEST_CHAINLINK_IMAGE"
	E2E_TEST_CHAINLINK_VERSION_ENV          = "E2E_TEST_CHAINLINK_VERSION"
	E2E_TEST_CHAINLINK_POSTGRES_VERSION_ENV = "E2E_TEST_CHAINLINK_POSTGRES_VERSION"
	E2E_TEST_CHAINLINK_UPGRADE_IMAGE_ENV    = "E2E_TEST_CHAINLINK_UPGRADE_IMAGE"
	E2E_TEST_CHAINLINK_UPGRADE_VERSION_ENV  = "E2E_TEST_CHAINLINK_UPGRADE_VERSION"
	E2E_TEST_SELECTED_NETWORK_ENV           = `E2E_TEST_SELECTED_NETWORK`
	E2E_TEST_WALLET_KEY_ENV                 = `E2E_TEST_(.+)_WALLET_KEY$`
	E2E_TEST_WALLET_KEYS_ENV                = `E2E_TEST_(.+)_WALLET_KEY_(\d+)$`
	E2E_TEST_RPC_HTTP_URL_ENV               = `E2E_TEST_(.+)_RPC_HTTP_URL$`
	E2E_TEST_RPC_HTTP_URLS_ENV              = `E2E_TEST_(.+)_RPC_HTTP_URL_(\d+)$`
	E2E_TEST_RPC_WS_URL_ENV                 = `E2E_TEST_(.+)_RPC_WS_URL$`
	E2E_TEST_RPC_WS_URLS_ENV                = `E2E_TEST_(.+)_RPC_WS_URL_(\d+)$`
)

Variables

View Source
var (
	ErrMissingEthereumVersion = errors.New("ethereum version is required")
	ErrMissingExecutionLayer  = errors.New("execution layer is required")
	Eth1NotSupportedByRethMsg = "eth1 is not supported by Reth, please use eth2"
	DefaultNodeLogLevel       = "info"
)

Functions

func BytesToAnyTomlStruct added in v1.23.0

func BytesToAnyTomlStruct(logger zerolog.Logger, filename, configurationName string, target any, content []byte) error

BytesToAnyTomlStruct unmarshals the given bytes into the given target struct, apart from unmarshalling the root it also looks for given configuration name and unmarshals it into the target struct overwriting the root. Target needs to be a struct with exported fields with `toml:"field_name"` tags.

func LoadSecretEnvsFromFiles added in v1.32.1

func LoadSecretEnvsFromFiles() error

func MightConfigOverridePyroscopeKey added in v1.23.0

func MightConfigOverridePyroscopeKey(config *PyroscopeConfig, target interface{})

MightConfigOverridePyroscope will override the pyroscope config in property maps from the passed config. If the config is nil, or the enabled flag is not set, or the key is not set, then this function will do nothing.

func MustConfigOverrideChainlinkVersion added in v1.23.0

func MustConfigOverrideChainlinkVersion(config *ChainlinkImageConfig, target interface{})

MustConfigOverrideChainlinkVersion will override the chainlink image and version in property maps from the passed config. It will panic if the config is nil.

func MustReadEnvVar_Boolean added in v1.32.3

func MustReadEnvVar_Boolean(name string) *bool

func MustReadEnvVar_String added in v1.32.3

func MustReadEnvVar_String(name string) string

func MustReadEnvVar_Strings added in v1.34.4

func MustReadEnvVar_Strings(name, sep string) []string

func ReadEnvVarGroupedMap added in v1.32.3

func ReadEnvVarGroupedMap(singleEnvPattern, groupEnvPattern string) map[string][]string

ReadEnvVarGroupedMap combines environment variables into a map where keys map to slices of strings. It accepts `singleEnvPattern` for single variables and `groupEnvPattern` for grouped variables. Returns a map combining values from both patterns, with single values wrapped in slices.

func ReadEnvVarSlice_String added in v1.34.1

func ReadEnvVarSlice_String(pattern string) []string

ReadEnvVarSlice_String reads all environment variables matching the specified pattern and returns a slice of strings.

Types

type AnvilConfig added in v1.28.5

type AnvilConfig struct {
	URL                *string                  `toml:"url,omitempty"`                   // Needed if you want to fork a network. URL is the URL of the node to fork from. Refer to https://book.getfoundry.sh/reference/anvil/#options
	BlockNumber        *int64                   `toml:"block_number,omitempty"`          // Needed if fork URL is provided for forking. BlockNumber is the block number to fork from. Refer to https://book.getfoundry.sh/reference/anvil/#options
	BlockTime          *int64                   `toml:"block_time,omitempty"`            // how frequent blocks are mined. By default, it automatically generates a new block as soon as a transaction is submitted. Refer to https://book.getfoundry.sh/reference/anvil/#options
	BlockGaslimit      *int64                   `toml:"block_gaslimit,omitempty"`        //  BlockGaslimit is the gas limit for each block. Refer to https://book.getfoundry.sh/reference/anvil/#options
	CodeSize           *int64                   `toml:"code_size,omitempty"`             //  CodeSize is the size of the code in bytes. Refer to https://book.getfoundry.sh/reference/anvil/#options
	BaseFee            *int64                   `toml:"base_fee,omitempty"`              //  BaseFee is the base fee for block. Refer to https://book.getfoundry.sh/reference/anvil/#options
	Retries            *int                     `toml:"retries,omitempty"`               //  Needed if fork URL is provided for forking. Number of retry requests for spurious networks (timed out requests). Refer to https://book.getfoundry.sh/reference/anvil/#options
	Timeout            *int64                   `toml:"timeout,omitempty"`               //  Needed if fork URL is provided for forking. Timeout in ms for requests sent to remote JSON-RPC server in forking mode. Refer to https://book.getfoundry.sh/reference/anvil/#options
	ComputePerSecond   *int64                   `toml:"compute_per_second,omitempty"`    // Needed if fork URL is provided for forking. Sets the number of assumed available compute units per second for this provider. Refer to https://book.getfoundry.sh/reference/anvil/#options
	RateLimitDisabled  *bool                    `toml:"rate_limit_disabled,omitempty"`   // Needed if fork URL is provided for forking. Rate limiting for this node’s provider. If set to true the node will start with --no-rate-limit Refer to https://book.getfoundry.sh/reference/anvil/#options
	NoOfAccounts       *int                     `toml:"no_of_accounts,omitempty"`        // Number of accounts to generate. Refer to https://book.getfoundry.sh/reference/anvil/#options
	EnableTracing      *bool                    `toml:"enable_tracing,omitempty"`        // Enable tracing for the node. Refer to https://book.getfoundry.sh/reference/anvil/#options
	BlocksToKeepInMem  *int64                   `toml:"blocks_to_keep_in_mem,omitempty"` // Refer to --transaction-block-keeper option in https://book.getfoundry.sh/reference/anvil/#options
	GasSpikeSimulation GasSpikeSimulationConfig `toml:"GasSpikeSimulation,omitempty"`
	GasLimitSimulation GasLimitSimulationConfig `toml:"GasLimitSimulation,omitempty"`
}

type ChainlinkImageConfig added in v1.23.0

type ChainlinkImageConfig struct {
	Image           *string `toml:"-"`
	Version         *string `toml:"version"`
	PostgresVersion *string `toml:"postgres_version,omitempty"`
}

func (*ChainlinkImageConfig) Validate added in v1.23.0

func (c *ChainlinkImageConfig) Validate() error

Validate checks that the chainlink image config is valid, which means that both image and version are set and non-empty

type ConsensusLayer added in v1.28.8

type ConsensusLayer string
var ConsensusLayer_Prysm ConsensusLayer = "prysm"

type ConsensusType deprecated added in v1.28.8

type ConsensusType string

Deprecated: use EthereumVersion instead

const (
	// Deprecated: use EthereumVersion_Eth2 instead
	ConsensusType_PoS ConsensusType = "pos"
	// Deprecated: use EthereumVersion_Eth1 instead
	ConsensusType_PoW ConsensusType = "pow"
)

type ContainerType added in v1.28.8

type ContainerType string
const (
	ContainerType_ExecutionLayer     ContainerType = "execution_layer"
	ContainerType_ConsensusLayer     ContainerType = "consensus_layer"
	ContainerType_ConsensusValidator ContainerType = "consensus_validator"
	ContainerType_GenesisGenerator   ContainerType = "genesis_generator"
	ContainerType_ValKeysGenerator   ContainerType = "val_keys_generator"
)

type EnvValueType added in v1.31.9

type EnvValueType int
const (
	String EnvValueType = iota
	Integer
	Boolean
	Float
)

type EthereumChainConfig added in v1.28.8

type EthereumChainConfig struct {
	SecondsPerSlot   int            `json:"seconds_per_slot" toml:"seconds_per_slot"`
	SlotsPerEpoch    int            `json:"slots_per_epoch" toml:"slots_per_epoch"`
	GenesisDelay     int            `json:"genesis_delay" toml:"genesis_delay"`
	ValidatorCount   int            `json:"validator_count" toml:"validator_count"`
	ChainID          int            `json:"chain_id" toml:"chain_id"`
	GenesisTimestamp int            // this is not serialized
	AddressesToFund  []string       `json:"addresses_to_fund" toml:"addresses_to_fund"`
	HardForkEpochs   map[string]int `json:"HardForkEpochs" toml:"HardForkEpochs"`
}

func MustGetDefaultChainConfig added in v1.34.0

func MustGetDefaultChainConfig() EthereumChainConfig

MustGetDefaultChainConfig returns the default EthereumChainConfig or panics if it can't be loaded

func (*EthereumChainConfig) ApplyOverrides added in v1.28.8

func (c *EthereumChainConfig) ApplyOverrides(from *EthereumChainConfig) error

ApplyOverrides applies overrides from another EthereumChainConfig

func (*EthereumChainConfig) Default added in v1.28.8

func (c *EthereumChainConfig) Default() error

Default sets the EthereumChainConfig to the default values

func (*EthereumChainConfig) DefaultFinalizationWaitDuration added in v1.34.0

func (c *EthereumChainConfig) DefaultFinalizationWaitDuration() time.Duration

DefaultFinalizationWaitDuration returns the default wait duration for finalization

func (*EthereumChainConfig) DefaultWaitDuration added in v1.34.0

func (c *EthereumChainConfig) DefaultWaitDuration() time.Duration

DefaultWaitDuration returns the default wait duration for the network based on the genesis delay and the number of validators

func (*EthereumChainConfig) FillInMissingValuesWithDefault added in v1.28.8

func (c *EthereumChainConfig) FillInMissingValuesWithDefault()

FillInMissingValuesWithDefault fills in missing/zero values with default values

func (*EthereumChainConfig) GenerateGenesisTimestamp added in v1.28.8

func (c *EthereumChainConfig) GenerateGenesisTimestamp()

func (*EthereumChainConfig) Validate added in v1.28.8

func (c *EthereumChainConfig) Validate(l zerolog.Logger, ethereumVersion *config_types.EthereumVersion, executionLayer *config_types.ExecutionLayer, customDockerImages map[ContainerType]string) error

Validate validates the EthereumChainConfig

func (*EthereumChainConfig) ValidateHardForks added in v1.28.8

func (c *EthereumChainConfig) ValidateHardForks(l zerolog.Logger, ethereumVersion *config_types.EthereumVersion, executionLayer *config_types.ExecutionLayer, customDockerImages map[ContainerType]string) error

ValidateHardForks validates hard forks based either on custom or default docker images for eth2 execution layer

func (*EthereumChainConfig) ValidatorBasedGenesisDelay added in v1.34.0

func (c *EthereumChainConfig) ValidatorBasedGenesisDelay() int

ValidatorBasedGenesisDelay returns the delay in seconds based on the number of validators

type EthereumNetworkConfig added in v1.28.8

type EthereumNetworkConfig struct {
	ConsensusType        *config_types.EthereumVersion `toml:"consensus_type"`
	EthereumVersion      *config_types.EthereumVersion `toml:"ethereum_version"`
	ConsensusLayer       *ConsensusLayer               `toml:"consensus_layer"`
	ExecutionLayer       *config_types.ExecutionLayer  `toml:"execution_layer"`
	DockerNetworkNames   []string                      `toml:"docker_network_names"`
	Containers           EthereumNetworkContainers     `toml:"containers"`
	WaitForFinalization  *bool                         `toml:"wait_for_finalization"`
	GeneratedDataHostDir *string                       `toml:"generated_data_host_dir"`
	ValKeysDir           *string                       `toml:"val_keys_dir"`
	EthereumChainConfig  *EthereumChainConfig          `toml:"EthereumChainConfig"`
	CustomDockerImages   map[ContainerType]string      `toml:"CustomDockerImages"`
	NodeLogLevel         *string                       `toml:"node_log_level,omitempty"`
}

func (*EthereumNetworkConfig) ApplyOverrides added in v1.28.8

func (en *EthereumNetworkConfig) ApplyOverrides(from *EthereumNetworkConfig) error

func (*EthereumNetworkConfig) Describe added in v1.28.8

func (en *EthereumNetworkConfig) Describe() string

func (*EthereumNetworkConfig) Validate added in v1.28.8

func (en *EthereumNetworkConfig) Validate() error

type EthereumNetworkContainer added in v1.28.8

type EthereumNetworkContainer struct {
	ContainerName string        `toml:"container_name"`
	ContainerType ContainerType `toml:"container_type"`
	Container     *tc.Container `toml:"-"`
}

type EthereumNetworkContainers added in v1.28.8

type EthereumNetworkContainers []EthereumNetworkContainer

type GasLimitSimulationConfig added in v1.30.9

type GasLimitSimulationConfig struct {
	Enabled                bool                   `toml:"enabled,omitempty"`
	NextGasLimitPercentage float64                `toml:"next_gas_limit_percentage,omitempty"` // Percentage of last gasUsed in previous block creating congestion
	DelayCreate            blockchain.StrDuration `toml:"delay_create,omitempty"`              // Delay before creating, expressed in Go duration format (e.g., "1m", "30s")
	Duration               blockchain.StrDuration `toml:"duration,omitempty"`                  // Duration of the gas simulation, expressed in Go duration format (e.g., "1m", "30s")
}

GasLimitSimulationConfig is the configuration for simulating gas limit changes on the network

type GasSpikeSimulationConfig added in v1.30.9

type GasSpikeSimulationConfig struct {
	Enabled           bool                   `toml:"enabled,omitempty"`
	StartGasPrice     int64                  `toml:"start_gas_price,omitempty"`
	GasRisePercentage float64                `toml:"gas_rise_percentage,omitempty"`
	GasSpike          bool                   `toml:"gas_spike,omitempty"`
	DelayCreate       blockchain.StrDuration `toml:"delay_create,omitempty"` // Delay before creating, expressed in Go duration format (e.g., "1m", "30s")
	Duration          blockchain.StrDuration `toml:"duration,omitempty"`     // Duration of the gas simulation, expressed in Go duration format (e.g., "1m", "30s")
}

GasSpikeSimulation is the configuration for simulating gas spikes on the network

type GlobalTestConfig added in v1.28.8

type GlobalTestConfig interface {
	GetChainlinkImageConfig() *ChainlinkImageConfig
	GetLoggingConfig() *LoggingConfig
	GetNetworkConfig() *NetworkConfig
	GetPrivateEthereumNetworkConfig() *EthereumNetworkConfig
	GetPyroscopeConfig() *PyroscopeConfig
	GetNodeConfig() *NodeConfig
	SethConfig
}

type GrafanaConfig added in v1.23.0

type GrafanaConfig struct {
	BaseUrl      *string `toml:"base_url"`
	DashboardUrl *string `toml:"dashboard_url"`
	DashboardUID *string `toml:"dashboard_uid"` // UID of the dashboard to put annotations on
	BearerToken  *string `toml:"-"`
}

func (*GrafanaConfig) Validate added in v1.23.0

func (c *GrafanaConfig) Validate() error

Validate checks that the grafana config is valid, which means that base url is a valid URL and dashboard url and bearer token are not empty but that only applies if they are set

type LogStreamConfig added in v1.23.0

type LogStreamConfig struct {
	LogTargets            []string                `toml:"log_targets"`
	LogProducerTimeout    *blockchain.StrDuration `toml:"log_producer_timeout"`
	LogProducerRetryLimit *uint                   `toml:"log_producer_retry_limit"`
}

func (*LogStreamConfig) Validate added in v1.23.0

func (l *LogStreamConfig) Validate() error

Validate checks that the log stream config is valid, which means that log targets are valid and log producer timeout is greater than 0

type LoggingConfig

type LoggingConfig struct {
	TestLogCollect         *bool            `toml:"test_log_collect,omitempty"`
	ShowHTMLCoverageReport *bool            `toml:"show_html_coverage_report,omitempty"` // Show reports with go coverage data
	RunId                  *string          `toml:"run_id,omitempty"`
	Loki                   *LokiConfig      `toml:"-"`
	Grafana                *GrafanaConfig   `toml:"Grafana,omitempty"`
	LogStream              *LogStreamConfig `toml:"LogStream,omitempty"`
}

func (*LoggingConfig) Validate added in v1.23.0

func (l *LoggingConfig) Validate() error

Validate executes config validation for LogStream, Grafana and Loki

type LokiConfig added in v1.23.0

type LokiConfig struct {
	TenantId    *string `toml:"-"`
	Endpoint    *string `toml:"-"`
	BasicAuth   *string `toml:"-"`
	BearerToken *string `toml:"-"`
}

func (*LokiConfig) Validate added in v1.23.0

func (l *LokiConfig) Validate() error

Validate checks that the loki config is valid, which means that endpoint is a valid URL and tenant id is not empty

type NamedConfigurations added in v1.31.7

type NamedConfigurations interface {
	GetConfigurationNames() []string
}

type NetworkConfig added in v1.23.0

type NetworkConfig struct {
	SelectedNetworks []string `toml:"selected_networks,omitempty"`
	// EVMNetworks is the configuration for the EVM networks, key is the network name as declared in selected_networks slice.
	// if not set, it will try to find the network from defined networks in MappedNetworks under known_networks.go
	EVMNetworks map[string]*blockchain.EVMNetwork `toml:"EVMNetworks,omitempty"`
	// AnvilConfigs is the configuration for forking from a node,
	// key is the network name as declared in selected_networks slice
	AnvilConfigs map[string]*AnvilConfig `toml:"AnvilConfigs,omitempty"`
	// GethReorgConfig is the configuration for handling reorgs on Simulated Geth
	GethReorgConfig ReorgConfig `toml:"GethReorgConfig,omitempty"`
	// RpcHttpUrls is the RPC HTTP endpoints for each network,
	// key is the network name as declared in selected_networks slice
	RpcHttpUrls map[string][]string `toml:"RpcHttpUrls,omitempty"`
	// RpcWsUrls is the RPC WS endpoints for each network,
	// key is the network name as declared in selected_networks slice
	RpcWsUrls map[string][]string `toml:"RpcWsUrls,omitempty"`
	// WalletKeys is the private keys for the funding wallets for each network,
	// key is the network name as declared in selected_networks slice
	WalletKeys map[string][]string `toml:"WalletKeys,omitempty"`
}

NetworkConfig is the configuration for the networks to be used

func (NetworkConfig) IsSimulatedGethSelected added in v1.30.3

func (n NetworkConfig) IsSimulatedGethSelected() bool

func (*NetworkConfig) OverrideURLsAndKeysFromEVMNetwork added in v1.24.0

func (n *NetworkConfig) OverrideURLsAndKeysFromEVMNetwork()

OverrideURLsAndKeysFromEVMNetwork applies the URLs and keys from the EVMNetworks to the NetworkConfig it overrides the URLs and Keys present in RpcHttpUrls, RpcWsUrls and WalletKeys in the NetworkConfig with the URLs and Keys provided in the EVMNetworks

func (*NetworkConfig) UpperCaseNetworkNames added in v1.23.0

func (n *NetworkConfig) UpperCaseNetworkNames()

UpperCaseNetworkNames converts all network name keys for wallet keys, rpc endpoints maps and selected network slice to upper case

func (*NetworkConfig) Validate added in v1.23.0

func (n *NetworkConfig) Validate() error

Validate checks if all required fields are set, meaning that there must be at least 1 selected network and unless it's a simulated network, there must be at least 1 rpc endpoint for HTTP and WS and 1 private key for funding wallet

type NodeConfig added in v1.28.12

type NodeConfig struct {
	BaseConfigTOML           string            `toml:",omitempty"`
	CommonChainConfigTOML    string            `toml:",omitempty"`
	ChainConfigTOMLByChainID map[string]string `toml:",omitempty"` // key is chainID
}

type PyroscopeConfig added in v1.23.0

type PyroscopeConfig struct {
	Enabled     *bool   `toml:"enabled"`
	ServerUrl   *string `toml:"-"`
	Key         *string `toml:"-"`
	Environment *string `toml:"-"`
}

func (*PyroscopeConfig) Validate added in v1.23.0

func (c *PyroscopeConfig) Validate() error

Validate checks that the pyroscope config is valid, which means that server url, environment and key are set and non-empty, but only if pyroscope is enabled

type ReorgConfig added in v1.30.3

type ReorgConfig struct {
	Enabled     bool                   `toml:"enabled,omitempty"`
	Depth       int                    `toml:"depth,omitempty"`
	DelayCreate blockchain.StrDuration `toml:"delay_create,omitempty"` // Delay before creating, expressed in Go duration format (e.g., "1m", "30s")
}

type SethConfig added in v1.28.7

type SethConfig interface {
	GetSethConfig() *seth.Config
}

type TestConfig added in v1.28.8

type TestConfig struct {
	ChainlinkImage         *ChainlinkImageConfig  `toml:"ChainlinkImage"`
	ChainlinkUpgradeImage  *ChainlinkImageConfig  `toml:"ChainlinkUpgradeImage"`
	Logging                *LoggingConfig         `toml:"Logging"`
	Network                *NetworkConfig         `toml:"Network"`
	Pyroscope              *PyroscopeConfig       `toml:"Pyroscope"`
	PrivateEthereumNetwork *EthereumNetworkConfig `toml:"PrivateEthereumNetwork"`
	WaspConfig             *WaspAutoBuildConfig   `toml:"WaspAutoBuild"`
	Seth                   *seth.Config           `toml:"Seth"`
	NodeConfig             *NodeConfig            `toml:"NodeConfig"`
}

func (TestConfig) GetChainlinkImageConfig added in v1.28.8

func (c TestConfig) GetChainlinkImageConfig() *ChainlinkImageConfig

func (*TestConfig) GetLoggingConfig added in v1.28.8

func (c *TestConfig) GetLoggingConfig() *LoggingConfig

func (TestConfig) GetNetworkConfig added in v1.28.8

func (c TestConfig) GetNetworkConfig() *NetworkConfig

func (*TestConfig) GetNodeConfig added in v1.28.12

func (c *TestConfig) GetNodeConfig() *NodeConfig

func (TestConfig) GetPrivateEthereumNetworkConfig added in v1.28.8

func (c TestConfig) GetPrivateEthereumNetworkConfig() *EthereumNetworkConfig

func (TestConfig) GetPyroscopeConfig added in v1.28.8

func (c TestConfig) GetPyroscopeConfig() *PyroscopeConfig

func (*TestConfig) ReadFromEnvVar added in v1.32.3

func (c *TestConfig) ReadFromEnvVar() error

Read config values from environment variables

type WaspAutoBuildConfig added in v1.23.6

type WaspAutoBuildConfig struct {
	Namespace           *string `toml:"namespace"`
	RepoImageVersionURI *string `toml:"repo_image_version_uri"`
	TestBinaryName      *string `toml:"test_binary_name"`
	TestName            *string `toml:"test_name"`
	TestTimeout         *string `toml:"test_timeout"`
	KeepJobs            bool    `toml:"keep_jobs"`
	WaspLogLevel        *string `toml:"wasp_log_level"`
	WaspJobs            *string `toml:"wasp_jobs"`
	UpdateImage         bool    `toml:"update_image"`
}

func (*WaspAutoBuildConfig) Validate added in v1.23.6

func (c *WaspAutoBuildConfig) Validate() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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