Skip to content
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] Prevent Store Creation #3444

Merged
merged 2 commits into from
Aug 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/Plugins/DBFTPlugin/Consensus/ConsensusContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ public ConsensusContext(NeoSystem neoSystem, Settings settings, Wallet wallet)
this.wallet = wallet;
this.neoSystem = neoSystem;
dbftSettings = settings;
store = neoSystem.LoadStore(settings.RecoveryLogs);

if (dbftSettings.IgnoreRecoveryLogs == false)
store = neoSystem.LoadStore(settings.RecoveryLogs);
}

public Block CreateBlock()
Expand Down Expand Up @@ -168,7 +170,7 @@ public Block EnsureHeader()

public bool Load()
{
byte[] data = store.TryGet(ConsensusStateKey);
byte[] data = store?.TryGet(ConsensusStateKey);
if (data is null || data.Length == 0) return false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this return false it could affect ConsensusService. (I think that is not possible)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we do something like change all Tryxxxx thing,,, make it return false or true

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This store is only for recovery.

if (!dbftSettings.IgnoreRecoveryLogs && context.Load())
{
if (context.Transactions != null)
{
blockchain.Ask<Blockchain.FillCompleted>(new Blockchain.FillMemoryPool
{
Transactions = context.Transactions.Values
}).Wait();
}
if (context.CommitSent)
{
CheckPreparations();
return;
}
}

MemoryReader reader = new(data);
try
Expand Down Expand Up @@ -272,7 +274,7 @@ public void Reset(byte viewNumber)

public void Save()
{
store.PutSync(ConsensusStateKey, this.ToArray());
store?.PutSync(ConsensusStateKey, this.ToArray());
}

public void Deserialize(ref MemoryReader reader)
Expand Down