config

package
v0.2.206 Latest Latest
Warning

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

Go to latest
Published: May 10, 2024 License: MIT Imports: 10 Imported by: 1

Documentation

Index

Constants

View Source
const MAX_SLICE_LEN = 10

Variables

This section is empty.

Functions

func BindEnv

func BindEnv(path []string, val reflect.Value)

func IsIndex

func IsIndex(s string) bool

Types

type AppSync

type AppSync struct {
	// Security token for AppSync
	Token string

	// URL of the AppSync endpoint
	Url string

	// Num of workers that send GQL requests
	MaxWorkers int

	// Max num of requests in worker's queue
	MaxQueueSize int

	// Max time a request should be retried. 0 means no limit.
	BackoffMaxElapsedTime time.Duration

	// Max time between failed retries to save data.
	BackoffMaxInterval time.Duration
}

type Arweave

type Arweave struct {
	// URL to arweave.net
	NodeUrl string

	// Time limit for requests. The timeout includes connection time, any
	// redirects, and reading the response body
	RequestTimeout time.Duration

	// Miminum time a peer needs to answer in order to be considered responsive.
	// This should be much smaller than request timeout
	CheckPeerTimeout time.Duration

	// Maximum amount of time a dial will wait for a connect to complete.
	DialerTimeout time.Duration

	// Interval between keep-alive probes for an active network connection.
	DialerKeepAlive time.Duration

	// Maximum amount of time an idle (keep-alive) connection will remain idle before closing itself.
	IdleConnTimeout time.Duration

	// Maximum amount of time waiting to wait for a TLS handshake
	TLSHandshakeTimeout time.Duration

	// https://ar-io.zendesk.com/hc/en-us/articles/7595655106971-arweave-net-Rate-Limits
	// Time in which max num of requests is enforced
	LimiterInterval time.Duration

	// Max num requests to particular peer per interval
	LimiterBurstSize int

	// Limit is a float numbef = max frequency per second. Whenever a HTTP 429 Too Many Requests is received we multiply limit by this factor.
	// This way even if the limit is set too high eventually it'll get small enough.
	LimiterDecreaseFactor float64

	// How often limiters get decreased. This timeout won't allow sudden burst to decrease the limit too much
	LimiterDecreaseInterval time.Duration
}

type Bundler

type Bundler struct {
	// Disable polling mechanism
	PollerDisabled bool

	// How often to poll the database
	PollerInterval time.Duration

	// How long does it wait for the query response
	PollerTimeout time.Duration

	// Maksimum number of requests run in parallel
	PollerMaxParallelQueries int

	// Maksimum number of interactions updated in the database in one db transaction
	PollerMaxBatchSize int

	// Retry sending bundles to bundlr.network
	PollerRetryBundleAfter time.Duration

	// Max queries in the queue
	WorkerPoolQueueSize int

	// Maksimum number of interactions selected from the database in one db transaction
	PollerMaxDownloadedBatchSize int

	// How often notifier monitors the number of pending tx to bundle
	DBPollerInterval time.Duration

	// Switch off listening for async notifications
	NotifierDisabled bool

	// Maksimum number of workers that handle notifications
	NotifierWorkerPoolSize int

	// Maksimum notifications waiting in the queue
	NotifierWorkerQueueSize int

	// How many batches are confirmet in one transaction
	ConfirmerBatchSize int

	// How often are states updated in the database
	ConfirmerInterval time.Duration

	// Max time confirmer will try to insert a batch of data to the database
	// 0 means no limit
	// This should be 0,
	ConfirmerBackoffMaxElapsedTime time.Duration

	// Max time between retries to insert a batch of confirmations to  the database
	ConfirmerBackoffMaxInterval time.Duration

	// Number of workers that send bundles in parallel
	BundlerNumBundlingWorkers int
}

type Bundlr

type Bundlr struct {
	// List of urls that can be used, order matters
	Urls []string

	// List of urls that can be used to upload bundles, order matters
	TurboUrls []string

	// Power of Turbo. TurboSendFactor + IrysSendFactor is 100%. If set to 0, skips sending to this provider.
	// This is a way to divide traffic between bundle providers
	TurboSendProbability int

	// Power of Irys
	IrysSendProbability int

	// Time limit for requests. The timeout includes connection time, any
	// redirects, and reading the response body
	RequestTimeout time.Duration

	// Miminum time a peer needs to answer in order to be considered responsive.
	// This should be much smaller than request timeout
	CheckPeerTimeout time.Duration

	// Maximum amount of time a dial will wait for a connect to complete.
	DialerTimeout time.Duration

	// Interval between keep-alive probes for an active network connection.
	DialerKeepAlive time.Duration

	// Maximum amount of time an idle (keep-alive) connection will remain idle before closing itself.
	IdleConnTimeout time.Duration

	// Maximum amount of time waiting to wait for a TLS handshake
	TLSHandshakeTimeout time.Duration

	// https://ar-io.zendesk.com/hc/en-us/articles/7595655106971-arweave-net-Rate-Limits
	// Time in which max num of requests is enforced
	LimiterInterval time.Duration

	// Max num requests to particular peer per interval
	LimiterBurstSize int

	// Wallet used to signing transactions
	Wallet string
}

type Checker

type Checker struct {
	// Minimal number of blocks to wait before checking the bundle
	MinConfirmationBlocks int64

	// Number of bundles to confirm in one run.
	MaxBundlesPerRun int

	// Number of workers that check bundles in parallel
	WorkerPoolSize int

	// Size of the queue for workers
	WorkerQueueSize int

	// How often for unfinished checks
	PollerInterval time.Duration

	// After this time retry checking the bundle
	PollerRetryCheckAfter time.Duration
}

type Config

type Config struct {
	// Is development mode on
	IsDevelopment bool

	// REST API address. API used for monitoring etc.
	RESTListenAddress string

	// Maximum time Syncer will be closing before stop is forced.
	StopTimeout time.Duration

	// Logging level
	LogLevel string

	Arweave               Arweave
	PeerMonitor           PeerMonitor
	TransactionDownloader TransactionDownloader
	NetworkMonitor        NetworkMonitor
	Syncer                Syncer
	Bundler               Bundler
	Sender                Sender
	Bundlr                Bundlr
	Sequencer             Sequencer
	Checker               Checker
	Database              Database
	ReadOnlyDatabase      Database
	Contract              Contract
	Redis                 []Redis
	AppSync               AppSync
	Forwarder             Forwarder
	Relayer               Relayer
	Gateway               Gateway
	Profiler              Profiler
	Interactor            Interactor
	Evolver               Evolver
	WarpySyncer           WarpySyncer
}

Config stores global configuration

func Default

func Default() (config *Config)

func Load

func Load(filename string) (config *Config, err error)

Load configuration from file and env

type Contract

type Contract struct {
	// Worker pool for fetching contact source and init state
	LoaderWorkerPoolSize int

	// Maksimum payloads in loader's queue
	LoaderWorkerQueueSize int

	// Possible contract source content types
	LoaderSupportedContentTypes []string

	// Max time we try to download contract from arweave. 0 means no limit
	LoaderBackoffMaxElapsedTime time.Duration

	// Max time between retries to insert a batch of confirmations to  the database
	LoaderBackoffMaxInterval time.Duration

	// Acceptable duration for loading a single contract. After this time arweave client will be reset/
	LoaderBackoffAcceptableDuration time.Duration

	// Max time for a transaction to be downloaded. 0 means no limit
	TransactionMaxElapsedTime time.Duration

	// Max time between transaction download retries
	TransactionMaxInterval time.Duration

	// How many contracts are saved in one transaction
	StoreBatchSize int

	// How often is an insert triggered
	StoreInterval time.Duration

	// Max time store will try to insert a batch of data to the database
	// 0 means no limit
	// This should be 0,
	StoreBackoffMaxElapsedTime time.Duration

	// Max time between retries to insert a batch of confirmations to  the database
	StoreBackoffMaxInterval time.Duration

	// Max size of a message that can be published to Redis, in bytes. 10MB by default
	PublisherMaxMessageSize int

	// Saved contracts are published on this Redis channel
	PublisherRedisChannelName string

	// Saved contracts are published on this AppSync channel
	PublisherAppSyncChannelName string
}

type Database

type Database struct {
	Port              uint16
	Host              string
	User              string
	Password          string
	Name              string
	SslMode           string
	PingTimeout       time.Duration
	ClientKey         string
	ClientKeyPath     string
	ClientCert        string
	ClientCertPath    string
	CaCert            string
	CaCertPath        string
	MigrationUser     string
	MigrationPassword string

	// Connection configuration
	MaxOpenConns    int
	MaxIdleConns    int
	ConnMaxIdleTime time.Duration
	ConnMaxLifetime time.Duration
}

type Evolver added in v0.2.124

type Evolver struct {
	// How often to poll the database
	PollerInterval time.Duration

	// How long does it wait for the query response
	PollerTimeout time.Duration

	// Maximum length of the channel buffer
	PollerChannelBufferLength int

	// Maximum number of evolved contract sources to be updated in the database
	PollerMaxBatchSize int

	// Max time between evolved source transaction retry
	DownloaderSourceTransactiondMaxInterval time.Duration

	// Number of workers that download the transactions
	DownloaderNumWorkers int

	// Max number of transactions that wait in the worker queue
	DownloaderWorkerQueueSize int

	// How many contract sources are saved in one transaction
	StoreBatchSize int

	// How often is an insert triggered
	StoreInterval time.Duration

	// Max time store will try to insert a batch of data to the database
	// 0 means no limit
	// This should be 0,
	StoreBackoffMaxElapsedTime time.Duration

	// Max time between retries to insert a batch of confirmations to  the database
	StoreBackoffMaxInterval time.Duration
}

type Forwarder

type Forwarder struct {
	// Last block height forwarder will attempt to set last sort keys
	FetcherLastSortKeySettingBlockHeight uint64

	// If true, L1 interactions get last sort key assigned and saved before being sent further
	FetcherLastSortKeySettingEnabled bool

	// How many L1 interactions are fetched from the DB at once
	FetcherBatchSize int

	// Interactions are saved to this Redis channel
	PublisherRedisChannelName string

	// How long to wait before after receiving a new block height before sending L1 interactions
	// This delay ensures sequencer finishes handling requests in time
	HeightDelay time.Duration

	// How many L1 interactions are cached in queue
	// This should be at least 1000 since this is how many tx are in Arweave block
	ArweaveFetcherQueueSize int

	// How long to wait to send all L1 interactions from a given block
	// There's 2m between blocks, so this should be at most 2m
	ArweaveFetcherBlockSendTimeout time.Duration

	// How many L2 interactions are cached in queue
	// Those are L2 interactions streamed live from the database
	InteractionsStreamerQueueSize int
}

type Gateway added in v0.1.284

type Gateway struct {
	// REST API address
	ServerListenAddress string

	// Max time a http request can take
	ServerRequestTimeout time.Duration
}

type Interactor added in v0.2.123

type Interactor struct {
	// Contract id tag for the generated data items
	GeneratorContractId string

	// How often to generate data item
	GeneratorInterval time.Duration

	// Key/wallet used to sign the generated data item
	GeneratorEthereumKey string

	// How often to check for processed data items in database
	CheckerInterval time.Duration

	// Number of workers that will be sending data items to sequencer
	SenderWorkerPoolSize int

	// Size of the queue that will be used to send data items to sequencer
	SenderWorkerQueueSize int
}

type NetworkMonitor

type NetworkMonitor struct {

	// Time between requests to the Warp's Gateway for network info
	Period time.Duration

	// Minimum amount of confirmations (blocks on top of the given block) that are required to consider
	// a given block as confirmed (i.e. not being a fork)
	RequiredConfirmationBlocks int64

	// URL of the node we're using to get the current block height.
	// It's the Warp's Gateway URL to avoid race conditions
	Url string
}

type PeerMonitor

type PeerMonitor struct {
	// Maximum time a peer is blacklisted.
	// Even after this duration is over it may take some time for the peer to be re-checked
	MaxTimeBlacklisted time.Duration

	// Maximum number of peers that can be removed from the blacklist
	// Peers that are blacklisted longer than `PeerMonitorMaxTimeBlacklisted` will get eventually re-used
	// To avoid spikes we can only remove at most this many peers from the blacklist in one try
	MaxPeersRemovedFromBlacklist int

	// Time between sending monitoring requests to peers
	// Peers are downloaded from the arweave API and checked in parallel by couple of workers
	Period time.Duration

	// Max number of peers that can be used for retrying requests
	MaxPeers int

	// Number of workers that check peers in parallel
	NumWorkers int

	// Number of peers pending verification in worker queue
	WorkerQueueSize int
}

type Profiler added in v0.2.39

type Profiler struct {
	// Are profiling endpoints registered
	Enabled bool

	//BlockProfileRate
	BlockProfileRate int
}

type Redis

type Redis struct {
	Port     uint16
	Host     string
	User     string
	Password string
	DB       int

	// TLS configuration
	ClientKey  string
	ClientCert string
	CaCert     string
	EnableTLS  bool

	// Connection configuration
	MinIdleConns    int
	MaxIdleConns    int
	ConnMaxIdleTime time.Duration
	MaxOpenConns    int
	ConnMaxLifetime time.Duration

	// Publish backoff configuration, 0 is no limit
	MaxElapsedTime time.Duration
	MaxInterval    time.Duration

	// Num of workers that publish messages
	MaxWorkers int

	// Max num of requests in worker's queue
	MaxQueueSize int
}

type Relayer added in v0.1.283

type Relayer struct {
	// Where is the relayer started (dev, main, test)
	Environment string

	// Websocket url of the Warp's sequencer
	SequencerUrl string

	// How many incomming events should be stored in channel
	SequencerQueueSize int

	// Max time request for a block to be downloaded. 0 means no limit
	ArweaveBlockDownloadTimeout time.Duration

	// Max time for a block to be downloaded. 0 means no limit
	ArweaveBlockDownloadMaxElapsedTime time.Duration

	// Max time between transaction download retries
	ArweaveBlockDownloadMaxInterval time.Duration

	// Worker pool size for downloading Sequencer's blocks
	SourceMaxWorkers int

	// Worker pool queue size for downloading Sequencer's  blocks
	SourceMaxQueueSize int

	// Max time a request should be retried. 0 means no limit.
	SourceBackoffMaxElapsedTime time.Duration

	// Max time between failed retries to save data.
	SourceBackoffMaxInterval time.Duration

	// How many blocks are downloaded in parallel
	SourceBatchSize int

	// Num of Interactions that are stored in the Store
	// before being inserted into the database in one db transaction and batch.
	StoreBatchSize int

	// After this time all Interactions in Store will be inserted to the database.
	// This is to avoid keeping them in the service for too long when waiting to fill the batch.
	StoreMaxTimeInQueue time.Duration

	// Max time between failed retries to save data.
	StoreMaxBackoffInterval time.Duration
}

type Sender added in v0.2.105

type Sender struct {
	// Disable polling mechanism
	PollerDisabled bool

	// How often to poll the database
	PollerInterval time.Duration

	// How long does it wait for the query response
	PollerTimeout time.Duration

	// Maksimum number of requests run in parallel
	PollerMaxParallelQueries int

	// Maksimum number of interactions updated in the database in one db transaction
	PollerMaxBatchSize int

	// Retry sending bundles to bundlr.network
	PollerRetryBundleAfter time.Duration

	// Max queries in the queue
	WorkerPoolQueueSize int

	// Maksimum number of interactions selected from the database in one db transaction
	PollerMaxDownloadedBatchSize int

	// How often notifier monitors the number of pending tx to bundle
	DBPollerInterval time.Duration

	// Switch off listening for async notifications
	NotifierDisabled bool

	// Maksimum number of workers that handle notifications
	NotifierWorkerPoolSize int

	// Maksimum notifications waiting in the queue
	NotifierWorkerQueueSize int

	// How many batches are confirmet in one transaction
	StoreBatchSize int

	// How often are states updated in the database
	StoreInterval time.Duration

	// Max time store will try to insert a batch of data to the database
	// 0 means no limit
	// This should be 0,
	StoreBackoffMaxElapsedTime time.Duration

	// Max time between retries to insert a batch of confirmations to  the database
	StoreBackoffMaxInterval time.Duration

	// Number of workers that send bundles in parallel
	BundlerNumBundlingWorkers int
}

type Sequencer added in v0.2.123

type Sequencer struct {
	// List of urls that can be used, order matters
	Urls []string

	// Time limit for requests. The timeout includes connection time, any
	// redirects, and reading the response body
	RequestTimeout time.Duration

	// Maximum amount of time a dial will wait for a connect to complete.
	DialerTimeout time.Duration

	// Interval between keep-alive probes for an active network connection.
	DialerKeepAlive time.Duration

	// Maximum amount of time an idle (keep-alive) connection will remain idle before closing itself.
	IdleConnTimeout time.Duration

	// Maximum amount of time waiting to wait for a TLS handshake
	TLSHandshakeTimeout time.Duration

	// Time in which max num of requests is enforced
	LimiterInterval time.Duration

	// Max num requests to particular host per interval
	LimiterBurstSize int

	// Endpoint to which data item will be sent
	UploadEndpoint string
}

type Syncer

type Syncer struct {
	// Is downloading arweave tx enabled, used in sequencer
	Enabled bool

	// Max time for a transaction to be downloaded. 0 means no limit
	BlockMaxElapsedTime time.Duration

	// Max time between transaction download retries
	BlockMaxInterval time.Duration

	// Max time for a transaction to be downloaded. 0 means no limit
	TransactionMaxElapsedTime time.Duration

	// Max time between transaction download retries
	TransactionMaxInterval time.Duration

	// Num of Interactions that are stored in the Store
	// before being inserted into the database in one db transaction and batch.
	StoreBatchSize int

	// After this time all Interactions in Store will be inserted to the database.
	// This is to avoid keeping them in the service for too long when waiting to fill the batch.
	StoreMaxTimeInQueue time.Duration

	// Max time between failed retries to save data.
	StoreMaxBackoffInterval time.Duration
}

type TransactionDownloader

type TransactionDownloader struct {
	// Number of workers that download the transactions
	NumWorkers int

	// Max number of transactions that wait in the worker queue
	WorkerQueueSize int
}

type WarpySyncer added in v0.2.173

type WarpySyncer struct {
	// Maximum length of the channel output
	BlockDownloaderChannelSize int

	// How often poll for new block
	BlockDownloaderInterval time.Duration

	// Max worker pool's queue size
	BlockDownloaderMaxQueueSize int

	// Max batch size for the number of blocks downloaded in one iteration
	BlockDownloaderBatchSize int

	// Max time between failed retries to download block
	BlockDownloaderBackoffInterval time.Duration

	// Time between poller task is called from block downloader
	BlockDownloaderPollerInterval int64

	// Block time
	BlockDownloaderBlockTime float64

	// If should download block by header number (for integrations which cannot decode transactions inside the block)
	BlockDownloaderByHeader bool

	// Warpy contract id
	SyncerContractId string

	// Name service contract id, usually the same as SyncerContractId
	SyncerNameServiceContractId string

	// Dre-Warpy URL
	SyncerDreUrl string

	// Warpy API url
	SyncerWarpyApiUrl string

	// Chain to by synced
	SyncerChain eth.Chain

	// Protocol to be synced
	SyncerProtocol eth.Protocol

	// API key
	SyncerApiKey string

	// Warpy admin id
	SyncerInteractionAdminId string

	// Signer for the Warpy interactions
	SyncerSigner string

	// Max time between failed retries to sync transaction
	SyncerDeltaBackoffInterval time.Duration

	// Number of workers that sync transactions
	SyncerDeltaNumWorkers int

	// Max number of transactions that wait in the worker queue
	SyncerDeltaWorkerQueueSize int

	// Data to be searched in transactions
	SyncerDeltaRedstoneData string

	// Number of points assigned in the Warpy interaction
	SyncerDeltaInteractionPoints int64

	// Sommelier contract id to be synced
	SyncerDepositContractId string

	// Sommelier functions to be synced
	SyncerDepositFunctions []string

	// Max time between failed retries to sync transaction
	SyncerDepositBackoffInterval time.Duration

	// Number of workers that sync transactions
	SyncerDepositNumWorkers int

	// Max number of transactions that wait in the worker queue
	SyncerDepositWorkerQueueSize int

	// Max batch size before last block synced will be inserted into database
	StoreBatchSize int

	// After this time last block synced will be inserted into database
	StoreInterval time.Duration

	// Sommelier functions for withdrawal
	StoreDepositWithdrawFunctions []string

	// Name of the deposit assets input name
	StoreDepositDepositAssetsName string

	// Name of the withdraw assets input name
	StoreDepositWithdrawAssetsName string

	// Max time between failed retries to save last block synced
	StoreMaxBackoffInterval time.Duration

	// Maximum length of the channel buffer
	PollerDepositChannelBufferLength int

	// How often to poll the database
	PollerDepositInterval time.Duration

	// How long does it wait for the query response
	PollerDepositTimeout time.Duration

	// Base for the points multiplication
	PollerDepositPointsBase int64

	// How much time should pass until we include transaction in rewards (in seconds)
	PollerDepositSecondsForSelect int64

	// Max time between failed retries to write interaction
	WriterBackoffInterval time.Duration

	// Timeout for HTTP requests
	WriterHttpRequestTimeout time.Duration

	// Writer splits interaction into chunks with max size of
	WriterInteractionChunkSize int
}

Jump to

Keyboard shortcuts

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