Closed ChihChengLiang closed 5 years ago
Totally agree with you. It makes a lot of sense. When we simplify the RPC call to notfiy(topic, bytes)
and send(topic, bytes)
, it will be a lot easier to replace it with PIPE.
Just for fun, I drew a flowchart for notify
from Go to Python. Hope it will be useful.
Addressed
What is wrong?
A beacon chain client sends and receives multiple types of messages, such as
blocks
andattestationRecords
. It would be tedious if implementing a new type of message requires modifications in several places in bothPython
andGo
codebase.For example, if a message
foo
is introduced, it is likely that we need to:foo
message inmessage.proto
in Python codebase.rpc send_foo
inrpc.proto
in Python codebase.rpc notify_foo
inevent.proto
in Python codebase.foo
in Python codebase.foo
in Go codebase.How can it be fixed?
Make Go codebase agnostic to message type, whenever it receives a new message, pass the raw byte to the Python host. The Python host deserializes the raw byte and determine it's validity and return to the Go.
The proposed solution requires only adding a generic
message
, rpc server, and event notifier in both Go and Python codebase. When introducing a new messagefoo
, the extra modification is reduced to:foo
in Python codebaseThis also comes a downside that the invalid messages can't be pre-filtered in Go side by the content but by the size. This could be an attacking vector but might be tolerable in the prototyping stage.