-
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
Optimize OnPersists #3146
Optimize OnPersists #3146
Conversation
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. |
|
@@ -283,9 +285,18 @@ private void SetGasPerBlock(ApplicationEngine engine, BigInteger gasPerBlock) | |||
throw new ArgumentOutOfRangeException(nameof(gasPerBlock)); | |||
if (!CheckCommittee(engine)) throw new InvalidOperationException(); | |||
|
|||
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 }; |
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.
one argument is missing here, no?
The correct constructor requires 3
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.
PreviousGas
default value is 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.
- We need some number to proof this is worth doing at all.
- How often people request this via RPC?
@@ -184,6 +185,7 @@ internal override ContractTask InitializeAsync(ApplicationEngine engine, Hardfor | |||
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 })); |
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.
Please, do not change the storage scheme, it's very easy to cache the value.
is not only requested by rpc, also is used on each block |
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. |
@neo-project/core what about this pr? |
@shargon any plan on this pr? |
I will use a different approach |
Close #3145