processor

package
v0.60.0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2022 License: MIT Imports: 42 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrPublicKeyCannotSubmitTransactionWithNoBalance  = errors.New("public key cannot submit transaction without balance")
	ErrUnexpectedTxPubKey                             = errors.New("no one listens to the public keys that signed this oracle data")
	ErrTradingDisabled                                = errors.New("trading disabled")
	ErrNoTransactionAllowedDuringBootstrap            = errors.New("no transaction allowed during the bootstraping period")
	ErrMarketProposalDisabled                         = errors.New("market proposal disabled")
	ErrAssetProposalDisabled                          = errors.New("asset proposal disabled")
	ErrNonValidatorTransactionDisabledDuringBootstrap = errors.New("non validator transaction disabled during bootstrap")
	ErrCheckpointRestoreDisabledDuringBootstrap       = errors.New("checkpoint restore disabled during bootstrap")
	ErrAwaitingCheckpointRestore                      = errors.New("transactions not allowed while waiting for checkpoint restore")
	ErrOracleNoSubscribers                            = errors.New("there are no subscribes to the oracle data")
	ErrOracleDataNormalization                        = func(err error) error {
		return fmt.Errorf("error normalizing incoming oracle data: %w", err)
	}
)
View Source
var (
	ErrNotAnERC20Event                                = errors.New("not an erc20 event")
	ErrNotABuiltinAssetEvent                          = errors.New("not an builtin asset event")
	ErrUnsupportedEventAction                         = errors.New("unsupported event action")
	ErrChainEventAssetListERC20WithoutEnoughSignature = errors.New("chain event for erc20 asset list received with missing node signatures")
)
View Source
var (
	ErrInvalidSignature                       = errors.New("invalid signature")
	ErrChainEventFromNonValidator             = errors.New("chain event emitted from a non-validator node")
	ErrUnsupportedChainEvent                  = errors.New("unsupported chain event")
	ErrNodeSignatureFromNonValidator          = errors.New("node signature not sent by validator")
	ErrNodeSignatureWithNonValidatorMasterKey = errors.New("node signature not signed with validator master key")
	ErrMarketBatchInstructionTooBig           = func(got, expected uint64) error {
		return fmt.Errorf("market batch instructions too big, got(%d), expected(%d)", got, expected)
	}
)
View Source
var ErrMissingWithdrawERC20Ext = errors.New("missing withdraw submission erc20 ext")

Functions

This section is empty.

Types

type App

type App struct {
	// contains filtered or unexported fields
}

func NewApp

func NewApp(
	log *logging.Logger,
	vegaPaths paths.Paths,
	config Config,
	cancelFn func(),
	assets Assets,
	banking Banking,
	broker Broker,
	witness Witness,
	evtfwd EvtForwarder,
	exec ExecutionEngine,
	ghandler *genesis.Handler,
	gov GovernanceEngine,
	notary Notary,
	stats Stats,
	time TimeService,
	epoch EpochService,
	top ValidatorTopology,
	netp NetworkParameters,
	oracles *Oracle,
	delegation DelegationEngine,
	limits Limits,
	stake StakeVerifier,
	checkpoint Checkpoint,
	spam SpamEngine,
	pow PoWEngine,
	stakingAccounts StakingAccounts,
	snapshot Snapshot,
	stateVarEngine StateVarEngine,
	blockchainClient BlockchainClient,
	erc20MultiSigTopology ERC20MultiSigTopology,
	version string,
	protocolUpgradeService ProtocolUpgradeService,
	codec abci.Codec,
) *App

func (*App) Abci

func (app *App) Abci() *abci.App

func (*App) CheckBatchMarketInstructions added in v0.55.0

func (app *App) CheckBatchMarketInstructions(ctx context.Context, tx abci.Tx) error

func (*App) CheckBatchMarketInstructionsW added in v0.55.0

func (app *App) CheckBatchMarketInstructionsW(
	f func(context.Context, abci.Tx) error,
) func(context.Context, abci.Tx) error

func (*App) CheckPropose added in v0.56.0

func (app *App) CheckPropose(ctx context.Context, tx abci.Tx) error

func (*App) CheckProposeW added in v0.56.0

func (app *App) CheckProposeW(
	f func(context.Context, abci.Tx) error,
) func(context.Context, abci.Tx) error

func (*App) CheckProtocolUpgradeProposal added in v0.55.0

func (app *App) CheckProtocolUpgradeProposal(ctx context.Context, tx abci.Tx) error

func (*App) CheckSubmitOracleData

func (app *App) CheckSubmitOracleData(_ context.Context, tx abci.Tx) error

func (*App) DeliverAmendLiquidityProvision

func (app *App) DeliverAmendLiquidityProvision(ctx context.Context, tx abci.Tx, deterministicID string) error

func (*App) DeliverAmendOrder

func (app *App) DeliverAmendOrder(
	ctx context.Context,
	tx abci.Tx,
	deterministicID string,
) (errl error)

func (*App) DeliverAnnounceNode

func (app *App) DeliverAnnounceNode(ctx context.Context, tx abci.Tx) error

func (*App) DeliverBatchMarketInstructions added in v0.55.0

func (app *App) DeliverBatchMarketInstructions(
	ctx context.Context,
	tx abci.Tx,
	deterministicID string,
) error

func (*App) DeliverCancelLiquidityProvision

func (app *App) DeliverCancelLiquidityProvision(ctx context.Context, tx abci.Tx) error

func (*App) DeliverCancelOrder

func (app *App) DeliverCancelOrder(ctx context.Context, tx abci.Tx, deterministicID string) error

func (*App) DeliverCancelTransferFunds

func (app *App) DeliverCancelTransferFunds(ctx context.Context, tx abci.Tx) error

func (*App) DeliverChainEvent

func (app *App) DeliverChainEvent(ctx context.Context, tx abci.Tx, id string) error

func (*App) DeliverDelegate

func (app *App) DeliverDelegate(ctx context.Context, tx abci.Tx) (err error)

func (*App) DeliverEthereumKeyRotateSubmission

func (app *App) DeliverEthereumKeyRotateSubmission(ctx context.Context, tx abci.Tx) error

func (*App) DeliverIssueSignatures added in v0.55.0

func (app *App) DeliverIssueSignatures(ctx context.Context, tx abci.Tx) error

func (*App) DeliverKeyRotateSubmission

func (app *App) DeliverKeyRotateSubmission(ctx context.Context, tx abci.Tx) error

func (*App) DeliverLiquidityProvision

func (app *App) DeliverLiquidityProvision(ctx context.Context, tx abci.Tx, deterministicID string) error

func (*App) DeliverNodeSignature

func (app *App) DeliverNodeSignature(ctx context.Context, tx abci.Tx) error

func (*App) DeliverNodeVote

func (app *App) DeliverNodeVote(ctx context.Context, tx abci.Tx) error

func (*App) DeliverPropose

func (app *App) DeliverPropose(ctx context.Context, tx abci.Tx, deterministicID string) error

func (*App) DeliverProtocolUpgradeCommand

func (app *App) DeliverProtocolUpgradeCommand(ctx context.Context, tx abci.Tx) error

func (*App) DeliverStateVarProposal

func (app *App) DeliverStateVarProposal(ctx context.Context, tx abci.Tx) error

func (*App) DeliverSubmitOracleData

func (app *App) DeliverSubmitOracleData(ctx context.Context, tx abci.Tx) error

func (*App) DeliverSubmitOrder

func (app *App) DeliverSubmitOrder(ctx context.Context, tx abci.Tx, deterministicID string) error

func (*App) DeliverTransferFunds

func (app *App) DeliverTransferFunds(ctx context.Context, tx abci.Tx, id string) error

func (*App) DeliverUndelegate

func (app *App) DeliverUndelegate(ctx context.Context, tx abci.Tx) (err error)

func (*App) DeliverValidatorHeartbeat

func (app *App) DeliverValidatorHeartbeat(ctx context.Context, tx abci.Tx) error

func (*App) DeliverVote

func (app *App) DeliverVote(ctx context.Context, tx abci.Tx) error

func (*App) DeliverWithdraw

func (app *App) DeliverWithdraw(
	ctx context.Context, tx abci.Tx, id string,
) error

func (*App) Info

func (*App) ListSnapshots

func (*App) OfferSnapshot

func (*App) OnBeginBlock

func (app *App) OnBeginBlock(
	req tmtypes.RequestBeginBlock,
) (ctx context.Context, resp tmtypes.ResponseBeginBlock)

OnBeginBlock updates the internal lastBlockTime value with each new block.

func (*App) OnCheckTx

OnCheckTx performs soft validations.

func (*App) OnCheckTxSpam

func (app *App) OnCheckTxSpam(tx abci.Tx) tmtypes.ResponseCheckTx

OnCheckTxSpam checks for spam and replay.

func (*App) OnCommit

func (app *App) OnCommit() (resp tmtypes.ResponseCommit)

func (*App) OnDeliverTXSpam

func (app *App) OnDeliverTXSpam(ctx context.Context, tx abci.Tx) tmtypes.ResponseDeliverTx

OnDeliverTXSpam checks spam and replay.

func (*App) OnDeliverTx

OnDeliverTx increments the internal tx counter and decorates the context with tracing information.

func (*App) OnEndBlock

func (app *App) OnEndBlock(req tmtypes.RequestEndBlock) (ctx context.Context, resp tmtypes.ResponseEndBlock)

func (*App) OnInitChain

func (app *App) OnInitChain(req tmtypes.RequestInitChain) tmtypes.ResponseInitChain

func (*App) OnSpamProtectionMaxBatchSizeUpdate added in v0.55.0

func (app *App) OnSpamProtectionMaxBatchSizeUpdate(ctx context.Context, u *num.Uint) error

func (*App) ReloadConf

func (app *App) ReloadConf(cfg Config)

ReloadConf updates the internal configuration.

func (*App) RequireValidatorMasterPubKey

func (app *App) RequireValidatorMasterPubKey(ctx context.Context, tx abci.Tx) error

func (*App) RequireValidatorMasterPubKeyW

func (app *App) RequireValidatorMasterPubKeyW(
	f func(context.Context, abci.Tx) error,
) func(context.Context, abci.Tx) error

func (*App) RequireValidatorPubKey

func (app *App) RequireValidatorPubKey(ctx context.Context, tx abci.Tx) error

func (*App) RequireValidatorPubKeyW

func (app *App) RequireValidatorPubKeyW(
	f func(context.Context, abci.Tx) error,
) func(context.Context, abci.Tx) error

func (*App) SendTransactionResult added in v0.58.0

func (app *App) SendTransactionResult(
	f func(context.Context, abci.Tx) error,
) func(context.Context, abci.Tx) error

type Assets

type Assets interface {
	NewAsset(ctx context.Context, ref string, assetSrc *types.AssetDetails) (string, error)
	StageAssetUpdate(*types.Asset) error
	Get(assetID string) (*assets.Asset, error)
	IsEnabled(string) bool
	EnactPendingAsset(assetID string)
}

type BMIProcessor added in v0.55.0

type BMIProcessor struct {
	// contains filtered or unexported fields
}

func NewBMIProcessor added in v0.55.0

func NewBMIProcessor(
	log *logging.Logger,
	exec ExecutionEngine,
) *BMIProcessor

func (*BMIProcessor) ProcessBatch added in v0.55.0

func (p *BMIProcessor) ProcessBatch(
	ctx context.Context,
	batch *commandspb.BatchMarketInstructions,
	party, determinitisticID string,
) error

ProcessBatch will process a batch of market transaction. Transaction are always executed in the following order: cancellation, amendment then submissions. All errors are returned as a single error.

type BlockchainClient

type BlockchainClient interface {
	Validators(height *int64) ([]*tmtypesint.Validator, error)
}

type Broker

type Broker interface {
	Send(e events.Event)
	SetStreaming(on bool) bool
}

Broker - the event bus.

type Checkpoint

type Checkpoint interface {
	BalanceCheckpoint(ctx context.Context) (*types.CheckpointState, error)
	Checkpoint(ctx context.Context, now time.Time) (*types.CheckpointState, error)
}

type Config

type Config struct {
	Level               encoding.LogLevel `long:"log-level"`
	LogOrderSubmitDebug encoding.Bool     `long:"log-order-submit-debug"`
	LogOrderAmendDebug  encoding.Bool     `long:"log-order-amend-debug"`
	LogOrderCancelDebug encoding.Bool     `long:"log-order-cancel-debug"`
	Ratelimit           ratelimit.Config  `group:"Ratelimit" namespace:"ratelimit"`
}

Config represent the configuration of the processor package.

func NewDefaultConfig

func NewDefaultConfig() Config

NewDefaultConfig creates an instance of the package specific configuration, given a pointer to a logger instance to be used for logging within the package.

type DelegationEngine

type DelegationEngine interface {
	Delegate(ctx context.Context, party string, nodeID string, amount *num.Uint) error
	UndelegateAtEndOfEpoch(ctx context.Context, party string, nodeID string, amount *num.Uint) error
	UndelegateNow(ctx context.Context, party string, nodeID string, amount *num.Uint) error
	ProcessEpochDelegations(ctx context.Context, epoch types.Epoch) []*types.ValidatorData
	Hash() []byte
}

type ERC20MultiSigTopology

type ERC20MultiSigTopology interface {
	ProcessSignerEvent(event *types.SignerEvent) error
	ProcessThresholdEvent(event *types.SignerThresholdSetEvent) error
}

type EpochService

type EpochService interface {
	NotifyOnEpoch(f func(context.Context, types.Epoch), r func(context.Context, types.Epoch))
	OnBlockEnd(ctx context.Context)
}

type EvtForwarder

type EvtForwarder interface {
	Ack(*commandspb.ChainEvent) bool
}

EvtForwarder ...

type ExecutionEngine

type ExecutionEngine interface {
	// orders stuff
	SubmitOrder(ctx context.Context, orderSubmission *types.OrderSubmission, party string, idgen execution.IDGenerator, orderID string) (*types.OrderConfirmation, error)
	CancelOrder(ctx context.Context, order *types.OrderCancellation, party string, idgen execution.IDGenerator) ([]*types.OrderCancellationConfirmation, error)
	AmendOrder(ctx context.Context, order *types.OrderAmendment, party string, idgen execution.IDGenerator) (*types.OrderConfirmation, error)

	// market stuff
	SubmitMarket(ctx context.Context, marketConfig *types.Market, proposer string) error
	UpdateMarket(ctx context.Context, marketConfig *types.Market) error
	RejectMarket(ctx context.Context, marketid string) error
	StartOpeningAuction(ctx context.Context, marketid string) error

	// LP stuff
	SubmitLiquidityProvision(ctx context.Context, sub *types.LiquidityProvisionSubmission, party, deterministicID string) error
	CancelLiquidityProvision(ctx context.Context, order *types.LiquidityProvisionCancellation, party string) error
	AmendLiquidityProvision(ctx context.Context, order *types.LiquidityProvisionAmendment, party string, deterministicID string) error
	Hash() []byte
}

type GovernanceEngine

type GovernanceEngine interface {
	SubmitProposal(context.Context, types.ProposalSubmission, string, string) (*governance.ToSubmit, error)
	FinaliseEnactment(ctx context.Context, prop *types.Proposal)
	AddVote(context.Context, types.VoteSubmission, string) error
	OnTick(context.Context, time.Time) ([]*governance.ToEnact, []*governance.VoteClosed)
	RejectProposal(context.Context, *types.Proposal, types.ProposalError, error) error
	Hash() []byte
}

type HasVegaAssetID

type HasVegaAssetID interface {
	GetVegaAssetID() string
}

type Limits

type Limits interface {
	CanProposeMarket() bool
	CanProposeAsset() bool
	CanTrade() bool
}

type NetworkParameters

type NetworkParameters interface {
	Update(ctx context.Context, key, value string) error
	DispatchChanges(ctx context.Context)
	IsUpdateAllowed(key string) error
}

NetworkParameters ...

type Notary

type Notary interface {
	StartAggregate(resID string, kind commandspb.NodeSignatureKind, signature []byte)
	RegisterSignature(ctx context.Context, pubKey string, ns commandspb.NodeSignature) error
	IsSigned(context.Context, string, commandspb.NodeSignatureKind) ([]commandspb.NodeSignature, bool)
}

Notary.

type NullBlockchainTxCodec

type NullBlockchainTxCodec struct{}

func (*NullBlockchainTxCodec) Decode

func (c *NullBlockchainTxCodec) Decode(payload []byte, _ string) (abci.Tx, error)

type Oracle

type Oracle struct {
	Engine   OraclesEngine
	Adaptors OracleAdaptors
}

type OracleAdaptors

type OracleAdaptors interface {
	Normalise(crypto.PublicKey, commandspb.OracleDataSubmission) (*oracles.OracleData, error)
}

type OraclesEngine

type OraclesEngine interface {
	BroadcastData(context.Context, oracles.OracleData) error
	ListensToPubKeys(oracles.OracleData) bool
	HasMatch(data oracles.OracleData) (bool, error)
}

type PoWEngine

type PoWEngine interface {
	api.ProofOfWorkParams
	BeginBlock(blockHeight uint64, blockHash string)
	EndOfBlock()
	CheckTx(tx abci.Tx) error
	DeliverTx(tx abci.Tx) error
	Commit()
}

type ProtocolUpgradeService

type ProtocolUpgradeService interface {
	BeginBlock(ctx context.Context, blockHeight uint64)
	UpgradeProposal(ctx context.Context, pk string, upgradeBlockHeight uint64, vegaReleaseTag string) error
	TimeForUpgrade() bool
	GetUpgradeStatus() types.UpgradeStatus
	SetReadyForUpgrade()
	Cleanup(ctx context.Context)
	IsValidProposal(ctx context.Context, pk string, upgradeBlockHeight uint64, vegaReleaseTag string) error
}

type Snapshot

type Snapshot interface {
	Info() ([]byte, int64, string)
	Snapshot(ctx context.Context) ([]byte, error)
	SnapshotNow(ctx context.Context) (b []byte, errlol error)
	AddProviders(provs ...types.StateProvider)
	CheckLoaded() (bool, error)
	ClearAndInitialise() error

	// Calls related to statesync
	List() ([]*types.Snapshot, error)
	ReceiveSnapshot(snap *types.Snapshot) error
	RejectSnapshot() error
	ApplySnapshotChunk(chunk *types.RawChunk) (bool, error)
	GetMissingChunks() []uint32
	ApplySnapshot(ctx context.Context) error
	LoadSnapshotChunk(height uint64, format, chunk uint32) (*types.RawChunk, error)
}

type SpamEngine

type SpamEngine interface {
	EndOfBlock(blockHeight uint64)
	PreBlockAccept(tx abci.Tx) (bool, error)
	PostBlockAccept(tx abci.Tx) (bool, error)
}

type StakeVerifier

type StakeVerifier interface {
	ProcessStakeRemoved(ctx context.Context, event *types.StakeRemoved) error
	ProcessStakeDeposited(ctx context.Context, event *types.StakeDeposited) error
}

type StakingAccounts

type StakingAccounts interface {
	Hash() []byte
	ProcessStakeTotalSupply(ctx context.Context, event *types.StakeTotalSupply) error
}

type StateVarEngine

type StateVarEngine interface {
	ProposedValueReceived(ctx context.Context, ID, nodeID, eventID string, bundle *statevar.KeyValueBundle) error
	OnBlockEnd(ctx context.Context)
}

type Stats

type Stats interface {
	IncTotalCreateOrder()
	AddCurrentTradesInBatch(i uint64)
	AddTotalTrades(i uint64) uint64
	IncTotalOrders()
	IncCurrentOrdersInBatch()
	IncTotalCancelOrder()
	IncTotalAmendOrder()
	// batch stats
	IncTotalBatches()
	NewBatch()
	TotalOrders() uint64
	TotalBatches() uint64
	SetAverageOrdersPerBatch(i uint64)
	SetBlockDuration(uint64)
	CurrentOrdersInBatch() uint64
	CurrentTradesInBatch() uint64
	SetOrdersPerSecond(i uint64)
	SetTradesPerSecond(i uint64)
	// blockchain stats
	IncTotalTxCurrentBatch()
	IncHeight()
	Height() uint64
	SetAverageTxPerBatch(i uint64)
	SetAverageTxSizeBytes(i uint64)
	SetTotalTxLastBatch(i uint64)
	SetTotalTxCurrentBatch(i uint64)
	TotalTxCurrentBatch() uint64
	TotalTxLastBatch() uint64
	SetHash(string)
	SetHeight(uint64)
}

type TimeService

type TimeService interface {
	GetTimeNow() time.Time
	GetTimeLastBatch() time.Time
	NotifyOnTick(...func(context.Context, time.Time))
	SetTimeNow(context.Context, time.Time)
}

type Tx

type Tx struct {
	// contains filtered or unexported fields
}

func DecodeTx

func DecodeTx(payload []byte, chainID string) (*Tx, error)

func DecodeTxNoValidation

func DecodeTxNoValidation(payload []byte) (*Tx, error)

func (Tx) BlockHeight

func (t Tx) BlockHeight() uint64

func (Tx) Command

func (t Tx) Command() txn.Command

func (Tx) GetCmd

func (t Tx) GetCmd() interface{}

func (Tx) GetPoWNonce

func (t Tx) GetPoWNonce() uint64

func (Tx) GetPoWTID

func (t Tx) GetPoWTID() string

func (Tx) GetVersion

func (t Tx) GetVersion() uint32

func (Tx) Hash

func (t Tx) Hash() []byte

func (Tx) Party

func (t Tx) Party() string

func (Tx) PubKey

func (t Tx) PubKey() []byte

func (Tx) PubKeyHex

func (t Tx) PubKeyHex() string

func (Tx) Signature

func (t Tx) Signature() []byte

func (Tx) Unmarshal

func (t Tx) Unmarshal(i interface{}) error

type TxCodec

type TxCodec struct{}

func (*TxCodec) Decode

func (c *TxCodec) Decode(payload []byte, chainID string) (abci.Tx, error)

Decode takes a raw input from a Tendermint Tx and decodes into a vega Tx, the decoding process involves a signature verification.

type ValidatorTopology

type ValidatorTopology interface {
	Len() int
	IsValidatorVegaPubKey(pk string) bool
	IsValidatorNodeID(nodeID string) bool
	AllVegaPubKeys() []string
	IsValidator() bool
	AddKeyRotate(ctx context.Context, nodeID string, currentBlockHeight uint64, kr *commandspb.KeyRotateSubmission) error
	ProcessEthereumKeyRotation(ctx context.Context, nodeID string, kr *commandspb.EthereumKeyRotateSubmission, verify func(message, signature []byte, hexAddress string) error) error
	BeginBlock(ctx context.Context, req abcitypes.RequestBeginBlock)
	GetValidatorPowerUpdates() []abcitypes.ValidatorUpdate
	ProcessAnnounceNode(ctx context.Context, nr *commandspb.AnnounceNode) error
	ProcessValidatorHeartbeat(context.Context, *commandspb.ValidatorHeartbeat, func(message, signature, pubkey []byte) error, func(message, signature []byte, hexAddress string) error) error
	AddForwarder(ID string)
	IssueSignatures(ctx context.Context, submitter, nodeID string, kind types.NodeSignatureKind) error
}

type Witness

type Witness interface {
	AddNodeCheck(ctx context.Context, nv *commandspb.NodeVote, key crypto.PublicKey) error
}

Witness ...

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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