Skip to content

Commit 63d647d

Browse files
committed
Merge branch 'main' into aw/new-schema
2 parents 14add23 + c5eb22d commit 63d647d

File tree

9 files changed

+59
-50
lines changed

9 files changed

+59
-50
lines changed

.circleci/config.yml

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ commands:
3535
- run:
3636
name: Run cosmwasm-check (<< parameters.min_version >>)
3737
command: |
38-
cargo install cosmwasm-check@~<< parameters.min_version >> --locked --force
38+
# Try installing min_version, but fall back to latest main version.
39+
# This allows us to test contracts against the latest cosmwasm-check before releasing it.
40+
cargo install cosmwasm-check@~<< parameters.min_version >> --locked --force \
41+
|| cargo install --path ../../packages/check --locked --force
3942
cosmwasm-check --version
4043
cosmwasm-check target/wasm32-unknown-unknown/release/*.wasm
4144
# Run clippy after wasm build to ensure target/wasm32-unknown-unknown/release/<contract>.wasm exists
@@ -92,7 +95,7 @@ workflows:
9295
matrix:
9396
parameters:
9497
# Run with MSRV and some modern stable Rust
95-
rust-version: ["1.74.0", "1.78.0"]
98+
rust-version: ["1.74.0", "1.82.0"]
9699
- benchmarking:
97100
requires:
98101
- package_vm
@@ -652,7 +655,8 @@ jobs:
652655

653656
contract_hackatom:
654657
docker:
655-
- image: rust:1.74
658+
# We compile this contract with the upper bound to detect issues with new Rust versions early
659+
- image: rust:1.82
656660
environment:
657661
RUST_BACKTRACE: 1
658662
working_directory: ~/cosmwasm/contracts/hackatom
@@ -664,10 +668,9 @@ jobs:
664668
command: rustc --version; cargo --version; rustup --version
665669
- restore_cache:
666670
keys:
667-
- cargocache-v2-contract_hackatom-rust:1.74-{{ checksum "Cargo.lock" }}
671+
- cargocache-v2-contract_hackatom-rust:1.82-{{ checksum "Cargo.lock" }}
668672
- check_contract:
669-
min_version: "1.4"
670-
skip_cosmwasm_check: true
673+
min_version: "2.2"
671674
- save_cache:
672675
paths:
673676
- /usr/local/cargo/registry
@@ -677,7 +680,7 @@ jobs:
677680
- target/wasm32-unknown-unknown/release/.fingerprint
678681
- target/wasm32-unknown-unknown/release/build
679682
- target/wasm32-unknown-unknown/release/deps
680-
key: cargocache-v2-contract_hackatom-rust:1.74-{{ checksum "Cargo.lock" }}
683+
key: cargocache-v2-contract_hackatom-rust:1.82-{{ checksum "Cargo.lock" }}
681684

682685
contract_ibc_callbacks:
683686
docker:
@@ -722,10 +725,8 @@ jobs:
722725
- restore_cache:
723726
keys:
724727
- cargocache-v2-contract_ibc_reflect-rust:1.74-{{ checksum "Cargo.lock" }}
725-
# TODO: enable again once 2.2 is released
726728
- check_contract:
727729
min_version: "2.2"
728-
skip_cosmwasm_check: true
729730
- save_cache:
730731
paths:
731732
- /usr/local/cargo/registry
@@ -864,10 +865,8 @@ jobs:
864865
- restore_cache:
865866
keys:
866867
- cargocache-v2-contract_reflect-rust:1.74-{{ checksum "Cargo.lock" }}
867-
# TODO: enable again once 2.2 is released
868868
- check_contract:
869869
min_version: "2.2"
870-
skip_cosmwasm_check: true
871870
- save_cache:
872871
paths:
873872
- /usr/local/cargo/registry
@@ -1144,7 +1143,7 @@ jobs:
11441143

11451144
coverage:
11461145
docker:
1147-
- image: rust:1.78.0-alpine3.19
1146+
- image: rust:1.82.0-alpine3.19
11481147
environment:
11491148
# Limit the number of parallel jobs to avoid OOM crashes during doc testing
11501149
RUST_TEST_THREADS: 8

CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,14 @@ and this project adheres to
2626
- cosmwasm-vm: Export a new `migrate_with_info` function ([#2212])
2727
- cosmwasm-derive: Add support for migrate method with
2828
`migrate_info: MigrateInfo` argument. ([#2212])
29+
- cosmwasm-vm: Enable support for reference-types proposal, required since Rust
30+
1.82 ([#2288])
2931

3032
[#2118]: https://github.com/CosmWasm/cosmwasm/pull/2118
3133
[#2196]: https://github.com/CosmWasm/cosmwasm/pull/2196
3234
[#2220]: https://github.com/CosmWasm/cosmwasm/pull/2220
3335
[#2212]: https://github.com/CosmWasm/cosmwasm/pull/2212
36+
[#2288]: https://github.com/CosmWasm/cosmwasm/pull/2288
3437

3538
### Changed
3639

@@ -48,7 +51,12 @@ and this project adheres to
4851
match the contract address from `mock_env`. ([#2211])
4952
- cosmwasm-derive: Automatically detect whether the package is a dependency or
5053
the primary package, only expanding entrypoints for the primary package. This
51-
effectively deprecates the usage of the `library` feature pattern. ([#2246])
54+
effectively deprecates the usage of the `library` feature pattern.
55+
56+
Note: This feature does **NOT** interact well with workspaces due to a cargo
57+
bug. If you have multiple contracts in a workspace, you might still want to
58+
use the library feature ([#2246])
59+
5260
- cosmwasm-std: Deprecate `BankQuery::AllBalances` and `IbcQuery::ListChannels`.
5361
Both are inherently problematic to use because the returned entries are
5462
unbounded. ([#2247])

packages/check/tests/cosmwasm_check_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ fn wasm_limits_string_check() -> Result<(), Box<dyn std::error::Error>> {
103103
let mut cmd = Command::cargo_bin("cosmwasm-check")?;
104104

105105
let mut limits = WasmLimits::default();
106-
limits.initial_memory_limit = Some(10);
106+
limits.initial_memory_limit_pages = Some(10);
107107

108108
cmd.arg("--wasm-limits")
109109
.arg(to_json_string(&limits).unwrap())

packages/vm/benches/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ fn bench_combined(c: &mut Criterion) {
386386

387387
group.bench_function("get instance from fs cache and execute", |b| {
388388
let mut non_memcache = options.clone();
389-
non_memcache.memory_cache_size = Size::kibi(0);
389+
non_memcache.memory_cache_size_bytes = Size::kibi(0);
390390

391391
let cache: Cache<MockApi, MockStorage, MockQuerier> =
392392
unsafe { Cache::new(non_memcache).unwrap() };

packages/vm/src/cache.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ where
142142
CacheOptions {
143143
base_dir,
144144
available_capabilities,
145-
memory_cache_size,
146-
instance_memory_limit,
145+
memory_cache_size_bytes,
146+
instance_memory_limit_bytes,
147147
},
148148
wasm_limits,
149149
} = config;
@@ -165,11 +165,11 @@ where
165165
inner: Mutex::new(CacheInner {
166166
wasm_path,
167167
pinned_memory_cache: PinnedMemoryCache::new(),
168-
memory_cache: InMemoryCache::new(memory_cache_size),
168+
memory_cache: InMemoryCache::new(memory_cache_size_bytes),
169169
fs_cache,
170170
stats: Stats::default(),
171171
}),
172-
instance_memory_limit,
172+
instance_memory_limit: instance_memory_limit_bytes,
173173
type_storage: PhantomData::<S>,
174174
type_api: PhantomData::<A>,
175175
type_querier: PhantomData::<Q>,
@@ -614,8 +614,8 @@ mod tests {
614614
CacheOptions {
615615
base_dir: TempDir::new().unwrap().into_path(),
616616
available_capabilities: default_capabilities(),
617-
memory_cache_size: TESTING_MEMORY_CACHE_SIZE,
618-
instance_memory_limit: TESTING_MEMORY_LIMIT,
617+
memory_cache_size_bytes: TESTING_MEMORY_CACHE_SIZE,
618+
instance_memory_limit_bytes: TESTING_MEMORY_LIMIT,
619619
}
620620
}
621621

@@ -625,8 +625,8 @@ mod tests {
625625
CacheOptions {
626626
base_dir: TempDir::new().unwrap().into_path(),
627627
available_capabilities: capabilities,
628-
memory_cache_size: TESTING_MEMORY_CACHE_SIZE,
629-
instance_memory_limit: TESTING_MEMORY_LIMIT,
628+
memory_cache_size_bytes: TESTING_MEMORY_CACHE_SIZE,
629+
instance_memory_limit_bytes: TESTING_MEMORY_LIMIT,
630630
}
631631
}
632632

@@ -755,8 +755,8 @@ mod tests {
755755
let options1 = CacheOptions {
756756
base_dir: tmp_dir.path().to_path_buf(),
757757
available_capabilities: default_capabilities(),
758-
memory_cache_size: TESTING_MEMORY_CACHE_SIZE,
759-
instance_memory_limit: TESTING_MEMORY_LIMIT,
758+
memory_cache_size_bytes: TESTING_MEMORY_CACHE_SIZE,
759+
instance_memory_limit_bytes: TESTING_MEMORY_LIMIT,
760760
};
761761
let cache1: Cache<MockApi, MockStorage, MockQuerier> =
762762
unsafe { Cache::new(options1).unwrap() };
@@ -767,8 +767,8 @@ mod tests {
767767
let options2 = CacheOptions {
768768
base_dir: tmp_dir.path().to_path_buf(),
769769
available_capabilities: default_capabilities(),
770-
memory_cache_size: TESTING_MEMORY_CACHE_SIZE,
771-
instance_memory_limit: TESTING_MEMORY_LIMIT,
770+
memory_cache_size_bytes: TESTING_MEMORY_CACHE_SIZE,
771+
instance_memory_limit_bytes: TESTING_MEMORY_LIMIT,
772772
};
773773
let cache2: Cache<MockApi, MockStorage, MockQuerier> =
774774
unsafe { Cache::new(options2).unwrap() };
@@ -800,8 +800,8 @@ mod tests {
800800
let options = CacheOptions {
801801
base_dir: tmp_dir.path().to_path_buf(),
802802
available_capabilities: default_capabilities(),
803-
memory_cache_size: TESTING_MEMORY_CACHE_SIZE,
804-
instance_memory_limit: TESTING_MEMORY_LIMIT,
803+
memory_cache_size_bytes: TESTING_MEMORY_CACHE_SIZE,
804+
instance_memory_limit_bytes: TESTING_MEMORY_LIMIT,
805805
};
806806
let cache: Cache<MockApi, MockStorage, MockQuerier> =
807807
unsafe { Cache::new(options).unwrap() };
@@ -1606,8 +1606,8 @@ mod tests {
16061606
let options = CacheOptions {
16071607
base_dir: tmp_dir.path().to_path_buf(),
16081608
available_capabilities: default_capabilities(),
1609-
memory_cache_size: TESTING_MEMORY_CACHE_SIZE,
1610-
instance_memory_limit: TESTING_MEMORY_LIMIT,
1609+
memory_cache_size_bytes: TESTING_MEMORY_CACHE_SIZE,
1610+
instance_memory_limit_bytes: TESTING_MEMORY_LIMIT,
16111611
};
16121612
let cache: Cache<MockApi, MockStorage, MockQuerier> =
16131613
unsafe { Cache::new(options).unwrap() };
@@ -1639,8 +1639,8 @@ mod tests {
16391639
cache: CacheOptions {
16401640
base_dir: tmp_dir.path().to_path_buf(),
16411641
available_capabilities: default_capabilities(),
1642-
memory_cache_size: TESTING_MEMORY_CACHE_SIZE,
1643-
instance_memory_limit: TESTING_MEMORY_LIMIT,
1642+
memory_cache_size_bytes: TESTING_MEMORY_CACHE_SIZE,
1643+
instance_memory_limit_bytes: TESTING_MEMORY_LIMIT,
16441644
},
16451645
};
16461646

packages/vm/src/compatibility.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ fn check_wasm_tables(module: &ParsedWasm, wasm_limits: &WasmLimits) -> VmResult<
122122
1 => {
123123
let limits = &module.tables[0];
124124
if let Some(maximum) = limits.maximum {
125-
if maximum > wasm_limits.table_size_limit() {
125+
if maximum > wasm_limits.table_size_limit_elements() {
126126
return Err(VmError::static_validation_err(
127127
"Wasm contract's first table section has a too large max limit",
128128
));
@@ -148,10 +148,10 @@ fn check_wasm_memories(module: &ParsedWasm, limits: &WasmLimits) -> VmResult<()>
148148
}
149149
let memory = &module.memories[0];
150150

151-
if memory.initial > limits.initial_memory_limit() as u64 {
151+
if memory.initial > limits.initial_memory_limit_pages() as u64 {
152152
return Err(VmError::static_validation_err(format!(
153153
"Wasm contract memory's minimum must not exceed {} pages.",
154-
limits.initial_memory_limit()
154+
limits.initial_memory_limit_pages()
155155
)));
156156
}
157157

packages/vm/src/config.rs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ pub struct WasmLimits {
5252
///
5353
/// Every Wasm memory has an initial size and an optional maximum size,
5454
/// both measured in Wasm pages. This limit applies to the initial size.
55-
pub initial_memory_limit: Option<u32>,
55+
pub initial_memory_limit_pages: Option<u32>,
5656
/// The upper limit for the `max` value of each table. CosmWasm contracts have
5757
/// initial=max for 1 table. See
5858
///
@@ -64,7 +64,7 @@ pub struct WasmLimits {
6464
/// - table[0] type=funcref initial=161 max=161
6565
/// ```
6666
///
67-
pub table_size_limit: Option<u32>,
67+
pub table_size_limit_elements: Option<u32>,
6868
/// If the contract has more than this amount of imports, it will be rejected
6969
/// during static validation before even looking into the imports.
7070
pub max_imports: Option<usize>,
@@ -88,12 +88,14 @@ pub struct WasmLimits {
8888
}
8989

9090
impl WasmLimits {
91-
pub fn initial_memory_limit(&self) -> u32 {
92-
self.initial_memory_limit.unwrap_or(DEFAULT_MEMORY_LIMIT)
91+
pub fn initial_memory_limit_pages(&self) -> u32 {
92+
self.initial_memory_limit_pages
93+
.unwrap_or(DEFAULT_MEMORY_LIMIT)
9394
}
9495

95-
pub fn table_size_limit(&self) -> u32 {
96-
self.table_size_limit.unwrap_or(DEFAULT_TABLE_SIZE_LIMIT)
96+
pub fn table_size_limit_elements(&self) -> u32 {
97+
self.table_size_limit_elements
98+
.unwrap_or(DEFAULT_TABLE_SIZE_LIMIT)
9799
}
98100

99101
pub fn max_imports(&self) -> usize {
@@ -130,24 +132,24 @@ pub struct CacheOptions {
130132
pub base_dir: PathBuf,
131133
pub available_capabilities: HashSet<String>,
132134
/// Memory limit for the cache, in bytes.
133-
pub memory_cache_size: Size,
135+
pub memory_cache_size_bytes: Size,
134136
/// Memory limit for instances, in bytes. Use a value that is divisible by the Wasm page size 65536,
135137
/// e.g. full MiBs.
136-
pub instance_memory_limit: Size,
138+
pub instance_memory_limit_bytes: Size,
137139
}
138140

139141
impl CacheOptions {
140142
pub fn new(
141143
base_dir: impl Into<PathBuf>,
142144
available_capabilities: impl Into<HashSet<String>>,
143-
memory_cache_size: Size,
144-
instance_memory_limit: Size,
145+
memory_cache_size_bytes: Size,
146+
instance_memory_limit_bytes: Size,
145147
) -> Self {
146148
Self {
147149
base_dir: base_dir.into(),
148150
available_capabilities: available_capabilities.into(),
149-
memory_cache_size,
150-
instance_memory_limit,
151+
memory_cache_size_bytes,
152+
instance_memory_limit_bytes,
151153
}
152154
}
153155
}

packages/vm/src/parsed_wasm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ impl<'a> ParsedWasm<'a> {
7979
multi_value: true,
8080
floats: true,
8181

82-
reference_types: false,
82+
reference_types: true,
8383
bulk_memory: false,
8484
simd: false,
8585
relaxed_simd: false,

packages/vm/src/wasm_backend/gatekeeper.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ impl Default for Gatekeeper {
5959
Self::new(GatekeeperConfig {
6060
allow_floats: true,
6161
allow_feature_bulk_memory_operations: false,
62-
allow_feature_reference_types: false,
62+
allow_feature_reference_types: true,
6363
allow_feature_simd: false,
6464
allow_feature_exception_handling: false,
6565
allow_feature_threads: false,

0 commit comments

Comments
 (0)