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

feat: merge wasmd v0.27.0 #570

Merged
merged 144 commits into from
Jul 8, 2022
Merged
Changes from 1 commit
Commits
Show all changes
144 commits
Select commit Hold shift + click to select a range
8e5f86d
Important: add iterator feature support
ethanfrey Sep 22, 2021
51db87b
Fix inconsistent return of contractAddress from keeper/init()
assafmo Sep 22, 2021
5eaa33d
Handle contract info query
alpe Sep 27, 2021
7596bc4
Implement tx counter for transaction info
alpe Sep 27, 2021
eba1387
Treat all contracts as pinned for gas costs in reply
ethanfrey Oct 7, 2021
40a4f52
Adjust gas prices in tests
ethanfrey Oct 7, 2021
566713c
Query all pinned code ids
alpe Oct 7, 2021
a488fab
Upgrade wasmvm-v1.0.0-soon2
alpe Oct 7, 2021
f985d50
Benchmarks for gas pricing
ethanfrey Oct 8, 2021
c1d2cb5
Update gas costs
alpe Oct 8, 2021
4e90a9b
fix: fix build error
shiki-tak Jun 8, 2022
7ff106e
remove unused flags from cmd prompt
fkneeland-figure Oct 14, 2021
43d8345
Add golangci lint check on pull requests
fkneeland-figure Oct 25, 2021
5e4eb96
Fix message representation for signing
alpe Oct 25, 2021
d247e9c
Add linter name and minor golint related updates
alpe Oct 25, 2021
763762e
Fixed wrong error message when lastCodeID value is incorrect
fkneeland-figure Oct 26, 2021
c62d0d9
Disable false positive
alpe Oct 26, 2021
c2b8b3c
Open read access to sequences
alpe Nov 5, 2021
aa6e12a
Limit simulation gas
alpe Nov 17, 2021
95f7d37
fix: build error
shiki-tak Jun 9, 2022
ac0957c
Return NoSuchContract system error instead of sdk error in ContractIn…
maurolacy Dec 16, 2021
0aa7bff
Implement PinCode and UnpinCode proposal client handlers (#707)
orkunkl Dec 23, 2021
dbf864e
Upgrade wasmvm to v1.0.0-beta5
alpe Jan 4, 2022
68a1a39
Upgrade to cosmos-sdk v0.45.0
alpe Jan 20, 2022
06c83fe
Proper systemerror follow-up
maurolacy Jan 20, 2022
86d0a86
Failing test showing it was not currently pinned
ethanfrey Jan 20, 2022
c2c461e
And properly pin it on governance vote
ethanfrey Jan 20, 2022
fa95a2f
Require --no-admin flag if no admin set
ethanfrey Jan 20, 2022
e1d1e12
Fix tests, handle genesis init as well
ethanfrey Jan 20, 2022
0fb3d3e
Fixed error message capitalization
ethanfrey Jan 21, 2022
d1e6f74
Add new proto types for the sudo an execute proposals
ethanfrey Jan 21, 2022
dde48d8
Compile proto files
shiki-tak Jun 14, 2022
a539857
Registered new proposal types
ethanfrey Jan 21, 2022
c612791
fix: remove unnecessary print
shiki-tak Jun 14, 2022
b3ec5ec
Wire up proposal handlers
ethanfrey Jan 21, 2022
ee96128
Wire up cli for exec and sudo proposal
ethanfrey Jan 21, 2022
ba93d96
Add rest routes for proposals;
ethanfrey Jan 24, 2022
72266ee
Add tests for Rest client
ethanfrey Jan 24, 2022
f9be9b2
Test execute and sudo proposal handlers
ethanfrey Jan 24, 2022
12faa2d
Remove RunAs from Migrate proposal
ethanfrey Jan 24, 2022
d13503b
fix tests
ethanfrey Jan 24, 2022
21163d8
Allow sending tokens along with governance wasm_execute proposal
ethanfrey Jan 24, 2022
5b639c7
Update documentation
ethanfrey Jan 24, 2022
275e1c5
Minor integration support
alpe Jan 28, 2022
0ccbd77
add missing colons in String of some proposals
loloicci Feb 10, 2022
a8c5282
Replace custom codec with sdk codec
alpe Feb 21, 2022
a5acf9f
Redact errors returned in reply
ethanfrey Feb 23, 2022
d672287
Fix lint error, failing test
ethanfrey Feb 23, 2022
abc8088
Fix submessage tests
ethanfrey Feb 23, 2022
fe5cf17
Adjust error string
ethanfrey Mar 2, 2022
3308c2d
Handle nil logger again
ethanfrey Mar 2, 2022
1e77542
Revert "Handle nil logger again"
alpe Mar 2, 2022
e485eb5
Fix test setup and assertions
alpe Mar 2, 2022
6225729
Add no admin flag for gov
alpe Mar 2, 2022
809883d
Relaxed address strength restrictions for legacy 20 byte addresses
iramiller Mar 3, 2022
ee91fa3
Make utils methods public
pinosu Mar 3, 2022
62e2ba7
Mark a whole lot of tests to skip on m1 as they core dump
ethanfrey Mar 7, 2022
b5362ba
Redact query errors
ethanfrey Mar 7, 2022
7684efc
Add deny list for some grpc queries
ethanfrey Mar 7, 2022
e24b4c4
fix: build error
shiki-tak Jun 15, 2022
e395e2f
Make type conversion helpers public
alpe Mar 9, 2022
cd78988
cleanup from PR comments
ethanfrey Mar 9, 2022
3a7a96e
fix: rename path
shiki-tak Jun 15, 2022
324b727
Improve how we redact query errors
ethanfrey Mar 9, 2022
ce654a8
Skip a few more tests on m1
ethanfrey Mar 9, 2022
d21ed2a
Ensure SystemError is consistently unredacted
ethanfrey Mar 9, 2022
cebe17d
fix: close iterators
albertchon Mar 22, 2022
7ca8673
Use callback pattern for contract state iterator
alpe Mar 25, 2022
b689f00
Add more tests for event edge cases
alpe Apr 6, 2022
35e17c4
fix: build error
shiki-tak Jun 16, 2022
596bf38
Unpack contract details from genesis
alpe Apr 12, 2022
1672d37
Revisit gov params doc and tests
alpe Apr 13, 2022
9beb9db
Add missing sudo and execute to codec
the-frey Apr 17, 2022
e874cf6
Add a basic validation test
the-frey Apr 17, 2022
5d9946d
Disable stargate queries
webmaster128 Apr 14, 2022
aca49b5
Remove dead code to make linter happy
webmaster128 Apr 21, 2022
e4a9894
Add ExecuteContractProposal test
the-frey Apr 21, 2022
6be179a
Make MaxLabelSize a var not const
ethanfrey Apr 27, 2022
606ba24
Add and test JSON object matcher
webmaster128 Apr 27, 2022
64da1eb
fix: fix import
shiki-tak Jun 16, 2022
81823ed
Make IsJSONObjectWithTopLevelKey public
webmaster128 Apr 27, 2022
930c4c0
Add WasmSnapshotter
assafmo Apr 25, 2022
1e31d3c
Make snapshot from keeper
ethanfrey Apr 27, 2022
de4689a
Rough draft of the restore method using multistore
ethanfrey Apr 27, 2022
4e2e7c4
properly register the snapshot manager
ethanfrey Apr 27, 2022
a8ce0cc
Move snapshotter to keeper and implement
ethanfrey Apr 27, 2022
69cd2b3
Add compression to snapshot wasm bytecode
ethanfrey Apr 27, 2022
713a951
Put GzipIt and Uncompress logic in a common folder
ethanfrey Apr 27, 2022
0f3fb97
Fix linting errors
ethanfrey Apr 27, 2022
6c33a30
Avoid sending duplicate wasm codes over the wire
ethanfrey Apr 27, 2022
1689a19
Properly handle when a message not for this extension arrives
ethanfrey Apr 27, 2022
34df544
Start testing snapshots
ethanfrey Apr 27, 2022
a3c98e1
Basic tend to end test for no errors
ethanfrey Apr 27, 2022
516d24d
Address @giansalex PR comments
ethanfrey Apr 27, 2022
e0ea888
Updates inspired by @giansalex branch
ethanfrey Apr 28, 2022
6cc82c5
Cannot commit in my test cases to load from proper height
ethanfrey Apr 28, 2022
8432d2b
SRemove loading history until I can fix tests here
ethanfrey Apr 28, 2022
100e4b6
Cleanup from Simon's comments
ethanfrey Apr 28, 2022
a974edd
Consolidate MaxWasmSize constraints into a single var
alpe Apr 29, 2022
febb194
fix: allow no admin in instantiation through proposal
jhernandezb May 2, 2022
5eb0a99
Add instantiate-nobody flag to cli store cmd (#827)
jhernandezb May 3, 2022
9359d65
Add MsgStoreCode and MsgInstantiateContract support to simulations
pinosu May 3, 2022
1a93cf4
Add snapshotter integration tests and minor cleanup
alpe May 3, 2022
de133ca
Minor test update
alpe May 3, 2022
01030e6
Fix linter warnings
alpe May 3, 2022
e4ed0e6
Delete duplicate testdata from simulation
pinosu May 3, 2022
0abdd6a
fix: build error
shiki-tak Jun 17, 2022
fef78a9
Fix contract path in simulations
alpe May 4, 2022
364346e
Add instantiate permission to CodeInfoResponse
jhernandezb May 5, 2022
d2c0bf8
chore: comment out snapshotter
shiki-tak Jun 17, 2022
f9573e6
Minor godoc update
alpe May 6, 2022
bd104e1
Bump wasmvm to v1.0.0-rc.0
alpe May 6, 2022
f2fc24a
Add libwasm-version query command
jhernandezb May 9, 2022
44e8e5d
add UpdateInstantiateConfig gov proposal
jhernandezb Apr 1, 2022
e8a1a61
update UpdateInstantiateConfigProposal proto definition
jhernandezb May 4, 2022
9456862
add to EnableAllProposals
jhernandezb May 5, 2022
a85ff59
add tests
jhernandezb May 5, 2022
feea968
fix: fix test error
shiki-tak Jun 17, 2022
2894e75
Add handlers
jhernandezb May 5, 2022
83cdcc3
add code-info query command
jhernandezb May 6, 2022
4e8029e
fix missing gov registration type
jhernandezb May 6, 2022
8e0ef5c
address code review comments
jhernandezb May 6, 2022
b360591
fix error message
jhernandezb May 6, 2022
f7f39aa
update proto field name
jhernandezb May 9, 2022
e003aae
Add compare logic for stricter AccessConfig
ethanfrey May 9, 2022
3e4ba9b
Enforce permission less permissive than default
ethanfrey May 9, 2022
cb271f2
Add a few more tests as requested in review
ethanfrey May 10, 2022
f4bb19c
Use LibwasmvmVersion from wasmvm root
webmaster128 May 16, 2022
78dcab0
Adapt codebase to new IBC3ChannelOpenResponse return value
webmaster128 May 16, 2022
bae4439
fix: test error
shiki-tak Jun 17, 2022
8544575
Use wasmvm import consistently
webmaster128 May 16, 2022
85751fa
Prepare release notes for 0.27
ethanfrey May 17, 2022
77cc9aa
Create query stack size limit
webmaster128 May 19, 2022
73ea0c2
fix: fix test error
shiki-tak Jun 21, 2022
f4f534a
fix: lint error
shiki-tak Jun 21, 2022
8fe027e
chore: update wasmvm version
shiki-tak Jun 21, 2022
a5775f3
Merge branch 'main' of github.com:line/lbm-sdk into issues/555
shiki-tak Jun 21, 2022
f38b645
chore: coverage up
shiki-tak Jun 27, 2022
cce1ef5
fix: change ContractAddrLen
shiki-tak Jul 7, 2022
c1d3995
fix: fix protobuf path
shiki-tak Jul 7, 2022
18ae5e2
fix: apply review
shiki-tak Jul 7, 2022
d704996
fix: fix typo & missing commit
shiki-tak Jul 7, 2022
7955f0b
chore: adjust gas
shiki-tak Jul 7, 2022
dba039e
chore: update go.mod
shiki-tak Jul 8, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 43 additions & 31 deletions x/wasm/wasm_snapshotter.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ package wasm

import (
"io"
"io/ioutil"
"os"
"path/filepath"

snapshot "github.com/cosmos/cosmos-sdk/snapshots/types"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down Expand Up @@ -54,8 +51,6 @@ type ExtensionSnapshotter interface {
type WasmSnapshotter struct {
wasm keeper.Keeper
cms sdk.CommitMultiStore
// obsolete placeholder to compile
wasmDirectory string
}

func NewWasmSnapshotter(cms sdk.CommitMultiStore, wasm keeper.Keeper) *WasmSnapshotter {
Expand Down Expand Up @@ -90,57 +85,74 @@ func (ws *WasmSnapshotter) Snapshot(height uint64, protoWriter protoio.Writer) e
}

// TODO: compress wasm bytes
// TODO: embed in a protobuf message
// TODO: embed in a protobuf message with more data
snapshot.WriteExtensionItem(protoWriter, wasmBytes)

return false
})

return nil
return rerr
Copy link
Contributor

Choose a reason for hiding this comment

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

typo?

}

func (ws *WasmSnapshotter) Restore(
height uint64, format uint32, protoReader protoio.Reader,
) (snapshot.SnapshotItem, error) {
if format != 1 {
return snapshot.SnapshotItem{}, snapshot.ErrUnknownFormat
if format == 1 {
err := ws.processAllItems(height, protoReader, restoreV1)
return snapshot.SnapshotItem{}, err
}
return snapshot.SnapshotItem{}, snapshot.ErrUnknownFormat
}

// Create .compute directory if it doesn't exist already
err := os.MkdirAll(ws.wasmDirectory, os.ModePerm)
if err != nil {
return snapshot.SnapshotItem{}, sdkerrors.Wrapf(err, "failed to create directory '%s'", ws.wasmDirectory)
}
func restoreV1(ctx sdk.Context, k keeper.Keeper, payload []byte) error {
panic("TODO")
// wasmCode, err = uncompress(wasmCode, k.GetMaxWasmCodeSize(ctx))
// if err != nil {
// return 0, sdkerrors.Wrap(types.ErrCreateFailed, err.Error())
// }
// checksum, err := k.wasmVM.Create(wasmCode)
// if err != nil {
// return 0, sdkerrors.Wrap(types.ErrCreateFailed, err.Error())
// }
}

func (ws *WasmSnapshotter) processAllItems(
height uint64, protoReader protoio.Reader, cb func(sdk.Context, keeper.Keeper, []byte) error,
) error {
ctx := sdk.NewContext(ws.cms, tmproto.Header{}, false, log.NewNopLogger())

for {
item := &snapshot.SnapshotItem{}
err = protoReader.ReadMsg(item)
err := protoReader.ReadMsg(item)
if err == io.EOF {
break
return nil
} else if err != nil {
return snapshot.SnapshotItem{}, sdkerrors.Wrap(err, "invalid protobuf message")
return sdkerrors.Wrap(err, "invalid protobuf message")
}

payload := item.GetExtensionPayload()
if payload == nil {
return snapshot.SnapshotItem{}, sdkerrors.Wrap(err, "invalid protobuf message")
return sdkerrors.Wrap(err, "invalid protobuf message")
}

// snapshotItem is 64 bytes of the file name, then the actual WASM bytes
if len(payload.Payload) < 64 {
return snapshot.SnapshotItem{}, sdkerrors.Wrapf(err, "wasm snapshot must be at least 64 bytes, got %v bytes", len(payload.Payload))
if err := cb(ctx, ws.wasm, payload.Payload); err != nil {
return sdkerrors.Wrap(err, "processing snapshot item")
}
}
}

wasmFileName := string(payload.Payload[0:64])
wasmBytes := payload.Payload[64:]
// // snapshotItem is 64 bytes of the file name, then the actual WASM bytes
// if len(payload.Payload) < 64 {
// return snapshot.SnapshotItem{}, sdkerrors.Wrapf(err, "wasm snapshot must be at least 64 bytes, got %v bytes", len(payload.Payload))
// }

wasmFilePath := filepath.Join(ws.wasmDirectory, wasmFileName)
// wasmBytes := payload.Payload[64:]

err = ioutil.WriteFile(wasmFilePath, wasmBytes, 0664 /* -rw-rw-r-- */)
if err != nil {
return snapshot.SnapshotItem{}, sdkerrors.Wrapf(err, "failed to write wasm file '%v' to disk", wasmFilePath)
}
}
// err = ioutil.WriteFile(wasmFilePath, wasmBytes, 0664 /* -rw-rw-r-- */)
// if err != nil {
// return snapshot.SnapshotItem{}, sdkerrors.Wrapf(err, "failed to write wasm file '%v' to disk", wasmFilePath)
// }
// }

return snapshot.SnapshotItem{}, nil
}
// return snapshot.SnapshotItem{}, nil
// }