Skip to content

Commit

Permalink
Simplify enclave batch streaming and fix p2p batch requesting (#1400)
Browse files Browse the repository at this point in the history
  • Loading branch information
BedrockSquirrel authored Jul 24, 2023
1 parent 3e9446d commit 922c1b1
Show file tree
Hide file tree
Showing 13 changed files with 1,226 additions and 1,166 deletions.
9 changes: 6 additions & 3 deletions go/common/enclave.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ type Enclave interface {
// GetBatch - retrieve a batch if existing within the enclave db.
GetBatch(hash L2BatchHash) (*ExtBatch, error)

// GetBatchBySeqNo - retrieve batch by sequencer number if it's in the db
GetBatchBySeqNo(seqNo uint64) (*ExtBatch, error)

// CreateBatch - creates a new head batch extending the previous one for the latest known L1 head if the node is
// a sequencer. Will panic otherwise.
CreateBatch() SystemError
Expand All @@ -116,9 +119,9 @@ type Enclave interface {
// DebugTraceTransaction returns the trace of a transaction
DebugTraceTransaction(hash gethcommon.Hash, config *tracers.TraceConfig) (json.RawMessage, SystemError)

// StreamL2Updates - will stream the batches following the L2 batch hash given along with any newly created batches
// in the right order. All will be queued in the channel that has been returned
StreamL2Updates(*L2BatchHash) (chan StreamL2UpdatesResponse, func())
// StreamL2Updates - will stream any new batches as they are created/detected
// All will be queued in the channel that has been returned.
StreamL2Updates() (chan StreamL2UpdatesResponse, func())
// DebugEventLogRelevancy returns the logs of a transaction
DebugEventLogRelevancy(hash gethcommon.Hash) (json.RawMessage, SystemError)
}
Expand Down
8 changes: 8 additions & 0 deletions go/common/host/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,11 @@ type L2BatchHandler interface {
// HandleBatch will be called in a new goroutine for each new batch as it arrives
HandleBatch(batch *common.ExtBatch)
}

// EnclaveService provides access to the host enclave(s), it monitors and manages the states of the enclaves, so it can
// help with failover, gate-keeping (throttling/load-balancing) and circuit-breaking when the enclave is not available
type EnclaveService interface {
// LookupBatchBySeqNo is used to fetch batch data from the enclave - it is only used as a fallback for the sequencer
// host if it's missing a batch (other host services should use L2Repo to fetch batch data)
LookupBatchBySeqNo(seqNo *big.Int) (*common.ExtBatch, error)
}
Loading

0 comments on commit 922c1b1

Please sign in to comment.