Skip to content
This repository has been archived by the owner on May 29, 2024. It is now read-only.

Commit

Permalink
[epociask/no-issue-refactored-invariant] Fault detection documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Ethen Pociask committed Jul 10, 2023
1 parent 98da7b8 commit 722ba1b
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 52 deletions.
40 changes: 36 additions & 4 deletions docs/invariants.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ The hardcoded `withdrawal_enforcement` invariant scans for active `WithdrawalPro
### Parameters
| Name | Type | Description |
| ---- | ---- | ----------- |
| l1_portal | string | The address of the L1Portal contract |
| l2_messager | string | The address of the L2ToL1MessagePasser contract |
| l1_portal_address | string | The address of the L1Portal contract |
| l2_to_l1_address | string | The address of the L2ToL1MessagePasser contract |


### Example Deploy Request
Expand All @@ -89,8 +89,40 @@ curl --location --request POST 'http://localhost:8080/v0/invariant' \
"start_height": null,
"alert_destination": "slack",
"invariant_params": {
"l1_portal": "0x111",
"l2_messager": "0x333",
"l1_portal_address": "0x111",
"l2_to_l1_address": "0x333",
},
}'
```

## Fault Detection
**NOTE:** This invariant requires an active RPC connection to both L1 and L2 networks. Furthermore, the Pessimism implementation of fault-detector assumes that a submitted L2 output on L1 will correspond to a canonical block on L2.

The hardcoded `fault_detector` invariant scans for active `OutputProposed` events on an L1 Output Oracle contract. Once an event is detected, the invariant implementation proceeds to reconstruct a local state output for the corresponding L2 block. If there is a mismatch between the L1 output and the local state output, the invariant alerts.


### Parameters
| Name | Type | Description |
| ---- | ---- | ----------- |
| l2_output_address | string | The address of the L1 output oracle |
| l2_to_l1_address | string | The address of the L2ToL1MessagePasser contract |


### Example Deploy Request
```
curl --location --request POST 'http://localhost:8080/v0/invariant' \
--header 'Content-Type: text/plain' \
--data-raw '{
"method": "run",
"params": {
"network": "layer1",
"pipeline_type": "live",
"type": "fault_detector",
"start_height": null,
"alert_destination": "slack",
"invariant_params": {
"l2_output_address": "0x111",
"l2_to_l1_address": "0x333",
},
}'
```
12 changes: 6 additions & 6 deletions internal/app/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ func InitializeAlerting(ctx context.Context, cfg *config.Config) alert.Manager {
return alert.NewManager(ctx, sc)
}

// InitalizeETL ... Performs dependency injection to build etl struct
func InitalizeETL(ctx context.Context, transit chan core.InvariantInput) pipeline.Manager {
// InitializeETL ... Performs dependency injection to build etl struct
func InitializeETL(ctx context.Context, transit chan core.InvariantInput) pipeline.Manager {
compRegistry := registry.NewRegistry()
analyzer := pipeline.NewAnalyzer(compRegistry)
store := pipeline.NewEtlStore()
Expand All @@ -104,11 +104,11 @@ func NewPessimismApp(ctx context.Context, cfg *config.Config) (*Application, fun
return nil, nil, err
}

alrt := InitializeAlerting(ctx, cfg)
engine := InitializeEngine(ctx, alrt.Transit())
etl := InitalizeETL(ctx, engine.Transit())
alerting := InitializeAlerting(ctx, cfg)
engine := InitializeEngine(ctx, alerting.Transit())
etl := InitializeETL(ctx, engine.Transit())

m := subsystem.NewManager(ctx, cfg.SystemConfig, etl, engine, alrt)
m := subsystem.NewManager(ctx, cfg.SystemConfig, etl, engine, alerting)

svr, shutDown, err := InitializeServer(ctx, cfg, m)
if err != nil {
Expand Down
42 changes: 1 addition & 41 deletions internal/client/eth_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ import (
)

// TODO (#20) : Introduce optional Retry-able EthClient
type EthClient struct {
url string
client *ethclient.Client
}

// EthClientInterface ... Provides interface wrapper for ethClient functions
// Useful for mocking go-etheruem node client logic
Expand Down Expand Up @@ -63,41 +59,5 @@ func NewEthClient(ctx context.Context, rawURL string) (EthClientInterface, error
return nil, err
}

return &EthClient{rawURL, client}, nil
}

// HeaderByNumber ... Wraps go-ethereum headerByNumber JSON-RPC method call
func (ec *EthClient) HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error) {
return ec.client.HeaderByNumber(ctx, number)
}

// BlockByNumber ... Wraps go-ethereum blockByNumber JSON-RPC method call
func (ec *EthClient) BlockByNumber(ctx context.Context, number *big.Int) (*types.Block, error) {
return ec.client.BlockByNumber(ctx, number)
}

// BalanceAt ... Wraps go-ethereum balanceAt JSON-RPC method call
func (ec *EthClient) BalanceAt(ctx context.Context, account common.Address, number *big.Int) (*big.Int, error) {
return ec.client.BalanceAt(ctx, account, number)
}

// FilterLogs ... Wraps go-ethereum balanceAt JSON-RPC method call
func (ec *EthClient) FilterLogs(ctx context.Context, query ethereum.FilterQuery) ([]types.Log, error) {
return ec.client.FilterLogs(ctx, query)
}

// CallContract ... Wraps go-ethereum callContract JSON-RPC method call
func (ec *EthClient) CallContract(ctx context.Context, msg ethereum.CallMsg, blockNumber *big.Int) ([]byte, error) {
return ec.client.CallContract(ctx, msg, blockNumber)
}

// CodeAt ... Wraps go-ethereum codeAt JSON-RPC method call
func (ec *EthClient) CodeAt(ctx context.Context, account common.Address, blockNumber *big.Int) ([]byte, error) {
return ec.client.CodeAt(ctx, account, blockNumber)
}

// SubscribeFilterLogs ... Wraps go-ethereum subscribeFilterLogs JSON-RPC method call
func (ec *EthClient) SubscribeFilterLogs(ctx context.Context, query ethereum.FilterQuery,
ch chan<- types.Log) (ethereum.Subscription, error) {
return ec.client.SubscribeFilterLogs(ctx, query, ch)
return client, nil
}
2 changes: 1 addition & 1 deletion internal/subsystem/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func (m *manager) RunInvSession(cfg *invariant.DeployConfig) (core.SUUID, error)
return sUUID, nil
}

if err = m.etl.RunPipeline(cfg.PUUID); err != nil { // Spinup pipeline components
if err = m.etl.RunPipeline(cfg.PUUID); err != nil { // Spin-up pipeline components
return core.NilSUUID(), err
}

Expand Down

0 comments on commit 722ba1b

Please sign in to comment.