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

contracts: Remove no longer enforced limits from the Schedule #3184

Merged
merged 6 commits into from
Feb 8, 2024
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
10 changes: 10 additions & 0 deletions prdoc/pr_3184.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
title: "Contracts: Remove no longer enforced limits from the Schedule"

doc:
- audience: Runtime Dev
description: |
The limits are no longer in use and do nothing. Every builder overwritting them
can just adapt their code to remove them without any consequence.

crates:
- name: pallet-contracts
39 changes: 0 additions & 39 deletions substrate/frame/contracts/src/schedule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,7 @@ use serde::{Deserialize, Serialize};
/// fn create_schedule<T: Config>() -> Schedule<T> {
/// Schedule {
/// limits: Limits {
/// globals: 3,
/// parameters: 3,
/// memory_pages: 16,
/// table_size: 3,
/// br_table_size: 3,
/// .. Default::default()
/// },
/// instruction_weights: InstructionWeights {
Expand Down Expand Up @@ -77,38 +73,9 @@ pub struct Limits {
/// The maximum number of topics supported by an event.
pub event_topics: u32,

/// Maximum number of globals a module is allowed to declare.
///
/// Globals are not limited through the linear memory limit `memory_pages`.
pub globals: u32,

/// Maximum number of locals a function can have.
///
/// As wasm engine initializes each of the local, we need to limit their number to confine
/// execution costs.
pub locals: u32,

/// Maximum numbers of parameters a function can have.
///
/// Those need to be limited to prevent a potentially exploitable interaction with
/// the stack height instrumentation: The costs of executing the stack height
/// instrumentation for an indirectly called function scales linearly with the amount
/// of parameters of this function. Because the stack height instrumentation itself is
/// is not weight metered its costs must be static (via this limit) and included in
/// the costs of the instructions that cause them (call, call_indirect).
pub parameters: u32,

/// Maximum number of memory pages allowed for a contract.
pub memory_pages: u32,

/// Maximum number of elements allowed in a table.
///
/// Currently, the only type of element that is allowed in a table is funcref.
pub table_size: u32,

/// Maximum number of elements that can appear as immediate value to the br_table instruction.
pub br_table_size: u32,

/// The maximum length of a subject in bytes used for PRNG generation.
pub subject_len: u32,

Expand Down Expand Up @@ -370,13 +337,7 @@ impl Default for Limits {
fn default() -> Self {
Self {
event_topics: 4,
globals: 256,
locals: 1024,
parameters: 128,
memory_pages: 16,
// 4k function pointers (This is in count not bytes).
table_size: 4096,
br_table_size: 256,
subject_len: 32,
payload_len: 16 * 1024,
runtime_memory: 1024 * 1024 * 128,
Expand Down
5 changes: 0 additions & 5 deletions substrate/frame/contracts/src/wasm/prepare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,12 +384,7 @@ mod tests {
let wasm = wat::parse_str($wat).unwrap().try_into().unwrap();
let schedule = Schedule {
limits: Limits {
globals: 3,
locals: 3,
parameters: 3,
memory_pages: 16,
table_size: 3,
br_table_size: 3,
.. Default::default()
},
.. Default::default()
Expand Down
Loading