pokt-network / pocket

Official implementation of the Pocket Network Protocol v1
https://pokt.network
MIT License
61 stars 33 forks source link

[Utility] Use TreeStore as source of truth #937

Closed h5law closed 11 months ago

h5law commented 11 months ago

Description

Summary generated by Reviewpad on 26 Jul 23 11:24 UTC

This pull request includes the following changes:

  1. In the trees.go file:

    • Added a new method Prove that generates and verifies a proof against a tree name stored in the TreeStore.
    • Updated the GetTreeHashes method to exclude the root tree from the map of tree names to their root hashes.
  2. In the treestore_module.go file:

    • Added a new method Prove that generates and verifies a proof against a tree with a matching name.
    • No other changes have been made to the existing methods in the file.
  3. In the transaction_test.go file:

    • Modified the import statements to use different package names.
    • Modified the test cases TestHandleTransaction_ErrorAlreadyInMempool, TestHandleTransaction_ErrorAlreadyCommitted, and TestHandleTransaction_BasicValidation.
    • Modified the function prepareEmptyIndexedTransaction.
    • Changed some variable names.
  4. In the ibc_msg_mempool_test.go file:

    • Added a new test function TestHandleMessage_ErrorAlreadyCommitted.
    • Added environment preparation code, code for indexing a test transaction, and handling the error.
    • Modified the error handling code.
  5. In the utility/transaction.go file:

    • Added an import statement for the github.com/pokt-network/pocket/shared/crypto package.
    • Updated the assignment of the txHash variable.
    • Updated the condition for checking if the transaction is already in the mempool.
    • Updated the call to u.GetBus().GetPersistenceModule().TransactionExists.
    • Updated the check for the existence of the transaction.
  6. In the persistence/trees/trees_test.go file:

    • Updated the package imports.
    • Added a new test function TestTreeStore_Prove and several test cases.
    • Updated the treeStore struct and the existing test function.
  7. In the persistence_module.go file:

    • Added a new method TransactionExists and commented out the old method.

Please let me know if you would like a more detailed review of any specific part of the diff.

Issue

Fixes #875

Type of change

Please mark the relevant option(s):

List of changes

Testing

Required Checklist

If Applicable Checklist