Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
22 changes: 22 additions & 0 deletions prdoc/pr_10427.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
title: Fix assertion
doc:
- audience: Runtime Dev
description: "# Description\nAccording to assertion message and comment(\"at least\"\
), `T::MaxDebugBufferLen::get() > MIN_DEBUG_BUF_SIZE` should be changed into `T::MaxDebugBufferLen::get()\
\ >= MIN_DEBUG_BUF_SIZE`\n```rust\n// Debug buffer should at least be large enough\
\ to accommodate a simple error message\nconst MIN_DEBUG_BUF_SIZE: u32 = 256;\n\
assert!(\n\tT::MaxDebugBufferLen::get() > MIN_DEBUG_BUF_SIZE,\n\t\"Debug buffer\
\ should have minimum size of {} (current setting is {})\",\n\tMIN_DEBUG_BUF_SIZE,\n\
\tT::MaxDebugBufferLen::get(),\n);\n```\nFor this assertion, the assertion message\
\ indicates assertion will fail when max_storage_size > storage_size_limit, which\
\ means it requires max_storage_size <= storage_size_limit, but assertion predicate\
\ is `max_storage_size < storage_size_limit`. Based on the code semantics, assertion\
\ predicate should be changed into `max_storage_size <= storage_size_limit`.\n\
```rust\nassert!(\n\tmax_storage_size < storage_size_limit,\n\t\"Maximal storage\
\ size {} exceeds the storage limit {}\",\n\tmax_storage_size,\n\tstorage_size_limit\n\
);\n```"
crates:
- name: pallet-contracts
bump: patch
- name: pallet-revive
bump: patch
6 changes: 3 additions & 3 deletions substrate/frame/contracts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ pub mod pallet {
// Debug buffer should at least be large enough to accommodate a simple error message
const MIN_DEBUG_BUF_SIZE: u32 = 256;
assert!(
T::MaxDebugBufferLen::get() > MIN_DEBUG_BUF_SIZE,
T::MaxDebugBufferLen::get() >= MIN_DEBUG_BUF_SIZE,
"Debug buffer should have minimum size of {} (current setting is {})",
MIN_DEBUG_BUF_SIZE,
T::MaxDebugBufferLen::get(),
Expand Down Expand Up @@ -706,7 +706,7 @@ pub mod pallet {
let storage_size_limit = max_validator_runtime_mem.saturating_sub(max_runtime_mem) / 2;

assert!(
max_storage_size < storage_size_limit,
max_storage_size <= storage_size_limit,
"Maximal storage size {} exceeds the storage limit {}",
max_storage_size,
storage_size_limit
Expand All @@ -726,7 +726,7 @@ pub mod pallet {
.expect("Events size too big");

assert!(
max_events_size < storage_size_limit,
max_events_size <= storage_size_limit,
"Maximal events size {} exceeds the events limit {}",
max_events_size,
storage_size_limit
Expand Down
4 changes: 2 additions & 2 deletions substrate/frame/revive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,7 @@ pub mod pallet {
.saturating_mul(limits::EVENT_BYTES.into());

assert!(
max_events_size < storage_size_limit,
max_events_size <= storage_size_limit,
"Maximal events size {} exceeds the events limit {}",
max_events_size,
storage_size_limit
Expand Down Expand Up @@ -1022,7 +1022,7 @@ pub mod pallet {
.saturating_add(max_eth_block_builder_bytes.into());

assert!(
max_storage_size < storage_size_limit,
max_storage_size <= storage_size_limit,
"Maximal storage size {} exceeds the storage limit {}",
max_storage_size,
storage_size_limit
Expand Down
Loading