1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package frontend
import (
"context"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum-optimism/optimism/op-supervisor/supervisor/types"
)
type AdminBackend interface {
Start(ctx context.Context) error
Stop(ctx context.Context) error
AddL2RPC(ctx context.Context, rpc string) error
}
type QueryBackend interface {
CheckMessage(identifier types.Identifier, payloadHash common.Hash) (types.SafetyLevel, error)
CheckMessages(messages []types.Message, minSafety types.SafetyLevel) error
CheckBlock(chainID *hexutil.U256, blockHash common.Hash, blockNumber hexutil.Uint64) (types.SafetyLevel, error)
}
type Backend interface {
AdminBackend
QueryBackend
}
type QueryFrontend struct {
Supervisor QueryBackend
}
// CheckMessage checks the safety-level of an individual message.
// The payloadHash references the hash of the message-payload of the message.
func (q *QueryFrontend) CheckMessage(identifier types.Identifier, payloadHash common.Hash) (types.SafetyLevel, error) {
return q.Supervisor.CheckMessage(identifier, payloadHash)
}
// CheckMessage checks the safety-level of a collection of messages,
// and returns if the minimum safety-level is met for all messages.
func (q *QueryFrontend) CheckMessages(
messages []types.Message,
minSafety types.SafetyLevel) error {
return q.Supervisor.CheckMessages(messages, minSafety)
}
// CheckBlock checks the safety-level of an L2 block as a whole.
func (q *QueryFrontend) CheckBlock(chainID *hexutil.U256, blockHash common.Hash, blockNumber hexutil.Uint64) (types.SafetyLevel, error) {
return q.Supervisor.CheckBlock(chainID, blockHash, blockNumber)
}
type AdminFrontend struct {
Supervisor Backend
}
// Start starts the service, if it was previously stopped.
func (a *AdminFrontend) Start(ctx context.Context) error {
return a.Supervisor.Start(ctx)
}
// Stop stops the service, if it was previously started.
func (a *AdminFrontend) Stop(ctx context.Context) error {
return a.Supervisor.Stop(ctx)
}
// AddL2RPC adds a new L2 chain to the supervisor backend
func (a *AdminFrontend) AddL2RPC(ctx context.Context, rpc string) error {
return a.Supervisor.AddL2RPC(ctx, rpc)
}