Documentation ¶
Index ¶
- Constants
- Variables
- type ClaimTxManager
- type ComposeCompressClaim
- type CompressClaimParameters
- type Config
- type ConfigGroupingClaims
- type EthermanI
- type GroupsTrigger
- type GrupedTxs
- type MonitorCompressedTxs
- func (tm *MonitorCompressedTxs) CanSendNewClaimCall(group *ctmtypes.MonitoredTxGroup) bool
- func (tm *MonitorCompressedTxs) CheckReceipts(ctx context.Context, pendingTx *PendingTxs) error
- func (tm *MonitorCompressedTxs) MonitorTxs(ctx context.Context) error
- func (tm *MonitorCompressedTxs) OnFailGroup(group *ctmtypes.MonitoredTxGroup)
- func (tm *MonitorCompressedTxs) OnFinishClaimGroupTxFailed(group *ctmtypes.MonitoredTxGroup, txIndex int, msg string)
- func (tm *MonitorCompressedTxs) OnFinishClaimGroupTxSuccessful(group *ctmtypes.MonitoredTxGroup, txIndex int)
- func (tm *MonitorCompressedTxs) OutdateClaims(pendingTx *PendingTxs) error
- func (tm *MonitorCompressedTxs) Process(ctx context.Context, pendingTxs *PendingTxs) error
- func (tm *MonitorCompressedTxs) SendClaims(pendingTx *PendingTxs, onlyFirstOne bool) error
- type MonitorTxs
- type NonceCache
- type PendingTxs
- type StorageCompressedInterface
- type StorageInterface
- type StoreChanges
- func (sc *StoreChanges) AddGroup(group ctmtypes.MonitoredTxGroupDBEntry)
- func (sc *StoreChanges) Execute(ctx context.Context, storage StorageCompressedInterface, dbTx pgx.Tx) error
- func (sc *StoreChanges) UpdateGroup(group ctmtypes.MonitoredTxGroupDBEntry)
- func (sc *StoreChanges) UpdateTx(tx ctmtypes.MonitoredTx)
Constants ¶
const (
LeafTypeMessage = uint8(1)
)
const (
MinTxPerGroup = 2
)
Variables ¶
var ( ErrNotImplemented = errors.New("not implemented") ErrMethodUnknown = errors.New("method unknown") )
Functions ¶
This section is empty.
Types ¶
type ClaimTxManager ¶
type ClaimTxManager struct {
// contains filtered or unexported fields
}
ClaimTxManager is the claim transaction manager for L2.
func NewClaimTxManager ¶
func NewClaimTxManager(ctx context.Context, cfg Config, chExitRootEvent chan *etherman.GlobalExitRoot, chSynced chan uint, l2NodeURL string, l2NetworkID uint, l2BridgeAddr common.Address, bridgeService bridgeServiceInterface, storage interface{}, rollupID uint, etherMan EthermanI, nonceCache *NonceCache, auth *bind.TransactOpts) (*ClaimTxManager, error)
NewClaimTxManager creates a new claim transaction manager.
func (*ClaimTxManager) ReviewMonitoredTx ¶
func (tm *ClaimTxManager) ReviewMonitoredTx(ctx context.Context, mTx *ctmtypes.MonitoredTx, reviewNonce bool) error
ReviewMonitoredTx checks if tx needs to be updated accordingly to the current information stored and the current state of the blockchain
func (*ClaimTxManager) Start ¶
func (tm *ClaimTxManager) Start()
Start will start the tx management, reading txs from storage, send then to the blockchain and keep monitoring them until they get mined
type ComposeCompressClaim ¶ added in v0.5.0
type ComposeCompressClaim struct {
// contains filtered or unexported fields
}
func NewComposeCompressClaim ¶ added in v0.5.0
func NewComposeCompressClaim() (*ComposeCompressClaim, error)
func (*ComposeCompressClaim) GetCompressClaimParameters ¶ added in v0.5.0
func (c *ComposeCompressClaim) GetCompressClaimParameters(txsData map[uint64][]byte) (*CompressClaimParameters, error)
GetCompressClaimParameters returns the parameters for the compressClaim method txData = map [depositID] = txData
func (*ComposeCompressClaim) GetCompressClaimParametersFromMonitoredTx ¶ added in v0.5.0
func (c *ComposeCompressClaim) GetCompressClaimParametersFromMonitoredTx(txs []ctmtypes.MonitoredTx) (*CompressClaimParameters, error)
type CompressClaimParameters ¶ added in v0.5.0
type CompressClaimParameters struct { MainnetExitRoot common.Hash RollupExitRoot common.Hash ClaimData []claimcompressor.ClaimCompressorCompressClaimCallData }
type Config ¶
type Config struct { //Enabled whether to enable this module Enabled bool `mapstructure:"Enabled"` // FrequencyToMonitorTxs frequency of the resending failed txs FrequencyToMonitorTxs types.Duration `mapstructure:"FrequencyToMonitorTxs"` // PrivateKey defines the key store file that is going // to be read in order to provide the private key to sign the claim txs PrivateKey types.KeystoreFileConfig `mapstructure:"PrivateKey"` // RetryInterval is time between each retry RetryInterval types.Duration `mapstructure:"RetryInterval"` // RetryNumber is the number of retries before giving up RetryNumber int `mapstructure:"RetryNumber"` // AuthorizedClaimMessageAddresses are the allowed address to bridge message with autoClaim AuthorizedClaimMessageAddresses []common.Address `mapstructure:"AuthorizedClaimMessageAddresses"` // GroupingClaims is the configuration for grouping claims GroupingClaims ConfigGroupingClaims `mapstructure:"GroupingClaims"` }
Config is configuration for L2 claim transaction manager
type ConfigGroupingClaims ¶ added in v0.5.0
type ConfigGroupingClaims struct { //Enabled whether to enable this module Enabled bool `mapstructure:"Enabled"` //FrequencyToProcessCompressedClaims wait time to process compressed claims FrequencyToProcessCompressedClaims types.Duration `mapstructure:"FrequencyToProcessCompressedClaims"` // TriggerNumberOfClaims is the number of claims to trigger sending the grouped claim tx TriggerNumberOfClaims int `mapstructure:"TriggerNumberOfClaims"` // MaxNumberOfClaimsPerGroup is the maximum number of claims per group MaxNumberOfClaimsPerGroup int `mapstructure:"MaxNumberOfClaimsPerGroup"` // TriggerRetainedClaimPeriod is maximum time that a claim can be retainer before creating a group TriggerRetainedClaimPeriod types.Duration `mapstructure:"TriggerRetainedClaimPeriod"` // MaxRetries is the maximum number of retries to send a compressed claim tx MaxRetries int `mapstructure:"MaxRetries"` // RetryInterval is time between each retry RetryInterval types.Duration `mapstructure:"RetryInterval"` // RetryTimeout is the maximum time to wait for a claim tx to be mined RetryTimeout types.Duration `mapstructure:"RetryTimeout"` }
type EthermanI ¶ added in v0.5.0
type EthermanI interface { CompressClaimCall(mainnetExitRoot, rollupExitRoot common.Hash, claimData []claimcompressor.ClaimCompressorCompressClaimCallData) ([]byte, error) SendCompressedClaims(auth *bind.TransactOpts, compressedTxData []byte) (common.Hash, error) }
type GroupsTrigger ¶ added in v0.5.0
type GroupsTrigger struct {
Cfg ConfigGroupingClaims
}
func NewGroupsTrigger ¶ added in v0.5.0
func NewGroupsTrigger(cfg ConfigGroupingClaims) *GroupsTrigger
func (*GroupsTrigger) ChooseTxs ¶ added in v0.5.0
func (t *GroupsTrigger) ChooseTxs(now time.Time, TxCandidatesForGroup []ctmtypes.MonitoredTx) []ctmtypes.MonitoredTx
type GrupedTxs ¶ added in v0.5.0
type GrupedTxs struct { // Status can be Compressing or Claiming Status ctmtypes.MonitoredTxStatus // Txs is a list of monitored txs Txs []ctmtypes.MonitoredTx // CompressingTxHash is the hash of the tx that will be used to compress the txs CompressingTxHash *common.Hash // ClaimingTxHash is the hash of the tx that will be used to claim the txs ClaimingTxHash *common.Hash }
type MonitorCompressedTxs ¶ added in v0.5.0
type MonitorCompressedTxs struct {
// contains filtered or unexported fields
}
func NewMonitorCompressedTxs ¶ added in v0.5.0
func NewMonitorCompressedTxs(ctx context.Context, storage StorageCompressedInterface, l2Node *utils.Client, cfg Config, nonceCache *NonceCache, auth *bind.TransactOpts, etherMan EthermanI, timeProvider utils.TimeProvider) *MonitorCompressedTxs
func (*MonitorCompressedTxs) CanSendNewClaimCall ¶ added in v0.5.0
func (tm *MonitorCompressedTxs) CanSendNewClaimCall(group *ctmtypes.MonitoredTxGroup) bool
func (*MonitorCompressedTxs) CheckReceipts ¶ added in v0.5.0
func (tm *MonitorCompressedTxs) CheckReceipts(ctx context.Context, pendingTx *PendingTxs) error
func (*MonitorCompressedTxs) MonitorTxs ¶ added in v0.5.0
func (tm *MonitorCompressedTxs) MonitorTxs(ctx context.Context) error
monitorTxs process all pending monitored tx
func (*MonitorCompressedTxs) OnFailGroup ¶ added in v0.5.0
func (tm *MonitorCompressedTxs) OnFailGroup(group *ctmtypes.MonitoredTxGroup)
func (*MonitorCompressedTxs) OnFinishClaimGroupTxFailed ¶ added in v0.5.0
func (tm *MonitorCompressedTxs) OnFinishClaimGroupTxFailed(group *ctmtypes.MonitoredTxGroup, txIndex int, msg string)
func (*MonitorCompressedTxs) OnFinishClaimGroupTxSuccessful ¶ added in v0.5.0
func (tm *MonitorCompressedTxs) OnFinishClaimGroupTxSuccessful(group *ctmtypes.MonitoredTxGroup, txIndex int)
OnFinishClaimGroupTx is called when a claim tx is mined successful
func (*MonitorCompressedTxs) OutdateClaims ¶ added in v0.5.0
func (tm *MonitorCompressedTxs) OutdateClaims(pendingTx *PendingTxs) error
func (*MonitorCompressedTxs) Process ¶ added in v0.5.0
func (tm *MonitorCompressedTxs) Process(ctx context.Context, pendingTxs *PendingTxs) error
func (*MonitorCompressedTxs) SendClaims ¶ added in v0.5.0
func (tm *MonitorCompressedTxs) SendClaims(pendingTx *PendingTxs, onlyFirstOne bool) error
type MonitorTxs ¶ added in v0.5.0
type MonitorTxs struct {
// contains filtered or unexported fields
}
func NewMonitorTxs ¶ added in v0.5.0
func NewMonitorTxs(ctx context.Context, storage StorageInterface, l2Node *utils.Client, cfg Config, nonceCache *NonceCache, auth *bind.TransactOpts) *MonitorTxs
func (*MonitorTxs) MonitorTxs ¶ added in v0.5.0
func (tm *MonitorTxs) MonitorTxs(ctx context.Context) error
MonitorTxs process all pending monitored tx
func (*MonitorTxs) ReviewMonitoredTx ¶ added in v0.5.0
func (tm *MonitorTxs) ReviewMonitoredTx(ctx context.Context, mTx *ctmtypes.MonitoredTx, reviewNonce bool) error
ReviewMonitoredTx checks if tx needs to be updated accordingly to the current information stored and the current state of the blockchain
type NonceCache ¶ added in v0.5.0
type NonceCache struct {
// contains filtered or unexported fields
}
func NewNonceCache ¶ added in v0.5.0
func (*NonceCache) GetNextNonce ¶ added in v0.5.0
func (tm *NonceCache) GetNextNonce(from common.Address) (uint64, error)
func (*NonceCache) Remove ¶ added in v0.5.0
func (tm *NonceCache) Remove(from string)
type PendingTxs ¶ added in v0.5.0
type PendingTxs struct { GroupTx map[uint64]*ctmtypes.MonitoredTxGroup TxCandidatesForGroup []ctmtypes.MonitoredTx LastGroupTxID uint64 }
func NewPendingTxs ¶ added in v0.5.0
func NewPendingTxs(mTxs []ctmtypes.MonitoredTx, groups map[uint64]ctmtypes.MonitoredTxGroupDBEntry, lastGroupID uint64) (PendingTxs, error)
func (*PendingTxs) AddGroup ¶ added in v0.5.0
func (m *PendingTxs) AddGroup(group ctmtypes.MonitoredTxGroup)
func (*PendingTxs) GenerateNewGroupID ¶ added in v0.5.0
func (m *PendingTxs) GenerateNewGroupID() uint64
func (*PendingTxs) IsEmpty ¶ added in v0.5.0
func (m *PendingTxs) IsEmpty() bool
func (*PendingTxs) SetGroupDBEntry ¶ added in v0.5.0
func (m *PendingTxs) SetGroupDBEntry(group ctmtypes.MonitoredTxGroupDBEntry)
type StorageCompressedInterface ¶ added in v0.5.0
type StorageCompressedInterface interface { GetClaimTxsByStatus(ctx context.Context, statuses []ctmtypes.MonitoredTxStatus, dbTx pgx.Tx) ([]ctmtypes.MonitoredTx, error) GetMonitoredTxsGroups(ctx context.Context, groupIds []uint64, dbTx pgx.Tx) (map[uint64]ctmtypes.MonitoredTxGroupDBEntry, error) AddMonitoredTxsGroup(ctx context.Context, mTxGroup *ctmtypes.MonitoredTxGroupDBEntry, dbTx pgx.Tx) error UpdateClaimTx(ctx context.Context, mTx ctmtypes.MonitoredTx, dbTx pgx.Tx) error GetLatestMonitoredTxGroupID(ctx context.Context, dbTx pgx.Tx) (uint64, error) UpdateMonitoredTxsGroup(ctx context.Context, mTxGroup *ctmtypes.MonitoredTxGroupDBEntry, dbTx pgx.Tx) error // atomic Rollback(ctx context.Context, dbTx pgx.Tx) error BeginDBTransaction(ctx context.Context) (pgx.Tx, error) Commit(ctx context.Context, dbTx pgx.Tx) error }
type StorageInterface ¶ added in v0.5.0
type StorageInterface interface { AddBlock(ctx context.Context, block *etherman.Block, dbTx pgx.Tx) (uint64, error) UpdateL1DepositsStatus(ctx context.Context, exitRoot []byte, dbTx pgx.Tx) ([]*etherman.Deposit, error) UpdateL2DepositsStatus(ctx context.Context, exitRoot []byte, rollupID, networkID uint, dbTx pgx.Tx) error AddClaimTx(ctx context.Context, mTx types.MonitoredTx, dbTx pgx.Tx) error UpdateClaimTx(ctx context.Context, mTx types.MonitoredTx, dbTx pgx.Tx) error GetClaimTxsByStatus(ctx context.Context, statuses []types.MonitoredTxStatus, dbTx pgx.Tx) ([]types.MonitoredTx, error) // atomic Rollback(ctx context.Context, dbTx pgx.Tx) error BeginDBTransaction(ctx context.Context) (pgx.Tx, error) Commit(ctx context.Context, dbTx pgx.Tx) error }
type StoreChanges ¶ added in v0.5.0
type StoreChanges struct { AddGroups []ctmtypes.MonitoredTxGroupDBEntry UpdateGroups []ctmtypes.MonitoredTxGroupDBEntry UpdateTxs []ctmtypes.MonitoredTx }
func GenerateStoreUpdate ¶ added in v0.5.0
func GenerateStoreUpdate(oldState, newState PendingTxs, timeProvider utils.TimeProvider) (*StoreChanges, error)
GenerateStoreUpdate generates the changes that need to be done in the storage
func NewStoreChanges ¶ added in v0.5.0
func NewStoreChanges() *StoreChanges
func (*StoreChanges) AddGroup ¶ added in v0.5.0
func (sc *StoreChanges) AddGroup(group ctmtypes.MonitoredTxGroupDBEntry)
func (*StoreChanges) Execute ¶ added in v0.5.0
func (sc *StoreChanges) Execute(ctx context.Context, storage StorageCompressedInterface, dbTx pgx.Tx) error
func (*StoreChanges) UpdateGroup ¶ added in v0.5.0
func (sc *StoreChanges) UpdateGroup(group ctmtypes.MonitoredTxGroupDBEntry)
func (*StoreChanges) UpdateTx ¶ added in v0.5.0
func (sc *StoreChanges) UpdateTx(tx ctmtypes.MonitoredTx)