-
Notifications
You must be signed in to change notification settings - Fork 410
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
Remove check for wasm limit size in state sync #1471
Conversation
24eb158
to
fab8f0e
Compare
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.
Good start but let's do less ;-)
An open question for me is the genesis import. Do we want to ensure the MaxWasmSize
or accept what comes in as in the state sync example? It feels that the cases are very similar. WDYT?
x/wasm/ioutils/ioutil.go
Outdated
|
||
// UncompressWithLimit fails if wasm size exceeds the limit. | ||
// It expects a valid gzip source to unpack or fails. See IsGzip | ||
func UncompressWithLimit(gzipSrc []byte, limit uint64) ([]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.
This will break api compatibility easily. Let's keep the old name just in case. The param is self explaining
x/wasm/ioutils/ioutil.go
Outdated
@@ -11,7 +11,21 @@ import ( | |||
) | |||
|
|||
// Uncompress expects a valid gzip source to unpack or fails. See IsGzip | |||
func Uncompress(gzipSrc []byte, limit uint64) ([]byte, error) { | |||
func Uncompress(gzipSrc []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.
No need to copy the code. Instead of adding a new method, you can simply pass math.MaxUint
as limit. This makes it also more readable on the caller, IMHO.
x/wasm/ioutils/ioutil_test.go
Outdated
assert.Equal(t, spec.expResult, r) | ||
}) | ||
} | ||
} |
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.
good test. But we would need one on the snapshotter to ensure a file > MaxWasmSize is accepted.
207d5ef
to
4091868
Compare
4091868
to
4a6962e
Compare
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.
Great work! Please see my comments on restoring the original size limit. Otherwise 💯 🏄
x/wasm/keeper/genesis_test.go
Outdated
@@ -133,6 +135,12 @@ func TestGenesisExportImport(t *testing.T) { | |||
srcIT := srcCtx.KVStore(wasmKeeper.storeKey).Iterator(nil, nil) | |||
dstIT := dstCtx.KVStore(dstKeeper.storeKey).Iterator(nil, nil) | |||
|
|||
t.Cleanup(func() { | |||
types.MaxWasmSize = 800 * 1024 |
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.
Great to do proper housekeeping here! I am a bit afraid that we will easily miss this line whenever the default would be touched in the future. Can you use a temp variable for the original value instead and then use it here?
like:
origMaxWasmSize := types.MaxWasmSize
types.MaxWasmSize = 1
...
types.MaxWasmSize = origMaxWasmSize
@@ -67,6 +67,11 @@ func TestSnapshotter(t *testing.T) { | |||
require.NoError(t, err) | |||
assert.NotNil(t, snapshot) | |||
|
|||
types.MaxWasmSize = 1 | |||
t.Cleanup(func() { | |||
types.MaxWasmSize = 800 * 1024 |
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.
As commented before, please use a temp variable to not hard code the value here
* Remove check for wasm limit size in state sync * Fix comments * Store original value in variable (cherry picked from commit 1763477) # Conflicts: # x/wasm/keeper/genesis_test.go
* Remove check for wasm limit size in state sync (#1471) * Remove check for wasm limit size in state sync * Fix comments * Store original value in variable (cherry picked from commit 1763477) # Conflicts: # x/wasm/keeper/genesis_test.go * Fix conflicts --------- Co-authored-by: pinosu <95283998+pinosu@users.noreply.github.com> Co-authored-by: Pino' Surace <pino.surace@live.it>
Resolves #1467