-
Notifications
You must be signed in to change notification settings - Fork 379
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
feat: small improvements for #1702 #2276
Conversation
gno.land/pkg/sdk/vm/builtins.go
Outdated
store.Print() | ||
fmt.Println(colors.Red("VMKeeper.init.getPackage ========================================= before wrote end")) | ||
} | ||
store.Write() // XXX XXX XXX or flush? |
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.
gnovm/pkg/gnolang/store.go
Outdated
} | ||
if cts, ok := ds.baseStore.(types.ClearThrougher); ok { | ||
cts.ClearThrough() | ||
} |
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.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2276 +/- ##
==========================================
+ Coverage 54.70% 54.72% +0.02%
==========================================
Files 582 582
Lines 78430 78354 -76
==========================================
- Hits 42902 42883 -19
+ Misses 32315 32259 -56
+ Partials 3213 3212 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
vmKpr.Initialize(baseApp.GetCacheMultiStore()) | ||
ms := baseApp.GetCacheMultiStore() | ||
vmKpr.Initialize(ms) | ||
ms.MultiWrite() // XXX why was't this needed? |
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 it was always requried, but its absence (of MultiWrite) being masked by the fact that later transactions would commit the same side effect, e.g. populate the mem package for dependencies like "time" or "strconv". But i'm not sure. If that's true, then loadpkg in genesis would have no effect for our integration tests?
Can somebody look into it?
gno.land/pkg/sdk/vm/builtins.go
Outdated
@@ -16,7 +16,7 @@ func (vm *VMKeeper) initBuiltinPackagesAndTypes(store gno.Store) { | |||
// NOTE: native functions/methods added here must be quick operations, |
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.
There's no real need to have this function at all... getPackage below might as well be a method on the store.
} | ||
store.SetPackageGetter(getPackage) | ||
store.SetNativeStore(stdlibs.NativeStore) |
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.
diff artifact, not actually removed from the original code block.
resStore.SetPackageGetter(getPackage) | ||
resStore.SetNativeStore(teststdlibs.NativeStore) | ||
resStore.SetPackageInjector(testPackageInjector) | ||
resStore.SetStrictGo2GnoMapping(false) |
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.
they're both new stores, so name neither "newStore" :)
@@ -86,7 +93,7 @@ type defaultStore struct { | |||
|
|||
// transient | |||
opslog []StoreOp // for debugging and testing. | |||
current []string | |||
current []string // for detecting import cycles. |
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.
it's still detecting import cycles.
} else { | ||
s += bytesColor(fmt.Sprintf("%02X", b)) | ||
s += bytesColor(buf) | ||
buf = "" |
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.
If somebody can write a perfect n len-capped implementation that is simpler than this, I'd be impressed. But it's also probably unnecessary.
Also includes improved coloredbytes and debug printing, and more comments. At first I thought gnolang#1702's passing of the store was not ideal, but upon much confusion with cache invalidation, it became clear that passing in a store to getPackage() makes sense. This means that any store operations that occur through the loading of dependencies will incur gas charges for the transaction, e.g. for AddPkg() with dependencies like "time" or "strconv". Rather than clear cache-misses from the cacheStore, which is confusing, we would be better off passing in a mutated store go getPackage (if we need to). Or, just load the standard packages upon genesis. Also added improvements to ColoredBytes; this is now faster since not every character needs to be escaped, but rather escaping happens in chunks. As part of this refactor, the key & values are also clipped. I suppose we could maybe 1. improve ColoredBytesN() to clip exactly to N, but implementing this is non-trivial, and also 2. make the key/value limits perhps depend on a configuration or environment variable. Poll... would you be sad if the Print() output for databases clipped the values? I think it makes it much better for dev experience; and if you need the full value you can tinker with the source where appropriate. The downside is, we might lose information from logs. But I'm not sure we even use the Print() feature for any logs as of now.
Also includes improved coloredbytes and debug printing, and more comments.
At first I thought #1702's passing of the store was not ideal, but upon much confusion with cache invalidation,
it became clear that passing in a store to getPackage() makes sense.
This means that any store operations that occur through the loading of dependencies will incur gas charges for the transaction, e.g. for AddPkg() with dependencies like "time" or "strconv". Rather than clear cache-misses from the cacheStore, which is confusing, we would be better off passing in a mutated store go getPackage (if we need to).
Or, just load the standard packages upon genesis.
Also added improvements to ColoredBytes; this is now faster since not every character needs to be escaped, but rather escaping happens in chunks. As part of this refactor, the key & values are also clipped. I suppose we could maybe 1. improve ColoredBytesN() to clip exactly to N, but implementing this is non-trivial, and also 2. make the key/value limits perhps depend on a configuration or environment variable.
Poll... would you be sad if the Print() output for databases clipped the values? I think it makes it much better for dev experience; and if you need the full value you can tinker with the source where appropriate. The downside is, we might lose information from logs. But I'm not sure we even use the Print() feature for any logs as of now.