---
# System prepended metadata

title: インターフェースまとめ
tags: [実装]

---

# インターフェースまとめ

###### tags: `実装`

## SRUのOperator同士のコミュニケーション
[SRUオペレーター同士の通信プロトコルのインターフェース](https://hackmd.io/6usS2AtdRuu-Si1rTxXqOQ)

## SRUのOperatorとTransactorのコミュニケーション
### txを受け取る

https://hackmd.io/eYGLs-vMTjSuiAl9ueTzjw#POST-sru_sendTransaction

### callの結果を返す
https://hackmd.io/eYGLs-vMTjSuiAl9ueTzjw#POST-sru_call


## Transactorの処理
### zkpで自分の資産の証明をする
https://hackmd.io/z6OI1vBuTNCtbClE8qD59A#User-State-Update
### 署名が正しいことを署名者の情報なしにやる
https://hackmd.io/z6OI1vBuTNCtbClE8qD59A#Transaction


## L1とSRUのOperator同士のコミュニケーション

### Depositする時
```solidity=
interface SRU {
    funciton deposit(IERC20 erc20, bytes to, amount) external;
}
```
### Exitする時
```solidity=
interface SRU {
    
    funciton exitForFreeze(bytes memory proof, bytes memory l2Erc20Address, address to, uint256 amount) external;
}
```

### コミット

```solidity=
interface SRU {
    
    funciton commitBatch(bytes memory proof) external;
    funciton commitBatchWithExit(bytes memory proof, bytes memory l2Erc20Address, address to, uint256 amount) external;
}
```

## SRUのOperatorと分散ストレージの通信
### 各種データの保存
[分散ストレージ](https://hackmd.io/RUzKWv6yQoK6MumW1oFWMQ)


## SRUのOperatorとLightning Networkでのコミュニケーション
### 手数料支払いを確認するとき

ref: [lightning.proto](https://github.com/lightningnetwork/lnd/blob/71b23a2c542d04cc9325014a81174f9238ffb61c/lnrpc/lightning.proto#L3359-L3399)

```proto=

message ListInvoiceRequest {
    /*
    If set, only invoices that are not settled and not canceled will be returned
    in the response.
    */
    bool pending_only = 1;

    /*
    The index of an invoice that will be used as either the start or end of a
    query to determine which invoices should be returned in the response.
    */
    uint64 index_offset = 4;

    // The max number of invoices to return in the response to this query.
    uint64 num_max_invoices = 5;

    /*
    If set, the invoices returned will result from seeking backwards from the
    specified index offset. This can be used to paginate backwards.
    */
    bool reversed = 6;
}

message ListInvoiceResponse {
    /*
    A list of invoices from the time slice of the time series specified in the
    request.
    */
    repeated Invoice invoices = 1;

    /*
    The index of the last item in the set of returned invoices. This can be used
    to seek further, pagination style.
    */
    uint64 last_index_offset = 2;

    /*
    The index of the last item in the set of returned invoices. This can be used
    to seek backwards, pagination style.
    */
    uint64 first_index_offset = 3;
}

serivce Lightning {
    rpc ListInvoices (ListInvoiceRequest) returns (ListInvoiceResponse);
}


```

## SRUのOperatorとProverのコミュニケーション
### ProverがOperatorを監視してProveする
```proto=
message GetGeneratedBlockRequest {

}

message EVMState {
    repeated bytes states = 1;
}

message VerkleProof {
    bytes states = 1;
}

message GetGeneratedBlockResponse {
    repeated Txs txs = 1;

    // evmの実行に必要なstate。txの数と必ず同じ
    repeated EVMState evm_states = 2;
    
    // アカウントのrootが内包されることを証明するためのVerkle Proof。txの数と必ず同じ
    repated VerkleProofs verkle_proofs = 3;
    
    bytes merkle_root = 3;
}

serivce Prover {
    rpc getGeneratedBlock (GetGeneratedBlockRequest) returns (GetGeneratedBlockResponse);
}

```

