-
Notifications
You must be signed in to change notification settings - Fork 113
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
chore(all): version trie calls #2774
Conversation
76f78d0
to
34e45da
Compare
@@ -60,6 +61,7 @@ type Service struct { | |||
|
|||
// Config holds the configuration for the core Service. | |||
type Config struct { | |||
// TODO add state version field 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.
TODO once tests are fixed
34e45da
to
b92f516
Compare
// Note: not too sure why this trie state call is needed, | ||
// but some RPC tests fail without it. |
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.
TODO see #2769
dot/state/block.go
Outdated
} | ||
|
||
return stateVersion, nil | ||
} |
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.
Add unit/integ test
// TODO shall we remove this? Both are coming from the internal state | ||
rootV0 := ts.MustRoot(trie.V0) | ||
if !rootV0.Equal(parent.StateRoot) { | ||
// TODO add extra check with rootV1 when v1 is supported | ||
panic("parent state root does not match snapshot state root") | ||
} |
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.
Opinions on that? Should we remove it? Otherwise we'll have to hash tries for v0 and v1 which might have a performance impact.
@@ -94,6 +97,23 @@ func (g *Genesis) ToRaw() error { | |||
return nil | |||
} | |||
|
|||
var ErrRuntimeCodeNotFound = errors.New("runtime code not found") | |||
|
|||
func (g *Genesis) RuntimeCode() (runtimeCode []byte, 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.
add unit test
lib/runtime/wasmer/exports.go
Outdated
// This is cheap to call since the instance version is cached. | ||
func (in *Instance) StateVersion() (stateVersion trie.Version, err error) { | ||
coreVersion := in.ctx.Version | ||
return trie.ParseVersion(coreVersion.StateVersion) |
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.
add unit test
return stateVersion, fmt.Errorf("parsing state version: %w", err) | ||
} | ||
|
||
return stateVersion, nil |
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.
add unit test
func ParseVersion[T string | uint32](x T) (version Version, err error) { | ||
var s string | ||
switch value := any(x).(type) { |
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.
This was a fun use of generic imo
78dce0a
to
f931f24
Compare
f931f24
to
85ebea7
Compare
85ebea7
to
f8c058b
Compare
c5ab500
to
3ac2daf
Compare
1a6b2ee
to
227f81e
Compare
3ac2daf
to
ecd481e
Compare
227f81e
to
bcb4229
Compare
ecd481e
to
0d47948
Compare
0d47948
to
afeb95d
Compare
ceb798e
to
1d661d6
Compare
bf21a41
to
10a8565
Compare
- Remove all utils/test helping global variables from `lib/genesis` and inline them where needed - Duplicate test-only code helping functions where they are needed in `helpers_test.go` and unexport them - Change test helping functions to return genesis, trie and block header as values instead of pointers - Move lib/genesis's `NewGenesisBlockFromTrie` function as `lib/trie` `Trie` method `GenesisBlock()` - Move lib/genesis's `NewTrieFromGenesis` function to `lib/runtime/wasmer` since it will need in #2774 to use wasmer functions - Move key constants from `lib/runtime/constants.go` to `lib/genesis/constants.go`
1d661d6
to
793bebc
Compare
a6fe2af
to
b3412a6
Compare
793bebc
to
7707152
Compare
b3412a6
to
13f0cae
Compare
Closed in favor of #3433 |
Changes
Version
to typedtrie.Version
Tests
Entire codebase test suite
Issues
#2418
Primary Reviewer
@edwardmack