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

Upgrade to wasmvm 1.3.0-rc.0 #1486

Merged
merged 2 commits into from
Jul 6, 2023
Merged

Upgrade to wasmvm 1.3.0-rc.0 #1486

merged 2 commits into from
Jul 6, 2023

Conversation

pinosu
Copy link
Contributor

@pinosu pinosu commented Jul 5, 2023

Part of #1296

  • use new checksum function in gov_tx.go instead of sha256.Sum256(raw); check for other places
  • Update go.mod
  • Update download links and checksum in Dockerfile
  • Update compatibility matrix
  • Use StoreCodeUnchecked in state sync
  • Deprecate wasmVM.Create and use wasmVM.StoreCode instead

@codecov
Copy link

codecov bot commented Jul 5, 2023

Codecov Report

Merging #1486 (80fb374) into main (1763477) will decrease coverage by 0.08%.
The diff coverage is 57.14%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1486      +/-   ##
==========================================
- Coverage   57.86%   57.78%   -0.08%     
==========================================
  Files          63       63              
  Lines        8344     8348       +4     
==========================================
- Hits         4828     4824       -4     
- Misses       3112     3116       +4     
- Partials      404      408       +4     
Impacted Files Coverage Δ
x/wasm/types/wasmer_engine.go 0.00% <ø> (ø)
x/wasm/client/cli/gov_tx.go 14.36% <33.33%> (-0.06%) ⬇️
x/wasm/types/test_fixtures.go 81.02% <50.00%> (-1.18%) ⬇️
x/wasm/keeper/keeper.go 86.46% <100.00%> (-0.31%) ⬇️
x/wasm/keeper/snapshotter.go 65.07% <100.00%> (ø)

@pinosu pinosu changed the title Upgrade to wasmvm 1.3.0 Upgrade to wasmvm 1.3.0-rc.0 Jul 6, 2023
@pinosu pinosu marked this pull request as ready for review July 6, 2023 08:52
@pinosu pinosu requested a review from alpe as a code owner July 6, 2023 08:52
Copy link
Contributor

@alpe alpe 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! Thanks a lot for taking this task. 💐
I have added some comment about the test mock to discuss. Otherwise excellent!

@@ -217,7 +217,7 @@ func (k Keeper) importCode(ctx sdk.Context, codeID uint64, codeInfo types.CodeIn
return types.ErrCreateFailed.Wrap(errorsmod.Wrap(err, "uncompress wasm archive").Error())
}
}
newCodeHash, err := k.wasmVM.Create(wasmCode)
newCodeHash, err := k.wasmVM.StoreCodeUnchecked(wasmCode)
Copy link
Contributor

Choose a reason for hiding this comment

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

nice!

@@ -106,7 +106,7 @@ func restoreV1(_ sdk.Context, k *Keeper, compressedCode []byte) error {
}

// FIXME: check which codeIDs the checksum matches??
_, err = k.wasmVM.Create(wasmCode)
_, err = k.wasmVM.StoreCodeUnchecked(wasmCode)
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@@ -88,6 +89,20 @@ func (m *MockWasmer) Create(codeID wasmvm.WasmCode) (wasmvm.Checksum, error) {
return m.CreateFn(codeID)
}

func (m *MockWasmer) StoreCode(codeID wasmvm.WasmCode) (wasmvm.Checksum, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I was wondering if we want to use Create at all now in this mock. The method is required to be compatible with the interface but why not always panic with "Deprecated: use StoreCode instead"? There should not be any reason to use it in tests anymore. WDYT?

Please add a deprecated annotation to the method, too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea!

sdk "github.com/cosmos/cosmos-sdk/types"
)

//go:embed testdata/reflect.wasm
var wasmCode []byte
Copy link
Contributor

Choose a reason for hiding this comment

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

it would be good to rename this to reflectWasmCode or something more verbose. There are some contracts used in this project

StoreCode(code wasmvm.WasmCode) (wasmvm.Checksum, error)

// Create will compile the wasm code, and store the resulting pre-compile
// as well as the original code. Both can be referenced later via CodeID
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: here and above

Suggested change
// as well as the original code. Both can be referenced later via CodeID
// as well as the original code. Both can be referenced later via checksum

PinFn func(checksum wasmvm.Checksum) error
UnpinFn func(checksum wasmvm.Checksum) error
GetMetricsFn func() (*wasmvmtypes.Metrics, error)
CreateFn func(codeID wasmvm.WasmCode) (wasmvm.Checksum, error)
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove? Please see my comment below

@pinosu pinosu merged commit 1a5a2d9 into main Jul 6, 2023
7 of 8 checks passed
@pinosu pinosu deleted the 1296-upgrade_wasmvm branch July 6, 2023 11:07
@webmaster128
Copy link
Member

LGTM. What iss missing for 1.3 is support for the new message and query types: #1296 (comment)

@faddat faddat mentioned this pull request Jul 16, 2023
@alpe alpe added the backport/v0.3x Backport patches to sdk45 release branch label Jul 17, 2023
mergify bot pushed a commit that referenced this pull request Jul 17, 2023
* Upgrade to wasmvm 1.3.0-rc.0

* Fix comments

(cherry picked from commit 1a5a2d9)

# Conflicts:
#	README.md
#	go.sum
#	x/wasm/client/cli/gov_tx.go
#	x/wasm/keeper/genesis_test.go
#	x/wasm/keeper/snapshotter_integration_test.go
pinosu added a commit that referenced this pull request Jul 18, 2023
* Upgrade to wasmvm 1.3.0-rc.0 (#1486)

* Upgrade to wasmvm 1.3.0-rc.0

* Fix comments

(cherry picked from commit 1a5a2d9)

# Conflicts:
#	README.md
#	go.sum
#	x/wasm/client/cli/gov_tx.go
#	x/wasm/keeper/genesis_test.go
#	x/wasm/keeper/snapshotter_integration_test.go

* Resolve conflicts

---------

Co-authored-by: pinosu <95283998+pinosu@users.noreply.github.com>
Co-authored-by: Alex Peters <alpe@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/v0.3x Backport patches to sdk45 release branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants