Skip to content
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

Add genesis files and balances #21

Merged

Conversation

Alann27
Copy link
Contributor

@Alann27 Alann27 commented Sep 30, 2024

Summary

  1. Added functionality to index genesis file.
  2. Added functionality to track balance of accounts by denom without needing to perform an aggregate.

Details

  1. Added GENESIS_FILE_PATH env to .env.sample and is being used to specify the path of the genesis file.
  2. Added testnet.json and localnet.json files to genesis directory.
  3. Added handleGenesis to the mappings datasources.
    1. In this handle we are reading the genesis file, saving the accounts specified in it and then saving the balances using the following entities: NativeBalanceChange, GenesisBalance and BalanceOfAccountByDenom.
  4. Created types/genesis.ts file with types related to the genesis index process.
  5. Added BalanceOfAccountByDenom entity type to the schema.graphql. This entity is beind used to save the coin (denom and amount) of an account without performing any aggregate, it can be queried with just a select.
  6. Added GenesisFile entity type to save the processed genesis file(s).
  7. Removed commented fields on schema.graphql.
  8. Added getEventId function to utils to create the id of the events.
  9. Added updateAccountBalance to update the balance of accounts using BalanceOfAccountByDenom entity.

Issue

The balances of the genesis accounts were not right because the genesis files was not being indexed.

Type of change

Select one or more:

  • New feature, functionality or library
  • Bug fix
  • Code health or cleanup
  • Documentation
  • Other (specify)

Sanity Checklist

  • I have tested my changes using the available tooling
  • I have commented my code
  • I have performed a self-review of my own code; both comments & source code
  • I create and reference any new tickets, if applicable
  • I have left TODOs throughout the codebase, if applicable

@jorgecuesta jorgecuesta marked this pull request as ready for review September 30, 2024 21:22
Copy link
Collaborator

@jorgecuesta jorgecuesta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm. Please @Olshansk @bryanchriswhite remember the scope of this genesis parsing is only for accounts. Later we will expand to save from Genesis the state of Applications, Gateways, Suppliers, etc.

@jorgecuesta jorgecuesta added the enhancement New feature or request label Sep 30, 2024
schema.graphql Show resolved Hide resolved
schema.graphql Outdated Show resolved Hide resolved
schema.graphql Outdated Show resolved Hide resolved
schema.graphql Show resolved Hide resolved
src/mappings/primitives.ts Outdated Show resolved Hide resolved
src/mappings/utils.ts Outdated Show resolved Hide resolved
src/mappings/primitives.ts Show resolved Hide resolved
src/mappings/primitives.ts Show resolved Hide resolved
src/mappings/primitives.ts Outdated Show resolved Hide resolved
src/mappings/primitives.ts Outdated Show resolved Hide resolved
Alann27 and others added 2 commits October 1, 2024 12:02
added comment explaining why to return early in handleGenesis when the block is not the genesis

Co-authored-by: Bryan White <[email protected]>
…LE_PATH with GENESIS_FILENAME at env.sample to only specify the file name of the genesis file and updated docker files to support this change
Copy link
Contributor

@bryanchriswhite bryanchriswhite left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing @Alann27, thanks! 🚀 This is great to see. 💪

I just had a couple more small suggestions (one of which is cleaning up my own mistake 😅). Otherwise, this LGTM! 🚢

src/mappings/primitives.ts Outdated Show resolved Hide resolved
src/mappings/utils.ts Show resolved Hide resolved
@jorgecuesta jorgecuesta self-requested a review October 3, 2024 16:38
@jorgecuesta jorgecuesta merged commit 058dcbf into pokt-network:main Oct 3, 2024
4 checks passed
@jorgecuesta jorgecuesta deleted the add-genesis-parsing-and-balances branch October 3, 2024 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

3 participants