configuration

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2020 License: Apache-2.0 Imports: 8 Imported by: 3

Documentation

Index

Constants

View Source
const (
	DefaultURL                               = "http://localhost:8080"
	DefaultSyncConcurrency                   = 8
	DefaultTransactionConcurrency            = 16
	DefaultActiveReconciliationConcurrency   = 16
	DefaultInactiveReconciliationConcurrency = 4
	DefaultInactiveReconciliationFrequency   = 250
	DefaultTimeout                           = 10
	DefaultConfirmationDepth                 = 10
	DefaultStaleDepth                        = 30
	DefaultBroadcastLimit                    = 3
	DefaultTipDelay                          = 300
	DefaultBlockBroadcastLimit               = 5
	DefaultNewAccountProbability             = 0.5
	DefaultMaxAddresses                      = 200

	// ETH Defaults
	EthereumIDBlockchain    = "Ethereum"
	EthereumIDNetwork       = "Ropsten"
	EthereumTransferType    = "transfer"
	EthereumSymbol          = "ETH"
	EthereumDecimals        = 18
	EthereumMinimumBalance  = "0"
	EthereumMaximumFee      = "5000000000000000" // 0.005 ETH
	EthereumCurveType       = types.Secp256k1
	EthereumAccountingModel = AccountModel
)

Default Configuration Values

Variables

View Source
var (
	EthereumNetwork = &types.NetworkIdentifier{
		Blockchain: EthereumIDBlockchain,
		Network:    EthereumIDNetwork,
	}
	EthereumCurrency = &types.Currency{
		Symbol:   EthereumSymbol,
		Decimals: EthereumDecimals,
	}
	EthereumTransfer = []*types.Operation{
		{
			OperationIdentifier: &types.OperationIdentifier{
				Index: 0,
			},
			Account: &types.AccountIdentifier{
				Address: scenario.Sender,
			},
			Type: EthereumTransferType,
			Amount: &types.Amount{
				Value: scenario.SenderValue,
			},
		},
		{
			OperationIdentifier: &types.OperationIdentifier{
				Index: 1,
			},
			RelatedOperations: []*types.OperationIdentifier{
				{
					Index: 0,
				},
			},
			Account: &types.AccountIdentifier{
				Address: scenario.Recipient,
			},
			Type: EthereumTransferType,
			Amount: &types.Amount{
				Value: scenario.RecipientValue,
			},
		},
	}
)

Default Configuration Values

Functions

This section is empty.

Types

type AccountingModel

type AccountingModel string

AccountingModel is a type representing possible accounting models in the Construction API.

const (
	// AccountModel is for account-based blockchains.
	AccountModel AccountingModel = "account"

	// UtxoModel is for UTXO-based blockchains.
	UtxoModel AccountingModel = "utxo"
)

type Configuration

type Configuration struct {
	// Network is the *types.NetworkIdentifier where transactions should
	// be constructed and where blocks should be synced to monitor
	// for broadcast success.
	Network *types.NetworkIdentifier `json:"network"`

	// OnlineURL is the URL of a Rosetta API implementation in "online mode".
	OnlineURL string `json:"online_url"`

	// DataDirectory is a folder used to store logs and any data used to perform validation.
	DataDirectory string `json:"data_directory"`

	// HTTPTimeout is the timeout for HTTP requests in seconds.
	HTTPTimeout uint64 `json:"http_timeout"`

	// SyncConcurrency is the concurrency to use while syncing blocks.
	SyncConcurrency uint64 `json:"sync_concurrency"`

	// TransactionConcurrency is the concurrency to use while fetching transactions (if required).
	TransactionConcurrency uint64 `json:"transaction_concurrency"`

	// TipDelay dictates how many seconds behind the current time is considered
	// tip. If we are > TipDelay seconds from the last processed block,
	// we are considered to be behind tip.
	TipDelay int64 `json:"tip_delay"`

	// DisableMemoryLimit uses a performance-optimized database mode
	// that uses more memory.
	DisableMemoryLimit bool `json:"disable_memory_limit"`

	// LogConfiguration determines if the configuration settings
	// should be printed to the console when a file is loaded.
	LogConfiguration bool `json:"log_configuration"`

	Construction *ConstructionConfiguration `json:"construction"`
	Data         *DataConfiguration         `json:"data"`
}

Configuration contains all configuration settings for running check:data or check:construction.

func DefaultConfiguration

func DefaultConfiguration() *Configuration

DefaultConfiguration returns a *Configuration with the EthereumNetwork, DefaultURL, DefaultTimeout, DefaultConstructionConfiguration and DefaultDataConfiguration.

func LoadConfiguration

func LoadConfiguration(filePath string) (*Configuration, error)

LoadConfiguration returns a parsed and asserted Configuration for running tests.

type ConstructionConfiguration

type ConstructionConfiguration struct {
	// OfflineURL is the URL of a Rosetta API implementation in "offline mode".
	OfflineURL string `json:"offline_url"`

	// Currency is the *types.Currency to track and use for transactions.
	Currency *types.Currency `json:"currency"`

	// MinimumBalance is balance at a particular address
	// that is not considered spendable.
	MinimumBalance string `json:"minimum_balance"`

	// MaximumFee is the maximum fee that could be used
	// to send a transaction. The sendable balance
	// of any address is calculated as balance - minimum_balance - maximum_fee.
	MaximumFee string `json:"maximum_fee"`

	// CurveType is the curve to use when generating a *keys.KeyPair.
	CurveType types.CurveType `json:"curve_type"`

	// AccountingModel is the type of acccount model to use for
	// testing (account vs UTXO).
	AccountingModel AccountingModel `json:"accounting_model"`

	// Scenario contains a slice of operations that
	// indicate how to construct a transaction on a blockchain. In the future
	// this will be expanded to support all kinds of construction scenarios (like
	// staking or governance).
	Scenario []*types.Operation `json:"scenario"`

	// ConfirmationDepth is the number of blocks that must be synced
	// after a transaction before a transaction is confirmed.
	//
	// Note: Rosetta uses Bitcoin's definition of depth, so
	// a transaction has depth 1 if it is in the head block.
	// Source: https://en.bitcoin.it/wiki/Confirmation
	ConfirmationDepth int64 `json:"confirmation_depth"`

	// StaleDepth is the number of blocks to wait before attempting
	// to rebroadcast after not finding a transaction on-chain.
	StaleDepth int64 `json:"stale_depth"`

	// BroadcastLimit is the number of times to attempt re-broadcast
	// before giving up on a transaction broadcast.
	BroadcastLimit int `json:"broadcast_limit"`

	// IgnoreBroadcastFailures determines if we should exit when there
	// are broadcast failures (that surpass the BroadcastLimit).
	IgnoreBroadcastFailures bool `json:"ignore_broadcast_failures"`

	// ChangeScenario is added to the scenario if it is possible to generate
	// a change transaction where the recipient address is over
	// the minimum balance. If this is left nil, no change
	// will ever be created. This is ONLY used for UTXO-based
	// testing.
	ChangeScenario *types.Operation `json:"change_scenario"`

	// ClearBroadcasts indicates if all pending broadcasts should
	// be removed from BroadcastStorage on restart.
	ClearBroadcasts bool `json:"clear_broadcasts"`

	// BroadcastBehindTip indicates if we should broadcast transactions
	// when we are behind tip (as defined by TipDelay).
	BroadcastBehindTip bool `json:"broadcast_behind_tip"`

	// BlockBroadcastLimit is the number of transactions to attempt
	// broadcast in a single block. When there are many pending
	// broadcasts, it may make sense to limit the number of broadcasts.
	BlockBroadcastLimit int `json:"block_broadcast_limit"`

	// RebroadcastAll indicates if all pending broadcasts should be
	// rebroadcast from BroadcastStorage on restart.
	RebroadcastAll bool `json:"rebroadcast_all"`

	// NewAccountProbability is the probability we create a new
	// recipient address on any transaction creation loop.
	NewAccountProbability float64 `json:"new_account_probability"`

	// MaxAddresses is the maximum number of addresses
	// to generate while testing.
	MaxAddresses int `json:"max_addresses"`
}

ConstructionConfiguration contains all configurations to run check:construction.

func DefaultConstructionConfiguration

func DefaultConstructionConfiguration() *ConstructionConfiguration

DefaultConstructionConfiguration returns the *ConstructionConfiguration used for testing Ethereum transfers on Ropsten.

type DataConfiguration

type DataConfiguration struct {
	// ActiveReconciliationConcurrency is the concurrency to use while fetching accounts
	// during active reconciliation.
	ActiveReconciliationConcurrency uint64 `json:"active_reconciliation_concurrency"`

	// InactiveReconciliationConcurrency is the concurrency to use while fetching accounts
	// during inactive reconciliation.
	InactiveReconciliationConcurrency uint64 `json:"inactive_reconciliation_concurrency"`

	// InactiveReconciliationFrequency is the number of blocks to wait between
	// inactive reconiliations on each account.
	InactiveReconciliationFrequency uint64 `json:"inactive_reconciliation_frequency"`

	// LogBlocks is a boolean indicating whether to log processed blocks.
	LogBlocks bool `json:"log_blocks"`

	// LogTransactions is a boolean indicating whether to log processed transactions.
	LogTransactions bool `json:"log_transactions"`

	// LogBalanceChanges is a boolean indicating whether to log all balance changes.
	LogBalanceChanges bool `json:"log_balance_changes"`

	// LogReconciliations is a boolean indicating whether to log all reconciliations.
	LogReconciliations bool `json:"log_reconciliations"`

	// IgnoreReconciliationError determines if block processing should halt on a reconciliation
	// error. It can be beneficial to collect all reconciliation errors or silence
	// reconciliation errors during development.
	IgnoreReconciliationError bool `json:"ignore_reconciliation_error"`

	// ExemptAccounts is a path to a file listing all accounts to exempt from balance
	// tracking and reconciliation. Look at the examples directory for an example of
	// how to structure this file.
	ExemptAccounts string `json:"exempt_accounts"`

	// BootstrapBalances is a path to a file used to bootstrap balances
	// before starting syncing. If this value is populated after beginning syncing,
	// it will be ignored.
	BootstrapBalances string `json:"bootstrap_balances"`

	// HistoricalBalanceDisabled is a boolean that dictates how balance lookup is performed.
	// When set to true, balances are looked up at the block where a balance
	// change occurred instead of at the current block. Blockchains that do not support
	// historical balance lookup should set this to false.
	HistoricalBalanceDisabled bool `json:"historical_balance_disabled"`

	// InterestingAccounts is a path to a file listing all accounts to check on each block. Look
	// at the examples directory for an example of how to structure this file.
	InterestingAccounts string `json:"interesting_accounts"`

	// ReconciliationDisabled is a boolean that indicates reconciliation should not
	// be attempted. When first testing an implementation, it can be useful to disable
	// some of the more advanced checks to confirm syncing is working as expected.
	ReconciliationDisabled bool `json:"reconciliation_disabled"`

	// InactiveDiscrepencySearchDisabled is a boolean indicating if a search
	// should be performed to find any inactive reconciliation discrepencies.
	// Note, a search will never be performed if historical balance lookup
	// is disabled.
	InactiveDiscrepencySearchDisabled bool `json:"inactive_discrepency_search_disabled"`

	// BalanceTrackingDisabled is a boolean that indicates balances calculation
	// should not be attempted. When first testing an implemenation, it can be
	// useful to just try to fetch all blocks before checking for balance
	// consistency.
	BalanceTrackingDisabled bool `json:"balance_tracking_disabled"`

	// CoinTrackingDisabled is a boolean that indicates coin (or UTXO) tracking
	// should not be attempted. When first testing an implemenation, it can be
	// useful to just try to fetch all blocks before checking for coin
	// consistency.
	CoinTrackingDisabled bool `json:"coin_tracking_disabled"`

	// EndCondition contains the conditions for the syncer to stop
	EndConditions *EndConditions `json:"end_conditions,omitempty"`
}

DataConfiguration contains all configurations to run check:data.

func DefaultDataConfiguration

func DefaultDataConfiguration() *DataConfiguration

DefaultDataConfiguration returns the default *DataConfiguration for running `check:data`.

type EndConditions added in v0.4.1

type EndConditions struct {
	// EndAtTip determines if syncer should stop once it reached the tip
	EndAtTip bool `json:"end_at_tip"`

	// EndDuration is an end condition that dictates how long the
	// check:data command would be running for in seconds
	EndDuration uint64 `json:"end_duration"`
}

EndConditions contains all the conditions for the syncer to stop.

Jump to

Keyboard shortcuts

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