-
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
[TxIndexer] Integration of transaction indexer (issue-#168) #302
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.
@andrewnguyen22 Took a first pass with some comments, but I also think it'll be productive to jump and discuss this over a call (@deblasis welcome to join). Specifically, I want to understand if:
- We can encapsulate the logic of indexing transaction to a postgres context (which can be rolled back and released)
- Avoid modifying utility's external-looking interfaces (it's less intuitive to me now)
- Get a better personal understand of the end-to-end flow & purpose of
StoreTransaction
and as it relates [Persistence] First Implementation of the StateHash (#284) #285.
Note, I will pause all work on #285 until we figure this out.
|
||
option go_package = "github.com/pokt-network/pocket/utility/types"; | ||
|
||
message DefaultTxResult { |
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.
Why do we call it just TxResult
in persistence/indexer/proto/transaction_indexer.proto
but DefaultTxResult
here?
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.
TxResult
is the interface DefaultTxResult
is the default transaction result implementation
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 realise I'm nit picking here, so feel free to push back (or let me know if we should do this in a future commit), but I'm just trying to understanding name naming
When I see DefaultTxResult
, I'm expecting there to be a non default too. And given that this is scoped to be within the utility module, does that mean we expect the utility module to have another TxResult at some point?
I would've named the interface to ITxResult
and this proto to TxResult
, but just wanted to understand the motivation first.
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.
The expectation - is that we could have other implementations in the future. The Default
vs NonDefault
pattern is found in golang libraries. If you think it's inappropriate in this context I can change it. I don't think it's a big deal IMO.
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.
Yea, not a big deal and not a reason for a blocker, but I wanted to understand.
We can always change it later
Co-authored-by: Daniel Olshansky <[email protected]>
Co-authored-by: Daniel Olshansky <[email protected]>
Co-authored-by: Daniel Olshansky <[email protected]>
@andrewnguyen22 I believe that we are aligned on next steps for both this and the follow up PR given the details in #315, but let me know if I missed anything or when this PR is simply ready for the next review. |
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.
Good use of the high priority label. Will prioritize looking at this again tomorrow morning.
Mostly just left a couple nits, a couple questions, and inserted #315 TODO in a couple places to make sure we're aligned.
} | ||
if err := u.GetPersistenceContext().StoreTransaction(transactionProtoBytes); err != nil { | ||
return nil, err | ||
// DISCUSS: currently, the pattern is allowing nil err with an error transaction... |
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.
ACK. Will think about it.
utility/test/transaction_test.go
Outdated
@@ -133,7 +134,7 @@ func TestUtilityContext_HandleMessage(t *testing.T) { | |||
|
|||
func newTestingTransaction(t *testing.T, ctx utility.UtilityContext) (transaction *typesUtil.Transaction, startingAmount, amountSent *big.Int, signer crypto.PrivateKey) { | |||
cdc := codec.GetCodec() | |||
recipient := GetAllTestingAccounts(t, ctx)[1] | |||
recipient := GetAllTestingAccounts(t, ctx)[2] |
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.
Not a blocker, but curious why this was changed.
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.
To prevent a collision with the first Validator who is the proposer in tests
|
||
option go_package = "github.com/pokt-network/pocket/utility/types"; | ||
|
||
message DefaultTxResult { |
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 realise I'm nit picking here, so feel free to push back (or let me know if we should do this in a future commit), but I'm just trying to understanding name naming
When I see DefaultTxResult
, I'm expecting there to be a non default too. And given that this is scoped to be within the utility module, does that mean we expect the utility module to have another TxResult at some point?
I would've named the interface to ITxResult
and this proto to TxResult
, but just wanted to understand the motivation first.
Co-authored-by: Daniel Olshansky <[email protected]>
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'm not the biggest fan of the DefaultTxResult
naming, but I'll look around what the best practices are in other major Goland libraries.
Please see the two mini edits I have, but otherwise good to go.
|
||
option go_package = "github.com/pokt-network/pocket/utility/types"; | ||
|
||
message DefaultTxResult { |
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.
Yea, not a big deal and not a reason for a blocker, but I wanted to understand.
We can always change it later
Co-authored-by: Daniel Olshansky <[email protected]>
## Description **TL;DR Encapsulate and commit the block and block parts within a persistence context** The objective of this issue is to "bridge" the work being done in #302 (tx indexer integration) and #285 (first state hash implementation. The interface and diagrams for the state hash computation were being done in #252 while the first implementation began in #285. However, since both of these are dependent on the integration of the tx indexer in #302, some conflicting design decisions arose. The goal of this ticket is to unblock #302, while also capturing the results of an offline discussion that led to a decision where the "ephemeral block state" should be wholly managed by the persistence context, being a single, "roll-backable" point of reference - [x] **Enable committing of a block to persistence by simply committing the persistence context** - [x] Remove ephemeral block-related state from the consensus module & utility module, and only maintain it in the persistence module - [x] Simply outward-facing module interfaces to only rely on primitive types - [ ] Remove validatorMap from the consensusModule struct state & access it from the persistence layer (added n the past) Opened new issue for last one to prevent scope from getting out of hand: #331 ## Issue Fixes #315 ## Type of change Please mark the relevant option(s): - [ ] New feature, functionality or library - [ ] 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 <!-- List out all the changes made--> - Removed `apphash` and `txResults` from `consensus Module` structure - Modified lifecycle to `set` the proposal block within a Persistence Context - Allow block and parts to be committed with the persistence context - Ported over storing blocks and block parts to persistence module from Consensus and Utility - Encapsulate TxIndexer logic only inside the persistence context - Remove TxResult from the utility module interface (added in [TxIndexer] Integration of transaction indexer (issue-#168) #302) - Combined creation and application of block in proposer lifecycle ## 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)
Description
Issue-#151 laid the foundation for a proper transaction indexer in isolation.
The integration of the transaction indexer into the M1 lifecycle is pending and required.
Integrate the transaction indexer into the lifecycle of M1
Issue
Fixes #168
Type of change
Please mark the relevant option(s):
List of changes
TxIndexer
sub-package (previously in Utility Module)TxIndexer
to bothPersistenceModule
andPersistenceContext
TransactionExists
andStoreTransaction
commit
[]TxResult
to the moduleDefaultTxResult
TxIndexer
into the lifecycleTxResult
from each played transactionTxResults
in theApplyBlock()
andGetProposalTransactions()
AnteHandleMessage()
now returnssigner
HandleMessage()
now returnsmessageType
andrecipient
ApplyTransaction()
returnsTxResult
ApplyBlock
andGetProposalTransactions
to returnTxResults
StoreTransaction
to store theTxResult
TxResult
under types.goTesting
make develop_test
README
Required Checklist
If Applicable Checklist
shared/docs/*
if I updatedshared/*
README(s)