seth

package
v1.50.13-alpha Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2024 License: MIT Imports: 9 Imported by: 3

Documentation

Index

Constants

View Source
const RootKeyNum = 0

Variables

View Source
var ErrInsufficientEphemeralKeys = `` /* 449-byte string literal not displayed */
View Source
var ErrInsufficientStaticKeys = `` /* 752-byte string literal not displayed */
View Source
var OneEphemeralKeysLiveTestnetAutoFixFn = func(sethCfg *pkg_seth.Config) error {
	concurrency := sethCfg.GetMaxConcurrency()

	if sethCfg.IsSimulatedNetwork() {
		if concurrency < 1 {
			return fmt.Errorf(ErrInsufficientEphemeralKeys, 0)
		}

		return nil
	}

	if sethCfg.EphemeralAddrs != nil && int(*sethCfg.EphemeralAddrs) > 0 {
		var zero int64 = 0
		sethCfg.EphemeralAddrs = &zero
	}

	if concurrency < 1 {
		return fmt.Errorf(ErrInsufficientStaticKeys, len(sethCfg.Network.PrivateKeys))
	}

	return nil
}

OneEphemeralKeysLiveTestnetAutoFixFn checks whether there's at least one ephemeral key on a simulated network or at least one static key on a live network, and that there are no ephemeral keys on a live network (if ephemeral keys count is different from zero, it will disable them). Root key is excluded from the check.

View Source
var OneEphemeralKeysLiveTestnetCheckFn = func(sethCfg *pkg_seth.Config) error {
	concurrency := sethCfg.GetMaxConcurrency()

	if sethCfg.IsSimulatedNetwork() {
		if concurrency < 1 {
			return fmt.Errorf(ErrInsufficientEphemeralKeys, 0)
		}

		return nil
	}

	if sethCfg.EphemeralAddrs != nil && int(*sethCfg.EphemeralAddrs) > 0 {
		ephMsg := `
			Error: Ephemeral Addresses Detected on Live Network

			Ephemeral addresses are currently set for use on a live network, which is not permitted. The number of ephemeral addresses set is %d. Please make the following update to your TOML configuration file to correct this:
			'[Seth] ephemeral_addresses_number = 0'

			Additionally, ensure the following requirements are met to run this test on a live network:
			1. Use more than one private key in your network configuration.
			`

		return errors.New(ephMsg)
	}

	if concurrency < 1 {
		return fmt.Errorf(ErrInsufficientStaticKeys, len(sethCfg.Network.PrivateKeys))
	}

	return nil
}

OneEphemeralKeysLiveTestnetCheckFn checks whether there's at least one ephemeral key on a simulated network or at least one static key on a live network, and that there are no ephemeral keys on a live network. Root key is excluded from the check.

Functions

func AvailableSethKeyNum

func AvailableSethKeyNum(client *pkg_seth.Client) int

AvailableSethKeyNum returns the available Seth address index If there are multiple addresses, it will return any synced key Otherwise it will return the root key

func GetChainClient

func GetChainClient(c config.SethConfig, network blockchain.EVMNetwork) (*pkg_seth.Client, error)

GetChainClient returns a seth client for the given network after validating the config

func GetChainClientWithConfigFunction

func GetChainClientWithConfigFunction(c config.SethConfig, network blockchain.EVMNetwork, configFn ConfigFunction) (*pkg_seth.Client, error)

GetChainClientWithConfigFunction returns a seth client for the given network after validating the config and applying the config function

func MergeSethAndEvmNetworkConfigs

func MergeSethAndEvmNetworkConfigs(evmNetwork blockchain.EVMNetwork, sethConfig pkg_seth.Config) (pkg_seth.Config, error)

MergeSethAndEvmNetworkConfigs merges EVMNetwork to Seth config. If Seth config already has Network settings, it will return unchanged Seth config that was passed to it. If the network is simulated, it will use Geth-specific settings. Otherwise, it will use the chain ID to find the correct network settings. If no match is found it will return error.

func MustReplaceSimulatedNetworkUrlWithK8

func MustReplaceSimulatedNetworkUrlWithK8(l zerolog.Logger, network blockchain.EVMNetwork, testEnvironment environment.Environment) blockchain.EVMNetwork

MustReplaceSimulatedNetworkUrlWithK8 replaces the simulated network URL with the K8 URL and returns the network. If the network is not simulated, it will return the network unchanged.

func ValidateSethNetworkConfig

func ValidateSethNetworkConfig(cfg *pkg_seth.Network) error

ValidateSethNetworkConfig validates the Seth network config

Types

type ConfigFunction

type ConfigFunction = func(*pkg_seth.Config) error

Jump to

Keyboard shortcuts

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