Skip to content

Remove MillisecondsPerBlock, MaxValidUntilBlockIncrement, MaxTraceableBlocks from PolicyContract#4337

Merged
erikzhang merged 7 commits intoneo-project:masterfrom
erikzhang:remove-some-api
Dec 1, 2025
Merged

Remove MillisecondsPerBlock, MaxValidUntilBlockIncrement, MaxTraceableBlocks from PolicyContract#4337
erikzhang merged 7 commits intoneo-project:masterfrom
erikzhang:remove-some-api

Conversation

@erikzhang
Copy link
Member

@erikzhang erikzhang commented Nov 25, 2025

…eBlocks from PolicyContract

Remove MillisecondsPerBlock, MaxValidUntilBlockIncrement, MaxTraceableBlocks from PolicyContract.

  1. The block time will be dynamically determined by the consensus nodes based on network load.
  2. MaxValidUntilBlockIncrement and MaxTraceableBlocks should be exposed as immutable values.

Type of change

  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

How Has This Been Tested?

  • Unit Testing
  • Run Application
  • Local Computer Tests
  • No Testing

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
@github-actions github-actions bot added the N4 label Nov 25, 2025
Copy link
Member

@vncoelho vncoelho left a comment

Choose a reason for hiding this comment

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

I understand the change and looks fine for its purpose.

The reasoning here is probably to avoid unnecessary state changes on a SC and the parameter become a stateless decision agreed by CN's.

On the hand other, one may need to monitor P2P to understand network heartbeat, right?

# Conflicts: # src/Neo/SmartContract/Native/PolicyContract.cs
@shargon
Copy link
Member

shargon commented Nov 26, 2025

The block time will be dynamically determined by the consensus nodes based on network load.

But this must be configured by the policy, isn't it? so instead of remove we should move this config to each level

@erikzhang
Copy link
Member Author

But this must be configured by the policy, isn't it? so instead of remove we should move this config to each level

I hope this parameter will be adaptive in the future, requiring no adjustment. For now, we can treat it as a configuration item for the consensus plugin.

@vncoelho
Copy link
Member

As I asked above, what is the main reason behind this? To avoid state changes on the blockchain, right?

{
var mtb = Policy.GetMaxTraceableBlocks(engine.SnapshotCache);
return IsTraceableBlock(engine.SnapshotCache, index, mtb);
return IsTraceableBlock(engine.SnapshotCache, index, engine.ProtocolSettings.MaxTraceableBlocks);
Copy link
Member

Choose a reason for hiding this comment

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

How can we ensure the deterministic behavior between nodes if any node can have a different configuration? We can use a hash of the config for Blockchain id, but seems easier in policy

Copy link
Member

Choose a reason for hiding this comment

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

In terms of behavior, as it will be we will only measure due to performance.
Maybe with something like neo-project/proposals#211 (comment)

On the other hand, I am trying to understand the real motivation behind this. If this is to avoid state changes.

In particular, I believe that for such things we should implement a temporary state, such as Blobs.

Copy link
Member

Choose a reason for hiding this comment

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

So, instead of writing on a Native Contract we publish that states with Blobs that will become unavailable in the future.

That is what ETH did for making Layer 2 cheaper.

Copy link
Member Author

Choose a reason for hiding this comment

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

How can we ensure the deterministic behavior between nodes if any node can have a different configuration? We can use a hash of the config for Blockchain id, but seems easier in policy

There's no difference between putting parameters in a configuration file and hard-coding them in the code. The purpose of a configuration file is to provide different parameters for different networks, not to allow different nodes to modify them arbitrarily.

@Wi1l-B0t
Copy link
Contributor

Remove MillisecondsPerBlock after dynamic block time is available?

@erikzhang
Copy link
Member Author

Remove MillisecondsPerBlock after dynamic block time is available?

In fact, another important reason for removing MillisecondsPerBlock from the PolicyContract is that its current implementation is incorrect. Changing the block time necessitates changing the GAS distribution model. Currently, GAS is distributed based on block height, and changing the block time alters the rate of GAS issuance. Under the current GAS distribution model, the block time must remain fixed.

Copy link
Member

@shargon shargon left a comment

Choose a reason for hiding this comment

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

Let's check the expected behavior when finish the dynamic block interval

@erikzhang erikzhang merged commit c104d63 into neo-project:master Dec 1, 2025
7 checks passed
@erikzhang erikzhang deleted the remove-some-api branch December 1, 2025 11:28
@vncoelho vncoelho mentioned this pull request Dec 29, 2025
18 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

5 participants