Skip to content

Conversation

mvds00
Copy link

@mvds00 mvds00 commented Feb 26, 2025

First draft of reworked async_substrate_interface/sync_substrate.py

Reworked async_substrate.py along the same lines.

Please find a simple testcase in test_old_new.py (maybe change network to finney) which demonstrates that without the fix, switching between blocks pre- and post-dtao leads to errors.

In total, a lot has changed, but the changes are done step by step in a lot of small commits, such that the thought process can be followed. In case something breaks, this should also help to narrow down the breaking change.

Until 6d0c878c5fb63d6cd9dd6b3d214b6da9da7a71e8 and 6d0c878c5fb63d6cd9dd6b3d214b6da9da7a71e8^ it is mostly refactoring, at which point the bug is pretty obvious, and fixed.

The refactoring boils down to pushing all runtime_version related items to the runtime object, which is cached. The cache uses runtime_version as key (so not block_hash), while additional caching is done at the point where the runtime_version is looked up for a block_hash/block_id.

Further simplifications and cleanup are possible, but first let's see how this works out.

@thewhaleking thewhaleking self-assigned this Feb 26, 2025
@mvds00 mvds00 force-pushed the feat/mvds00/runtime-version-fixes branch from 63517b5 to 542cc67 Compare February 26, 2025 22:27
µ added 27 commits February 27, 2025 12:30
…tions, explicitly use last block for extrinsics
…ctions, explicitly use last block for extrinsics
- add get_block_runtime_version_for() with large cache, to get runtime version required for block_hash
- add small cache to get_parent_block_hash() and get_block_runtime_version()
- rename get_block_runtime_version() to get_block_runtime_info()
- add get_block_runtime_version_for() with large cache, to get runtime version required for block_hash
- add small cache to get_parent_block_hash() and get_block_runtime_version()
- rename get_block_runtime_version() to get_block_runtime_info()
… inner function get_runtime(), add cache key runtime_version
µ added 23 commits February 27, 2025 12:41
…on dependent properties from substrate to substrate.runtime
… version dependent properties from asyncsubstrate to asyncsubstrate.runtime
…type registry, as it depends on self.runtime
… type registry, as it depends on self.runtime
@mvds00 mvds00 force-pushed the feat/mvds00/runtime-version-fixes branch from d033e4d to 04e7050 Compare February 27, 2025 11:43
@thewhaleking thewhaleking mentioned this pull request Mar 3, 2025
@thewhaleking
Copy link
Collaborator

Moved to #65 to apply fixes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants