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

Add unstable-api feature flag to pallet-revive #6866

Merged
merged 14 commits into from
Dec 13, 2024
4 changes: 4 additions & 0 deletions substrate/frame/revive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ xcm-builder = { workspace = true, default-features = true }

[features]
default = ["std"]
unstable-api = [
"pallet-revive-uapi/unstable-api",
"pallet-revive-fixtures/unstable-api",
]
davidk-pt marked this conversation as resolved.
Show resolved Hide resolved
std = [
"codec/std",
"environmental/std",
Expand Down
1 change: 1 addition & 0 deletions substrate/frame/revive/fixtures/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@ anyhow = { workspace = true, default-features = true }

[features]
default = ["std"]
unstable-api = []
davidk-pt marked this conversation as resolved.
Show resolved Hide resolved
# only when std is enabled all fixtures are available
std = ["anyhow", "frame-system", "log/std", "sp-core", "sp-io", "sp-runtime"]
3 changes: 3 additions & 0 deletions substrate/frame/revive/fixtures/build/_Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ uapi = { package = 'pallet-revive-uapi', path = "", default-features = false }
common = { package = 'pallet-revive-fixtures-common', path = "" }
polkavm-derive = { version = "0.17.0" }

[features]
unstable-api = []

davidk-pt marked this conversation as resolved.
Show resolved Hide resolved
[profile.release]
opt-level = 3
lto = true
Expand Down
1 change: 1 addition & 0 deletions substrate/frame/revive/fixtures/contracts/block_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#![no_std]
#![no_main]
#![cfg(feature = "unstable-api")]

use common::input;
use uapi::{HostFn, HostFnImpl as api};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

#![no_std]
#![no_main]
#![cfg(feature = "unstable-api")]

extern crate common;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
//! It also forwards its input to the callee.
#![no_std]
#![no_main]
#![cfg(feature = "unstable-api")]

use common::input;
use uapi::{HostFn, HostFnImpl as api};
Expand Down
1 change: 1 addition & 0 deletions substrate/frame/revive/fixtures/contracts/call_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
//! This passes its input to `call_runtime` and returns the return value to its caller.
#![no_std]
#![no_main]
#![cfg(feature = "unstable-api")]

use common::input;
use uapi::{HostFn, HostFnImpl as api};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#![no_std]
#![no_main]
#![cfg(feature = "unstable-api")]

use common::input;
use uapi::{HostFn, HostFnImpl as api};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
//! Call chain extension by passing through input and output of this contract.
#![no_std]
#![no_main]
#![cfg(feature = "unstable-api")]

use common::input;
use uapi::{HostFn, HostFnImpl as api};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
//! It then calls itself once
#![no_std]
#![no_main]
#![cfg(feature = "unstable-api")]

use common::input;
use uapi::{HostFn, HostFnImpl as api};
Expand Down
1 change: 1 addition & 0 deletions substrate/frame/revive/fixtures/contracts/code_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#![no_std]
#![no_main]
#![cfg(feature = "unstable-api")]

use common::input;
use uapi::{HostFn, HostFnImpl as api};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ license.workspace = true
description = "Common utilities for pallet-revive-fixtures."

[dependencies]
uapi = { package = 'pallet-revive-uapi', path = "../../../uapi", default-features = false }
uapi = { package = 'pallet-revive-uapi', path = "../../../uapi", default-features = false }
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
//! This calls another contract as passed as its account id. It also creates some storage.
#![no_std]
#![no_main]
#![cfg(feature = "unstable-api")]

use common::input;
use uapi::{HostFn, HostFnImpl as api, StorageFlags};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
//! This instantiates another contract and passes some input to its constructor.
#![no_std]
#![no_main]
#![cfg(feature = "unstable-api")]

use common::{input, u256_bytes};
use uapi::{HostFn, HostFnImpl as api};
Expand Down
6 changes: 6 additions & 0 deletions substrate/frame/revive/fixtures/contracts/crypto_hashes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ pub extern "C" fn call() {
match chosen_hash_fn {
1 => {
let mut output = [0u8; 32];
#[cfg(feature = "unstable-api")]
api::hash_sha2_256(input, &mut output);
#[cfg(feature = "unstable-api")]
api::return_value(uapi::ReturnFlags::empty(), &output);
},
2 => {
Expand All @@ -71,12 +73,16 @@ pub extern "C" fn call() {
},
3 => {
let mut output = [0u8; 32];
#[cfg(feature = "unstable-api")]
api::hash_blake2_256(input, &mut output);
#[cfg(feature = "unstable-api")]
api::return_value(uapi::ReturnFlags::empty(), &output);
},
4 => {
let mut output = [0u8; 16];
#[cfg(feature = "unstable-api")]
api::hash_blake2_128(input, &mut output);
#[cfg(feature = "unstable-api")]
api::return_value(uapi::ReturnFlags::empty(), &output);
},
_ => panic!("unknown crypto hash function identifier"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
//! Emit a debug message with an invalid utf-8 code.
#![no_std]
#![no_main]
#![cfg(feature = "unstable-api")]

extern crate common;
use uapi::{HostFn, HostFnImpl as api};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ pub extern "C" fn deploy() {}

#[no_mangle]
#[polkavm_derive::polkavm_export]
#[cfg(feature = "unstable-api")]
pub extern "C" fn call() {
assert_eq!(api::debug_message(b"Hello World!"), Err(ReturnErrorCode::LoggingDisabled));
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
//! Emit a "Hello World!" debug message.
#![no_std]
#![no_main]
#![cfg(feature = "unstable-api")]

extern crate common;
use uapi::{HostFn, HostFnImpl as api};
Expand Down
1 change: 1 addition & 0 deletions substrate/frame/revive/fixtures/contracts/drain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#![no_std]
#![no_main]
#![cfg(feature = "unstable-api")]

use common::{u256_bytes, u64_output};
use uapi::{HostFn, HostFnImpl as api};
Expand Down
1 change: 1 addition & 0 deletions substrate/frame/revive/fixtures/contracts/dummy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
// limitations under the License.
#![no_std]
#![no_main]
#![cfg(feature = "unstable-api")]

extern crate common;

Expand Down
1 change: 1 addition & 0 deletions substrate/frame/revive/fixtures/contracts/ecdsa_recover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#![no_std]
#![no_main]
#![cfg(feature = "unstable-api")]

use common::input;
use uapi::{HostFn, HostFnImpl as api};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#![no_std]
#![no_main]
#![cfg(feature = "unstable-api")]

extern crate common;
use uapi::{HostFn, HostFnImpl as api};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#![no_std]
#![no_main]
#![cfg(feature = "unstable-api")]

use common::{input, u256_bytes};
use uapi::{HostFn, HostFnImpl as api};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
// limitations under the License.
#![no_std]
#![no_main]
#![cfg(feature = "unstable-api")]

extern crate common;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
//! calling into a contract.
#![no_std]
#![no_main]
#![cfg(feature = "unstable-api")]

use common::input;
use uapi::{HostFn, HostFnImpl as api};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#![no_std]
#![no_main]
#![cfg(feature = "unstable-api")]

extern crate common;
use uapi::{HostFn, HostFnImpl as api};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#![no_std]
#![no_main]
#![cfg(feature = "unstable-api")]

use common::input;
use uapi::{HostFn, HostFnImpl as api};
Expand Down
1 change: 1 addition & 0 deletions substrate/frame/revive/fixtures/contracts/oom_ro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#![no_std]
#![no_main]
#![cfg(feature = "unstable-api")]

extern crate common;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#![no_std]
#![no_main]
#![cfg(feature = "unstable-api")]

extern crate common;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#![no_std]
#![no_main]
#![cfg(feature = "unstable-api")]

extern crate common;

Expand Down
2 changes: 2 additions & 0 deletions substrate/frame/revive/fixtures/contracts/return_with_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#![no_std]
#![no_main]
#![cfg(feature = "unstable-api")]

use common::input;
use uapi::{HostFn, HostFnImpl as api, StorageFlags};
Expand All @@ -40,6 +41,7 @@ pub extern "C" fn call() {

// Burn some PoV, clear_storage consumes some PoV as in order to clear the storage we need to we
// need to read its size first.
#[cfg(feature = "unstable-api")]
api::clear_storage(StorageFlags::empty(), b"");

let exit_status = uapi::ReturnFlags::from_bits(exit_status[0] as u32).unwrap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#![no_std]
#![no_main]
#![cfg(feature = "unstable-api")]

extern crate common;
use uapi::{HostFn, HostFnImpl as api};
Expand Down
1 change: 1 addition & 0 deletions substrate/frame/revive/fixtures/contracts/set_code_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#![no_std]
#![no_main]
#![cfg(feature = "unstable-api")]

use common::input;
use uapi::{HostFn, HostFnImpl as api};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#![no_std]
#![no_main]
#![cfg(feature = "unstable-api")]

use common::input;
use uapi::{HostFn, HostFnImpl as api};
Expand Down
1 change: 1 addition & 0 deletions substrate/frame/revive/fixtures/contracts/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
//! versions of the storage APIs.
#![no_std]
#![no_main]
#![cfg(feature = "unstable-api")]

use common::unwrap_output;
use uapi::{HostFn, HostFnImpl as api, StorageFlags};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#![no_std]
#![no_main]
#![cfg(feature = "unstable-api")]

extern crate common;
use uapi::{HostFn, HostFnImpl as api};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#![no_std]
#![no_main]
#![cfg(feature = "unstable-api")]

use common::u256_bytes;
use uapi::{HostFn, HostFnImpl as api};
Expand Down
1 change: 1 addition & 0 deletions substrate/frame/revive/fixtures/contracts/xcm_execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#![no_std]
#![no_main]
#![cfg(feature = "unstable-api")]

use common::input;
use uapi::{HostFn, HostFnImpl as api};
Expand Down
1 change: 1 addition & 0 deletions substrate/frame/revive/fixtures/contracts/xcm_send.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#![no_std]
#![no_main]
#![cfg(feature = "unstable-api")]

use common::input;
use uapi::{HostFn, HostFnImpl as api};
Expand Down
Loading
Loading