github.com/0xPolygon/supernets2-node@v0.0.0-20230711153321-2fe574524eaa/sequencer/config.go (about)

     1  package sequencer
     2  
     3  import (
     4  	"github.com/0xPolygon/supernets2-node/config/types"
     5  )
     6  
     7  // Config represents the configuration of a sequencer
     8  type Config struct {
     9  	// WaitPeriodPoolIsEmpty is the time the sequencer waits until
    10  	// trying to add new txs to the state
    11  	WaitPeriodPoolIsEmpty types.Duration `mapstructure:"WaitPeriodPoolIsEmpty"`
    12  
    13  	// BlocksAmountForTxsToBeDeleted is blocks amount after which txs will be deleted from the pool
    14  	BlocksAmountForTxsToBeDeleted uint64 `mapstructure:"BlocksAmountForTxsToBeDeleted"`
    15  
    16  	// FrequencyToCheckTxsForDelete is frequency with which txs will be checked for deleting
    17  	FrequencyToCheckTxsForDelete types.Duration `mapstructure:"FrequencyToCheckTxsForDelete"`
    18  
    19  	// MaxTxsPerBatch is the maximum amount of transactions in the batch
    20  	MaxTxsPerBatch uint64 `mapstructure:"MaxTxsPerBatch"`
    21  
    22  	// MaxBatchBytesSize is the maximum batch size in bytes
    23  	// (subtracted bits of all types.Sequence fields excluding BatchL2Data from MaxTxSizeForL1)
    24  	MaxBatchBytesSize uint64 `mapstructure:"MaxBatchBytesSize"`
    25  
    26  	// MaxCumulativeGasUsed is max gas amount used by batch
    27  	MaxCumulativeGasUsed uint64 `mapstructure:"MaxCumulativeGasUsed"`
    28  
    29  	// MaxKeccakHashes is max keccak hashes used by batch
    30  	MaxKeccakHashes uint32 `mapstructure:"MaxKeccakHashes"`
    31  
    32  	// MaxPoseidonHashes is max poseidon hashes batch can handle
    33  	MaxPoseidonHashes uint32 `mapstructure:"MaxPoseidonHashes"`
    34  
    35  	// MaxPoseidonPaddings is max poseidon paddings batch can handle
    36  	MaxPoseidonPaddings uint32 `mapstructure:"MaxPoseidonPaddings"`
    37  
    38  	// MaxMemAligns is max mem aligns batch can handle
    39  	MaxMemAligns uint32 `mapstructure:"MaxMemAligns"`
    40  
    41  	// MaxArithmetics is max arithmetics batch can handle
    42  	MaxArithmetics uint32 `mapstructure:"MaxArithmetics"`
    43  
    44  	// MaxBinaries is max binaries batch can handle
    45  	MaxBinaries uint32 `mapstructure:"MaxBinaries"`
    46  
    47  	// MaxSteps is max steps batch can handle
    48  	MaxSteps uint32 `mapstructure:"MaxSteps"`
    49  
    50  	// WeightBatchBytesSize is the cost weight for the BatchBytesSize batch resource
    51  	WeightBatchBytesSize int `mapstructure:"WeightBatchBytesSize"`
    52  
    53  	// WeightCumulativeGasUsed is the cost weight for the CumulativeGasUsed batch resource
    54  	WeightCumulativeGasUsed int `mapstructure:"WeightCumulativeGasUsed"`
    55  
    56  	// WeightKeccakHashes is the cost weight for the KeccakHashes batch resource
    57  	WeightKeccakHashes int `mapstructure:"WeightKeccakHashes"`
    58  
    59  	// WeightPoseidonHashes is the cost weight for the PoseidonHashes batch resource
    60  	WeightPoseidonHashes int `mapstructure:"WeightPoseidonHashes"`
    61  
    62  	// WeightPoseidonPaddings is the cost weight for the PoseidonPaddings batch resource
    63  	WeightPoseidonPaddings int `mapstructure:"WeightPoseidonPaddings"`
    64  
    65  	// WeightMemAligns is the cost weight for the MemAligns batch resource
    66  	WeightMemAligns int `mapstructure:"WeightMemAligns"`
    67  
    68  	// WeightArithmetics is the cost weight for the Arithmetics batch resource
    69  	WeightArithmetics int `mapstructure:"WeightArithmetics"`
    70  
    71  	// WeightBinaries is the cost weight for the Binaries batch resource
    72  	WeightBinaries int `mapstructure:"WeightBinaries"`
    73  
    74  	// WeightSteps is the cost weight for the Steps batch resource
    75  	WeightSteps int `mapstructure:"WeightSteps"`
    76  
    77  	// TxLifetimeCheckTimeout is the time the sequencer waits to check txs lifetime
    78  	TxLifetimeCheckTimeout types.Duration `mapstructure:"TxLifetimeCheckTimeout"`
    79  
    80  	// MaxTxLifetime is the time a tx can be in the sequencer memory
    81  	MaxTxLifetime types.Duration `mapstructure:"MaxTxLifetime"`
    82  
    83  	// Finalizer's specific config properties
    84  	Finalizer FinalizerCfg `mapstructure:"Finalizer"`
    85  
    86  	// DBManager's specific config properties
    87  	DBManager DBManagerCfg `mapstructure:"DBManager"`
    88  
    89  	// Worker's specific config properties
    90  	Worker WorkerCfg `mapstructure:"Worker"`
    91  }
    92  
    93  // FinalizerCfg contains the finalizer's configuration properties
    94  type FinalizerCfg struct {
    95  	// GERDeadlineTimeout is the time the finalizer waits after receiving closing signal to update Global Exit Root
    96  	GERDeadlineTimeout types.Duration `mapstructure:"GERDeadlineTimeout"`
    97  
    98  	// ForcedBatchDeadlineTimeout is the time the finalizer waits after receiving closing signal to process Forced Batches
    99  	ForcedBatchDeadlineTimeout types.Duration `mapstructure:"ForcedBatchDeadlineTimeout"`
   100  
   101  	// SleepDuration is the time the finalizer sleeps between each iteration, if there are no transactions to be processed
   102  	SleepDuration types.Duration `mapstructure:"SleepDuration"`
   103  
   104  	// ResourcePercentageToCloseBatch is the percentage window of the resource left out for the batch to be closed
   105  	ResourcePercentageToCloseBatch uint32 `mapstructure:"ResourcePercentageToCloseBatch"`
   106  
   107  	// GERFinalityNumberOfBlocks is number of blocks to consider GER final
   108  	GERFinalityNumberOfBlocks uint64 `mapstructure:"GERFinalityNumberOfBlocks"`
   109  
   110  	// ClosingSignalsManagerWaitForCheckingL1Timeout is used by the closing signals manager to wait for its operation
   111  	ClosingSignalsManagerWaitForCheckingL1Timeout types.Duration `mapstructure:"ClosingSignalsManagerWaitForCheckingL1Timeout"`
   112  
   113  	// ClosingSignalsManagerWaitForCheckingGER is used by the closing signals manager to wait for its operation
   114  	ClosingSignalsManagerWaitForCheckingGER types.Duration `mapstructure:"ClosingSignalsManagerWaitForCheckingGER"`
   115  
   116  	// ClosingSignalsManagerWaitForCheckingL1Timeout is used by the closing signals manager to wait for its operation
   117  	ClosingSignalsManagerWaitForCheckingForcedBatches types.Duration `mapstructure:"ClosingSignalsManagerWaitForCheckingForcedBatches"`
   118  
   119  	// ForcedBatchesFinalityNumberOfBlocks is number of blocks to consider GER final
   120  	ForcedBatchesFinalityNumberOfBlocks uint64 `mapstructure:"ForcedBatchesFinalityNumberOfBlocks"`
   121  
   122  	// TimestampResolution is the resolution of the timestamp used to close a batch
   123  	TimestampResolution types.Duration `mapstructure:"TimestampResolution"`
   124  }
   125  
   126  // WorkerCfg contains the Worker's configuration properties
   127  type WorkerCfg struct {
   128  	// ResourceCostMultiplier is the multiplier for the resource cost
   129  	ResourceCostMultiplier float64 `mapstructure:"ResourceCostMultiplier"`
   130  }
   131  
   132  // DBManagerCfg contains the DBManager's configuration properties
   133  type DBManagerCfg struct {
   134  	PoolRetrievalInterval    types.Duration `mapstructure:"PoolRetrievalInterval"`
   135  	L2ReorgRetrievalInterval types.Duration `mapstructure:"L2ReorgRetrievalInterval"`
   136  }