-
Notifications
You must be signed in to change notification settings - Fork 33
Closed
Labels
code healthNice to have code improvementNice to have code improvementconsensusConsensus specific changesConsensus specific changescoreCore infrastructure - protocol relatedCore infrastructure - protocol relatedpersistencePersistence specific changesPersistence specific changesutilityUtility specific changesUtility specific changes
Milestone
Description
Objective
Improve the interface exposed by UtilityContext, so it is more functional and has fewer side effects. This will make it clearer how to use it in the context of block preparation, validation and application.
Origin Document
The UtilityContext in shared/modules/utility_module.go partially exposes the following interface:
type UtilityContext interface {
// ...
SetProposalBlock(blockHash string, proposerAddr []byte, txs [][]byte) error
// ...
CreateAndApplyProposalBlock(proposer []byte, maxTxBytes int) (stateHash string, txs [][]byte, err error)
// ...
ApplyBlock() (stateHash string, err error)
// ...
}There are various side effects, as well as implicit behaviour and expectations. For example:
SetProposalBlockmust be called beforeApplyBlock- Only the leader should call
CreateAndApplyProposalBlock CreateAndApplyProposalBlockmodifies the state (not reversible) of the chain even before other validators sign it off
Goals
- Decouple the business logic of block creation and application
- Understand the flow of block preparation, validation and application (for the assignee)
- Make the interface clearer (by improving the interface & documentation) for others to use (e.g. consensus module) and reduce side effects
- Think through ways of rolling back the changes
CreateAndApplyProposalBlockbecause it does not imply that 2/3 of signatures were received
Deliverable
- Split
CreateAndApplyBlockintoCreateBlockandApplyBlock - Reduce the code duplication in
block.gobetween the functionsCreateAndApplyProposalBlockandApplyBlock - Add logs to understand to track the process of block creation and application
- Increase (a bit) test coverage for this functionality
- Search for all
CreateAndApplyProposalBlockorprepareAndApplyBlockinstances in the codebase and refactor those parts of the code- Update consensus module code
- Update utility module code
- Update documentation and end-to-end flows
Non-goals / Non-deliverables
- Implementing rollbacks
General issue deliverables
- Update the appropriate CHANGELOG
- Update any relevant READMEs (local and/or global)
- Update any relevant global documentation & references
- If applicable, update the source code tree explanation
- If applicable, add or update a state, sequence or flowchart diagram using mermaid
Testing Methodology
- New tests related to block creation & validation
- All tests:
make test_all - LocalNet: verify a
LocalNetis still functioning correctly by following the instructions at docs/development/README.md
Creator: @jessicadaugherty
Co-owner: @Olshansk
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
code healthNice to have code improvementNice to have code improvementconsensusConsensus specific changesConsensus specific changescoreCore infrastructure - protocol relatedCore infrastructure - protocol relatedpersistencePersistence specific changesPersistence specific changesutilityUtility specific changesUtility specific changes
Type
Projects
Status
Done