Skip to content

Commit b4cfe36

Browse files
authored
Merge pull request #977 from CosmWasm/bump_interface_version
Bump interface version to interface_version_6
2 parents e0178a9 + fa910a3 commit b4cfe36

File tree

11 files changed

+36
-19
lines changed

11 files changed

+36
-19
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ and this project adheres to
5656
- contracts: Rename `ReflectSubCall` to `ReflectSubMsg` and `SubCallResult` to
5757
`SubCallMsg` in the `reflect` contract.
5858
- cosmwasm-std: Rename the `subcall` module to `submessages`.
59+
- cosmwasm-vm: Bump required marker export `cosmwasm_vm_version_5` to
60+
`interface_version_6`.
5961

6062
[#961]: https://github.com/CosmWasm/cosmwasm/pull/961
6163

packages/std/src/entry_points.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ macro_rules! create_entry_points {
8181

8282
$crate::create_entry_points!(@migration; $contract, $migration);
8383

84-
// Other C externs like interface_version_5, allocate, deallocate are available
84+
// Other C externs like interface_version_6, allocate, deallocate are available
8585
// automatically because we `use cosmwasm_std`.
8686
}
8787
};

packages/std/src/exports.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! exports exposes the public wasm API
22
//!
3-
//! interface_version_5, allocate and deallocate turn into Wasm exports
3+
//! interface_version_6, allocate and deallocate turn into Wasm exports
44
//! as soon as cosmwasm_std is `use`d in the contract, even privately.
55
//!
66
//! `do_execute`, `do_instantiate`, `do_migrate`, `do_query`, `do_reply`
@@ -33,7 +33,7 @@ extern "C" fn requires_stargate() -> () {}
3333
/// They can be checked by cosmwasm_vm.
3434
/// Update this whenever the Wasm VM interface breaks.
3535
#[no_mangle]
36-
extern "C" fn interface_version_5() -> () {}
36+
extern "C" fn interface_version_6() -> () {}
3737

3838
/// allocate reserves the given number of bytes in wasm memory and returns a pointer
3939
/// to a Region defining this data. This space is managed by the calling process

packages/vm/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ compatibility list:
1616

1717
| cosmwasm-vm | Supported interface versions | cosmwasm-std |
1818
| ----------- | ---------------------------- | ------------ |
19+
| 0.15 | `interface_version_6` | 0.15 |
1920
| 0.14 | `interface_version_5` | 0.14 |
2021
| 0.13 | `cosmwasm_vm_version_4` | 0.11-0.13 |
2122
| 0.12 | `cosmwasm_vm_version_4` | 0.11-0.13 |
@@ -24,6 +25,14 @@ compatibility list:
2425
| 0.9 | `cosmwasm_vm_version_2` | 0.9 |
2526
| 0.8 | `cosmwasm_vm_version_1` | 0.8 |
2627

28+
### Changes between interface versions
29+
30+
**interface_version_5 -> interface_version_6**
31+
32+
- Rename the fields from `send` to `funds` in `WasmMsg::Instantiate` and
33+
`WasmMsg::Execute`.
34+
- Merge messages and sub-messages.
35+
2736
## Setup
2837

2938
There are demo files in `testdata/*.wasm`. Those are compiled and optimized
@@ -47,6 +56,12 @@ docker run --rm -v "$(pwd)":/code \
4756
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
4857
cosmwasm/rust-optimizer:0.11.4 ./contracts/ibc-reflect \
4958
&& cp artifacts/ibc_reflect.wasm packages/vm/testdata/ibc_reflect_0.15.wasm
59+
60+
docker run --rm -v "$(pwd)":/code \
61+
--mount type=volume,source="devcontract_cache_floaty",target=/code/contracts/floaty/target \
62+
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
63+
cosmwasm/rust-optimizer:0.11.4 ./contracts/floaty \
64+
&& cp artifacts/floaty.wasm packages/vm/testdata/floaty.wasm
5065
```
5166

5267
## Testing

packages/vm/src/compatibility.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const SUPPORTED_IMPORTS: &[&str] = &[
3232
/// Other optional exports exist, e.g. "execute", "migrate" and "query".
3333
/// This is unlikely to change much, must be frozen at 1.0 to avoid breaking existing contracts
3434
const REQUIRED_EXPORTS: &[&str] = &[
35-
"interface_version_5",
35+
"interface_version_6",
3636
"instantiate",
3737
"allocate",
3838
"deallocate",
@@ -169,15 +169,15 @@ mod tests {
169169
fn check_wasm_old_contract() {
170170
match check_wasm(CONTRACT_0_7, &default_features()) {
171171
Err(VmError::StaticValidationErr { msg, .. }) => assert!(msg.starts_with(
172-
"Wasm contract doesn't have required export: \"interface_version_5\""
172+
"Wasm contract doesn't have required export: \"interface_version_6\""
173173
)),
174174
Err(e) => panic!("Unexpected error {:?}", e),
175175
Ok(_) => panic!("This must not succeeed"),
176176
};
177177

178178
match check_wasm(CONTRACT_0_6, &default_features()) {
179179
Err(VmError::StaticValidationErr { msg, .. }) => assert!(msg.starts_with(
180-
"Wasm contract doesn't have required export: \"interface_version_5\""
180+
"Wasm contract doesn't have required export: \"interface_version_6\""
181181
)),
182182
Err(e) => panic!("Unexpected error {:?}", e),
183183
Ok(_) => panic!("This must not succeeed"),
@@ -291,7 +291,7 @@ mod tests {
291291
match check_wasm_exports(&module) {
292292
Err(VmError::StaticValidationErr { msg, .. }) => {
293293
assert!(msg.starts_with(
294-
"Wasm contract doesn't have required export: \"interface_version_5\""
294+
"Wasm contract doesn't have required export: \"interface_version_6\""
295295
));
296296
}
297297
Err(e) => panic!("Unexpected error {:?}", e),
@@ -305,7 +305,7 @@ mod tests {
305305
match check_wasm_exports(&module) {
306306
Err(VmError::StaticValidationErr { msg, .. }) => {
307307
assert!(msg.starts_with(
308-
"Wasm contract doesn't have required export: \"interface_version_5\""
308+
"Wasm contract doesn't have required export: \"interface_version_6\""
309309
));
310310
}
311311
Err(e) => panic!("Unexpected error {:?}", e),

packages/vm/src/environment.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,7 @@ mod tests {
704704
let (env, _instance) = make_instance(TESTING_GAS_LIMIT);
705705
leave_default_data(&env);
706706

707-
env.call_function0("interface_version_5", &[]).unwrap();
707+
env.call_function0("interface_version_6", &[]).unwrap();
708708
}
709709

710710
#[test]

packages/vm/src/instance.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ mod tests {
391391
let instance = mock_instance(&CONTRACT, &[]);
392392

393393
instance
394-
.call_function0("interface_version_5", &[])
394+
.call_function0("interface_version_6", &[])
395395
.expect("error calling function");
396396
}
397397

@@ -534,7 +534,7 @@ mod tests {
534534
535535
(type (func))
536536
(func (type 0) nop)
537-
(export "interface_version_5" (func 0))
537+
(export "interface_version_6" (func 0))
538538
(export "instantiate" (func 0))
539539
(export "allocate" (func 0))
540540
(export "deallocate" (func 0))
@@ -552,7 +552,7 @@ mod tests {
552552
553553
(type (func))
554554
(func (type 0) nop)
555-
(export "interface_version_5" (func 0))
555+
(export "interface_version_6" (func 0))
556556
(export "instantiate" (func 0))
557557
(export "allocate" (func 0))
558558
(export "deallocate" (func 0))
@@ -606,7 +606,7 @@ mod tests {
606606

607607
let report2 = instance.create_gas_report();
608608
assert_eq!(report2.used_externally, 73);
609-
assert_eq!(report2.used_internally, 38880);
609+
assert_eq!(report2.used_internally, 36378);
610610
assert_eq!(report2.limit, LIMIT);
611611
assert_eq!(
612612
report2.remaining,
@@ -805,7 +805,7 @@ mod singlepass_tests {
805805
.unwrap();
806806

807807
let init_used = orig_gas - instance.get_gas_left();
808-
assert_eq!(init_used, 38953);
808+
assert_eq!(init_used, 36451);
809809
}
810810

811811
#[test]
@@ -828,7 +828,7 @@ mod singlepass_tests {
828828
.unwrap();
829829

830830
let execute_used = gas_before_execute - instance.get_gas_left();
831-
assert_eq!(execute_used, 159317);
831+
assert_eq!(execute_used, 159020);
832832
}
833833

834834
#[test]
@@ -862,6 +862,6 @@ mod singlepass_tests {
862862
assert_eq!(answer.as_slice(), b"{\"verifier\":\"verifies\"}");
863863

864864
let query_used = gas_before_query - instance.get_gas_left();
865-
assert_eq!(query_used, 28999);
865+
assert_eq!(query_used, 27629);
866866
}
867867
}

packages/vm/src/static_analysis.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ mod tests {
124124
125125
(type (func))
126126
(func (type 0) nop)
127-
(export "interface_version_5" (func 0))
127+
(export "interface_version_6" (func 0))
128128
(export "instantiate" (func 0))
129129
(export "allocate" (func 0))
130130
(export "deallocate" (func 0))
@@ -142,7 +142,7 @@ mod tests {
142142
143143
(type (func))
144144
(func (type 0) nop)
145-
(export "interface_version_5" (func 0))
145+
(export "interface_version_6" (func 0))
146146
(export "instantiate" (func 0))
147147
(export "execute" (func 0))
148148
(export "allocate" (func 0))
@@ -167,7 +167,7 @@ mod tests {
167167
168168
(type (func))
169169
(func (type 0) nop)
170-
(export "interface_version_5" (func 0))
170+
(export "interface_version_6" (func 0))
171171
(export "instantiate" (func 0))
172172
(export "execute" (func 0))
173173
(export "allocate" (func 0))

packages/vm/testdata/floaty.wasm

-21.2 KB
Binary file not shown.
-23.3 KB
Binary file not shown.

0 commit comments

Comments
 (0)