Skip to content

Commit

Permalink
Merge branch 'master' into snowbridge-westend-migration
Browse files Browse the repository at this point in the history
  • Loading branch information
yrong authored Sep 19, 2024
2 parents efe6099 + 69b02a3 commit 608d7ee
Show file tree
Hide file tree
Showing 17 changed files with 373 additions and 137 deletions.
64 changes: 32 additions & 32 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1217,7 +1217,7 @@ snowbridge-router-primitives = { path = "bridges/snowbridge/primitives/router",
snowbridge-runtime-common = { path = "bridges/snowbridge/runtime/runtime-common", default-features = false }
snowbridge-runtime-test-common = { path = "bridges/snowbridge/runtime/test-common", default-features = false }
snowbridge-system-runtime-api = { path = "bridges/snowbridge/pallets/system/runtime-api", default-features = false }
soketto = { version = "0.7.1" }
soketto = { version = "0.8.0" }
solochain-template-runtime = { path = "templates/solochain/runtime" }
sp-api = { path = "substrate/primitives/api", default-features = false }
sp-api-proc-macro = { path = "substrate/primitives/api/proc-macro", default-features = false }
Expand Down
14 changes: 14 additions & 0 deletions prdoc/pr_5726.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
title: "revive: Limit the amount of static memory"

doc:
- audience: Runtime Dev
description: |
Limit the amount of static memory a contract can declare.

crates:
- name: pallet-revive
bump: major
- name: pallet-revive-fixtures
bump: minor
- name: pallet-revive-uapi
bump: patch
Empty file modified scripts/update-ui-tests.sh
100644 → 100755
Empty file.
1 change: 0 additions & 1 deletion substrate/bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1410,7 +1410,6 @@ impl pallet_revive::Config for Runtime {
type WeightInfo = pallet_revive::weights::SubstrateWeight<Self>;
type ChainExtension = ();
type AddressMapper = pallet_revive::DefaultAddressMapper;
type MaxCodeLen = ConstU32<{ 123 * 1024 }>;
type RuntimeMemory = ConstU32<{ 128 * 1024 * 1024 }>;
type PVFMemory = ConstU32<{ 512 * 1024 * 1024 }>;
type UnsafeUnstableInterface = ConstBool<false>;
Expand Down
2 changes: 1 addition & 1 deletion substrate/frame/revive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
environmental = { workspace = true }
paste = { workspace = true }
polkavm = { version = "0.10.0", default-features = false }
polkavm = { version = "0.11.0", default-features = false }
bitflags = { workspace = true }
codec = { features = [
"derive",
Expand Down
2 changes: 1 addition & 1 deletion substrate/frame/revive/fixtures/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ log = { workspace = true }
parity-wasm = { workspace = true }
tempfile = { workspace = true }
toml = { workspace = true }
polkavm-linker = { version = "0.10.0" }
polkavm-linker = { version = "0.11.0" }
anyhow = { workspace = true, default-features = true }

[features]
Expand Down
2 changes: 1 addition & 1 deletion substrate/frame/revive/fixtures/build/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ edition = "2021"
[dependencies]
uapi = { package = 'pallet-revive-uapi', path = "", default-features = false }
common = { package = 'pallet-revive-fixtures-common', path = "" }
polkavm-derive = { version = "0.10.0" }
polkavm-derive = { version = "0.11.0" }

[profile.release]
opt-level = 3
Expand Down
44 changes: 44 additions & 0 deletions substrate/frame/revive/fixtures/contracts/oom_ro.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// This file is part of Substrate.

// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

//! This creates a large ro section. Even though it is zero
//! initialized we expect them to be included into the blob.
//! This means it will fail at the blob size check.

#![no_std]
#![no_main]

extern crate common;

use uapi::{HostFn, HostFnImpl as api, ReturnFlags};

static BUFFER: [u8; 1025 * 1024] = [0; 1025 * 1024];

#[no_mangle]
#[polkavm_derive::polkavm_export]
pub extern "C" fn call_never() {
// make sure the buffer is not optimized away
api::return_value(ReturnFlags::empty(), &BUFFER);
}

#[no_mangle]
#[polkavm_derive::polkavm_export]
pub extern "C" fn deploy() {}

#[no_mangle]
#[polkavm_derive::polkavm_export]
pub extern "C" fn call() {}
44 changes: 44 additions & 0 deletions substrate/frame/revive/fixtures/contracts/oom_rw_included.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// This file is part of Substrate.

// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

//! This creates a large rw section but with its contents
//! included into the blob. It should be rejected for its
//! blob size.

#![no_std]
#![no_main]

extern crate common;

use uapi::{HostFn, HostFnImpl as api, ReturnFlags};

static mut BUFFER: [u8; 513 * 1024] = [42; 513 * 1024];

#[no_mangle]
#[polkavm_derive::polkavm_export]
pub unsafe extern "C" fn call_never() {
// make sure the buffer is not optimized away
api::return_value(ReturnFlags::empty(), &BUFFER);
}

#[no_mangle]
#[polkavm_derive::polkavm_export]
pub extern "C" fn deploy() {}

#[no_mangle]
#[polkavm_derive::polkavm_export]
pub extern "C" fn call() {}
44 changes: 44 additions & 0 deletions substrate/frame/revive/fixtures/contracts/oom_rw_trailing.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// This file is part of Substrate.

// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

//! This creates a large rw section but the trailing zeroes
//! are removed by the linker. It should be rejected even
//! though the blob is small enough.

#![no_std]
#![no_main]

extern crate common;

use uapi::{HostFn, HostFnImpl as api, ReturnFlags};

static mut BUFFER: [u8; 1025 * 1024] = [0; 1025 * 1024];

#[no_mangle]
#[polkavm_derive::polkavm_export]
pub unsafe extern "C" fn call_never() {
// make sure the buffer is not optimized away
api::return_value(ReturnFlags::empty(), &BUFFER);
}

#[no_mangle]
#[polkavm_derive::polkavm_export]
pub extern "C" fn deploy() {}

#[no_mangle]
#[polkavm_derive::polkavm_export]
pub extern "C" fn call() {}
Loading

0 comments on commit 608d7ee

Please sign in to comment.