Skip to content

Commit 15bb414

Browse files
authored
Merge pull request #2169 from CosmWasm/chipshort/fix-cw-migrate-version
Fix `cw_migrate_version`
2 parents e4445bf + bcc1fc6 commit 15bb414

File tree

6 files changed

+11
-8
lines changed

6 files changed

+11
-8
lines changed

contracts/hackatom/src/contract.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ pub fn instantiate(
3636
}
3737

3838
#[entry_point]
39+
#[migrate_version(42)]
3940
pub fn migrate(deps: DepsMut, _env: Env, msg: MigrateMsg) -> Result<Response, HackError> {
4041
let data = deps
4142
.storage

packages/derive/src/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ fn expand_attributes(func: &mut ItemFn) -> syn::Result<TokenStream> {
145145
}
146146

147147
let version = version.base10_digits();
148+
let n = version.len();
149+
let version = proc_macro2::Literal::byte_string(version.as_bytes());
148150

149151
stream = quote! {
150152
#stream
@@ -155,7 +157,7 @@ fn expand_attributes(func: &mut ItemFn) -> syn::Result<TokenStream> {
155157
#[link_section = "cw_migrate_version"]
156158
/// This is an internal constant exported as a custom section denoting the contract migrate version.
157159
/// The format and even the existence of this value is an implementation detail, DO NOT RELY ON THIS!
158-
static __CW_MIGRATE_VERSION: &str = #version;
160+
static __CW_MIGRATE_VERSION: [u8; #n] = *#version;
159161
};
160162
}
161163

@@ -267,7 +269,7 @@ mod test {
267269
#[link_section = "cw_migrate_version"]
268270
/// This is an internal constant exported as a custom section denoting the contract migrate version.
269271
/// The format and even the existence of this value is an implementation detail, DO NOT RELY ON THIS!
270-
static __CW_MIGRATE_VERSION: &str = "2";
272+
static __CW_MIGRATE_VERSION: [u8; 1usize] = *b"2";
271273

272274
fn migrate(deps: DepsMut, env: Env, msg: MigrateMsg) -> Response {
273275
// Logic here

packages/vm/src/cache.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1416,7 +1416,7 @@ mod tests {
14161416
E::Query
14171417
]),
14181418
required_capabilities: BTreeSet::new(),
1419-
contract_migrate_version: None,
1419+
contract_migrate_version: Some(42),
14201420
}
14211421
);
14221422

packages/vm/src/instance.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -914,7 +914,7 @@ mod tests {
914914

915915
let report2 = instance.create_gas_report();
916916
assert_eq!(report2.used_externally, 251);
917-
assert_eq!(report2.used_internally, 12109530);
917+
assert_eq!(report2.used_internally, 11473730);
918918
assert_eq!(report2.limit, LIMIT);
919919
assert_eq!(
920920
report2.remaining,
@@ -1105,7 +1105,7 @@ mod tests {
11051105
.unwrap();
11061106

11071107
let init_used = orig_gas - instance.get_gas_left();
1108-
assert_eq!(init_used, 12109781);
1108+
assert_eq!(init_used, 11473981);
11091109
}
11101110

11111111
#[test]
@@ -1130,7 +1130,7 @@ mod tests {
11301130
.unwrap();
11311131

11321132
let execute_used = gas_before_execute - instance.get_gas_left();
1133-
assert_eq!(execute_used, 12658786);
1133+
assert_eq!(execute_used, 12086566);
11341134
}
11351135

11361136
#[test]
@@ -1173,6 +1173,6 @@ mod tests {
11731173
);
11741174

11751175
let query_used = gas_before_query - instance.get_gas_left();
1176-
assert_eq!(query_used, 8094896);
1176+
assert_eq!(query_used, 7570446);
11771177
}
11781178
}

packages/vm/testdata/hackatom.wasm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
hackatom_1.2.wasm
1+
hackatom_1.3.wasm
227 KB
Binary file not shown.

0 commit comments

Comments
 (0)