-
Notifications
You must be signed in to change notification settings - Fork 214
cosmos to swingset message flow.md
Michael FIG edited this page Jun 15, 2023
·
3 revisions
- 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 toCallToNode
at handler.go#L123 -
CallToNode
passes toNodeMessageSender
, which is registered at startup time (lib/daemon/main.go line 67) to point atsendToNode
-
sendToNode
(lib/agcosmosdaemon.go line 34) is a Go function that calls a C functiontoNode
, which is passed intoRunAG_COSMOS
byrunAG_COSMOS
(lib/agcosmosdaemon-node.cc line 144) where it comes fromSendToNode
-
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-reportingthen()
s -
toSwingSet0
starts swingset, if necessary, then callsdeliverInbound()
- that's for messages in transactions
-
BeginBlock
follows a similar pathway and langes ondeliverStartBlock()
-
deliverInbound()
dispatches intolib/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 usescontroller.run()
to cycle the kernel run-queue to completion - then it copies any outgoing messages into
mailboxStorage
, which routes back into Go- that lands in x/swingset/storage.go
storageHandler.Receive
line 58 - that goes to the Keeper in x/swingset/internal/keeper.go
- that adds it to the Cosmos-SDK application state, where it gets hashed into the next block, and can be queried by clients like
agd
- that lands in x/swingset/storage.go
- it calls
This wiki is for developing agoric-sdk. For help using Agoric SDK, see https://docs.agoric.com/ and https://agoric-sdk.pages.dev/