Skip to content

Conversation

@shargon
Copy link
Member

@shargon shargon commented Feb 17, 2024

Close #3145

@Jim8y
Copy link
Contributor

Jim8y commented Feb 17, 2024

A glance of this pr, no idea what its for. Would be great to have some comments in the code, and description in the pr.

@shargon
Copy link
Member Author

shargon commented Feb 17, 2024

A glance of this pr, no idea what its for. Would be great to have some comments in the code, and description in the pr.

#3145


uint index = engine.PersistingBlock.Index + 1;
StorageItem entry = engine.Snapshot.GetAndChange(CreateStorageKey(Prefix_GasPerBlock).AddBigEndian(index), () => new StorageItem(gasPerBlock));
var gp = new GasPerBlock() { Gas = gasPerBlock, Index = engine.PersistingBlock.Index + 1 };
Copy link
Member

Choose a reason for hiding this comment

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

one argument is missing here, no?
The correct constructor requires 3

Copy link
Member Author

Choose a reason for hiding this comment

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

PreviousGas default value is 0

Copy link
Contributor

@roman-khimov roman-khimov left a comment

Choose a reason for hiding this comment

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

  1. We need some number to proof this is worth doing at all.
  2. How often people request this via RPC?

engine.Snapshot.Add(CreateStorageKey(Prefix_Committee), new StorageItem(cachedCommittee));
engine.Snapshot.Add(CreateStorageKey(Prefix_VotersCount), new StorageItem(System.Array.Empty<byte>()));
engine.Snapshot.Add(CreateStorageKey(Prefix_GasPerBlock).AddBigEndian(0u), new StorageItem(5 * GAS.Factor));
engine.Snapshot.Add(CreateStorageKey(Prefix_GasPerBlockCurrent), new StorageItem(new GasPerBlock() { Gas = 5 * GAS.Factor, PreviousGas = 5 * GAS.Factor, Index = 0 }));
Copy link
Contributor

Choose a reason for hiding this comment

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

Please, do not change the storage scheme, it's very easy to cache the value.

@shargon
Copy link
Member Author

shargon commented May 24, 2024

  1. We need some number to proof this is worth doing at all.
  2. How often people request this via RPC?

is not only requested by rpc, also is used on each block

@roman-khimov
Copy link
Contributor

This returns us to #3145. It's very easy to cache for blocks (and not only for blocks). Storage scheme change that duplicates some already existing data should have more justification to me.

@Jim8y
Copy link
Contributor

Jim8y commented Jun 1, 2024

@neo-project/core what about this pr?

@Jim8y
Copy link
Contributor

Jim8y commented Jun 24, 2024

@shargon any plan on this pr?

@shargon
Copy link
Member Author

shargon commented Jun 25, 2024

I will use a different approach

@shargon shargon closed this Jun 25, 2024
@shargon shargon deleted the core-optimize-persist branch June 25, 2024 09:03
@shargon shargon mentioned this pull request Jan 21, 2025
15 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Optimize OnPersist

6 participants