Skip to content

Conversation

@2xburnt
Copy link
Contributor

@2xburnt 2xburnt commented Jul 29, 2025

This pull request introduces several enhancements and refactors to improve the functionality, maintainability, and configurability of the blockchain application. Key changes include the addition of environment variables for block fetching configuration, integration of a new chain (xion), refactoring of block-related stores and modules, and dynamic adjustment of blocktime intervals based on chain data.

Environment Configuration Updates:

  • .env.example: Added new environment variables (VITE_REFRESH_INTERVAL, VITE_FETCH_ALL_BLOCKS, VITE_RECENT_BLOCK_LIMIT) to allow customization of refresh intervals, block fetching behavior, and the limit for recent blocks.

Chain Integration:

Store and Module Refactoring:

  • src/modules/[chain]/block/block.ts: Refactored the block module to delegate most operations to the useBaseStore, simplifying the module's logic and ensuring consistency across block-related actions. (src/modules/[chain]/block/block.tsL2-R39)
  • src/stores/useBaseStore.ts: Enhanced the base store with new features, including dynamic blocktime calculation, support for fetching all blocks since the last known block, and improved error handling during RPC calls. Added configurable limits for recent blocks and a flag to enable fetching all blocks. [1] [2]

Dynamic Refresh Interval Adjustments:

@liangping
Copy link
Member

There are a few issues:

  • Reducing the fetch interval will significantly increase the number of requests, but many public APIs have strict rate limits.
  • You removed the network connection check, which was important for preventing a backlog of requests when someone has a poor network connection. Without it, numerous requests could accumulate.
  • The fetch frequency may not be critical, as it only samples blocks. It doesn't need to occur for every block.

@2xburnt
Copy link
Contributor Author

2xburnt commented Jul 30, 2025

There are a few issues:

  • Reducing the fetch interval will significantly increase the number of requests, but many public APIs have strict rate limits.
  • I have restored the fetch interval in main.ts to default to 6000 with the option to be changed via and env var
  • You removed the network connection check, which was important for preventing a backlog of requests when someone has a poor network connection. Without it, numerous requests could accumulate.
  • I am not sure if you were referencing the code in main.ts or useBaseStore.ts either way the check should be restored
  • The fetch frequency may not be critical, as it only samples blocks. It doesn't need to occur for every block.
  • Instead of increasing the fetch frequency I have modified useBaseStore to backfill recent blocks, in addition I have made this only activated by setting an env var to retain the current behavior by default

Also, I retained the changes to the consensus page, I think are still desirable as this page is not very useful if the refresh rate is slower than the block time.

Lastly, the issue I am trying to address by backfilling the missing blocks is that the transactions page uses 'txsInRecents' to populate data, thus missing blocks lead to missing transactions which has been a source of confusion from users.

@2xburnt 2xburnt changed the title use basetore blocktime, eliminate redundant block fetching add optional basestore features, eliminate redundant block fetching Jul 30, 2025
@liangping liangping merged commit 6d85f2f into ping-pub:master Jul 31, 2025
1 check passed
@liangping
Copy link
Member

thanks @2xburnt

@2xburnt 2xburnt deleted the feat/blocktime branch July 31, 2025 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants