-
Notifications
You must be signed in to change notification settings - Fork 144
feat(client): Implement read-only StorageState
functionality on ClientAdapter
#4769
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
base: development
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM but there are some things we can check or / and change before merging
} | ||
|
||
h := common.NewHashFromGeneric((*header).StateRoot()) | ||
return &h, nil | ||
} | ||
|
||
func (ca *ClientAdapter[H, Hasher, N, E, Header]) GenerateTrieProof(stateRoot common.Hash, keys [][]byte) ( | ||
[][]byte, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any reason why this is still unimplemented?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Originally the answer to that question was because I overlooked it. Now the answer is because I don't know how. 😅 Looking at the old implementation hasn't helped so far.
I also overlooked StorageState.TrieState()
, which I've implemented here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can use NewMerkleProof
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dimartiro thanks for pointing me towards NewMerkleProof()
. There's just one issue; it expects a hashdb.HashDB
and all i have is a ClientAdapterDB
and a statemachine.Backend
.
7d9bbab
to
37dd38d
Compare
func (ca *ClientAdapter[H, Hasher, N, E, Header]) GetRoundAndSetID() (uint64, uint64) { | ||
panic("unimplemented") | ||
} | ||
|
||
func (ca *ClientAdapter[H, Hasher, N, E, Header]) GetRuntime(blockHash common.Hash) (instance rt.Instance, err error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should implement this in some point if we want to achieve a full read-only shim type. Do we have an issue for this one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it part of #4807?
@@ -63,6 +63,7 @@ var ( | |||
statemachine.Backend[hash.H256, runtime.BlakeTwo256], any, | |||
*generic.Header[uint64, hash.H256, runtime.BlakeTwo256], | |||
]] = &TestClient{} | |||
_ api.StorageProvider[hash.H256, runtime.BlakeTwo256] = &TestClient{} | |||
) | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can add more tests cases here since you added the api.StorageProvider
implementation for Client
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.
Changes
This PR should cover all changes mentioned in the issue, except for changing
StorageState.Entries()
to return astatemachine.PairsIter
. As we discussed on Slack, this will be postponed since it is only used in RPC, which is currently not a priority.Regarding
LoadCode()
; The implementation onClientAdapter
expects a block hash as the argument. The current implementation instate.InMemoryStorageState
callsGetStorage()
, which expects a state root hash. I'm pretty sure this is a long existing bug that hasn't been noticed becauseLoadCode()
is called withnil
on startup, which defaults to the best block.Tests
go test github.com/ChainSafe/gossamer/internal/client/adapter
Issues
#4467