-
Notifications
You must be signed in to change notification settings - Fork 100
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
[dBFT CONSENSUS]: dBFT 3.0 with double speakers model #680
Closed
Closed
Changes from 42 commits
Commits
Show all changes
69 commits
Select commit
Hold shift + click to select a range
e97daeb
Draft 0.1 for dBFT 3.0
vncoelho 0343f4a
Moving on
vncoelho c432ffc
Moving on
vncoelho 970e482
format
vncoelho 01d033c
moving on
vncoelho 02fa0b7
format
vncoelho 5523a31
Adding new
vncoelho bbb33ae
More fix
vncoelho ab8eec2
Additional fix
vncoelho cad5562
General fixes
vncoelho 43166ec
format
vncoelho 94e42b4
Minor fix
vncoelho 6d5939c
Minor fix fixed
vncoelho 4489d37
Fixing conditions and other fixed variables
vncoelho bedb125
Format
vncoelho 73626ac
Fixing state
vncoelho ff7a5a1
Merge branch 'master' into dbft3.0-doublespeakers
29e267b
fix build error
d0b1c75
optimize
d06424f
fix commitedcount
482d055
recovery contains PreCommit and P2 messages
d7f452a
fix OnStart and message sizes
ffc5771
optimize
52f0659
optimize primary check
40348e1
Round-Robin strategy 2
7a43c5c
rm comment
11a7747
clean
e2ad61e
apply https://github.com/neo-project/neo/issues/2058
6772a46
format
a811dcf
Merge branch 'master' into dbft3.0-doublespeakers
cc4b3d0
Merge branch 'master' into dbft3.0-doublespeakers
6d5daf5
Merge branch 'master' into dbft3.0-doublespeakers
vncoelho e86de2a
fix tx dump
c86f4ce
Merge branch 'master' into dbft3.0-doublespeakers
c2f0b02
fix
19d2810
clean
d524245
Initial fix on countcommitted and fix cleaning CommitPayloads after c…
vncoelho 76f4253
pId
7009fa8
log
6e59214
ValidatorIndex in PrepareRequest of RecoveryMessage
f9f0465
Comment
vncoelho 9324899
name
a91dd63
fix fallback primary index
e490566
Merge branch 'master' into dbft3.0-doublespeakers
vncoelho dc474fc
Merge branch 'master' into dbft3.0-doublespeakers
superboyiii 8d3f65d
Merge branch 'master' into dbft3.0-doublespeakers
superboyiii 0c7b5eb
Fix Null with basic logic following Owen finding
vncoelho a2df166
Format
vncoelho 4e8c6ba
Merge branch 'master' into dbft3.0-doublespeakers
vncoelho 78f3033
Merge branch 'master' into dbft3.0-doublespeakers
vncoelho 5677567
Merge branch 'master' into dbft3.0-doublespeakers
superboyiii 3f90ec4
Merge branch 'master' into dbft3.0-doublespeakers
vncoelho 44c5d7c
format
vncoelho 33aaeb3
Merge branch 'master' into dbft3.0-doublespeakers
vncoelho b13b6c4
Update ConsensusService.cs
vncoelho 47f83fc
Merge branch 'master' into dbft3.0-doublespeakers
vncoelho d2e314a
Merge branch 'master' into dbft3.0-doublespeakers
vncoelho ff291f6
Merge branch 'master' into dbft3.0-doublespeakers
Jim8y 7aa1b45
Merge branch 'master' into dbft3.0-doublespeakers
vncoelho cb370f1
Merge branch 'master' into dbft3.0-doublespeakers
vncoelho d2c4e6a
Merge branch 'master' into dbft3.0-doublespeakers
vncoelho 8b493f2
dotnet format
vncoelho 2cda440
Merge branch 'master' into dbft3.0-doublespeakers
vncoelho 8048f69
Merge branch 'master' into dbft3.0-doublespeakers
vncoelho 7445a1c
Merge branch 'master' into dbft3.0-doublespeakers
vncoelho 2f793cf
Merge branch 'master' into dbft3.0-doublespeakers
vncoelho fc82203
Merge branch 'master' into dbft3.0-doublespeakers
vncoelho 653c615
Merge branch 'master' into dbft3.0-doublespeakers
vncoelho c72c9c6
Merge branch 'master' into dbft3.0-doublespeakers
Jim8y 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 |
---|---|---|
|
@@ -8,11 +8,11 @@ | |
// Redistribution and use in source and binary forms with or without | ||
// modifications are permitted. | ||
|
||
using System.Linq; | ||
using System.Runtime.CompilerServices; | ||
using Neo.Network.P2P.Payloads; | ||
using Neo.SmartContract; | ||
using Neo.Wallets; | ||
using System.Linq; | ||
using System.Runtime.CompilerServices; | ||
using static Neo.Consensus.RecoveryMessage; | ||
|
||
namespace Neo.Consensus | ||
|
@@ -44,6 +44,18 @@ private ChangeViewPayloadCompact GetChangeViewPayloadCompact(ExtensiblePayload p | |
}; | ||
} | ||
|
||
private PreCommitPayloadCompact GetPreCommitPayloadCompact(ExtensiblePayload payload) | ||
{ | ||
PreCommit preCommit = GetMessage<PreCommit>(payload); | ||
return new PreCommitPayloadCompact | ||
{ | ||
ViewNumber = preCommit.ViewNumber, | ||
ValidatorIndex = preCommit.ValidatorIndex, | ||
PreparationHash = preCommit.PreparationHash, | ||
InvocationScript = payload.Witness.InvocationScript, | ||
}; | ||
} | ||
|
||
private CommitPayloadCompact GetCommitPayloadCompact(ExtensiblePayload payload) | ||
{ | ||
Commit message = GetMessage<Commit>(payload); | ||
|
@@ -66,12 +78,21 @@ private PreparationPayloadCompact GetPreparationPayloadCompact(ExtensiblePayload | |
} | ||
|
||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public byte GetPrimaryIndex(byte viewNumber) | ||
public byte GetPriorityPrimaryIndex(byte viewNumber) | ||
{ | ||
int p = ((int)Block.Index - viewNumber) % Validators.Length; | ||
int p = ((int)Block[0].Index - viewNumber) % Validators.Length; | ||
return p >= 0 ? (byte)p : (byte)(p + Validators.Length); | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public byte GetFallbackPrimaryIndex(byte viewNumber, byte priorityPrimaryIndex) | ||
{ | ||
if (Validators.Length <= 1) return priorityPrimaryIndex; | ||
vncoelho marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe Validators.Length <= 3. We need to check that. |
||
int p = ((int)Block[0].Index - viewNumber + 1) % (Validators.Length - 1); | ||
p = p >= 0 ? (byte)p : (byte)(p + Validators.Length); | ||
return p < priorityPrimaryIndex ? (byte)p : (byte)(p + 1); | ||
} | ||
|
||
public UInt160 GetSender(int index) | ||
{ | ||
return Contract.CreateSignatureRedeemScript(Validators[index]).ToScriptHash(); | ||
|
@@ -80,18 +101,18 @@ public UInt160 GetSender(int index) | |
/// <summary> | ||
/// Return the expected block size | ||
/// </summary> | ||
public int GetExpectedBlockSize() | ||
public int GetExpectedBlockSize(uint pId) | ||
{ | ||
return GetExpectedBlockSizeWithoutTransactions(Transactions.Count) + // Base size | ||
Transactions.Values.Sum(u => u.Size); // Sum Txs | ||
return GetExpectedBlockSizeWithoutTransactions(Transactions[pId].Count) + // Base size | ||
Transactions[pId].Values.Sum(u => u.Size); // Sum Txs | ||
} | ||
|
||
/// <summary> | ||
/// Return the expected block system fee | ||
/// </summary> | ||
public long GetExpectedBlockSystemFee() | ||
public long GetExpectedBlockSystemFee(uint pId) | ||
{ | ||
return Transactions.Values.Sum(u => u.SystemFee); // Sum Txs | ||
return Transactions[pId].Values.Sum(u => u.SystemFee); // Sum Txs | ||
} | ||
|
||
/// <summary> | ||
|
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.
viewNumber is not needed for this formula, because fallback is always 0
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.
Done