-
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
[Utility] Foundational bugs, tests, code cleanup and improvements (1 / 2) #503
Conversation
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.
@deblasis I'm still thinking through a couple of your comments and will follow up if I have a better idea. In the meantime, left some responses and addressed some of the changes.
shared/codec/codec.go
Outdated
} | ||
|
||
var _ Codec = &ProtoCodec{} | ||
type ICodec proto.Message |
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.
I added it, but then actually did not end up using it as intended.
The idea was to show that some of our interfaces add functionality to serializable types based on the codec we're using.
_ codec.ICodec = &Transaction{}
I'm removing it for now (since it is extra code that doesn't provide much benefit), but we should discuss that this is a very implicit design pattern others might not understand.
Adding the following in codec.go
in the meantime:
// DOCUMENT: Some of the types through the code based (e.g. Transaction) are defined via serializable
// files (e.g. .proto files) and add functionality defined in go on top of it (e.g. ITransaction). This
// a very implicit design pattern that may be non-obvious to new developers.
shared/codec/codec.go
Outdated
} | ||
|
||
var _ Codec = &ProtoCodec{} | ||
type ICodec proto.Message |
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.
After doing the above and running tests, I got the following errors:
utility/types/message.go:179:20: msg.ProtoReflect undefined (type Message has no field or method ProtoReflect)
utility/types/message.go:183:38: cannot use msg (variable of type Message) as type protoreflect.ProtoMessage in argument to codec.GetCodec().Marshal:
For now, I've renamed ICodec
to CodecType
so I can embed it in message but going to keep thinking.
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.
@deblasis PTAL (please take another look).
Left some replies in the resolved comments as well as kept a few ones open. Will also update the chanelogs.
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.
@Olshansk I guess the pending convos are:
- [Utility] Foundational bugs, tests, code cleanup and improvements (1 / 2) #503 (comment)
- [Utility] Foundational bugs, tests, code cleanup and improvements (1 / 2) #503 (comment)
- [Utility] Foundational bugs, tests, code cleanup and improvements (1 / 2) #503 (comment)
They are mostly questions and nits. I feel confident to just approve at this point. The main points have been already addressed I reckon
* pokt/main: [Infra] KISS 3 - Cluster Manager [Merge me after #521] - (Issues: #490) (#522) Refactor/fix state sync logs (#515) [P2P] KISS 2 - Peer discovery [Merge me after #520] - (Issues: #416, #429) (#521) [Core] KISS 1 - Finite State Machine [Merge me first] - (Issue: #499) (#520) [CLI] Stake command bugfix (#518) [CLI] Cannot run make localnet_client_debug: Cannot initialise the keybase with the validator keys: Unable to find YAML file (#517) Fix the link shown by `make go_doc` Fixed duplicate GITHUB_WIKI tag [Documentation] Update Devlog Formatting (#512) [Docs & Bugs] Minor fixes post keybase changes (#513) [Utility] Foundational bugs, tests, code cleanup and improvements (1 / 2) (#503) [Tooling] Integrate Keybase w/ CLI (Issue #484 ) (#501) update devlog2.md update devlog2.md Update devlog1.md
* pokt/main: [Infra] KISS 3 - Cluster Manager [Merge me after #521] - (Issues: #490) (#522) Refactor/fix state sync logs (#515) [P2P] KISS 2 - Peer discovery [Merge me after #520] - (Issues: #416, #429) (#521) [Core] KISS 1 - Finite State Machine [Merge me first] - (Issue: #499) (#520) [CLI] Stake command bugfix (#518) [CLI] Cannot run make localnet_client_debug: Cannot initialise the keybase with the validator keys: Unable to find YAML file (#517) Fix the link shown by `make go_doc` Fixed duplicate GITHUB_WIKI tag [Documentation] Update Devlog Formatting (#512) [Docs & Bugs] Minor fixes post keybase changes (#513) [Utility] Foundational bugs, tests, code cleanup and improvements (1 / 2) (#503) [Tooling] Integrate Keybase w/ CLI (Issue #484 ) (#501) update devlog2.md update devlog2.md Update devlog1.md
…3) (#550) ## Description The second of three changes necessary to refactor and improve the utility module to enable implementation of future, more complex, interfaces. While the list of changes in #503 was more bug & testing focused, this PR was more readability & documentation focused in preparation for M3. ## Issue Fixes #504 ## Type of change Please mark the relevant option(s): - [ ] New feature, functionality or library - [x] Bug fix - [x] Code health or cleanup - [x] Major breaking change - [ ] Documentation - [ ] Other <!-- add details here if it a different type of change --> ## List of changes - Fixed bug where we were not removing txs from the mempool of replicas - Improved the readability of the `Block` lifecycle and `Message` validation - Replace unnecessary functions in such as `Store()`, `getStoreAndHeight()` and a few otherwise - Moved the `Transaction` proto to the shared module - Added documentation to `TxResult` result and removed `DefaultTxResult` and - Added extensive documentation to functions involved in the Block lifecycle - Removed unnecessary fields from the `BlockHeader` - Renamed `GenericParam` to `ServiceURL` - Consolidated `StakeStatus` in the shared package - Renamed governance parametesr related to rate limitting Applications - Renamed `applyTx` to `hydrateTx` and added documentation on its functionality ## Testing - [x] `make develop_test` - [x] [LocalNet](https://github.com/pokt-network/pocket/blob/main/docs/development/README.md) w/ all of the steps outlined in the `README` ## Required Checklist - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [x] I have tested my changes using the available tooling - [x] I have updated the corresponding CHANGELOG ### If Applicable Checklist - [ ] I have updated the corresponding README(s); local and/or global - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] I have added, or updated, [mermaid.js](https://mermaid-js.github.io) diagrams in the corresponding README(s) - [ ] I have added, or updated, documentation and [mermaid.js](https://mermaid-js.github.io) diagrams in `shared/docs/*` if I updated `shared/*`README(s) --- Co-authored-by: Alessandro De Blasis <alex@deblasis.net>
Description
This is the first of several changes necessary to refactor and improve the utility module to enable implementation of future, more complex, interfaces.
Issue
Fixes #475
Type of change
Please mark the relevant option(s):
List of changes
Changes
Utility
Validatable
type for basic validationContext
struct; unnecessary abstractionITransaction
, an interface for theTransaction
protocol to help capture the functionality it adds to the core typeCode Confusion
IUnstakingActor
and useUnstakingActor
directly. Guideline for removing future unnecessary types (e.g. TxResult)Bugs
tx.Equals
was comparing the same transaction against itself (major bug)Code optimization
byte
<->string
conversions in several placesbigInt
<->string
conversions in several placesCode health
actorTypes
)codec
package & add some TODOsFiles focused on
utility
Testing
make develop_test
README
Required Checklist
If Applicable Checklist
shared/docs/*
if I updatedshared/*
README(s)