# SRUオペレーター同士の通信プロトコルのインターフェース ###### tags: `インターフェース` protocol buffersっぽい感じで書いてく。id(フィールド番号)は追加するとズレるので、今は1固定とかでいいかもしれない。 ## ベースの型 ### Tx ```proto message SignedTransaction { bytes tx_hash = 1; message TransactionPayload { string contract_address = 1; string onetime_address = 2; uint64 nonce = 3; bytes data = 4; bytes user_state_value = 5; bytes user_state_zk_proof = 6; bytes signed_transaction_zk_proof = 7; } } // txHashだけの簡易的なもの message LiteTx { bytes tx_hash = 1; } ``` ### Block ```proto message Header { bytes parent_hash = 1; bytes merkle_root = 1; bytes txs_root = 1; bytes reciept_root = 1; bytes state_root = 1; string state_cid = 2; // 分散ストレージのCID uint64 gas_limit = 3; uint64 gas_used = 4; uint64 number = 5; // ブロック高 uint64 time = 6; // unix time bytes zk_evm_state_proof = 7; bytes zk_evm_execution_proof = 8; } message Block { bytes block_hash = 1; Header header = 1; repeated LiteTx txs = 1; } ``` ## Broadcast ```proto message BroadcastTxsReq { repeated SignedTransactions SignedTransaction = 1; } message BroadcastBlocksReq { Block Block = 1; } message GetBlockReq { bytes block_hash = 1; } service Block { rpc broadcastBlock (BroadcastBlockReq) returns () {} rpc getBlock (GetBlockReq) returns (Block) {} } service Tx { rpc broadcastTxs (BroadcastTxsReq) returns () {} rpc getTx (LiteTx) returns (SignedTransaction) {} }} ``` ## :memo: protobufで使える型一覧 Protoでの型 | 説明 | Goでの型 -- | -- | -- double | 倍精度浮動小数点型 | float64 float | 浮動小数点型 | float32 int32 | 32 ビット整数型 | int32 int64 | 64 ビット整数型 | int64 uint32 | 32 ビット符号なし整数型 | uint32 uint64 | 64 ビット符号なし整数型 | uint64 sint32 | int32 と同様。負数をより効率的に扱うことができる。 | int32 sint64 | int64 と同様。負数をより効率的に扱うことができる。 | int64 fixed32 | 4 バイト固定の 32 ビット符号なし整数型 | uint32 fixed64 | 8 バイト固定の 64 ビット符号なし整数型 | uint64 sfixed32 | 4 バイト固定の 32 ビット整数型 | int32 sfixed64 | 8 バイト固定の 64 ビット整数型 | int64 bool | 真偽値 | bool string | UTF-8 エンコードされた文字列もしくは ASCII | string bytes | バイト列 | []byte
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up