Documentation ¶
Index ¶
- type Backend
- type Batch
- type Client
- func (c *Client) GetEnqueue(index uint64) (*types.Transaction, error)
- func (c *Client) GetEthContext(blockNumber uint64) (*EthContext, error)
- func (c *Client) GetLastConfirmedEnqueue() (*types.Transaction, error)
- func (c *Client) GetLatestEnqueue() (*types.Transaction, error)
- func (c *Client) GetLatestEnqueueIndex() (*uint64, error)
- func (c *Client) GetLatestEthContext() (*EthContext, error)
- func (c *Client) GetLatestTransaction(backend Backend) (*types.Transaction, error)
- func (c *Client) GetLatestTransactionBatch() (*Batch, []*types.Transaction, error)
- func (c *Client) GetLatestTransactionBatchIndex() (*uint64, error)
- func (c *Client) GetLatestTransactionIndex(backend Backend) (*uint64, error)
- func (c *Client) GetRawTransaction(index uint64, backend Backend) (*TransactionResponse, error)
- func (c *Client) GetTransaction(index uint64, backend Backend) (*types.Transaction, error)
- func (c *Client) GetTransactionBatch(index uint64) (*Batch, []*types.Transaction, error)
- func (c *Client) SyncStatus(backend Backend) (*SyncStatus, error)
- type Config
- type Enqueue
- type EthContext
- type L1GasPrice
- type OVMContext
- type RollupClient
- type SyncService
- func (s *SyncService) GasPriceOracleOwnerAddress() *common.Address
- func (s *SyncService) GetLatestBatchIndex() *uint64
- func (s *SyncService) GetLatestEnqueueIndex() *uint64
- func (s *SyncService) GetLatestIndex() *uint64
- func (s *SyncService) GetLatestL1BlockNumber() uint64
- func (s *SyncService) GetLatestL1Timestamp() uint64
- func (s *SyncService) GetLatestVerifiedIndex() *uint64
- func (s *SyncService) GetNextBatchIndex() uint64
- func (s *SyncService) GetNextEnqueueIndex() uint64
- func (s *SyncService) GetNextIndex() uint64
- func (s *SyncService) GetNextVerifiedIndex() uint64
- func (s *SyncService) IngestTransaction(tx *types.Transaction) error
- func (s *SyncService) IsSyncing() bool
- func (s *SyncService) SequencerLoop()
- func (s *SyncService) SetLatestBatchIndex(index *uint64)
- func (s *SyncService) SetLatestEnqueueIndex(index *uint64)
- func (s *SyncService) SetLatestIndex(index *uint64)
- func (s *SyncService) SetLatestL1BlockNumber(bn uint64)
- func (s *SyncService) SetLatestL1Timestamp(ts uint64)
- func (s *SyncService) SetLatestVerifiedIndex(index *uint64)
- func (s *SyncService) Start() error
- func (s *SyncService) Stop() error
- func (s *SyncService) SubscribeNewTxsEvent(ch chan<- core.NewTxsEvent) event.Subscription
- func (s *SyncService) ValidateAndApplySequencerTransaction(tx *types.Transaction) error
- func (s *SyncService) VerifierLoop()
- type SyncStatus
- type TransactionBatchResponse
- type TransactionResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend uint
Backend represents the type of transactions that are being synced. The different types have different security models.
const ( // BackendL1 Backend involves syncing transactions that have been batched to // Layer One. Once the transactions have been batched to L1, they cannot be // removed assuming that they are not reorganized out of the chain. BackendL1 Backend = iota // BackendL2 Backend involves syncing transactions from the sequencer, // meaning that the transactions may have not been batched to Layer One yet. // This gives higher latency access to the sequencer data but no guarantees // around the transactions as they have not been submitted via a batch to // L1. BackendL2 )
func NewBackend ¶
NewBackend creates a Backend from a human readable string
type Batch ¶
type Batch struct { Index uint64 `json:"index"` Root common.Hash `json:"root,omitempty"` Size uint32 `json:"size,omitempty"` PrevTotalElements uint32 `json:"prevTotalElements,omitempty"` ExtraData hexutil.Bytes `json:"extraData,omitempty"` BlockNumber uint64 `json:"blockNumber"` Timestamp uint64 `json:"timestamp"` Submitter common.Address `json:"submitter"` }
Batch represents the data structure that is submitted with a series of transactions to layer one
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is an HTTP based RollupClient
func (*Client) GetEnqueue ¶
func (c *Client) GetEnqueue(index uint64) (*types.Transaction, error)
GetEnqueue fetches an `enqueue` transaction by queue index
func (*Client) GetEthContext ¶
func (c *Client) GetEthContext(blockNumber uint64) (*EthContext, error)
GetEthContext will return the EthContext by block number
func (*Client) GetLastConfirmedEnqueue ¶
func (c *Client) GetLastConfirmedEnqueue() (*types.Transaction, error)
GetLastConfirmedEnqueue will get the last `enqueue` transaction that has been batched up
func (*Client) GetLatestEnqueue ¶
func (c *Client) GetLatestEnqueue() (*types.Transaction, error)
GetLatestEnqueue fetches the latest `enqueue`, meaning the `enqueue` transaction with the greatest queue index.
func (*Client) GetLatestEnqueueIndex ¶
GetLatestEnqueueIndex returns the latest `enqueue()` index
func (*Client) GetLatestEthContext ¶
func (c *Client) GetLatestEthContext() (*EthContext, error)
GetLatestEthContext will return the latest EthContext
func (*Client) GetLatestTransaction ¶
func (c *Client) GetLatestTransaction(backend Backend) (*types.Transaction, error)
GetLatestTransaction will get the latest transaction, meaning the transaction with the greatest Canonical Transaction Chain index
func (*Client) GetLatestTransactionBatch ¶
func (c *Client) GetLatestTransactionBatch() (*Batch, []*types.Transaction, error)
GetLatestTransactionBatch will return the latest transaction batch
func (*Client) GetLatestTransactionBatchIndex ¶
GetLatestTransactionBatchIndex returns the latest transaction batch index
func (*Client) GetLatestTransactionIndex ¶
GetLatestTransactionIndex returns the latest CTC index that has been batch submitted or not, depending on the backend
func (*Client) GetRawTransaction ¶
func (c *Client) GetRawTransaction(index uint64, backend Backend) (*TransactionResponse, error)
GetTransaction will get a transaction by Canonical Transaction Chain index
func (*Client) GetTransaction ¶
GetTransaction will get a transaction by Canonical Transaction Chain index
func (*Client) GetTransactionBatch ¶
GetTransactionBatch will return the transaction batch by batch index
func (*Client) SyncStatus ¶
func (c *Client) SyncStatus(backend Backend) (*SyncStatus, error)
SyncStatus will query the remote server to determine if it is still syncing
type Config ¶
type Config struct { // Maximum calldata size for a Queue Origin Sequencer Tx MaxCallDataSize int // Verifier mode IsVerifier bool // Enable the sync service Eth1SyncServiceEnable bool // Gas Limit GasLimit uint64 // HTTP endpoint of the data transport layer RollupClientHttp string // Owner of the GasPriceOracle contract GasPriceOracleOwnerAddress common.Address // Turns on checking of state for L2 gas price EnableL2GasPolling bool // Deployment Height of the canonical transaction chain CanonicalTransactionChainDeployHeight *big.Int // Polling interval for rollup client PollInterval time.Duration // Interval for updating the timestamp TimestampRefreshThreshold time.Duration // Represents the source of the transactions that is being synced Backend Backend // Only accept transactions with fees EnforceFees bool // Allow fees within a buffer upwards or downwards // to take fee volatility into account between being // quoted and the transaction being executed FeeThresholdDown *big.Float FeeThresholdUp *big.Float // HTTP endpoint of the sequencer SequencerClientHttp string }
type Enqueue ¶
type Enqueue struct { Index *uint64 `json:"ctcIndex"` Target *common.Address `json:"target"` Data *hexutil.Bytes `json:"data"` GasLimit *uint64 `json:"gasLimit,string"` Origin *common.Address `json:"origin"` BlockNumber *uint64 `json:"blockNumber"` Timestamp *uint64 `json:"timestamp"` QueueIndex *uint64 `json:"index"` }
Enqueue represents an `enqueue` transaction or a L1 to L2 transaction.
type EthContext ¶
type EthContext struct { BlockNumber uint64 `json:"blockNumber"` BlockHash common.Hash `json:"blockHash"` Timestamp uint64 `json:"timestamp"` }
EthContext represents the L1 EVM context that is injected into the OVM at runtime. It is updated with each `enqueue` transaction and needs to be fetched from a remote server to be updated when too much time has passed between `enqueue` transactions.
type L1GasPrice ¶
type L1GasPrice struct {
GasPrice string `json:"gasPrice"`
}
L1GasPrice represents the gas price of L1. It is used as part of the gas estimatation logic.
type OVMContext ¶
type OVMContext struct {
// contains filtered or unexported fields
}
OVMContext represents the blocknumber and timestamp that exist during L2 execution
type RollupClient ¶
type RollupClient interface { GetEnqueue(index uint64) (*types.Transaction, error) GetLatestEnqueue() (*types.Transaction, error) GetLatestEnqueueIndex() (*uint64, error) GetRawTransaction(uint64, Backend) (*TransactionResponse, error) GetTransaction(uint64, Backend) (*types.Transaction, error) GetLatestTransaction(Backend) (*types.Transaction, error) GetLatestTransactionIndex(Backend) (*uint64, error) GetEthContext(uint64) (*EthContext, error) GetLatestEthContext() (*EthContext, error) GetLastConfirmedEnqueue() (*types.Transaction, error) GetLatestTransactionBatch() (*Batch, []*types.Transaction, error) GetLatestTransactionBatchIndex() (*uint64, error) GetTransactionBatch(uint64) (*Batch, []*types.Transaction, error) SyncStatus(Backend) (*SyncStatus, error) }
RollupClient is able to query for information that is required by the SyncService
type SyncService ¶
type SyncService struct { RollupGpo *gasprice.RollupOracle OVMContext OVMContext // contains filtered or unexported fields }
SyncService implements the main functionality around pulling in transactions and executing them. It can be configured to run in both sequencer mode and in verifier mode.
func NewSyncService ¶
func NewSyncService(ctx context.Context, cfg Config, txpool *core.TxPool, bc *core.BlockChain, db ethdb.Database) (*SyncService, error)
NewSyncService returns an initialized sync service
func (*SyncService) GasPriceOracleOwnerAddress ¶
func (s *SyncService) GasPriceOracleOwnerAddress() *common.Address
A thread safe getter for the gas price oracle owner address
func (*SyncService) GetLatestBatchIndex ¶
func (s *SyncService) GetLatestBatchIndex() *uint64
GetLatestBatchIndex reads the last processed transaction batch
func (*SyncService) GetLatestEnqueueIndex ¶
func (s *SyncService) GetLatestEnqueueIndex() *uint64
GetLatestEnqueueIndex reads the last queue index processed
func (*SyncService) GetLatestIndex ¶
func (s *SyncService) GetLatestIndex() *uint64
GetLatestIndex reads the last CTC index that was processed
func (*SyncService) GetLatestL1BlockNumber ¶
func (s *SyncService) GetLatestL1BlockNumber() uint64
GetLatestL1BlockNumber returns the OVMContext blocknumber
func (*SyncService) GetLatestL1Timestamp ¶
func (s *SyncService) GetLatestL1Timestamp() uint64
GetLatestL1Timestamp returns the OVMContext timestamp
func (*SyncService) GetLatestVerifiedIndex ¶
func (s *SyncService) GetLatestVerifiedIndex() *uint64
GetLatestVerifiedIndex reads the last verified CTC index that was processed These are set by processing batches of transactions that were submitted to the Canonical Transaction Chain.
func (*SyncService) GetNextBatchIndex ¶
func (s *SyncService) GetNextBatchIndex() uint64
GetNextBatchIndex reads the index of the next transaction batch to process
func (*SyncService) GetNextEnqueueIndex ¶
func (s *SyncService) GetNextEnqueueIndex() uint64
GetNextEnqueueIndex returns the next queue index to process
func (*SyncService) GetNextIndex ¶
func (s *SyncService) GetNextIndex() uint64
GetNextIndex reads the next CTC index to process
func (*SyncService) GetNextVerifiedIndex ¶
func (s *SyncService) GetNextVerifiedIndex() uint64
GetNextVerifiedIndex reads the next verified index
func (*SyncService) IngestTransaction ¶
func (s *SyncService) IngestTransaction(tx *types.Transaction) error
IngestTransaction should only be called by trusted parties as it skips all validation and applies the transaction
func (*SyncService) IsSyncing ¶
func (s *SyncService) IsSyncing() bool
IsSyncing returns the syncing status of the syncservice. Returns false if not yet set.
func (*SyncService) SequencerLoop ¶
func (s *SyncService) SequencerLoop()
SequencerLoop is the polling loop that runs in sequencer mode. It sequences transactions and then updates the EthContext.
func (*SyncService) SetLatestBatchIndex ¶
func (s *SyncService) SetLatestBatchIndex(index *uint64)
SetLatestBatchIndex writes the last index of the transaction batch that was processed
func (*SyncService) SetLatestEnqueueIndex ¶
func (s *SyncService) SetLatestEnqueueIndex(index *uint64)
SetLatestEnqueueIndex writes the last queue index that was processed
func (*SyncService) SetLatestIndex ¶
func (s *SyncService) SetLatestIndex(index *uint64)
SetLatestIndex writes the last CTC index that was processed
func (*SyncService) SetLatestL1BlockNumber ¶
func (s *SyncService) SetLatestL1BlockNumber(bn uint64)
SetLatestL1BlockNumber will set the OVMContext blocknumber
func (*SyncService) SetLatestL1Timestamp ¶
func (s *SyncService) SetLatestL1Timestamp(ts uint64)
SetLatestL1Timestamp will set the OVMContext timestamp
func (*SyncService) SetLatestVerifiedIndex ¶
func (s *SyncService) SetLatestVerifiedIndex(index *uint64)
SetLatestVerifiedIndex writes the last verified index that was processed
func (*SyncService) Stop ¶
func (s *SyncService) Stop() error
Stop will close the open channels and cancel the goroutines started by this service.
func (*SyncService) SubscribeNewTxsEvent ¶
func (s *SyncService) SubscribeNewTxsEvent(ch chan<- core.NewTxsEvent) event.Subscription
SubscribeNewTxsEvent registers a subscription of NewTxsEvent and starts sending event to the given channel.
func (*SyncService) ValidateAndApplySequencerTransaction ¶
func (s *SyncService) ValidateAndApplySequencerTransaction(tx *types.Transaction) error
Higher level API for applying transactions. Should only be called for queue origin sequencer transactions, as the contracts on L1 manage the same validity checks that are done here.
func (*SyncService) VerifierLoop ¶
func (s *SyncService) VerifierLoop()
VerifierLoop is the main loop for Verifier mode
type SyncStatus ¶
type SyncStatus struct { Syncing bool `json:"syncing"` HighestKnownTransactionIndex uint64 `json:"highestKnownTransactionIndex"` CurrentTransactionIndex uint64 `json:"currentTransactionIndex"` }
SyncStatus represents the state of the remote server. The SyncService does not want to begin syncing until the remote server has fully synced.
type TransactionBatchResponse ¶
type TransactionBatchResponse struct { Batch *Batch `json:"batch"` Transactions []*transaction `json:"transactions"` }
TransactionBatchResponse represents the response from the remote server when querying batches.
type TransactionResponse ¶
type TransactionResponse struct { Transaction *transaction `json:"transaction"` Batch *Batch `json:"batch"` }
TransactionResponse represents the response from the remote server when querying transactions.