or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Do you want to remove this version name and description?
Syncing
xxxxxxxxxx
Eudico Ordering Layer Interface
This document describes the interface between the Eudico Filecoin client and its ordering layer subsystem. As the ordering layer is part of the Eudico client, this is an internal interface that Eudico uses to interact with its ordering component. We describe
SubmitRequests(refs []RequestRef)
GetRequest(r RequestRef) Request
NewBlock(block Block)
StateSnapshot(height t.BlockHeight) []byte
RestoreState(snapshot []byte, height t.BlockHeight)
In code snippets, we use the Go language syntax. Data types prefixed with
t.
are abstract types defined by the implementation.The current implementation in Eudico
The main logic is implemented in the Mine function, which implements the following algorithm:
SubmitRequest
function.SyncSubmitBlock
function.Then the block will be validated and applied, all messages from the block will be garbage collected from the mempool.
How SyncSubmitBlock works
SyncSubmitBlock is used "to submit a newly created block to the network through this node". The function restores a full block from the input block header and messages' CIDs. Then it calls
ValidateMsgMeta
that "performs structural and content hash validation of the messages within this block. If validation passes, it stores the messages in the underlying IPLD block store."Ordering layer API called by Eudico
The ordering layer exposes the following interface to the Eudico system. It consists of a single function.
SubmitRequests(refs []RequestRef)
Submits request references to the ordering layer for ordering, i.e., tells the ordering layer to order the referenced requests.
SubmitRequests
receives a list of request references, where a request reference uniquely identifies a message stored by Eudico (most likely inside Eudico's mempool). Eudico submits its messages to the ordering layer as requests.Request format
A submitted request and the reference to it have, respectively, the following format:
The
Request
interface represents anything that can be ordered by the ordering layer. Currently it can be either a Eudico message (signed or cross-net messages) or a reconfiguration messages for the ordering layer itself.The
RequestRef
represents a reference to a request. It has the following fields:ClientID
field uniquely identifies the application-level source of the request (Eudico message), i.e., an actor or wallet within a subnet. We will henceforth refer to such entities as clients.ReqNo
(the request number) is the client-local sequence number of the request. In other words, it is the number of requests previously produced by the same client. Each client's first request hasReqNo = 0
, the second request hasReqNo = 1
, etc. The request numbers must start at 0 and be contiguous. The tuple(ClientID, ReqNo)
thus uniquely identifies each request submitted to the ordering layer. TwoRequest
objects with the sameClientID
andReqNo
are considered the same and all their fields must be equal. If they are not, the client that produced them is assumed to be faulty.Data
is the payload of the request.Digest
field of aRequestRef
contains a hash of the referencedRequest
, computed over all its fields.Type
field defines the type of the referenced request. This is expected to be an enumeration type and for now we consider only 2 possible values:EudicoSignedMessage
: the request is a signed Eudico messageEudicoCrossMessage
: the request is a cross-net Eudico messageConfigRequest
: the request is a configuration request for the ordering layer itselfDurability
Before invoking
SubmitRequests
, all requests referenced in the argument must be durably stored by Eudico in stable storage. Even after a restart, the ordering layer expects to be able to retrieve each of those requestsreq
by callingGetRequest(ref)
, whereref
is the reference toreq
.Delivery guarantees
Eudico guarantees that, if
SubmitRequest(reqRefs)
is called at a correct node, then references to all requests included inreqRefs
will eventually be submitted (not necessarily in a single invocation) to the ordering layer at all correct nodes.Duplication
The ordering layer considers two requests
r1
andr2
repeated iffr1.ClientID == r2.ClientID
andr1.ReqNo == r2.ReqNo
. During normal operation (no restarts), in presence of repeated messages, Eudico should invokeSubmitRequests
for exatly one of them. The ordering layer, however, must be able to deal with requests being submitted multiple times and still deliver each request only once, albeit its performance might be decreased.Authentication
Eudico's API called by the ordering layer
Eudico makes the following functions available for the ordering layer to call.
GetRequest(r RequestRef) Request
NewBlock(b Block)
StateSnapshot(height t.BlockHeight) []byte
RestoreState(snapshot []byte, height t.BlockHeight)
GetRequest(reqRef RequestRef) Request
Returns the request that corresponds to the given reference.
NewBlock(block Block)
Announces the delivery of a block to Eudico. The block has the following format.
The
Requests
field is an ordered sequence of requests contained in the block.The
Height
field indicates the block height, i.e. the number of blocks ordered before the new block being announced.The
Metadata
field contains arbitrary metadata that the ordering layer might need to attach to the block. It has the form of key-value pairs, withstring
keys and[]byte
values, that is to be interpreted by Eudico depending on the particular implementation of the ordering layer used. If, for example, Eudico uses a protocol that signs blocks and relies on knowing those signatures, theMetadata
field might contain a signature stored under thesignature
key. If "mining" is used to produce blocks and the miner needs to be rewarded, the miner's wallet address can be stored under aminer
key. These are just simple examples, however, and arbitrary metadata can be encoded under arbitrary keys.Eudico guarantees that after
ApplyBlock
returns, the effect of applying the given block (i.e., the resulting state) is persistently stored in stable storage and can be recovered even after a restart of the node.StateSnapshot(height t.BlockHeight) []byte
Returns a representation of Eudico's state. The returned state snapshot must take all blocks with height lower than
height
into account.RestoreState(snapshot []byte, height t.BlockHeight)
Restores Eudico's state to the one encoded in
snapshot
. It is the Eudico state that results from applying the firstheight
blocks.