Native: move MillisecondsPerBlock setting to native Policy#3895
Native: move MillisecondsPerBlock setting to native Policy#3895
Conversation
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
| /// <param name="snapshot">The snapshot used to read data.</param> | ||
| /// <returns>The block generation time in milliseconds.</returns> | ||
| [ContractMethod(Hardfork.HF_Echidna, CpuFee = 1 << 15, RequiredCallFlags = CallFlags.ReadStates)] | ||
| public uint GetMSPerBlock(IReadOnlyStore snapshot) |
There was a problem hiding this comment.
GetMillisecondsPerBlock and SetMillisecondsPerBlock are better.
Abbreviation is not good idea.
There was a problem hiding this comment.
Or getTimePerBlock
The problem with getTimePerBlock is that it returns an integer and this integer is not the number of seconds (which is a default unit when we're talking about the time). So it's not clear to the end user what is the unit of the time.
That's why we changed it from GetTimePerBlock to GetMSPerBlock in nspcc-dev/neo-go#3835 (comment).
GetMillisecondsPerBlock and SetMillisecondsPerBlock are better.
From the code prospective I agree, but it's the native contract method, and originally I picked shorter name because it will cost less GAS to invoke GetMSPerBlock (just shorter transaction script).
So given these arguments, do you still want to change this name?
There was a problem hiding this comment.
OK, there's not a large diff in GAS price, let's use GetMillisecondsPerBlock and SetMillisecondsPerBlock.
| /// <summary> | ||
| /// The event name for the block generation time changed. | ||
| /// </summary> | ||
| private const string MSPerBlockChangedEventName = "MSPerBlockChanged"; |
There was a problem hiding this comment.
Also change here, "TimePerBlockChanged" or even better "ConsensusTimePerBlockChanged"
There was a problem hiding this comment.
This name must be kept in accordance with the getter/setter name, so we firstly need to agree on #3895 (comment).
| { | ||
| TimeSpan nextDelay = expected_delay - (TimeProvider.Current.UtcNow - clock_started) | ||
| + TimeSpan.FromMilliseconds(maxDelayInBlockTimes * neoSystem.Settings.MillisecondsPerBlock / (double)context.M); | ||
| + TimeSpan.FromMilliseconds(maxDelayInBlockTimes * context.TimePerBlock.TotalMilliseconds / (double)context.M); |
There was a problem hiding this comment.
Later we need to improve this formula as @superboyiii said.
This requires larger extend by factor when block times are slower because the NETWORK P2P delay did not change (it is the same for both cases).
Here we have a parameter that was initially set based on the network delay, that was calibrated for 15s block.
Let's keep this in mind @shargon @AnnaShaleva @Jim8y @roman-khimov
There was a problem hiding this comment.
It's a separate issue that needs careful evaluation, so it won't be done in the current PR.
vncoelho
left a comment
There was a problem hiding this comment.
looks all good! Just some minor changes and ready to go
|
@Jim8y pay attention to my previous comments, I have just reviewed O.o |
|
#3895 (comment) please check it |
No functional changes, fix #3895 (comment). Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
|
@AnnaShaleva good that you fixed RPC, nice catch @shargon I think it is ready |
|
LGTM |
* master: DBFTPlugin: include consensus time into block interval (neo-project#3900) Isolate unit tests (neo-project#3904) Use DateTime.UtcNow (neo-project#3902) Update workflow (neo-project#3901) optimize: show state more readable (neo-project#3899) Optimize KeyedCollectionSlim (neo-project#3877) Native: move MillisecondsPerBlock setting to native Policy (neo-project#3895) optimize: history command support (neo-project#3892) Ensure that view interops can't be changed outside (neo-project#3812)
…ct#3895) * docs: add missing hardforks to the node configuration doc Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru> * Native: move MillisecondsPerBlock setting to native Policy Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru> * Native: rename [get,set]MSPerBlock to [get,set]MillisecondsPerBlock No functional changes, fix neo-project#3895 (comment). Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru> * RpcServer: include dynamic block time into getversion response Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru> --------- Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru> Co-authored-by: Jimmy <jinghui@wayne.edu> Co-authored-by: Christopher Schuchardt <cschuchardt88@gmail.com> Co-authored-by: NGD Admin <154295625+NGDAdmin@users.noreply.github.com>
Description
Move
MillisecondsPerBlockprotocol configuration setting to native Policy contract.Type of change
How Has This Been Tested?
Check_SetMSPerBlockunit-testChecklist: