-
Notifications
You must be signed in to change notification settings - Fork 33
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
[Persistence][Utility] Separate all CreateAndApply functions into more functional components - Issue #508 #652
Changes from 21 commits
716ffa5
f7e21f4
7d3bf19
096470e
d6335e4
1ab4d5f
54af6c9
88388f8
f6cf148
719c436
af89d70
33e19c1
f092dcd
657841c
9a54d76
239bc72
c5d07f5
c80c0fd
c3828cf
757ebff
a8f80d0
9b8c85f
5c625ee
4be8bf7
391db17
9208678
ed49d93
d96bb0e
7f5df10
1911fb1
abbe4e6
3ecdc23
d17a865
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 | |
|
||
## [Unreleased] | ||
|
||
## [0.0.0.48] - 2023-04-06 | ||
|
||
- Renamed `CreateAndApplyProposalBlock` to `CreateProposalBlock` | ||
|
||
## [0.0.0.47] - 2023-04-06 | ||
|
||
- Updated to reflect pools address changes | ||
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. The provided code patch shows changes in a project's version history, specifically the addition of version 0.0.0.48 entry with a change made on 2023-04-06. The actual code change consists of renaming a function:
Here are some considerations for this change:
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. This actually isn't bad |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 | |
|
||
## [0.0.0.34] - 2023-04-06 | ||
|
||
- Renamed `CreateAndApplyProposalBlock` to `CreateProposalBlock` | ||
- Added `GetPrevBlockByzantineValidators` and `ProposalBlockNotSet` errors | ||
- Instrumented `CreateProposalBlock` and `ApplyBlock` with log statements | ||
- Refactored functions for block creation and application to be more readable/modular | ||
- Added TODOs for future refactoring | ||
- Renamed `u` to `uow` for consistency | ||
Olshansk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## [0.0.0.34] - 2023-04-06 | ||
|
||
- Updated to reflect pools address changes | ||
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. Overall, the code patch seems to be well-documented and easy to understand. Here are a few suggestions that might improve the patch:
Since I don't have access to the full code, I cannot point out any functionality bugs, but these suggestions can help improve the code you've provided. 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. Here's a brief review of the provided code patch:
Overall, the patch seems focused on increasing code readability and improving functionality. Testing the updated code thoroughly, both automatically and manually, is critical to ensure correctness and stability. Additionally, prompt action on the TODOs mentioned would be ideal for continuous improvement. |
||
|
||
## [0.0.0.33] - 2023-03-30 | ||
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. Your code patch seems to include the following changes:
Quick code review suggestions:
Without the full context of your project, it's not possible to be more detailed about specific risks or improvements. However, always write comprehensive unit tests to mitigate risks in introducing logic problems, and follow good coding practices. Also, consider running static analysis tools to identify any other improvement opportunities. |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,7 +40,7 @@ func NewError(code Code, msg string) Error { | |
} | ||
} | ||
|
||
// NextCode: 133 | ||
// NextCode: 135 | ||
type Code float64 // CONSIDERATION: Should these be a proto enum or a golang iota? | ||
|
||
//nolint:gosec // G101 - Not hard-coded credentials | ||
|
@@ -115,6 +115,7 @@ const ( | |
CodeInvalidServiceURLError Code = 70 | ||
CodeNotExistsError Code = 71 | ||
CodeGetMissedBlocksError Code = 72 | ||
CodeGetPrevBlockByzantineValidators Code = 134 | ||
CodeEmptyHashError Code = 73 | ||
CodeInvalidBlockHeightError Code = 74 | ||
CodeUnequalPublicKeysError Code = 75 | ||
|
@@ -174,6 +175,7 @@ const ( | |
CodeGetHeightError Code = 129 | ||
CodeUnknownActorType Code = 130 | ||
CodeUnknownMessageType Code = 131 | ||
CodeProposalBlockNotSet Code = 133 | ||
) | ||
|
||
const ( | ||
|
@@ -184,6 +186,7 @@ const ( | |
UnequalVoteTypesError = "the vote types are not equal" | ||
UnequalPublicKeysError = "the two public keys are not equal" | ||
GetMissedBlocksError = "an error occurred getting the missed blocks field" | ||
GetPrevBlockByzantineValidators = "an error occurred getting the previous block's byzantine validators" | ||
DecodeMessageError = "unable to decode the message" | ||
NotExistsError = "the actor does not exist in the state" | ||
InvalidServiceURLError = "the service url is not valid" | ||
|
@@ -284,6 +287,7 @@ const ( | |
InvalidTransactionCountError = "the total transactions are less than the block transactions" | ||
EmptyTimestampError = "the timestamp field is empty" | ||
EmptyProposerError = "the proposer field is empty" | ||
ProposalBlockNotSet = "the proposal block is not set" | ||
EmptyNetworkIDError = "the network id field is empty" | ||
InvalidHashLengthError = "the length of the hash is not the correct size" | ||
NilQuorumCertificateError = "the quorum certificate is nil" | ||
|
@@ -366,6 +370,10 @@ func ErrGetMissedBlocks(err error) Error { | |
return NewError(CodeGetMissedBlocksError, fmt.Sprintf("%s: %s", GetMissedBlocksError, err.Error())) | ||
} | ||
|
||
func ErrGetPrevBlockByzantineValidators(err error) Error { | ||
return NewError(CodeGetPrevBlockByzantineValidators, fmt.Sprintf("%s: %s", GetPrevBlockByzantineValidators, err.Error())) | ||
} | ||
|
||
func ErrGetStakedTokens(err error) Error { | ||
return NewError(CodeGetStakedAmountError, GetStakedAmountsError) | ||
} | ||
|
@@ -767,6 +775,10 @@ func ErrEmptyProposer() Error { | |
return NewError(CodeEmptyProposerError, EmptyProposerError) | ||
} | ||
|
||
func ErrProposalBlockNotSet() Error { | ||
return NewError(CodeProposalBlockNotSet, ProposalBlockNotSet) | ||
} | ||
|
||
func ErrEmptyTimestamp() Error { | ||
return NewError(CodeEmptyTimestampError, EmptyTimestampError) | ||
} | ||
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. Overall, the code patch seems to be mainly adding new error codes and corresponding error messages. Here are a few observations and suggestions:
Add comments like the following example for better understanding: + CodeGetPrevBlockByzantineValidators Code = 134 // Add a brief description here
+ CodeProposalBlockNotSet Code = 133 // Add a brief description here
With these observations and suggestions, your code should be more maintainable and easier to understand. |
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on the given code patch, here's a brief code review:
The changes in versioning and release notes are well-documented and clear.
Renaming
CreateAndApplyProposalBlock
toCreateProposalBlock
potentially reflects better separation of concerns in your application.Updating to use the new
ApplyBlock
signature andGetStateHash()
function fromutilityUnitOfWork
ensures consistency across the project.Removing the duplicate import means the code will be cleaner and more efficient.
Formatting inconsistencies are fixed by adding line breaks before and after listing updates for [0.0.0.42].
Overall, the changes appear beneficial and I don't see any obvious bugs or risks. However, it's important to ensure these changes are covered by appropriate tests and don't introduce unintended behavior throughout the project.