1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-22 15:38:11 +00:00

protob: add graph.py script, small fixes to proto files

This commit is contained in:
Pavol Rusnak 2018-07-16 18:19:46 +02:00
parent 25bc3b4570
commit f7df570194
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
11 changed files with 79 additions and 18 deletions

1
protob/.gitignore vendored
View File

@ -1 +1,2 @@
*.pb *.pb
graph.gv*

55
protob/graph.py Executable file
View File

@ -0,0 +1,55 @@
#!/usr/bin/env python3
import sys
from graphviz import Digraph
class Message(object):
def __init__(self, name, attrs):
self.name = name
self.attrs = attrs
def generate_messages(files):
attrs = []
msgs = []
for f in files:
for line in open(f, "rt").readlines():
line = line.rstrip()
if line.startswith(" * @"):
attrs.append(line[4:].split(" "))
elif line.startswith("message "):
name = line[8:-2]
msgs.append(Message(name, attrs))
attrs = []
return msgs
def generate_graph(msgs, fn):
dot = Digraph(format="png")
dot.attr(rankdir="LR")
for m in msgs:
typ = m.attrs[0][0]
if typ == "start":
dot.node(m.name, shape="box", color="blue")
elif typ == "end":
dot.node(m.name, shape="box", color="green3")
elif typ == "auxstart":
dot.node(m.name, shape="diamond", color="blue")
elif typ == "auxend":
dot.node(m.name, shape="diamond", color="green3")
elif typ == "next":
dot.node(m.name) # no attrs
elif typ in ["embed", "ignore"]:
continue
else:
raise ValueError("wrong message type in message '%s'" % m.name)
for m in msgs:
for a in m.attrs:
if a[0] == "next":
dot.edge(m.name, a[1])
dot.render(fn)
msgs = generate_messages(sys.argv)
generate_graph(msgs, "graph.gv")

View File

@ -58,6 +58,7 @@ message PublicKey {
/** /**
* Request: Ask device for address corresponding to address_n path * Request: Ask device for address corresponding to address_n path
* @start
* @next Address * @next Address
* @next Failure * @next Failure
*/ */

View File

@ -118,6 +118,15 @@ message CardanoTxRequest {
optional bytes tx_body = 3; // serialised body of the signed transaction optional bytes tx_body = 3; // serialised body of the signed transaction
} }
/**
* Request: Reported transaction data
* @next CardanoSignedTransaction
* @next CardanoTxRequest
*/
message CardanoTxAck {
optional bytes transaction = 1;
}
/** /**
* Response: Serialised signed cardano transaction * Response: Serialised signed cardano transaction
* @end * @end
@ -126,11 +135,3 @@ message CardanoSignedTransaction {
optional bytes tx_hash = 1; // hash of the signed transaction optional bytes tx_hash = 1; // hash of the signed transaction
optional bytes tx_body = 2; // serialised body of the signed transaction optional bytes tx_body = 2; // serialised body of the signed transaction
} }
/**
* Request: Reported transaction data
* @next CardanoTxRequest
*/
message CardanoTxAck {
optional bytes transaction = 1;
}

View File

@ -52,6 +52,7 @@ message DebugLinkStop {
/** /**
* Response: Device wants host to log event * Response: Device wants host to log event
* @ignore
*/ */
message DebugLinkLog { message DebugLinkLog {
optional uint32 level = 1; optional uint32 level = 1;

View File

@ -123,6 +123,7 @@ message Ping {
/** /**
* Request: Abort last operation that required user interaction * Request: Abort last operation that required user interaction
* @start * @start
* @next Failure
*/ */
message Cancel { message Cancel {
} }

View File

@ -52,6 +52,7 @@ message StellarPublicKey {
/** /**
* Request: ask device to sign Stellar transaction * Request: ask device to sign Stellar transaction
* @start
* @next StellarTxOpRequest * @next StellarTxOpRequest
*/ */
message StellarSignTx { message StellarSignTx {