Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
TLDR
Libplanet
project, BLS support is postponed.The reason for BLS implementation
The BLS signature is faster than the current libplanet implementation of secp256k11, and it can reduce the verification step by the aggregation of signatures. The initial decision was made because fast cryptography is needed for handling multiple signature verification in a limited time (
PreCommit,
PreVote
, using round short as possible2.) The interoperability is also part of the reason why BLS is needed (One simple example is an alternative method for random seed by using drand. the random created from drand beacon chain, it needed to be verified whether the random is valid.3)Timeline
The goal of this sprint was implementing BLS for me, and it was almost completed in a sense of creating a binding of C# with multi-platform support and preparing for interfacing in libplanet.
C# binding
There was no multiplatform supporting or implemented C# BLS library, so it has to be made for bringing it to libplanet. Decided to create a C# binding based on herumi/bls which is a BLS Signature in C. There was a time of testing, however, most of the sprint time is used for creating a C# binding (The multithread-safeness, RPATH in CMake, and AutoNativeImport) and it was necessary to make it work.4 Despite of worries, making a multi-platform support C# binding was done successfully.5
Interfacing
For interfacing, following changes are made:
BoundPeer
, creates a newAddress
and retyping PBFT-related public key fromPublicKey
toBlsPublicKey
, changingITransport
to take multiple types of a public key. It seems like to pass the unit test, but the unity test.Unity support
The problem arises with Unity support. For binding to work, it requires
System.Reflection.Emit
to dynamically load C library. However, due to IL2CPP, it is limited to being used.6 The mistake were made from here. I was interpreting "the build is passing, and the test is failing" as it would be okay if it doesn't use BLS in unity directly. It appeared to be wrong and failed to build the NineChronicle (unity part.)Separation
For solving problem, the BLS, and PBFT-related consensus part has to be separated from libplanet (e.g., RocksDBStore.) For that, It requires some structural reorganization and that seems like It would require another sprint cycle to be done. (Define a new type for placeholding the
Vote
data in libplanet, creates a new project, and move PBFT implementation into it. (Context
,BlsPublicKey
,BlsPrivateKey
,ConsensusReactor
,ConsensusContext
,Vote
,VoteSet
etc...) and resolves circular reference betweenLibplanet.Net
and the new consensus project.)For Previewnet
I was thinking that BLS might delay the whole test phase of PBFT. It works without BLS, so the roll-back decision has been made without hesitation. it is postponed until the separation is done.
Related or Following closed issues/PRs/repository
Footnotes
https://github.com/planetarium/libplanet/pull/2223 Section. How Fast it is?, Note that it is not the time of libSecp256k1 which is used in NineChronicle.Headless. ↩
https://github.com/planetarium/libplanet/blob/ec354eb5b5fc6295bab444ba7300f309fed0bf9a/Libplanet.Net/Consensus/Context.cs#L81-L86 ↩
https://drand.love/docs/cryptography/#pairing-based-cryptography ↩
On second thought, the work-through time of RPATH and importing the native library dynamically could have been shorter than now if I have seen this document. ↩
Note that it is not "true-C#" implementation. Creating own library without proper knowledge is considered dangerous. ↩
https://docs.unity3d.com/Manual/ScriptingRestrictions.html ↩