Documentation ¶
Index ¶
- Constants
- type ClientFlushIDControl
- type ClientSynchronizer
- func (s *ClientSynchronizer) CheckFlushID(dbTx pgx.Tx) error
- func (s *ClientSynchronizer) CleanTrustedState()
- func (s *ClientSynchronizer) IsTrustedSequencer() bool
- func (s *ClientSynchronizer) PendingFlushID(flushID uint64, proverID string)
- func (s *ClientSynchronizer) ProcessBlockRange(blocks []etherman.Block, order map[common.Hash][]etherman.Order) error
- func (s *ClientSynchronizer) RequestAndProcessRollupGenesisBlock(dbTx pgx.Tx, lastEthBlockSynced *state.Block) error
- func (s *ClientSynchronizer) Stop()
- func (s *ClientSynchronizer) Sync() error
- type Config
- type ExtCmdArgs
- type ExtControlCmd
- type FlushIDController
- type L1ParallelSynchronizationConfig
- type L1PerformanceCheckConfig
- type Synchronizer
- type TrustedState
Constants ¶
const ( // ParallelMode is the value for L1SynchronizationMode to run in parallel mode ParallelMode = "parallel" // SequentialMode is the value for L1SynchronizationMode to run in sequential mode SequentialMode = "sequential" )
const (
//L2BlockHeaderForGenesis = "0b73e6af6f00000000"
L2BlockHeaderForGenesis = "0b0000000000000000"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClientFlushIDControl ¶ added in v0.0.990
type ClientFlushIDControl struct {
// contains filtered or unexported fields
}
ClientFlushIDControl is a struct to control the flushID and ProverID, implements FlushIDController interface
func NewFlushIDController ¶ added in v0.0.990
func NewFlushIDController(state syncinterfaces.StateFullInterface, ctx context.Context, eventLog *event.EventLog) *ClientFlushIDControl
NewFlushIDController create a new struct ClientFlushIDControl
func (*ClientFlushIDControl) BlockUntilLastFlushIDIsWritten ¶ added in v0.0.990
func (s *ClientFlushIDControl) BlockUntilLastFlushIDIsWritten(dbTx pgx.Tx) error
BlockUntilLastFlushIDIsWritten blocks until the last flushID is written in DB. It keep in a loop asking to executor the flushid written, also check ProverID
func (*ClientFlushIDControl) SetPendingFlushIDAndCheckProverID ¶ added in v0.0.990
func (s *ClientFlushIDControl) SetPendingFlushIDAndCheckProverID(flushID uint64, proverID string, callDescription string)
SetPendingFlushIDAndCheckProverID set the pending flushID to be written in DB and check proverID
func (*ClientFlushIDControl) UpdateAndCheckProverID ¶ added in v0.0.990
func (s *ClientFlushIDControl) UpdateAndCheckProverID(proverID string)
UpdateAndCheckProverID check the incomming proverID from executor with the last one, if no match finalize synchronizer if there are no previous one it keep this value as the current one
type ClientSynchronizer ¶
type ClientSynchronizer struct {
// contains filtered or unexported fields
}
ClientSynchronizer connects L1 and L2
func (*ClientSynchronizer) CheckFlushID ¶ added in v0.5.0
func (s *ClientSynchronizer) CheckFlushID(dbTx pgx.Tx) error
CheckFlushID is called when a flushID is pending to be stored in the db
func (*ClientSynchronizer) CleanTrustedState ¶ added in v0.5.0
func (s *ClientSynchronizer) CleanTrustedState()
CleanTrustedState Clean cache of TrustedBatches and StateRoot
func (*ClientSynchronizer) IsTrustedSequencer ¶ added in v0.5.0
func (s *ClientSynchronizer) IsTrustedSequencer() bool
IsTrustedSequencer returns true is a running in a trusted sequencer
func (*ClientSynchronizer) PendingFlushID ¶ added in v0.5.0
func (s *ClientSynchronizer) PendingFlushID(flushID uint64, proverID string)
PendingFlushID is called when a flushID is pending to be stored in the db
func (*ClientSynchronizer) ProcessBlockRange ¶ added in v0.5.0
func (s *ClientSynchronizer) ProcessBlockRange(blocks []etherman.Block, order map[common.Hash][]etherman.Order) error
ProcessBlockRange process the L1 events and stores the information in the db
func (*ClientSynchronizer) RequestAndProcessRollupGenesisBlock ¶ added in v0.6.0
func (s *ClientSynchronizer) RequestAndProcessRollupGenesisBlock(dbTx pgx.Tx, lastEthBlockSynced *state.Block) error
RequestAndProcessRollupGenesisBlock it requests the rollup genesis block and processes it
and execute it
func (*ClientSynchronizer) Stop ¶
func (s *ClientSynchronizer) Stop()
Stop function stops the synchronizer
func (*ClientSynchronizer) Sync ¶
func (s *ClientSynchronizer) Sync() error
Sync function will read the last state synced and will continue from that point. Sync() will read blockchain events to detect rollup updates
type Config ¶
type Config struct { // SyncInterval is the delay interval between reading new rollup information SyncInterval types.Duration `mapstructure:"SyncInterval"` // SyncChunkSize is the number of blocks to sync on each chunk SyncChunkSize uint64 `mapstructure:"SyncChunkSize"` // TrustedSequencerURL is the rpc url to connect and sync the trusted state TrustedSequencerURL string `mapstructure:"TrustedSequencerURL"` // L1SyncCheckL2BlockHash if is true when a batch is closed is force to check L2Block hash against trustedNode (only apply for permissionless) L1SyncCheckL2BlockHash bool `mapstructure:"L1SyncCheckL2BlockHash"` // L1SyncCheckL2BlockNumberhModulus is the modulus used to choose the l2block to check // a modules 5, for instance, means check all l2block multiples of 5 (10,15,20,...) L1SyncCheckL2BlockNumberhModulus uint64 `mapstructure:"L1SyncCheckL2BlockNumberhModulus"` // L1SynchronizationMode define how to synchronize with L1: // - parallel: Request data to L1 in parallel, and process sequentially. The advantage is that executor is not blocked waiting for L1 data // - sequential: Request data to L1 and execute L1SynchronizationMode string `jsonschema:"enum=sequential,enum=parallel"` // L1ParallelSynchronization Configuration for parallel mode (if L1SynchronizationMode equal to 'parallel') L1ParallelSynchronization L1ParallelSynchronizationConfig // L2Synchronization Configuration for L2 synchronization L2Synchronization l2_sync.Config `mapstructure:"L2Synchronization"` }
Config represents the configuration of the synchronizer
type ExtCmdArgs ¶ added in v0.6.1
type ExtCmdArgs []string
ExtCmdArgs is the type of the arguments of the command
type ExtControlCmd ¶ added in v0.6.1
type ExtControlCmd interface { // FunctionName returns the name of the function to be called example: "l1_producer_stop" FunctionName() string // ValidateArguments validates the arguments of the command, returns nil if ok, error if not ValidateArguments(ExtCmdArgs) error // Process the command // args: the arguments of the command // return: string with the output and an error Process(ExtCmdArgs) (string, error) // Help returns the help of the command Help() string }
ExtControlCmd is the interface of the external command
type FlushIDController ¶ added in v0.0.990
type FlushIDController interface { // UpdateAndCheckProverID check the incomming proverID from executor with the last one, if no match finalize synchronizer // if there are no previous one it keep this value as the current one UpdateAndCheckProverID(proverID string) // BlockUntilLastFlushIDIsWritten blocks until the last flushID is written in DB. It keep in a loop asking to executor // the flushid written, also check ProverID BlockUntilLastFlushIDIsWritten(dbTx pgx.Tx) error // SetPendingFlushIDAndCheckProverID set the pending flushID to be written in DB and check proverID SetPendingFlushIDAndCheckProverID(flushID uint64, proverID string, callDescription string) }
FlushIDController is an interface to control the flushID and ProverID
type L1ParallelSynchronizationConfig ¶ added in v0.0.990
type L1ParallelSynchronizationConfig struct { // MaxClients Number of clients used to synchronize with L1 MaxClients uint64 // MaxPendingNoProcessedBlocks Size of the buffer used to store rollup information from L1, must be >= to NumberOfEthereumClientsToSync // sugested twice of NumberOfParallelOfEthereumClients MaxPendingNoProcessedBlocks uint64 // RequestLastBlockPeriod is the time to wait to request the // last block to L1 to known if we need to retrieve more data. // This value only apply when the system is synchronized RequestLastBlockPeriod types.Duration // Consumer Configuration for the consumer of rollup information from L1 PerformanceWarning L1PerformanceCheckConfig // RequestLastBlockTimeout Timeout for request LastBlock On L1 RequestLastBlockTimeout types.Duration // RequestLastBlockMaxRetries Max number of retries to request LastBlock On L1 RequestLastBlockMaxRetries int // StatisticsPeriod how ofter show a log with statistics (0 is disabled) StatisticsPeriod types.Duration // TimeOutMainLoop is the timeout for the main loop of the L1 synchronizer when is not updated TimeOutMainLoop types.Duration // RollupInfoRetriesSpacing is the minimum time between retries to request rollup info (it will sleep for fulfill this time) to avoid spamming L1 RollupInfoRetriesSpacing types.Duration // FallbackToSequentialModeOnSynchronized if true switch to sequential mode if the system is synchronized FallbackToSequentialModeOnSynchronized bool }
L1ParallelSynchronizationConfig Configuration for parallel mode (if UL1SynchronizationMode equal to 'parallel')
type L1PerformanceCheckConfig ¶ added in v0.0.990
type L1PerformanceCheckConfig struct { // AceptableInacctivityTime is the expected maximum time that the consumer // could wait until new data is produced. If the time is greater it emmit a log to warn about // that. The idea is keep working the consumer as much as possible, so if the producer is not // fast enought then you could increse the number of parallel clients to sync with L1 AceptableInacctivityTime types.Duration // ApplyAfterNumRollupReceived is the number of iterations to // start checking the time waiting for new rollup info data ApplyAfterNumRollupReceived int }
L1PerformanceCheckConfig Configuration for the consumer of rollup information from L1
type Synchronizer ¶
type Synchronizer interface { Sync() error Stop() }
Synchronizer connects L1 and L2
func NewSynchronizer ¶
func NewSynchronizer( isTrustedSequencer bool, ethMan syncinterfaces.EthermanFullInterface, etherManForL1 []syncinterfaces.EthermanFullInterface, st syncinterfaces.StateFullInterface, pool syncinterfaces.PoolInterface, ethTxManager syncinterfaces.EthTxManager, zkEVMClient syncinterfaces.ZKEVMClientInterface, eventLog syncinterfaces.EventLogInterface, genesis state.Genesis, cfg Config, runInDevelopmentMode bool) (Synchronizer, error)
NewSynchronizer creates and initializes an instance of Synchronizer
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
package synchronizer This file contains common struct definitions and functions used by L1 sync.
|
package synchronizer This file contains common struct definitions and functions used by L1 sync. |
l2_shared
// https://www.digitalocean.com/community/tutorials/how-to-add-extra-information-to-errors-in-go
|
// https://www.digitalocean.com/community/tutorials/how-to-add-extra-information-to-errors-in-go |