Skip to main content

MarloweBulkSync sub-protocol

The MarloweBulkSync sub-protocol is defined here:

The MarloweBulkSync sub-protocol is used to synchronize all marlowe contract transactions. The client receives a stream of blocks, each of which contains collections of create, apply inputs, and withdraw transactions.

This is a firehose protocol. It gives far more information than the header sync or regular sync protocols, but it may be inefficient for following a small set of contracts.

Sub-protocol states

Protocol stateAgencyDescription
1. IdleClientThe initial state.
2. IntersectServerWhen the client asks the server to fast forward to a known chain point.
3. NextServerWhen the client asks the server to provide the next block of Marlowe transactions.
4. PollClientWhen the server has no more blocks to send (i.e., the client has reached the tip of the chain).
5. DoneNobodyThe terminal state.

The Intersect state

The Intersect is when the client asks the server to fast forward to a known chain point. For example, in a situation where the client has already done a fair amount of synchronization and then quits, when it starts up again, rather than starting over from Genesis, it can start from where it last left off. The Intersect is the server recognizing a point that both it and the client know about, then starting from there. On the other hand, if the server does not or cannot recognize what the client is referencing, it will start from the beginning of the chain (from Genesis).

MarloweHeaderSync sub-protocol messages

MessageBegin stateEnd stateParameterDescription
1. RequestNextIdleNextThe client requests the next block of headers from the server.
extraCounta number in the range [0, 255] that represents the number of extra blocks to fetch (0 = 1 block will be fetched).
2. RollForward blks blockHeaderNextIdleThe server sends the next n blocks of transactions to the client.
blksThe next extraCount + 1 blocks in the chain.
tipThe tip of the chain.
3. RollBackward point tipNextIdleThe client's current position was rolled back, the server tells the client of the point to which it was rolled back.
pointChain point (either a block header or Genesis if the chain has rolled all the way back to Genesis).
tipThe tip of the chain (either a block header or Genesis).
4. WaitNextPollThe client is at the chain tip. There are no more Marlowe contract transactions to send. The client may choose to wait and poll until more are available.
5. PollPollNextThe client is checking with the server to find out if there are new blocks available.
6. CancelPollIdleThe client doesn't wish to wait, and returns to the idle state. Usually, when you send a cancel, in nearly all cases, it is followed by a done message. This is the case for clients that are only concerned about getting everything that is currently on the chain. Once that point is reached, when it reaches the tip, it communicates done.
7. DoneIdleDoneTerminates the session.
8. Intersect blksIdleIntersectThe client tells the server which blocks it has already seen so that the server can start syncing from an appropriate point in the chain.
blksA contiguous list of block headers in ascending order. These block headers represent the most recent blocks from the client's chain.
9. IntersectFound blkIntersectIdleThe server has found an intersection point with the client and will start syncing after this point (i.e., the next RollForward message will be after this block).
blkThe most recent block contained in both the client's chain and the server's chain.
10. IntersectNotFoundIntersectIdleThe server was unable to find an intersection point with the client and will start syncing from Genesis.