-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Seconds to milliseconds #918
Conversation
@@ -27,7 +27,7 @@ public static PingPayload Create(uint height, uint nonce) | |||
return new PingPayload | |||
{ | |||
LastBlockIndex = height, | |||
Timestamp = DateTime.UtcNow.ToTimestamp(), | |||
Timestamp = DateTime.UtcNow.ToTimestampMS(), |
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.
Maybe we can leave the Ping in seconds.
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.
It is better to leave everything using the same "unit", what do you think?
@@ -31,7 +31,7 @@ public static VersionPayload Create(uint nonce, string userAgent, params NodeCap | |||
{ | |||
Magic = ProtocolSettings.Default.Magic, | |||
Version = LocalNode.ProtocolVersion, | |||
Timestamp = DateTime.Now.ToTimestamp(), | |||
Timestamp = DateTime.Now.ToTimestampMS(), |
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.
Maybe we can leave the version payload in seconds as well.
Codecov Report
@@ Coverage Diff @@
## master #918 +/- ##
==========================================
- Coverage 45.53% 45.47% -0.06%
==========================================
Files 178 178
Lines 12635 12639 +4
==========================================
- Hits 5753 5748 -5
- Misses 6882 6891 +9
Continue to review full report at Codecov.
|
neo.UnitTests/UT_Consensus.cs
Outdated
@@ -79,7 +79,7 @@ public void ConsensusService_Primary_Sends_PrepareRequest_After_OnStart() | |||
|
|||
Console.WriteLine($"header {header} hash {header.Hash} timstamp {timestampVal}"); | |||
|
|||
timestampVal.Should().Be(4244941696); //1968-06-01 00:00:00 | |||
timestampVal.Should().Be(1514007552); //1968-06-01 00:00:00 |
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.
@igormcoelho, can you check this adjustment on these tests? I just copied the new generated timestamp.
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.
This doesn't look right... it should increase, never decrease 😂 probably, it is overflowing some int32 size (should be int64 or long, at least).
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.
kkkkkkkkkkk
I knew that....
Things need all be long for us. Ram never was a problem when things have vallgrind.
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.
What is this date?
How did you guys manage to make 4244941696 be 1968-06-01 00:00:00? Seems weird to me. Maybe the tests were broken all this time?
neo/Consensus/ConsensusService.cs
Outdated
private void ExtendTimerByFactor(int maxDelayInBlockTimes) | ||
{ | ||
TimeSpan nextDelay = expected_delay - (TimeProvider.Current.UtcNow - clock_started) + TimeSpan.FromMilliseconds(maxDelayInBlockTimes * Blockchain.SecondsPerBlock * 1000.0 / context.M); | ||
TimeSpan nextDelay = expected_delay - (TimeProvider.Current.UtcNow - clock_started) + TimeSpan.FromMilliseconds(maxDelayInBlockTimes * Blockchain.MillisecondsPerBlock * 1000 / context.M); |
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.
Does we need to include this .0
for forcing to float?
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.
TimePerBlock ?
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.
Fix the dates - We should use 01/01/1970 00:00:00 instead of 01/06/1968 00:00
Use ulong instead of uint.
neo.UnitTests/UT_Consensus.cs
Outdated
@@ -79,7 +79,7 @@ public void ConsensusService_Primary_Sends_PrepareRequest_After_OnStart() | |||
|
|||
Console.WriteLine($"header {header} hash {header.Hash} timstamp {timestampVal}"); | |||
|
|||
timestampVal.Should().Be(4244941696); //1968-06-01 00:00:00 | |||
timestampVal.Should().Be(1514007552); //1968-06-01 00:00:00 |
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.
What is this date?
How did you guys manage to make 4244941696 be 1968-06-01 00:00:00? Seems weird to me. Maybe the tests were broken all this time?
@@ -27,7 +27,7 @@ public static PingPayload Create(uint height, uint nonce) | |||
return new PingPayload | |||
{ | |||
LastBlockIndex = height, | |||
Timestamp = DateTime.UtcNow.ToTimestamp(), | |||
Timestamp = DateTime.UtcNow.ToTimestampMS(), |
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.
It is better to leave everything using the same "unit", what do you think?
…into seconds-to-milliseconds
Thanks, @lock9, I am thinking about still waiting a little bit more until @erikzhang and @shargon can give another last check. |
@@ -283,7 +283,10 @@ private RelayResultReason OnNewBlock(Block block) | |||
block_cache_unverified.Remove(blockToPersist.Index); | |||
Persist(blockToPersist); | |||
|
|||
if (blocksPersisted++ < blocksToPersistList.Count - (2 + Math.Max(0, (15 - SecondsPerBlock)))) continue; | |||
// 15000 is the default among of seconds per block, while MilliSecondsPerBlock is the current | |||
uint extraBlocks = (15000 - MillisecondsPerBlock) / 1000; |
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.
15000 is a hardcoded value, you should take this from the config
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.
That is right, it has been like this. I just adjusted to ms.
We can do that in another PR, for avoiding other possible mistakes.
Furthermore, I am not good with this config until nowdays...
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.
This, should take the value from the configuration
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.
I don't understand this logic very well ... why it used this?
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.
As faster the network is (privatenets with 1s) more blocks are rebroadcasted each time you Persist, limitted to 2+15.
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.
Is possible to store it in 6 bytes instead of 8.
- 4 for seconds, and 2 more for milliseconds.
We can save 2 bytes.
It is possible, @shargon, however, the timestamp in seconds will also expire in 27 years...kkkkkkkk I think that it is ok as |
Co-Authored-By: Shargon <shargon@gmail.com>
i will review it tomorrow |
This was already from milliseconds, thus, just removing the multiplier
🚀 aheuaheuaea |
We should merge it when the tests come |
The basic UTs were accomplished. Furthermore, each time more we gonna have to work double because of conflicts between PRs, and after merged we can focused on the next idea. |
* Seconds to milliseconds * Sending unsaved files * fixing formula of consensus bonification * Refactoring milliseconds * Refactoring milliseconds from capeslock * Refactoring milliseconds from capeslock II * Adjusting UT * Adjusting UT II * Super fast protocol to 2s * Fixing timestamps to long and tests * Minor adjusts * Change view deserialization fix * Timestamp to ulong * Update neo/Helper.cs Co-Authored-By: Shargon <shargon@gmail.com> * Update JNumber.cs * Optimize and remove TODO * Update ApplicationEngine.cs * Fixing ExtendTimerByFactor This was already from milliseconds, thus, just removing the multiplier
Follow-up for 6604647 and 15a7927 to provide Neo 3 compatibility. Neo PR: neo-project/neo#918.
Follow-up for 6604647 and 15a7927 to provide Neo 3 compatibility. Neo PR: neo-project/neo#918.
closes #651
Let's review this with careful.
I believe it will be a great chance, in particular, for very lightweight local neo privatenets.