0001 EVS-01d: NPL Broker #3
wojake
started this conversation in
Standard Proposals
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
NPL Brokerage System
HotPocket supports sub-consensus communication, in which, arbitrary data is distributed and collected between nodes to collectively come to a consensus on a particular set of (unique) data, allowing a HP cluster to maintain a canonical state & return a valid, consistent response across the cluster.
This proposal, EVS-01d, structures an internal brokerage system on a HP instance, that manages sub-consensus "NPL" communication systematically.
More on NPL messaging.
1. Problem Statement
Out of the box, the Node Party Line channel "NPL" enables instances to read incoming sub-consensus messages and relay sub-consensus messages to their peers in raw format. HotPocket does not facilitate a built-in system to manage NPL messages in a systematic manner per se.
The simplicity of the NPL channel may introduce issues for most HP dApps, such as:
On the other hand, the flexibility comes at a cost, as different third-party components (libraries) have to come to an agreement on which NPL framework/standard they will be adopting. This inherent problem is solveable as we introduce a standard that may be adequate for future production use.
Discussions, tests, and reviews are more than welcome from all developers, as this standard will be crucial as a foundational building block in the HotPocket ecosystem.
2. Implementation
An
EVS-01d
NPL broker manages NPL rounds in a timely manner, and each NPL round being performed consumes a unique "spot" on the NPL broker's round registry according to its round name (i.e.,DKM-signature-collection-rXXRP
). For example, the "DKM-signature-collection-rXXRP
" round will temporarily consume the "DKM-signature-collection-rXXRP
" position on the NPL broker's round registry.tl;dr:
Function: Initialize NPL Broker
This function creates an NPL Broker instance on a HP instance and returns said instance to the caller, the caller's runtime could interact with NPL Broker.
The function must have the following fields:
ctx
object
object
EVS-01d
follows a singelton pattern; after the NPL Broker instance has been initialized, any additional calls toinit()
will return the NPL Broker instance rather than initializing it again. There could only be one instance of an NPL Broker per ledger.JavaScript implementation sample:
Function: Perform NPL Round
This function performs an NPL round, which distributes arbitary data within the instance's UNL via
ctx.unl.send()
and collects NPL messages from its peers.The function must have the following fields:
roundName
string
string
content
string, number, object, array, boolean, date
string
desiredCount
number
number
timeout
number
number
Perform NPL round sample:
The function returns the following fields:
roundName
string
record
array
desiredCount
number
desiredCountReached
boolean
timeout
number
timeTaken
number
meanTime
number
NPL round result sample:
Function: Subscribe to Round
This function subscribes to an NPL round name.
This function must have the following fields:
roundName
string
listener
function
This function is separate from an NPL round being performed, it does not influence an NPL round in any way. Each incoming NPL message will pass through the subscribed function '
listener
' and thelistener
function could react according to its defined code block.The amount of NPL messages passing through the
listener
function is capped according to the desired amount of NPL messages that the NPL round will be collecting.Function: Unsubscribe to Round
This function removes a particular subscriber of an NPL round name, only one unique subscriber is removed per each call.
roundName
string
listener
function
3. Adoption & Interoperability
As an NPL Broker calls the
ctx.unl.onMessage()
during initialization, each component (library) on a HP dApp must adopt and utilizeEVS-01d
.If
EVS-01d
is not adopted throughout the ecosystem, it would be difficult or impossible to adopt an implementation of this standard in any mainstream component (library).Security Considerations
Utilizing
EVS-01d
does not entirely combat overlapping NPL rounds, however, it does introduce a guard to avoid repeated NPL messages from the same HP peer, which would combat overlapping NPL rounds as one instance would only be able to send 1 NPL message per round.It is advisable to not re-use an NPL round name twice.
Reference Implementation
We've developed an implementation of
EVS-01d
on NodeJS.Beta Was this translation helpful? Give feedback.
All reactions