Skip to content
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

Add customizable WasmLimits #1989

Merged
merged 11 commits into from
Nov 8, 2024
Merged

Add customizable WasmLimits #1989

merged 11 commits into from
Nov 8, 2024

Conversation

chipshort
Copy link
Collaborator

closes #1986

Copy link

codecov bot commented Sep 15, 2024

Codecov Report

Attention: Patch coverage is 72.22222% with 10 lines in your changes missing coverage. Please review.

Project coverage is 48.88%. Comparing base (6fa6afc) to head (930241d).
Report is 15 commits behind head on main.

Files with missing lines Patch % Lines
x/wasm/types/types.go 0.00% 4 Missing ⚠️
x/wasm/module.go 0.00% 3 Missing ⚠️
x/wasm/keeper/querier.go 71.42% 1 Missing and 1 partial ⚠️
app/ante.go 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1989      +/-   ##
==========================================
+ Coverage   48.82%   48.88%   +0.05%     
==========================================
  Files          65       65              
  Lines       10082    10101      +19     
==========================================
+ Hits         4923     4938      +15     
- Misses       4725     4727       +2     
- Partials      434      436       +2     
Files with missing lines Coverage Δ
app/app.go 85.98% <100.00%> (+0.02%) ⬆️
x/wasm/keeper/keeper.go 77.61% <100.00%> (-0.19%) ⬇️
x/wasm/keeper/keeper_cgo.go 95.55% <100.00%> (+1.11%) ⬆️
app/ante.go 63.63% <50.00%> (ø)
x/wasm/keeper/querier.go 77.27% <71.42%> (-0.14%) ⬇️
x/wasm/module.go 0.00% <0.00%> (ø)
x/wasm/types/types.go 60.25% <0.00%> (ø)

@chipshort
Copy link
Collaborator Author

obviously not mergeable yet, but would love some feedback from you @pinosu

Copy link
Contributor

@pinosu pinosu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!
I'm still thinking if it's best to have the wasmLimits in wasmConfig or add a new paramenter to the NewKeeper func . I guess we need to think about the scope of the two things and if they can match or just have similar names.

// QueryWasmLimitsConfigResponse is the response type for the
// Query/WasmLimitsConfig RPC method. It contains the JSON encoded limits for
// static validation of Wasm files.
message QueryWasmLimitsConfigResponse { string config = 1; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have a specific struct that we can define for config or we want to keep it flexible?
In that case, we could evaluate using bytes instead of string. WDYT?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned in our chat, I want to keep it flexible. The reason for string instead of bytes is that I want to make it easy for contract devs to copy and paste the limits. They need pass them into cosmwasm-check. See here: https://github.com/CosmWasm/cosmwasm/blob/cf413c5ad6a58a87e0be894584f01506f3b2e0af/packages/check/src/main.rs#L41-L50

x/wasm/keeper/test_common.go Outdated Show resolved Hide resolved
@@ -315,8 +315,14 @@ func NewWasmCoins(cosmosCoins sdk.Coins) (wasmCoins []wasmvmtypes.Coin) {
return wasmCoins
}

// WasmConfig is the extra config required for wasm
type WasmConfig struct {
// VMConfig contains configurations that are passed on to CosmWasm VM.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Copy link
Contributor

@pinosu pinosu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work!
Should we also define DefaultVMConfig(), with the limits set o some reasonable default value?

@chipshort
Copy link
Collaborator Author

Should we also define DefaultVMConfig(), with the limits set o some reasonable default value?

This is handled in cosmwasm-vm because I want to avoid chain developers forgetting to set one of the values to the default. That's why the values all use pointers. If you pass a nil ptr, cosmwasm-vm uses the default value.

@chipshort
Copy link
Collaborator Author

I rebased this on main, removing the commit with the replace for the local wasmvm dependency. Only changes other than that are in the latest commit (just some changes to adjust to the renamings in wasmvm)

@chipshort chipshort marked this pull request as ready for review November 7, 2024 15:01
@chipshort chipshort requested a review from pinosu November 8, 2024 05:32
Copy link
Contributor

@pinosu pinosu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! LGTM 👍

@chipshort chipshort merged commit 40b8010 into main Nov 8, 2024
17 checks passed
@chipshort chipshort deleted the co/customizable-limits branch November 8, 2024 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pass Config to wasmvm and make WasmLimits available to contract dev
2 participants