-
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
Initialize Consensus at the correct view #779
Conversation
@superboyiii, can you test? |
@dotnet-policy-service agree |
@dotnet-policy-service agree |
@vncoelho is this one ready for review? |
Yes |
@shargon how do you think about this pr? @roman-khimov can you please also take a look? |
Co-authored-by: Shargon <shargon@gmail.com>
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 committed @shargon suggestion, it makes it simpler.
@@ -157,7 +157,7 @@ private void OnStart() | |||
return; | |||
} | |||
} | |||
InitializeConsensus(0); | |||
InitializeConsensus(context.ViewNumber); |
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's good that you've simplified the code by removing the unnecessary if condition. However, it would be better to add a null check for context
before using context.ViewNumber
to avoid potential NullReferenceException.
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.
Thanks bot, I thought about that in previous discussions here. That why I did not applied the change before.
Perhaps we need to check if its null and then set to 0 for such case.
Can you apply that?
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 bot is so polite.
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.
Thanks bot, I thought about that in previous discussions here. That why I did not applied the change before. Perhaps we need to check if its null and then set to 0 for such case. Can you apply that?
InitializeConsensus(context?.ViewNumber ?? 0);
This bot is so polite.
Well the difference is I have the solution
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.
If it's null
then highly likely we're dead already at the line 145, so I don't think it's a problem.
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.
Thanks Cris, can you suggest the change?
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.
Line 145 @roman-khimov is
https://github.com/neo-project/neo-modules/blob/a57e51fa85c03f3f8823bdb7701a95aa0478df5c/src/DBFTPlugin/Consensus/ConsensusService.cs#L145C1-L145C68
I do not see where context.ViewNumber was initialized in a normal use case, without recovery.
Maybe 0 is the default of the C# creation of the context class, but I am not sure.
@@ -157,7 +157,7 @@ private void OnStart() | |||
return; | |||
} | |||
} | |||
InitializeConsensus(0); | |||
InitializeConsensus(context.ViewNumber); |
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.
If it's null
then highly likely we're dead already at the line 145, so I don't think it's a problem.
I am going to test, but last time (1 year ago), I thought that @cschuchardt88 suggestion |
My comment from Dec,2022 |
I cannot test against current master, there is some another error in my setup neo> FATAL [23:55:59.600] System.Collections.Generic.KeyNotFoundException
The given key 'Store' was not present in the dictionary.
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at Neo.Persistence.StoreFactory.GetStore(String storageEngine, String path) in /opt/neoLib/src/Neo/Persistence/StoreFactory.cs:line 48
at Neo.NeoSystem.LoadStore(String path) in /opt/neoLib/src/Neo/NeoSystem.cs:line 228
at Neo.Plugins.TokensTracker.OnSystemLoaded(NeoSystem system)
at Neo.NeoSystem..ctor(ProtocolSettings settings, IStore storage) in /opt/neoLib/src/Neo/NeoSystem.cs:line 137
at Neo.NeoSystem..ctor(ProtocolSettings settings, String storageEngine, String storagePath) in /opt/neoLib/src/Neo/NeoSystem.cs:line 118
at Neo.CLI.MainService.Start(CommandLineOptions options) in /opt/neoLib/src/Neo.CLI/CLI/MainService.cs:line 380
at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_1(Object state)
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()
Unhandled exception. System.Collections.Generic.KeyNotFoundException: The given key 'Store' was not present in the dictionary.
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at Neo.Persistence.StoreFactory.GetStore(String storageEngine, String path) in /opt/neoLib/src/Neo/Persistence/StoreFactory.cs:line 48
at Neo.NeoSystem.LoadStore(String path) in /opt/neoLib/src/Neo/NeoSystem.cs:line 228
at Neo.Plugins.TokensTracker.OnSystemLoaded(NeoSystem system)
at Neo.NeoSystem..ctor(ProtocolSettings settings, IStore storage) in /opt/neoLib/src/Neo/NeoSystem.cs:line 137
at Neo.NeoSystem..ctor(ProtocolSettings settings, String storageEngine, String storagePath) in /opt/neoLib/src/Neo/NeoSystem.cs:line 118
at Neo.CLI.MainService.Start(CommandLineOptions options) in /opt/neoLib/src/Neo.CLI/CLI/MainService.cs:line 380
at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_1(Object state)
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()
/opt/start_node.sh: line 2: 128 Aborted (core dumped) dotnet neo-cli.dll |
@neo-project/core please wait until I can test the PR against current master branch, or, at least, add @cschuchardt88 suggestion. |
Yes it is needed because of line |
You do not have the |
close #778