Add generation balance validation#1938
Merged
nickeskov merged 87 commits intodetermenistic-finality-featurefrom Dec 16, 2025
Merged
Add generation balance validation#1938nickeskov merged 87 commits intodetermenistic-finality-featurefrom
nickeskov merged 87 commits intodetermenistic-finality-featurefrom
Conversation
Submodule updated to the latest commit.
Package renamed from blssig to bls. Crypto primitives SecretKey, PublicKey and Signature were added. Public functions Sing and Verify reimplemented to use new primitives. Function to create aggregated signature from multiple Waves secrets keys was removed because it was useful only in tests. PoP functions moved to separate file.
Fixed review issues.
…ration-transaction
…ration-transaction
BLS package used to validate PoP during transaction validation.
Test on Protobuf round-trip added.
Reduced cognitive complexity of the new test.
Added test on JSON serialization of new transaction. WIP: added skipped test on Scala compatibility of JSON serialization.
esuwu
reviewed
Dec 11, 2025
Test on CommitToGeneration transaction JSON deserialization updated and skip removed.
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request adds generation balance validation to CommitToGenerationWithProofs transactions, ensuring that generators have sufficient balance before committing to the next generation period.
Key Changes
- Added balance validation in
checkCommitToGenerationWithProofsthat verifies the generator has enough balance after deducting the deposit (100 WAVES) and transaction fee to meet the minimal generating balance requirement - Implemented
minimalGeneratingBalanceAtHeightfunction in the features layer to calculate the required minimal generating balance based on feature activations (1,000 WAVES with SmallerMinimalGeneratingBalance feature, otherwise 10,000 WAVES) - Refactored code for improved maintainability, including extracting Ethereum transaction validation logic into separate methods and consolidating common asset operation checks
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/state/transaction_checker_test.go | Added comprehensive test cases for insufficient generating balance scenarios; updated existing test values to use smaller block heights for faster execution |
| pkg/state/transaction_checker.go | Implemented generation balance validation logic; refactored Ethereum transaction checking into separate helper methods; improved error messages with proper capitalization |
| pkg/state/features.go | Added minimalGeneratingBalanceAtHeight function to compute minimal generating balance based on timestamp and feature activation |
| pkg/state/state.go | Added public MinimalGeneratingBalanceAtHeight method; improved recipient-to-address conversion with nil checks; removed unnecessary else clauses |
| pkg/state/feautures_interface.go | Extended interface with minimalGeneratingBalanceAtHeight method |
| pkg/state/feautures_moq_test.go | Updated mock implementation with new method |
| pkg/consensus/blocks_validation.go | Refactored to use centralized minimalGeneratingBalanceAtHeight from state layer; removed duplicate constants and logic |
| pkg/consensus/validator_moq_test.go | Updated mock with MinimalGeneratingBalanceAtHeight method |
| pkg/state/ethereum_tx_test.go | Updated test expectations to match corrected error message capitalization |
| pkg/proto/block.go | Fixed grammar in comment ("a io.Reader" → "an io.Reader"); removed unnecessary else clauses |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
nickeskov
reviewed
Dec 12, 2025
Increased value is used only in tests on CommitToGeneration transaction validations.
More review fixes.
…ration-transaction
Collaborator
|
@alexeykiselev should we mere this PR first or #1841? |
…on-balace-validation
Base automatically changed from
add-commit-to-generation-transaction
to
determenistic-finality-feature
December 16, 2025 07:01
nickeskov
approved these changes
Dec 16, 2025
nickeskov
approved these changes
Dec 16, 2025
87af3f3
into
determenistic-finality-feature
16 of 17 checks passed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This pull request refactors how the minimal generating balance for block validation is determined, making it more flexible and future-proof by moving the logic into the state layer and using feature activation checks. Additionally, it updates related interfaces, mock implementations, and test code to support this change. Minor code cleanups and test message corrections are also included.
Consensus and Validation Logic Improvements:
blocks_validation.gonow retrieves the required balance dynamically via the newMinimalGeneratingBalanceAtHeightmethod from the state, instead of using hardcoded constants and feature checks. This centralizes and simplifies the logic for determining the required balance for block generation. [1] [2]smallerMinimalGeneratingBalanceActivatedmethod and related constants, as this logic is now encapsulated in the state layer. [1] [2]State Layer Enhancements:
minimalGeneratingBalanceAtHeightmethod to thefeaturesstruct, which determines the minimal generating balance based on height, timestamp, and feature activation. The corresponding interface and mock implementations are updated to support this. [1] [2] [3] [4]Testing and Mock Updates:
stateInfoProviderandfeaturesStatemocks and their usage in tests to support the new method signatures and logic, including tracking calls and arguments for the new and modified methods. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11]Minor Cleanups:
block.gofor marshaling logic and fixed a comment typo. [1] [2] [3]