Skip to content

Conversation

@haikoschol
Copy link
Contributor

@haikoschol haikoschol commented Jun 30, 2025

Changes

This PR changes the semantics of some methods in the StorageState interface and its implementations by InmemoryStorageState and ClientAdapter.

Before this change, those methods expected a state root hash as parameter. This was probably done due to how the internal Tries data structure works, maintaining a map from state root hash to Trie. In any case, its inconvenient, unintuitive and in some cases just plain wrong. These methods are also sometimes called incorrectly with a block hash.

In order to enable implementing StorageState on ClientAdapter for the ongoing db.Backend rework, without requiring hacky workarounds, I propose to merge this PR into my feature branch for #4467.

Tests

go test -tags integration github.com/ChainSafe/gossamer

Issues

#4467

@haikoschol haikoschol requested a review from dimartiro June 30, 2025 08:39
@haikoschol haikoschol self-assigned this Jun 30, 2025
@haikoschol haikoschol changed the base branch from development to haiko/read-only-storage-state June 30, 2025 08:39
@haikoschol haikoschol changed the title fix(state): Change StorageState methods to always expect a block hash fix(state): Change StorageState methods to always expect a block hash Jun 30, 2025
@haikoschol haikoschol requested review from jimjbrettj and removed request for jimjbrettj June 30, 2025 08:40
@haikoschol haikoschol force-pushed the haiko/fix-StorageState branch from f810b70 to 7fdcd0b Compare June 30, 2025 08:52
@P1sar P1sar self-requested a review June 30, 2025 10:41
@haikoschol haikoschol force-pushed the haiko/fix-StorageState branch from 7fdcd0b to c0524b4 Compare July 1, 2025 07:25
Before, it expected a state root hash. This also fixes notifications for
the state_subscribeStorage RPC call.
@haikoschol haikoschol force-pushed the haiko/fix-StorageState branch from c0524b4 to f412899 Compare July 1, 2025 08:56
@haikoschol haikoschol force-pushed the haiko/fix-StorageState branch from 33d59e9 to 1b1c4d6 Compare July 1, 2025 13:25
@haikoschol haikoschol force-pushed the haiko/fix-StorageState branch from 3be6ad6 to f6b3457 Compare July 1, 2025 14:03
@haikoschol haikoschol marked this pull request as ready for review July 2, 2025 07:52
@haikoschol haikoschol removed the request for review from jimjbrettj July 3, 2025 10:34
Copy link
Contributor

@dimartiro dimartiro left a comment

Choose a reason for hiding this comment

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

Cleaner now! I like it

Copy link
Contributor

@timwu20 timwu20 left a comment

Choose a reason for hiding this comment

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

I really think you should merge this to development given the nature of the fixes.

@haikoschol
Copy link
Contributor Author

I really think you should merge this to development given the nature of the fixes.

Yeah, I thought about that too. Shouldn't make too much of a difference since I'll probably merge development into the branch for #4769 before merging that anyway.

@haikoschol haikoschol changed the base branch from haiko/read-only-storage-state to development July 4, 2025 05:51
@haikoschol haikoschol changed the base branch from development to haiko/read-only-storage-state July 4, 2025 05:55
@haikoschol
Copy link
Contributor Author

haikoschol commented Jul 4, 2025

I really think you should merge this to development given the nature of the fixes.

Yeah, I thought about that too. Shouldn't make too much of a difference since I'll probably merge development into the branch for #4769 before merging that anyway.

Just tried this and actually it does make a difference because I based this branch off haiko/read-only-storage-state and changing the target to development includes all the commits from that branch as well.

Let's just get #4769 done quickly after merging this to get these fixes onto development.

@haikoschol haikoschol requested a review from timwu20 July 4, 2025 05:59
@haikoschol haikoschol merged commit 3a71c45 into haiko/read-only-storage-state Jul 5, 2025
94 of 104 checks passed
@haikoschol haikoschol deleted the haiko/fix-StorageState branch July 5, 2025 04:47
haikoschol added a commit that referenced this pull request Jul 5, 2025
After #4792, StorageState methods that expected a state root hash now
take a block hash. This updates all affected StorageState methods on
ClientAdapter and simplifies their implementation.
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.

4 participants