claimsponsor

package
v0.4.0-beta2 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2024 License: AGPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PendingClaimStatus = "pending"
	WIPStatus          = "work in progress"
	SuccessClaimStatus = "success"
	FailedClaimStatus  = "failed"
)
View Source
const (
	// LeafTypeAsset represents a bridge asset
	LeafTypeAsset uint8 = 0
	// LeafTypeMessage represents a bridge message
	LeafTypeMessage uint8 = 1
)

Variables

View Source
var (
	ErrInvalidClaim = errors.New("invalid claim")
)

Functions

This section is empty.

Types

type Claim

type Claim struct {
	LeafType            uint8
	ProofLocalExitRoot  tree.Proof
	ProofRollupExitRoot tree.Proof
	GlobalIndex         *big.Int
	MainnetExitRoot     common.Hash
	RollupExitRoot      common.Hash
	OriginNetwork       uint32
	OriginTokenAddress  common.Address
	DestinationNetwork  uint32
	DestinationAddress  common.Address
	Amount              *big.Int
	Metadata            []byte

	Status ClaimStatus
	TxID   string
}

Claim representation of a claim event

func (*Claim) Key

func (c *Claim) Key() []byte

type ClaimSender

type ClaimSender interface {
	// contains filtered or unexported methods
}

type ClaimSponsor

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

func NewEVMClaimSponsor

func NewEVMClaimSponsor(
	logger *log.Logger,
	dbPath string,
	l2Client EthClienter,
	bridge common.Address,
	sender common.Address,
	maxGas, gasOffset uint64,
	ethTxManager EthTxManager,
	retryAfterErrorPeriod time.Duration,
	maxRetryAttemptsAfterError int,
	waitTxToBeMinedPeriod time.Duration,
	waitOnEmptyQueue time.Duration,
) (*ClaimSponsor, error)

func (*ClaimSponsor) AddClaimToQueue

func (c *ClaimSponsor) AddClaimToQueue(ctx context.Context, claim *Claim) error

func (*ClaimSponsor) GetClaim

func (c *ClaimSponsor) GetClaim(ctx context.Context, globalIndex *big.Int) (*Claim, error)

func (*ClaimSponsor) Start

func (c *ClaimSponsor) Start(ctx context.Context)

type ClaimStatus

type ClaimStatus string

type EVMClaimSponsor

type EVMClaimSponsor struct {
	*ClaimSponsor
	// contains filtered or unexported fields
}

type EVMClaimSponsorConfig

type EVMClaimSponsorConfig struct {
	// DBPath path of the DB
	DBPath string `mapstructure:"DBPath"`
	// Enabled indicates if the sponsor should be run or not
	Enabled bool `mapstructure:"Enabled"`
	// SenderAddr is the address that will be used to send the claim txs
	SenderAddr common.Address `mapstructure:"SenderAddr"`
	// BridgeAddrL2 is the address of the bridge smart contract on L2
	BridgeAddrL2 common.Address `mapstructure:"BridgeAddrL2"`
	// MaxGas is the max gas (limit) allowed for a claim to be sponsored
	MaxGas uint64 `mapstructure:"MaxGas"`
	// RetryAfterErrorPeriod is the time that will be waited when an unexpected error happens before retry
	RetryAfterErrorPeriod configTypes.Duration `mapstructure:"RetryAfterErrorPeriod"`
	// MaxRetryAttemptsAfterError is the maximum number of consecutive attempts that will happen before panicing.
	// Any number smaller than zero will be considered as unlimited retries
	MaxRetryAttemptsAfterError int `mapstructure:"MaxRetryAttemptsAfterError"`
	// WaitTxToBeMinedPeriod is the period that will be used to ask if a given tx has been mined (or failed)
	WaitTxToBeMinedPeriod configTypes.Duration `mapstructure:"WaitTxToBeMinedPeriod"`
	// WaitOnEmptyQueue is the time that will be waited before trying to send the next claim of the queue
	// if the queue is empty
	WaitOnEmptyQueue configTypes.Duration `mapstructure:"WaitOnEmptyQueue"`
	// EthTxManager is the configuration of the EthTxManager to be used by the claim sponsor
	EthTxManager ethtxmanager.Config `mapstructure:"EthTxManager"`
	// GasOffset is the gas to add on top of the estimated gas when sending the claim txs
	GasOffset uint64 `mapstructure:"GasOffset"`
}

type EthClienter

type EthClienter interface {
	ethereum.GasEstimator
	bind.ContractBackend
}

type EthTxManager

type EthTxManager interface {
	Remove(ctx context.Context, id common.Hash) error
	ResultsByStatus(ctx context.Context, statuses []ethtxtypes.MonitoredTxStatus) ([]ethtxtypes.MonitoredTxResult, error)
	Result(ctx context.Context, id common.Hash) (ethtxtypes.MonitoredTxResult, error)
	Add(ctx context.Context, to *common.Address, value *big.Int, data []byte,
		gasOffset uint64, sidecar *types.BlobTxSidecar) (common.Hash, error)
}

Jump to

Keyboard shortcuts

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