Light state#2019
Conversation
Current coverage is
|
eaec7f2 to
5ab52d8
Compare
|
@obscuren fixed the issues you mentioned and rebased on develop |
ef5968d to
053cd5f
Compare
There was a problem hiding this comment.
We need to find a way to share some of the logic with package state.
Most of the code (decoding, accessors, etc.) is simply copied from package state.
Maybe one way to do it would be to split state.StateObject into two parts, one of which doesn't
contain a DB. In that case, you could simply embed it here and get all the boring methods for free.
There was a problem hiding this comment.
On second thought, we could also address the duplication later when the protocol is in.
There was a problem hiding this comment.
The highest priority is to not mess up existing stuff so I'd definitely wait with that until we have a functional light client. After everything is built up (including the VM calls) we can make better decisions about what code can be shared and how that should be done.
19e1fd7 to
67058ad
Compare
|
@fjl the issues you mentioned are fixed now |
|
👍 |
There was a problem hiding this comment.
if you wrap the request in a struct, you can DRY up all the GetCtx redundancies.
type OdrBackend interface {
Database() ethdb.Database
Retrieve(req *OdrRequestWithCtx)
}
type OdrRequestWithCtx struct {
ctx context.Context
OdrRequest
}
type OdrRequest interface {
StoreResult(db ethdb.Database)
}
// GetCtx not needs to be defined exactly once not 5 times
func (req *OdrRequestWithCtx) GetCtx() context.Context { return req.ctx }
// this now does not need the ctx field and the GetCtx method to be defined
type TrieRequest struct {
root common.Hash
key []byte
proof []rlp.RawValue
}
But the question is, do you really need the ctx embedded in the request? cant you always just pass it to Retrieve if it was OdrBackend#Retrieve(req OdrRequest, context.Context)
and eliminate the extra wrapping, GetCtx and ctx fields altogether.
There was a problem hiding this comment.
You're right, that was a remnant of an old design. I don't want it wrapped in a struct but contexts shouldn't be wrapped anyways so they are now directly passed to Retrieve.
67058ad to
b461171
Compare
|
👍 great stuff |
|
👎 (just so it shown up for @robotally and doesn't get accidentally merged) |
|
@zsfelfoldi I'll update #2064 tonight so it is mergeable |
b461171 to
bba7172
Compare
|
@obscuren I updated the entire stateobject.go with all the rlp changes and added missing comments to trie.go. I did not yet comment all the state and stateobject functions because there's a shitload of them and they're not commented in the original version either :) I'll do those too of course but maybe I should do that in the two versions together in a separate PR after both this PR and #2064 are merged. |
|
I don't see why we should neglect on commenting because someone else has a year ago (me). Since this PR adds the methods we should add the documentation in this PR. |
|
@obscuren ok, I'll do it in this PR today. |
bba7172 to
d14464c
Compare
d14464c to
ef422ee
Compare
|
@obscuren done |
This PR implements ODR capable state & trie structures for the light client.