cosmos to swingset message flow.md - Agoric/agoric-sdk GitHub Wiki
- Cosmos-SDK -based application starts from app.go
- app knows about swingset due to inclusion of
swingset.NewAppModule
at line 201
- cosmos transaction arrives, containing a message for swingset
- block proposer processes txn from mempool, or validator processes txn from proposed block
- swingset message is parsed/routed to swingset handler x/swingset/handler.go: NewHandler
- message goes to
handleMsgDeliverInbound()
- message is wrapped in a
DELIVER_INBOUND
JSON structure, stringified, sent to CallToNode
at handler.go#L123
CallToNode
passes to NodeMessageSender
, which is registered at startup time (lib/daemon/main.go line 67) to point at sendToNode
sendToNode
(lib/agcosmosdaemon.go line 34) is a Go function that calls a C function toNode
, which is passed into RunAG_COSMOS
by runAG_COSMOS
(lib/agcosmosdaemon-node.cc line 144) where it comes from SendToNode
SendToNode
is defined in agcosmosdaemon-node.cc line 73
- ... additional magic happens ...
- something appears in javascript in
toSwingSet
(lib/ag-chain-cosmos line 80)
- that calls
toSwingSet0
wrapped in some error-reporting then()
s
toSwingSet0
starts swingset, if necessary, then calls deliverInbound()
- that's for messages in transactions
BeginBlock
follows a similar pathway and langes on deliverStartBlock()
deliverInbound()
dispatches into lib/launch-chain
line 113
- that calls a method on the Mailbox device (
md.deliverInbound
) which might add a delivery to the kernel run-queue
- if so:
- it calls
turnCrank()
, which uses controller.run()
to cycle the kernel run-queue to completion
- then it copies any outgoing messages into
mailboxStorage
, which routes back into Go