-
Couldn't load subscription status.
- Fork 118
[Protocol] 3 seconds dbft consensus #190
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
Open
Jim8y
wants to merge
9
commits into
neo-project:master
Choose a base branch
from
Jim8y:3-seconds
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
0677205
3 seconds
58fbad9
remove unnecessary issue
09e0406
Update nep-3-seconds.mediawiki
f04e949
Update nep-3-seconds.mediawiki
cc0771e
Update nep-3-seconds.mediawiki
0365d6e
Update nep-3-seconds.mediawiki
0961492
Update nep-3-seconds.mediawiki
aa989ad
Update nep-3-seconds.mediawiki
50c3596
Update nep-3-seconds.mediawiki
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,177 @@ | ||||||||||||||||||||||||||||||||||||||
| <NEP: xxx> | ||||||||||||||||||||||||||||||||||||||
| Title: Reduce Block Time and Gas Generation Rate | ||||||||||||||||||||||||||||||||||||||
| Author: Jimmy Liao <[email protected]>, Vitor Nazário Coelho <[email protected]>, Fernando Díaz Toledano <[email protected]>, Roman Khimov <[email protected]>, Christopher Schuchardt <[email protected]> | ||||||||||||||||||||||||||||||||||||||
| Type: Standard | ||||||||||||||||||||||||||||||||||||||
| Status: Draft | ||||||||||||||||||||||||||||||||||||||
| Created: 2025-02-11 | ||||||||||||||||||||||||||||||||||||||
| Replaces: N/A | ||||||||||||||||||||||||||||||||||||||
| Hardfork: Echidna | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| ==Abstract== | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| This NEP proposes two significant changes to the Neo N3 network parameters: | ||||||||||||||||||||||||||||||||||||||
| 1. Reducing the block time from 15 seconds to 3 seconds | ||||||||||||||||||||||||||||||||||||||
| 2. Reducing the GAS generation rate per block from 5 GAS to 1 GAS | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| ==Motivation== | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| The primary motivations for these changes are: | ||||||||||||||||||||||||||||||||||||||
| 1. Improve transaction throughput and user experience | ||||||||||||||||||||||||||||||||||||||
| 2. Maintain a stable GAS/NEO ratio in the ecosystem | ||||||||||||||||||||||||||||||||||||||
| 3. Better compete with other high-performance blockchain platforms | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| ==Specification== | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| ===Block Time Reduction=== | ||||||||||||||||||||||||||||||||||||||
| * Current value: 15 seconds | ||||||||||||||||||||||||||||||||||||||
| * Proposed value: 3 seconds | ||||||||||||||||||||||||||||||||||||||
| * Implementation: | ||||||||||||||||||||||||||||||||||||||
| * Move block time configuration from dBFT plugin to Policy native contract | ||||||||||||||||||||||||||||||||||||||
| * Allow the council to configure block time through the Policy contract | ||||||||||||||||||||||||||||||||||||||
| * Consensus mechanism will read block time from the Policy contract | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| ===GAS Generation Rate Reduction=== | ||||||||||||||||||||||||||||||||||||||
| * Current value: 5 GAS per block | ||||||||||||||||||||||||||||||||||||||
| * Proposed value: 1 GAS per block | ||||||||||||||||||||||||||||||||||||||
| * Implementation: | ||||||||||||||||||||||||||||||||||||||
| * Retain the existing governance model where council controls GasPerBlock | ||||||||||||||||||||||||||||||||||||||
| * Council will need to adjust GasPerBlock separately after block time changes | ||||||||||||||||||||||||||||||||||||||
| * Coordination between the two changes will be managed through governance | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| ===Policy Contract Enhancement=== | ||||||||||||||||||||||||||||||||||||||
| * New native method: `SetBlockTime(BigInteger milliseconds)` | ||||||||||||||||||||||||||||||||||||||
| * Allows council to set block time through the Policy contract | ||||||||||||||||||||||||||||||||||||||
| * Parameters: | ||||||||||||||||||||||||||||||||||||||
| * `milliseconds`: The new block time in milliseconds | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| ===Native Contract Interface=== | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| The block time configuration method will be added to the <code>PolicyContract</code> native contract in hardfork <code>Echidna</code> with the following interface: | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| <pre> | ||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||
| "name": "setBlockTime", | ||||||||||||||||||||||||||||||||||||||
| "safe": false, | ||||||||||||||||||||||||||||||||||||||
| "parameters": [ | ||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||
| "name": "milliseconds", | ||||||||||||||||||||||||||||||||||||||
| "type": "Integer" | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
| ], | ||||||||||||||||||||||||||||||||||||||
| "returntype": "Boolean" | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
| </pre> | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| ===Method Specification=== | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| The <code>setBlockTime</code> method MUST follow these rules: | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| 1. Permission Requirements: | ||||||||||||||||||||||||||||||||||||||
| * MUST only be callable by the Neo Council through a committee multi-signature transaction | ||||||||||||||||||||||||||||||||||||||
| * MUST fail if called by any other entity | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| 2. Input Requirements: | ||||||||||||||||||||||||||||||||||||||
| * <code>milliseconds</code> MUST be a positive integer representing block time in milliseconds | ||||||||||||||||||||||||||||||||||||||
| * <code>milliseconds</code> MUST be greater than or equal to 1000 (1 second) | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| 3. Behavior: | ||||||||||||||||||||||||||||||||||||||
| * MUST update the block time configuration | ||||||||||||||||||||||||||||||||||||||
| * MUST take effect immediately after the transaction is executed | ||||||||||||||||||||||||||||||||||||||
| * Consensus nodes MUST use the new block time for the next consensus round | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| 4. Return Value: | ||||||||||||||||||||||||||||||||||||||
| * Returns true if the operation is successful | ||||||||||||||||||||||||||||||||||||||
| * Returns false if any validation fails | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| 5. Effect on Contracts: | ||||||||||||||||||||||||||||||||||||||
| * Contract executions MUST adapt to the new block time for all time-related calculations | ||||||||||||||||||||||||||||||||||||||
| * The consensus mechanism MUST read the block time from the Policy contract for each consensus round | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
We'd better add an eventlog in the end of the method. |
||||||||||||||||||||||||||||||||||||||
| ===Hardfork Activation=== | ||||||||||||||||||||||||||||||||||||||
| * The hardfork will: | ||||||||||||||||||||||||||||||||||||||
| * Add the new `SetBlockTime` method to the Policy contract | ||||||||||||||||||||||||||||||||||||||
| * Move block time configuration from consensus settings to Policy contract | ||||||||||||||||||||||||||||||||||||||
| * Initially set the default block time to 15 seconds (current value) | ||||||||||||||||||||||||||||||||||||||
| * After hardfork activation, the council will: | ||||||||||||||||||||||||||||||||||||||
| * Call the new method to set the block time to 3 seconds | ||||||||||||||||||||||||||||||||||||||
| * Adjust the GasPerBlock value separately to 1 GAS | ||||||||||||||||||||||||||||||||||||||
| * Careful coordination will be needed to ensure economic balance | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| ==Rationale== | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| The reduction in block time from 15 to 3 seconds will: | ||||||||||||||||||||||||||||||||||||||
| * Reduce transaction confirmation waiting times | ||||||||||||||||||||||||||||||||||||||
| * Improve DApp responsiveness and user experience | ||||||||||||||||||||||||||||||||||||||
| * Better compete with other high-performance blockchains | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| The reduction in GAS generation from 5 to 1 GAS per block will: | ||||||||||||||||||||||||||||||||||||||
| * Maintain economic balance despite increased block production | ||||||||||||||||||||||||||||||||||||||
| * Preserve the intended tokenomics of the Neo ecosystem | ||||||||||||||||||||||||||||||||||||||
| * Prevent potential GAS oversupply and value dilution | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| == Affected Configurations == | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| * Block Time Configuration: | ||||||||||||||||||||||||||||||||||||||
| * Current: Hardcoded in consensus settings (MillisecondsPerBlock: 15000) | ||||||||||||||||||||||||||||||||||||||
| * Proposed: Configurable via Policy contract with initial value of 15000 | ||||||||||||||||||||||||||||||||||||||
| * Target after council update: 3000 (3 seconds) | ||||||||||||||||||||||||||||||||||||||
| * MaxTransactionsPerBlock: 512 => 256 | ||||||||||||||||||||||||||||||||||||||
| * GasPerBlock: | ||||||||||||||||||||||||||||||||||||||
| * Current: 5 GAS | ||||||||||||||||||||||||||||||||||||||
| * Proposed: Remains configurable by council via existing mechanisms | ||||||||||||||||||||||||||||||||||||||
| * Target after council update: 1 GAS | ||||||||||||||||||||||||||||||||||||||
| * MaxValidUntilBlockIncrement: 100 => 500 | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| ==Backwards Compatibility== | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| This change requires a hard fork as it modifies fundamental network parameters. All nodes must upgrade to maintain network consensus. | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| ==Test Cases== | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| The following scenarios should be tested: | ||||||||||||||||||||||||||||||||||||||
| 1. Network stability under 3-second block times | ||||||||||||||||||||||||||||||||||||||
| 2. Transaction processing under high load | ||||||||||||||||||||||||||||||||||||||
| 3. Node synchronization with faster blocks | ||||||||||||||||||||||||||||||||||||||
| 4. GAS generation and distribution accuracy | ||||||||||||||||||||||||||||||||||||||
| 5. Smart contract execution under new timing constraints | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| ==Potential Issues and Mitigations== | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| 1. Network Stability | ||||||||||||||||||||||||||||||||||||||
| * Issue: Faster block times may increase network overhead | ||||||||||||||||||||||||||||||||||||||
| * Mitigation: Implement improved network optimization and node requirements | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| 2. Smart Contract Timing | ||||||||||||||||||||||||||||||||||||||
| * Issue: Some contracts may assume 15-second blocks | ||||||||||||||||||||||||||||||||||||||
| * Mitigation: Provide migration guidelines and testing framework | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| 3. Network Synchronization | ||||||||||||||||||||||||||||||||||||||
| * Issue: Faster blocks may impact node sync speed | ||||||||||||||||||||||||||||||||||||||
Jim8y marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||
| * Mitigation: Implement enhanced sync protocols | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| 4. Governance Coordination | ||||||||||||||||||||||||||||||||||||||
| * Issue: Non-atomic updates between block time and GAS generation rate | ||||||||||||||||||||||||||||||||||||||
| * Mitigation: Careful governance coordination to adjust both settings in close succession | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| 5. Contract Dependency on Block Time | ||||||||||||||||||||||||||||||||||||||
| * Issue: Contracts relying on block time for time-related calculations will be affected | ||||||||||||||||||||||||||||||||||||||
| * Mitigation: Documentation and tools to help developers update affected contracts | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| ==Implementation== | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| The implementation requires modifications to: | ||||||||||||||||||||||||||||||||||||||
| 1. Policy native contract to add the new `SetBlockTime` method | ||||||||||||||||||||||||||||||||||||||
| 2. Consensus mechanism to read block time from Policy contract | ||||||||||||||||||||||||||||||||||||||
| 3. Neo native contract to coordinate with the new timing system | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| A phased implementation approach is recommended: | ||||||||||||||||||||||||||||||||||||||
| 1. TestNet deployment and testing (2 weeks) | ||||||||||||||||||||||||||||||||||||||
| 2. MainNet deployment preparation (2 weeks) | ||||||||||||||||||||||||||||||||||||||
| 3. Hard fork coordination and execution | ||||||||||||||||||||||||||||||||||||||
| 4. Council governance actions after hardfork: | ||||||||||||||||||||||||||||||||||||||
| * Call `SetBlockTime(3000)` to set new block time | ||||||||||||||||||||||||||||||||||||||
| * Adjust GasPerBlock to 1 GAS using existing governance mechanisms | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| ==Reference Implementation== | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| CSharp implementation: https://github.com/neo-project/neo/pull/3622 | ||||||||||||||||||||||||||||||||||||||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.