-
Notifications
You must be signed in to change notification settings - Fork 26
log :: 2025‐12
Tip
Mini-Protocols, Pure-Stage, Tx Submission, ChainSync, NetworkResource / Mempool
Handshake, keepalive, txsubmission, and chainsync are implemented as stages (mostly pure-stage) with protocol state in amaru-network and event processing in amaru-consensus; txsubmission hooks into a TxSubmissionMempool via a centralized NetworkResource.
The network stack now avoids pallas-network for handshake/keepalive (precise wire types), while txsubmission depends on a pending Pallas PR; handshake compat with the Haskell node is a known blocker.
Client/server txsubmission wiring is progressing (effects, actors, simulation mocks), with plans to test via a mempool that replays transactions from stored blocks.
Operational notes: large PRs scheduled for group review; build tuned (codegen-units=8) to reduce compile time, to be revisited for runtime performance.
-
The
handshakestage is implemented as apure-stagestage in #603.- A
connectionstage manages the connection, starts theMuxerfor that connection, and initializes the handshake mini-protocol.
- A
-
The
keepaliveprotocol is implemented as apure-stagestage in #608. -
The
txsubmissionprotocol is implemented as a stage in #611- For now the sizes and timeouts limits are not enforced.
- Additionally a pass over the existing Haskell node must be done to check if some important implementation decisions
not present in the network specification should be ported over to the
amarunode.
-
The
chainsyncprotocol is implemented as a stage in #612. -
Notes:
-
The
connection,handshakeandkeepaliveprotocols are implemented in theamaru-networkcrate and don't rely on thepallas-networkcrate anymore. This allows us to precisely control the data types used on the wire and internally. -
The
txsubmissionprotocol relies on a network resource (inpure-stageterms) that offers aTxSubmissionMempoolinterface to the Mempool.- The
Mempoolitself is implemented in theamaru-mempoolcrate. - Everything is eventually wired-up in the
amaru-consensuscrate.
- The
-
The
chainsyncprotocol require more stages for its full processing, with stages to validate headers, fetch blocks, etc... The code is divided in two parts:- The management of the protocol state is done in the
amaru-networkcrate. That stage emits events to a stage reference that does the rest of the processing. - The processing of chain sync events is then done with several stages in the
amaru-consensuscrate.
- The management of the protocol state is done in the
-
The overall dependencies are:
-
+-----------+
| consensus |-----+-------------+
+-----------+ | |
| v v
| +---------+ +---------+
| | network | | mempool |
| +---------+ +---------+
| | |
v v |
+------------------+ |
| ouroboros-traits |<-----------+
+------------------+
- The PR implementing a first pass at the protocol is ready for review: https://github.com/pragma-org/amaru/pull/587.
- The PR description details the main modifications and has a few implementation notes.
- This is a pretty large PR so we will do a group review with Roland and Arnaud on Friday.
- One blocker will be the merge of this Pallas PR: https://github.com/txpipe/pallas/pull/715, since the current code depends on it.
- The next important step will be to fix the handshake protocol between the Amaru node and the Haskell node since it prevents us from testing the tx submission protocol.
- I did a bit of refactor to move all the network effects to one place
NetworkResourcewith anUpstreamClientcontaining actors and clients to connect to upstream peers +DownstreamServerto serve downstream peers. - Then I had an issue building
amaruwith thereleaseprofile. The build takes forever. I eventually setcodegen-units = 8to bring the compilation time down to 2m40s. This will have to be fixed though since changing this parameter has an impact on runtime performance. - When I tried to connect nodes to do some testing I realized something: there are no transactions in the mempool at the moment :-).
- They could come from the local tx submission protocol but this will be implemented later.
- I guess the best way to test for now will be to have a
Mempoolimplementation that grabs a block from store, and returns transactions from that block, in order to send them to an Amaru node upstream. Since theMempooldoes not yet validate transactions that should be fine. - That being said, I'm observing a disconnection from the upstream Haskell node at the mempool and I don't see a reason why that should happen The Haskell node should just wait until transactions are available.
- I took the same approach as the one taken for the client:
- Create a pull stage looping with a
NextTxRequestmessage. - On each loop a
ReceiveTxReplyEffectis triggered to get the nextTxReplyfrom a downstream client. - The effect is implemented with the
NetworkResourceand eventually with the actor code accepting client requests.
- Create a pull stage looping with a
- I removed the
ForwardListenerResourcethat was used to implement aForwardEventEffect(to send chain sync events downstream).- This functionality is now supported by the
NetworkResourcein order to keep all network effects close.
- This functionality is now supported by the
- The final connection between the
NetworkResourceand the actor code is not done and there are also changes to some mocks in the simulation code (those mocks avoid network calls).
- I had to take a detour to add some useful instances to some
pallascrates:- One PR to add instances on top of
main. But we cannot use it for now, it has too many changes. - One PR to add instances on top of
lts/v0(those are slightly different). - This means that my current PR relies on a branch at the moment but Santiago told me during office hours that he should merge those PRs quite quickly
- Note: he said that releasing the
ltsversion (as0.34.0) might not happen right away but he would do it if we needed to.
- Note: he said that releasing the
- One PR to add instances on top of
- I have integrated the client side of the protocol as a stage with the necessary "mempool" and "network" effects to support the simulation.
- Next: the integration of the server side of the protocol
- For the integration of the tx submission client, I chose to use the same strategy as what we currently do for getting headers from upstream:
- A
pull_tx_requeststage loops with a singleNextTxRequestmessage. - On each loop it performs a
TxRequestEffectimplemented by the existingNetworkOperationstrait with an additional method:next_tx_request. -
NetworkOperationsis implemented as aNetworkResource. That data type makes connections to upstream peers and maintains a set of mini-protocol clients per peer. - I've extended that code to have a
Receiver<TxRequest>that receives a new request every time the underlying Pallas client gets aRequest<EraTxId, EraTxBody>.
- A
- Then the stage implementation consists in reusing the code I already have in the
TxSubmissionClientby:- Isolating the "mempool" effects (
wait_until_tx_ready,get_tx_idsetc...) - Processing each
TxRequestby interacting with theMempool - Using additional network effects to send back responses => This part is not yet wired.
- Note that the stage contains a
Map<Peer, TxSubmissionClient>. Eventually it will also contain some logic to control the behavior we require across all peers. - Concretely I've been a bit stuck trying to work-around some missing instances in
pallas. My initial attempts were ok but the requirements we have in terms of serialization for the simulation framework make that really cumbersome. After reaching out to Santiago @ TxPipe we agreed to merge the changes in this PR: https://github.com/txpipe/pallas/pull/714 to the long-term maintenance branch forpallas-0.x. This should unblock me and simplify a few things.
- Isolating the "mempool" effects (
- Next steps:
- Get everything to compile with the LTS Pallas branch.
- Complete the execution path for replies
- Integrate the server