relayer

package
v0.0.0-...-be882d2 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2023 License: Apache-2.0 Imports: 43 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// WaitingForWitnesses stands for a transfer which needs more valid witnesses
	WaitingForWitnesses ValidationStatusType = "new"
	// ValidationInProcess stands for a transfer in process
	ValidationInProcess = "processing"
	// ValidationSubmitted stands for a transfer with validation submitted
	ValidationSubmitted = "validated"
	// TransferSettled stands for a transfer which has been settled
	TransferSettled = "settled"
	// ValidationFailed stands for the validation of a transfer failed
	ValidationFailed = "failed"
	// ValidationRejected stands for the validation of a transfer is rejected
	ValidationRejected = "rejected"
)

Variables

This section is empty.

Functions

func StartServer

func StartServer(srv *Service, grpcPort int, grpcProxyPort int)

Types

type Recorder

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

Recorder is a logger based on sql to record exchange events

func NewRecorder

func NewRecorder(
	store *db.SQLStore,
	explorerStore *db.SQLStore,
	transferTableName string,
	witnessTableName string,
	explorerTableName string,
) *Recorder

NewRecorder returns a recorder for exchange

func (*Recorder) AddWitness

func (recorder *Recorder) AddWitness(transfer *Transfer, witness *Witness) error

AddWitness records a new witness

func (*Recorder) Count

func (recorder *Recorder) Count(opts ...TransferQueryOption) (int, error)

Count returns the number of records of given restrictions

func (*Recorder) MarkAsFailed

func (recorder *Recorder) MarkAsFailed(id common.Hash) error

MarkAsFailed marks a record as failed

func (*Recorder) MarkAsProcessing

func (recorder *Recorder) MarkAsProcessing(id common.Hash) error

MarkAsProcessing marks a record as processing

func (*Recorder) MarkAsRejected

func (recorder *Recorder) MarkAsRejected(id common.Hash) error

MarkAsRejected marks a record as failed

func (*Recorder) MarkAsSettled

func (recorder *Recorder) MarkAsSettled(id common.Hash, gas uint64, ts time.Time) error

MarkAsSettled marks a record as settled

func (*Recorder) MarkAsValidated

func (recorder *Recorder) MarkAsValidated(id common.Hash, txhash common.Hash, relayer common.Address, nonce uint64, gasPrice *big.Int) error

MarkAsValidated marks a transfer as validated

func (*Recorder) Reset

func (recorder *Recorder) Reset(id common.Hash) error

Reset marks a record as new

func (*Recorder) ResetCausedByNonce

func (recorder *Recorder) ResetCausedByNonce(id common.Hash) error

ResetCausedByNonce marks a record as new

func (*Recorder) Start

func (recorder *Recorder) Start(ctx context.Context) error

Start starts the recorder

func (*Recorder) Stop

func (recorder *Recorder) Stop(ctx context.Context) error

Stop stops the recorder

func (*Recorder) Transfer

func (recorder *Recorder) Transfer(id common.Hash) (*Transfer, error)

Transfer returns the validation tx related information of a given transfer

func (*Recorder) Transfers

func (recorder *Recorder) Transfers(
	offset uint32,
	limit uint8,
	byUpdateTime bool,
	desc bool,
	queryOpts ...TransferQueryOption,
) ([]*Transfer, error)

Transfers returns the list of records of given status

func (*Recorder) UpdateRecord

func (recorder *Recorder) UpdateRecord(id common.Hash, txhash common.Hash, relayer common.Address, nonce uint64, gasPrice *big.Int) error

UpdateRecord updates a transfer gas price

func (*Recorder) Witnesses

func (recorder *Recorder) Witnesses(ids ...common.Hash) (map[common.Hash][]*Witness, error)

Witnesses returns the witnesses of a transfer

type Service

type Service struct {
	services.UnimplementedRelayServiceServer
	// contains filtered or unexported fields
}

Service defines the relayer service

func NewService

func NewService(tv TransferValidator, recorder *Recorder, interval time.Duration) (*Service, error)

NewService creates a new relay service

func (*Service) Check

Check checks the status of a transfer

func (*Service) List

List lists the recent transfers

func (*Service) Start

func (s *Service) Start(ctx context.Context) error

Start starts the service

func (*Service) Stop

func (s *Service) Stop(ctx context.Context) error

Stop stops the service

func (*Service) Submit

Submit accepts a submission of witness

type StatusOnChainType

type StatusOnChainType int

StatusOnChainType type of transfer status on chain

const (
	StatusOnChainUnknown StatusOnChainType = iota
	StatusOnChainNotConfirmed
	StatusOnChainNeedSpeedUp
	StatusOnChainRejected
	StatusOnChainNonceOverwritten
	StatusOnChainSettled
)

type Transfer

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

Transfer defines a transfer structure

func UnmarshalTransferProto

func UnmarshalTransferProto(validatorAddr common.Address, transfer *types.Transfer) (*Transfer, error)

UnmarshalTransferProto unmarshals a transfer proto

func (*Transfer) ID

func (transfer *Transfer) ID() common.Hash

func (*Transfer) Status

func (transfer *Transfer) Status() ValidationStatusType

func (*Transfer) ToTypesTransfer

func (transfer *Transfer) ToTypesTransfer() *types.Transfer

func (*Transfer) TxHash

func (transfer *Transfer) TxHash() common.Hash

type TransferQueryOption

type TransferQueryOption func() (string, []interface{})

func CashiersQueryOption

func CashiersQueryOption(cashiers []common.Address) TransferQueryOption

func ExcludeTokenQueryOption

func ExcludeTokenQueryOption(token common.Address) TransferQueryOption

func RecipientQueryOption

func RecipientQueryOption(recipient common.Address) TransferQueryOption

func SenderQueryOption

func SenderQueryOption(sender common.Address) TransferQueryOption

func StatusQueryOption

func StatusQueryOption(statuses ...ValidationStatusType) TransferQueryOption

func TokenQueryOption

func TokenQueryOption(token common.Address) TransferQueryOption

type TransferValidator

type TransferValidator interface {
	// Size returns the number of relayers
	Size() int
	// Address returns the transfer validator contract address
	Address() common.Address
	// Check returns transfer status on chain
	Check(transfer *Transfer) (StatusOnChainType, error)
	// Submit submits validation for a transfer
	Submit(transfer *Transfer, witnesses []*Witness) (common.Hash, common.Address, uint64, *big.Int, error)
	// SpeedUp resubmits validation with higher gas price
	SpeedUp(transfer *Transfer, witnesses []*Witness) (common.Hash, common.Address, uint64, *big.Int, error)
}

TransferValidator defines the interface of a transfer validator

func NewTransferValidatorOnEthereum

func NewTransferValidatorOnEthereum(
	client *ethclient.Client,
	privateKeys []*ecdsa.PrivateKey,
	confirmBlockNumber uint16,
	defaultGasPrice *big.Int,
	gasPriceLimit *big.Int,
	gasPriceDeviation *big.Int,
	gasPriceGap *big.Int,
	validatorContractAddr common.Address,
) (TransferValidator, error)

NewTransferValidatorOnEthereum creates a new TransferValidator

func NewTransferValidatorOnIoTeX

func NewTransferValidatorOnIoTeX(
	client iotex.AuthedClient,
	validatorContractAddr address.Address,
) (TransferValidator, error)

NewTransferValidatorOnIoTeX creates a new TransferValidator on IoTeX

type ValidationStatusType

type ValidationStatusType string

ValidationStatusType type of transfer validation status

type Witness

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

Witness defines a witness structure

func NewWitness

func NewWitness(witnessAddr common.Address, signature []byte) (*Witness, error)

NewWitness creates a new witness struct

func (*Witness) Address

func (w *Witness) Address() common.Address

Jump to

Keyboard shortcuts

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