-
Notifications
You must be signed in to change notification settings - Fork 171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Weak blocks WIP #1 #2055
Open
kushti
wants to merge
64
commits into
master
Choose a base branch
from
weak-blocks
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Weak blocks WIP #1 #2055
Changes from 24 commits
Commits
Show all changes
64 commits
Select commit
Hold shift + click to select a range
10362c9
WeakBlockAlgos
kushti 76e2f60
Merge branch 'v5.0.15' of github.com:ergoplatform/ergo into weak-blocks
kushti c5d30d3
WeakBlockInfo, WeakBlockMessageSpec
kushti 5c2eb29
impl steps
kushti d378942
Merge branch 'v5.0.16' of github.com:ergoplatform/ergo into weak-blocks
kushti 8843114
initial weak blocks structures and algos
kushti 5c4f9c2
compact block like messaging
kushti 0dbfeb0
before structures
kushti 1a68d0e
skeleton of processing algo
kushti 1040926
weak blocks => sub blocks
kushti 636f3d8
more weak=>sub renaming
kushti 6293421
returning download plan
kushti 23a5db0
better comments and todos, formatting
kushti 2c5cf3c
motivation started in EIP, data structures refined
kushti 4189783
Merge branch 'master' of github.com:ergoplatform/ergo into weak-blocks
kushti 4962218
pow, superblocks
kushti 514e6fb
subblocks section finished
kushti 564ad05
propagation text started, prevSubBlockId made optional (comp fails)
kushti 346e1a7
commitment
kushti a068545
styling fixes
kushti c0709f2
key spaces for sub-blocks and sidechains
kushti 85de7a4
eip update
kushti a248ccf
dag note, new subsections added
kushti 0a9fd56
Merge branch 'master' of github.com:ergoplatform/ergo into weak-blocks
kushti 93bc6bc
merging w. master, accounting for optional prevSubBlockId
kushti 02056c2
Merge branch 'master' of github.com:ergoplatform/ergo into weak-blocks
kushti 92baed0
input/ordering blocks intro
kushti 54c9971
script execution ctx started
kushti 73d76f2
extending subblocks info
kushti 69adf58
Merge branch 'master' of github.com:ergoplatform/ergo into weak-blocks
kushti bed12e6
SubsPerBlock* improved comments in SubBlockAlgos
kushti 01da1a0
BlockKind, distnguishing fn
kushti e448fb8
Merge branch 'master' of github.com:ergoplatform/ergo into weak-blocks
kushti 3e9f4d1
blockKind()
kushti 1a8aaeb
unused reportModifierIsInvalid removed
kushti 184996e
ProgressInfo.empty, removing implicit ScorexEncoder
kushti 8bc72cc
MessageSpecInitial / MessageSpecSubBlock
kushti 4192c61
merkle proof added to SubBlockInfo, serializer updated, SubBlockMessa…
kushti a044955
batch merkle proof usage and serialization
kushti 613fc58
Merge branch 'jni-dep' of github.com:ergoplatform/ergo into weak-blocks
kushti c382a38
processSubblock started
kushti 15ca997
subblock height check
kushti 222c850
SubBlockTransactionsRequestSpec, completing processSubblock stub
kushti e6ee392
SubBlockTransactionsSpec
kushti fb98a2e
subblocks p2p logic stub
kushti 95fb95e
LocallyGeneratedSubBlock
kushti 5f66580
subblock keys, CandidateGenerator simplification
kushti f118879
more simplification in CandidateGenerator
kushti e8bcdfa
bestSubblock() stub. createCandidate #1
kushti 647b6db
initial version of best subblock selection
kushti e93d333
merging w. 5.0.23
kushti e0feb83
input/ordering block distintcion in mining logic #1, input block gene…
kushti 9ebe5db
subblocks generation
kushti 5e623b4
fixing delivery of sub-blocks to processing
kushti c9de516
input block pow validation
kushti b908142
completeOrderingBlock / completeInputBlock
kushti 08c52d6
sendInputToNodeView stub (pre-refactoring)
kushti ac824a4
LocallyGeneratedInputBlock / LocallyGeneratedOrderingBlock
kushti 4fc43c5
reworked LocallyGeneratedInputBlock signature
kushti ef02664
forum post
kushti 4011aa5
removing subblock field from Candidate
kushti e9811ce
Merge branch 'master' of github.com:ergoplatform/ergo into weak-blocks
kushti c81839d
papers/subblocks folder
kushti 319f7a6
forming SubBlockInfo, SubBlockTransactionsData moved to completeInput…
kushti File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
Sub-Blocks and Improved Confirmed Transactions Propagation | ||
========================== | ||
|
||
* Author: kushti | ||
* Status: Proposed | ||
* Created: 31-Oct-2023 | ||
* License: CC0 | ||
* Forking: Soft Fork | ||
|
||
Motivation | ||
---------- | ||
|
||
Currently, a block is generated every two minutes on average, and confirmed transactions are propagated along with | ||
other block sections. | ||
|
||
This is not efficient at all. Most of new block's transactions are already available in a node's mempool, and | ||
bottlenecking network bandwidth after two minutes of (more or less) idle state is also downgrading network performance. | ||
|
||
Also, while average block delay in Ergo is 2 minutes, variance is high, and often a user may wait 10 minutes for | ||
first confirmation. Proposals to lower variance are introducing experimental and controversial changes in consensus protocol. | ||
Changing block delay via hardfork would have a lot of harsh consequences (e.g. many contracts relying on current block | ||
delay would be broken). Thus it makes sense to consider weaker notions of confirmation which still could be useful for | ||
a variety of applications. | ||
|
||
Sub-Blocks | ||
---------- | ||
|
||
A valid block is sequence of (semantically valid) header fields (and corresponding valid block sections, such as block | ||
transactions), including special field to iterate over, called nonce, such as *H(b) < T*, where *H()* is Autolykos Proof-of-Work | ||
function, *b* are block bytes (including nonce), and *T* is a Proof-of-Work *target* value. A value which is reverse | ||
to target is called difficulty *D*: *D = 2^256 / T* (in fact, slightly less value than 2^256 is taken, namely, order of | ||
secp256k1 curve group, this is inherited from initial Autolykos 1 Proof-of-Work algorithm). *D* (and so *T*) is being readjusted | ||
regularly via a deterministic procedure (called difficulty readjustment algorithm) to have blocks coming every two minutes on average. | ||
|
||
Aside of blocks, *superblocks" are also used in the Ergo protocol, for building NiPoPoWs on top of them. A superblock is | ||
a block which is more difficult to find than an ordinary, for example, for a (level-1) superblock *S* we may require | ||
*H(S) < T/2*, and in general, we can call n-level superblock a block *S* for which *H(S) < T/2^n*. Please note that a | ||
superblock is also a valid block (every superblock is passing block PoW test). | ||
|
||
Similarly, we can go in opposite direction and use *subblocks*, so blocks with lower difficulty. We can set *t = T/64* | ||
and define superblock *s* as *H(s) < t*, then miner can generate on average 64 subblocks (including normal block itself) | ||
per block generation period. Please note that, unlike superblocks, subblocks are not blocks, but a block is passing | ||
subblock check. | ||
|
||
Subblocks are similar to block shares already used in pooled mining. Rather, this proposal is considering to use | ||
sub-blocks for improving transactions propagation and providing a framework for weaker confirmations. | ||
|
||
Sub-Blocks And Transactions Propagation | ||
--------------------------------------- | ||
|
||
Let's consider that new block is just generated. Miners A and B (among others) are working on a new block. Users are | ||
submitting new unconfirmed transactions at the same time to the p2p network, and eventually they are reaching miners | ||
(including A and B, but at a given time a transaction could be in one of the mempools just, not necessarily both, it | ||
could also be somewhere else and not known to both A and B). | ||
|
||
Then, for example, miner A is generating a sub-block committing to new transactions after last block. It sends sub-block | ||
header as well as weak transaction ids (6 bytes hashes) of transactions included into this sub-block but not previous | ||
sub-blocks to peers. Peers then are asking for transactions they do not know only, and if previous sub-block is not | ||
known, they are downloading it along with its transactions delta, and go further recursively if needed. | ||
|
||
Thus pulse of sub-blocks will allow to exchange transactions quickly. And when a new sub-block is also a block (passing | ||
normal difficulty check), not many transactions to download, normally. Thus instead of exchanging all the full-block | ||
transactions when a new block comes, peers will exchange relatively small transaction deltas all the time. Full-block | ||
transactions sections exchange still will be supported, to support downloading historical blocks, and also old clients. | ||
|
||
Sub-blocks Structure and Commitment to Sub-Blocks | ||
------------------------------------------------- | ||
|
||
Here we consider what kind of footprint sub-blocks would have in consensus-enforced data structures (i.e. on-chain). | ||
Proper balance here is critical and hard to achieve. Strict consensus-enforced commitments (when all the | ||
sub-blocks committed on-chain) require from all the miners to have all the sub-blocks in order to check them. But, | ||
at the same time, consensus-enforced commitments to properly ordered sub-blocks would allow for protocols and | ||
applications using sub-blocks data. | ||
|
||
We have chosen weak commitments. That is, a miner may (and incentivized to) to commit to longest sub-blocks chain | ||
since previous full-block, but that there are no any requirements about that in Ergo consensus rules. | ||
|
||
New extension key space starting with 0x03 will be used for sub-blocks related data, with one key used per this EIP: | ||
|
||
0x03 0x00 - digest of a Merkle tree of longest sub-blocks chain starting with previous block (but not including it). | ||
|
||
So first sub-block having full-block as a parent will have empty tree, next one will have only first, and next | ||
full-block will commit to all the sub-blocks since previous full-block. | ||
|
||
At the same time, no any new checks are planned for the Ergo protocol. Checks are possible for sidechains. | ||
|
||
|
||
Sub-Block Based Sidechains | ||
-------------------------- | ||
|
||
As L1 incentivization for propagating and committing on-chain to sub-blocks are missed, we consider sub-block based | ||
merge-mined sidechains as possible option to incentivize miners to participate in the sub-blocks sub-protocol. They | ||
also can be used to enforce linearity (so that transactions added in a previous sub-block can't be reversed). | ||
|
||
A merged-mined sidechain is using sub-blocks as well as blocks to update its state which can be committed via main-chain | ||
transactions even. That is, in every sub-blocks side-chain state (sidechain UTXO set digest etc) can be written in a box | ||
with sidechain NFT, and then every sub-block the box may be updated. | ||
|
||
For rewarding miners submitting sub-blocks to Ergo network (sidechain block generators are listening to), a sidechain block | ||
may be consist of main-chain sub-block and sidechain state along with membership proof. For enforcing linearity of transactions | ||
, sidechain consensus may enforce rollback to a sub-block before transaction reversal on proof of reversal being published. | ||
|
||
Incentivization | ||
--------------- | ||
|
||
No incentives to generate and propagate sub-blocks are planned for the Ergo core protocols at the moment. At the same | ||
time, incentives can be provided on the sub-block based merge-mined sidechains, or via application-specific agreements | ||
(where applications may pay to miners for faster confirmations). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be worth detailing weak transaction ids a little bit, why 6 bytes of hashes specifically?