mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 22:51:13 +00:00
contracts: Deprecate random interface (#13204)
* Deprecate random interface * Revert change to runtime file * Fix docs * Fix tests * Rename to not_deprecated * Apply suggestions from code review Co-authored-by: Sasha Gryaznov <hi@agryaznov.com> * Deprecate `set_rent_allowance` Co-authored-by: Sasha Gryaznov <hi@agryaznov.com>
This commit is contained in:
committed by
GitHub
parent
e66c53089d
commit
3b03862caf
@@ -24,13 +24,15 @@ mod runtime;
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
pub use crate::wasm::code_cache::reinstrument;
|
||||
pub use crate::wasm::{
|
||||
prepare::TryInstantiate,
|
||||
runtime::{CallFlags, Environment, ReturnCode, Runtime, RuntimeCosts},
|
||||
};
|
||||
|
||||
#[cfg(doc)]
|
||||
pub use crate::wasm::runtime::api_doc;
|
||||
pub use crate::wasm::{
|
||||
prepare::TryInstantiate,
|
||||
runtime::{
|
||||
AllowDeprecatedInterface, AllowUnstableInterface, CallFlags, Environment, ReturnCode,
|
||||
Runtime, RuntimeCosts,
|
||||
},
|
||||
};
|
||||
|
||||
use crate::{
|
||||
exec::{ExecResult, Executable, ExportedFunction, Ext},
|
||||
@@ -205,6 +207,7 @@ impl<T: Config> PrefabWasmModule<T> {
|
||||
host_state: H,
|
||||
memory: (u32, u32),
|
||||
stack_limits: StackLimits,
|
||||
allow_deprecated: AllowDeprecatedInterface,
|
||||
) -> Result<(Store<H>, Memory, Instance), wasmi::Error>
|
||||
where
|
||||
E: Environment<H>,
|
||||
@@ -220,7 +223,16 @@ impl<T: Config> PrefabWasmModule<T> {
|
||||
let module = Module::new(&engine, code)?;
|
||||
let mut store = Store::new(&engine, host_state);
|
||||
let mut linker = Linker::new();
|
||||
E::define(&mut store, &mut linker, T::UnsafeUnstableInterface::get())?;
|
||||
E::define(
|
||||
&mut store,
|
||||
&mut linker,
|
||||
if T::UnsafeUnstableInterface::get() {
|
||||
AllowUnstableInterface::Yes
|
||||
} else {
|
||||
AllowUnstableInterface::No
|
||||
},
|
||||
allow_deprecated,
|
||||
)?;
|
||||
let memory = Memory::new(&mut store, MemoryType::new(memory.0, Some(memory.1))?).expect(
|
||||
"The limits defined in our `Schedule` limit the amount of memory well below u32::MAX; qed",
|
||||
);
|
||||
@@ -233,20 +245,14 @@ impl<T: Config> PrefabWasmModule<T> {
|
||||
Ok((store, memory, instance))
|
||||
}
|
||||
|
||||
/// Create and store the module without checking nor instrumenting the passed code.
|
||||
///
|
||||
/// # Note
|
||||
///
|
||||
/// This is useful for benchmarking where we don't want instrumentation to skew
|
||||
/// our results. This also does not collect any deposit from the `owner`.
|
||||
/// See [`Self::from_code_unchecked`].
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
pub fn store_code_unchecked(
|
||||
original_code: Vec<u8>,
|
||||
schedule: &Schedule<T>,
|
||||
owner: T::AccountId,
|
||||
) -> DispatchResult {
|
||||
let executable = prepare::benchmarking::prepare(original_code, schedule, owner)
|
||||
.map_err::<DispatchError, _>(Into::into)?;
|
||||
let executable = Self::from_code_unchecked(original_code, schedule, owner)?;
|
||||
code_cache::store(executable, false)
|
||||
}
|
||||
|
||||
@@ -255,6 +261,23 @@ impl<T: Config> PrefabWasmModule<T> {
|
||||
pub fn decrement_version(&mut self) {
|
||||
self.instruction_weights_version = self.instruction_weights_version.checked_sub(1).unwrap();
|
||||
}
|
||||
|
||||
/// Create the module without checking nor instrumenting the passed code.
|
||||
///
|
||||
/// # Note
|
||||
///
|
||||
/// This is useful for benchmarking where we don't want instrumentation to skew
|
||||
/// our results. This also does not collect any deposit from the `owner`. Also useful
|
||||
/// during testing when we want to deploy codes that do not pass the instantiation checks.
|
||||
#[cfg(any(test, feature = "runtime-benchmarks"))]
|
||||
fn from_code_unchecked(
|
||||
original_code: Vec<u8>,
|
||||
schedule: &Schedule<T>,
|
||||
owner: T::AccountId,
|
||||
) -> Result<Self, DispatchError> {
|
||||
prepare::benchmarking::prepare(original_code, schedule, owner)
|
||||
.map_err::<DispatchError, _>(Into::into)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Config> OwnerInfo<T> {
|
||||
@@ -294,6 +317,10 @@ impl<T: Config> Executable<T> for PrefabWasmModule<T> {
|
||||
runtime,
|
||||
(self.initial, self.maximum),
|
||||
StackLimits::default(),
|
||||
match function {
|
||||
ExportedFunction::Constructor => AllowDeprecatedInterface::No,
|
||||
ExportedFunction::Call => AllowDeprecatedInterface::Yes,
|
||||
},
|
||||
)
|
||||
.map_err(|msg| {
|
||||
log::debug!(target: "runtime::contracts", "failed to instantiate code: {}", msg);
|
||||
@@ -629,38 +656,77 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
/// Execute the supplied code.
|
||||
///
|
||||
/// Not used directly but through the wrapper functions defined below.
|
||||
fn execute_internal<E: BorrowMut<MockExt>>(
|
||||
wat: &str,
|
||||
input_data: Vec<u8>,
|
||||
mut ext: E,
|
||||
entry_point: &ExportedFunction,
|
||||
unstable_interface: bool,
|
||||
skip_checks: bool,
|
||||
) -> ExecResult {
|
||||
type RuntimeConfig = <MockExt as Ext>::T;
|
||||
RuntimeConfig::set_unstable_interface(unstable_interface);
|
||||
let wasm = wat::parse_str(wat).unwrap();
|
||||
let schedule = crate::Schedule::default();
|
||||
let executable = PrefabWasmModule::<RuntimeConfig>::from_code(
|
||||
wasm,
|
||||
&schedule,
|
||||
ALICE,
|
||||
Determinism::Deterministic,
|
||||
TryInstantiate::Skip,
|
||||
)
|
||||
.map_err(|err| err.0)?;
|
||||
executable.execute(ext.borrow_mut(), &ExportedFunction::Call, input_data)
|
||||
let executable = if skip_checks {
|
||||
PrefabWasmModule::<RuntimeConfig>::from_code_unchecked(wasm, &schedule, ALICE)?
|
||||
} else {
|
||||
PrefabWasmModule::<RuntimeConfig>::from_code(
|
||||
wasm,
|
||||
&schedule,
|
||||
ALICE,
|
||||
Determinism::Deterministic,
|
||||
TryInstantiate::Instantiate,
|
||||
)
|
||||
.map_err(|err| err.0)?
|
||||
};
|
||||
executable.execute(ext.borrow_mut(), entry_point, input_data)
|
||||
}
|
||||
|
||||
/// Execute the suppplied code.
|
||||
fn execute<E: BorrowMut<MockExt>>(wat: &str, input_data: Vec<u8>, ext: E) -> ExecResult {
|
||||
execute_internal(wat, input_data, ext, true)
|
||||
execute_internal(wat, input_data, ext, &ExportedFunction::Call, true, false)
|
||||
}
|
||||
|
||||
/// Execute the supplied code with disabled unstable functions.
|
||||
///
|
||||
/// In our test config unstable functions are disabled so that we can test them.
|
||||
/// In order to test that code using them is properly rejected we temporarily disable
|
||||
/// them when this test is run.
|
||||
#[cfg(not(feature = "runtime-benchmarks"))]
|
||||
fn execute_no_unstable<E: BorrowMut<MockExt>>(
|
||||
wat: &str,
|
||||
input_data: Vec<u8>,
|
||||
ext: E,
|
||||
) -> ExecResult {
|
||||
execute_internal(wat, input_data, ext, false)
|
||||
execute_internal(wat, input_data, ext, &ExportedFunction::Call, false, false)
|
||||
}
|
||||
|
||||
/// Execute code without validating it first.
|
||||
///
|
||||
/// This is mainly useful in order to test code which uses deprecated functions. Those
|
||||
/// would fail when validating the code.
|
||||
fn execute_unvalidated<E: BorrowMut<MockExt>>(
|
||||
wat: &str,
|
||||
input_data: Vec<u8>,
|
||||
ext: E,
|
||||
) -> ExecResult {
|
||||
execute_internal(wat, input_data, ext, &ExportedFunction::Call, false, true)
|
||||
}
|
||||
|
||||
/// Execute instantiation entry point of code without validating it first.
|
||||
///
|
||||
/// Same as `execute_unvalidated` except that the `deploy` entry point is ran.
|
||||
#[cfg(not(feature = "runtime-benchmarks"))]
|
||||
fn execute_instantiate_unvalidated<E: BorrowMut<MockExt>>(
|
||||
wat: &str,
|
||||
input_data: Vec<u8>,
|
||||
ext: E,
|
||||
) -> ExecResult {
|
||||
execute_internal(wat, input_data, ext, &ExportedFunction::Constructor, false, true)
|
||||
}
|
||||
|
||||
const CODE_TRANSFER: &str = r#"
|
||||
@@ -1861,7 +1927,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn random() {
|
||||
let output = execute(CODE_RANDOM, vec![], MockExt::default()).unwrap();
|
||||
let output = execute_unvalidated(CODE_RANDOM, vec![], MockExt::default()).unwrap();
|
||||
|
||||
// The mock ext just returns the same data that was passed as the subject.
|
||||
assert_eq!(
|
||||
@@ -1931,7 +1997,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn random_v1() {
|
||||
let output = execute(CODE_RANDOM_V1, vec![], MockExt::default()).unwrap();
|
||||
let output = execute_unvalidated(CODE_RANDOM_V1, vec![], MockExt::default()).unwrap();
|
||||
|
||||
// The mock ext just returns the same data that was passed as the subject.
|
||||
assert_eq!(
|
||||
@@ -3007,6 +3073,29 @@ mod tests {
|
||||
execute(CODE, vec![], &mut mock_ext).unwrap();
|
||||
}
|
||||
|
||||
/// Code with deprecated functions cannot be uploaded or instantiated. However, we
|
||||
/// need to make sure that it still can be re-instrumented.
|
||||
#[test]
|
||||
fn can_reinstrument_deprecated() {
|
||||
const CODE_RANDOM: &str = r#"
|
||||
(module
|
||||
(import "seal0" "random" (func $seal_random (param i32 i32 i32 i32)))
|
||||
(func (export "call"))
|
||||
(func (export "deploy"))
|
||||
)
|
||||
"#;
|
||||
let wasm = wat::parse_str(CODE_RANDOM).unwrap();
|
||||
let schedule = crate::Schedule::<Test>::default();
|
||||
#[cfg(not(feature = "runtime-benchmarks"))]
|
||||
assert_err!(execute(CODE_RANDOM, vec![], MockExt::default()), <Error<Test>>::CodeRejected);
|
||||
self::prepare::reinstrument::<runtime::Env, Test>(
|
||||
&wasm,
|
||||
&schedule,
|
||||
Determinism::Deterministic,
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
/// This test check that an unstable interface cannot be deployed. In case of runtime
|
||||
/// benchmarks we always allow unstable interfaces. This is why this test does not
|
||||
/// work when this feature is enabled.
|
||||
@@ -3026,4 +3115,80 @@ mod tests {
|
||||
);
|
||||
assert_ok!(execute(CANNOT_DEPLOY_UNSTABLE, vec![], MockExt::default()));
|
||||
}
|
||||
|
||||
/// The random interface is deprecated and hence new contracts using it should not be deployed.
|
||||
/// In case of runtime benchmarks we always allow deprecated interfaces. This is why this
|
||||
/// test doesn't work if this feature is enabled.
|
||||
#[cfg(not(feature = "runtime-benchmarks"))]
|
||||
#[test]
|
||||
fn cannot_deploy_deprecated() {
|
||||
const CODE_RANDOM_0: &str = r#"
|
||||
(module
|
||||
(import "seal0" "seal_random" (func $seal_random (param i32 i32 i32 i32)))
|
||||
(func (export "call"))
|
||||
(func (export "deploy"))
|
||||
)
|
||||
"#;
|
||||
const CODE_RANDOM_1: &str = r#"
|
||||
(module
|
||||
(import "seal1" "seal_random" (func $seal_random (param i32 i32 i32 i32)))
|
||||
(func (export "call"))
|
||||
(func (export "deploy"))
|
||||
)
|
||||
"#;
|
||||
const CODE_RANDOM_2: &str = r#"
|
||||
(module
|
||||
(import "seal0" "random" (func $seal_random (param i32 i32 i32 i32)))
|
||||
(func (export "call"))
|
||||
(func (export "deploy"))
|
||||
)
|
||||
"#;
|
||||
const CODE_RANDOM_3: &str = r#"
|
||||
(module
|
||||
(import "seal1" "random" (func $seal_random (param i32 i32 i32 i32)))
|
||||
(func (export "call"))
|
||||
(func (export "deploy"))
|
||||
)
|
||||
"#;
|
||||
|
||||
assert_ok!(execute_unvalidated(CODE_RANDOM_0, vec![], MockExt::default()));
|
||||
assert_err!(
|
||||
execute_instantiate_unvalidated(CODE_RANDOM_0, vec![], MockExt::default()),
|
||||
<Error<Test>>::CodeRejected,
|
||||
);
|
||||
assert_err!(
|
||||
execute(CODE_RANDOM_0, vec![], MockExt::default()),
|
||||
<Error<Test>>::CodeRejected,
|
||||
);
|
||||
|
||||
assert_ok!(execute_unvalidated(CODE_RANDOM_1, vec![], MockExt::default()));
|
||||
assert_err!(
|
||||
execute_instantiate_unvalidated(CODE_RANDOM_1, vec![], MockExt::default()),
|
||||
<Error<Test>>::CodeRejected,
|
||||
);
|
||||
assert_err!(
|
||||
execute(CODE_RANDOM_1, vec![], MockExt::default()),
|
||||
<Error<Test>>::CodeRejected,
|
||||
);
|
||||
|
||||
assert_ok!(execute_unvalidated(CODE_RANDOM_2, vec![], MockExt::default()));
|
||||
assert_err!(
|
||||
execute_instantiate_unvalidated(CODE_RANDOM_2, vec![], MockExt::default()),
|
||||
<Error<Test>>::CodeRejected,
|
||||
);
|
||||
assert_err!(
|
||||
execute(CODE_RANDOM_2, vec![], MockExt::default()),
|
||||
<Error<Test>>::CodeRejected,
|
||||
);
|
||||
|
||||
assert_ok!(execute_unvalidated(CODE_RANDOM_3, vec![], MockExt::default()));
|
||||
assert_err!(
|
||||
execute_instantiate_unvalidated(CODE_RANDOM_3, vec![], MockExt::default()),
|
||||
<Error<Test>>::CodeRejected,
|
||||
);
|
||||
assert_err!(
|
||||
execute(CODE_RANDOM_3, vec![], MockExt::default()),
|
||||
<Error<Test>>::CodeRejected,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,9 @@
|
||||
use crate::{
|
||||
chain_extension::ChainExtension,
|
||||
storage::meter::Diff,
|
||||
wasm::{Determinism, Environment, OwnerInfo, PrefabWasmModule},
|
||||
wasm::{
|
||||
runtime::AllowDeprecatedInterface, Determinism, Environment, OwnerInfo, PrefabWasmModule,
|
||||
},
|
||||
AccountIdOf, CodeVec, Config, Error, Schedule,
|
||||
};
|
||||
use codec::{Encode, MaxEncodedLen};
|
||||
@@ -54,6 +56,14 @@ pub enum TryInstantiate {
|
||||
Skip,
|
||||
}
|
||||
|
||||
/// The reason why a contract is instrumented.
|
||||
enum InstrumentReason {
|
||||
/// A new code is uploaded.
|
||||
New,
|
||||
/// Existing code is re-instrumented.
|
||||
Reinstrument,
|
||||
}
|
||||
|
||||
struct ContractModule<'a, T: Config> {
|
||||
/// A deserialized module. The module is valid (this is Guaranteed by `new` method).
|
||||
module: elements::Module,
|
||||
@@ -381,6 +391,7 @@ fn instrument<E, T>(
|
||||
schedule: &Schedule<T>,
|
||||
determinism: Determinism,
|
||||
try_instantiate: TryInstantiate,
|
||||
reason: InstrumentReason,
|
||||
) -> Result<(Vec<u8>, (u32, u32)), (DispatchError, &'static str)>
|
||||
where
|
||||
E: Environment<()>,
|
||||
@@ -454,11 +465,20 @@ where
|
||||
// We don't actually ever run any code so we can get away with a minimal stack which
|
||||
// reduces the amount of memory that needs to be zeroed.
|
||||
let stack_limits = StackLimits::new(1, 1, 0).expect("initial <= max; qed");
|
||||
PrefabWasmModule::<T>::instantiate::<E, _>(&code, (), (initial, maximum), stack_limits)
|
||||
.map_err(|err| {
|
||||
log::debug!(target: "runtime::contracts", "{}", err);
|
||||
(Error::<T>::CodeRejected.into(), "new code rejected after instrumentation")
|
||||
})?;
|
||||
PrefabWasmModule::<T>::instantiate::<E, _>(
|
||||
&code,
|
||||
(),
|
||||
(initial, maximum),
|
||||
stack_limits,
|
||||
match reason {
|
||||
InstrumentReason::New => AllowDeprecatedInterface::No,
|
||||
InstrumentReason::Reinstrument => AllowDeprecatedInterface::Yes,
|
||||
},
|
||||
)
|
||||
.map_err(|err| {
|
||||
log::debug!(target: "runtime::contracts", "{}", err);
|
||||
(Error::<T>::CodeRejected.into(), "new code rejected after instrumentation")
|
||||
})?;
|
||||
}
|
||||
|
||||
Ok((code, (initial, maximum)))
|
||||
@@ -486,8 +506,13 @@ where
|
||||
E: Environment<()>,
|
||||
T: Config,
|
||||
{
|
||||
let (code, (initial, maximum)) =
|
||||
instrument::<E, T>(original_code.as_ref(), schedule, determinism, try_instantiate)?;
|
||||
let (code, (initial, maximum)) = instrument::<E, T>(
|
||||
original_code.as_ref(),
|
||||
schedule,
|
||||
determinism,
|
||||
try_instantiate,
|
||||
InstrumentReason::New,
|
||||
)?;
|
||||
|
||||
let original_code_len = original_code.len();
|
||||
|
||||
@@ -532,21 +557,30 @@ where
|
||||
E: Environment<()>,
|
||||
T: Config,
|
||||
{
|
||||
instrument::<E, T>(original_code, schedule, determinism, TryInstantiate::Skip)
|
||||
.map_err(|(err, msg)| {
|
||||
log::error!(target: "runtime::contracts", "CodeRejected during reinstrument: {}", msg);
|
||||
err
|
||||
})
|
||||
.map(|(code, _)| code)
|
||||
instrument::<E, T>(
|
||||
original_code,
|
||||
schedule,
|
||||
determinism,
|
||||
// This function was triggered by an interaction with an existing contract code
|
||||
// that will try to instantiate anyways. Failing here would not help
|
||||
// as the contract is already on chain.
|
||||
TryInstantiate::Skip,
|
||||
InstrumentReason::Reinstrument,
|
||||
)
|
||||
.map_err(|(err, msg)| {
|
||||
log::error!(target: "runtime::contracts", "CodeRejected during reinstrument: {}", msg);
|
||||
err
|
||||
})
|
||||
.map(|(code, _)| code)
|
||||
}
|
||||
|
||||
/// Alternate (possibly unsafe) preparation functions used only for benchmarking.
|
||||
/// Alternate (possibly unsafe) preparation functions used only for benchmarking and testing.
|
||||
///
|
||||
/// For benchmarking we need to construct special contracts that might not pass our
|
||||
/// sanity checks or need to skip instrumentation for correct results. We hide functions
|
||||
/// allowing this behind a feature that is only set during benchmarking to prevent usage
|
||||
/// in production code.
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
/// allowing this behind a feature that is only set during benchmarking or testing to
|
||||
/// prevent usage in production code.
|
||||
#[cfg(any(test, feature = "runtime-benchmarks"))]
|
||||
pub mod benchmarking {
|
||||
use super::*;
|
||||
|
||||
@@ -600,7 +634,7 @@ mod tests {
|
||||
#[allow(unreachable_code)]
|
||||
mod env {
|
||||
use super::*;
|
||||
use crate::wasm::runtime::TrapReason;
|
||||
use crate::wasm::runtime::{AllowDeprecatedInterface, AllowUnstableInterface, TrapReason};
|
||||
|
||||
// Define test environment for tests. We need ImportSatisfyCheck
|
||||
// implementation from it. So actual implementations doesn't matter.
|
||||
|
||||
@@ -37,6 +37,22 @@ use wasmi::{core::HostError, errors::LinkerError, Linker, Memory, Store};
|
||||
/// The maximum nesting depth a contract can use when encoding types.
|
||||
const MAX_DECODE_NESTING: u32 = 256;
|
||||
|
||||
/// Passed to [`Environment`] to determine whether it should expose deprecated interfaces.
|
||||
pub enum AllowDeprecatedInterface {
|
||||
/// No deprecated interfaces are exposed.
|
||||
No,
|
||||
/// Deprecated interfaces are exposed.
|
||||
Yes,
|
||||
}
|
||||
|
||||
/// Passed to [`Environment`] to determine whether it should expose unstable interfaces.
|
||||
pub enum AllowUnstableInterface {
|
||||
/// No unstable interfaces are exposed.
|
||||
No,
|
||||
/// Unstable interfaces are exposed.
|
||||
Yes,
|
||||
}
|
||||
|
||||
/// Trait implemented by the [`define_env`](pallet_contracts_proc_macro::define_env) macro for the
|
||||
/// emitted `Env` struct.
|
||||
pub trait Environment<HostState> {
|
||||
@@ -45,14 +61,15 @@ pub trait Environment<HostState> {
|
||||
fn define(
|
||||
store: &mut Store<HostState>,
|
||||
linker: &mut Linker<HostState>,
|
||||
allow_unstable: bool,
|
||||
allow_unstable: AllowUnstableInterface,
|
||||
allow_deprecated: AllowDeprecatedInterface,
|
||||
) -> Result<(), LinkerError>;
|
||||
}
|
||||
|
||||
/// Type of a storage key.
|
||||
#[allow(dead_code)]
|
||||
enum KeyType {
|
||||
/// Deprecated fix sized key `[u8;32]`.
|
||||
/// Legacy fix sized key `[u8;32]`.
|
||||
Fix,
|
||||
/// Variable sized key used in transparent hashing,
|
||||
/// cannot be larger than MaxStorageKeyLen.
|
||||
@@ -91,12 +108,8 @@ pub enum ReturnCode {
|
||||
CalleeReverted = 2,
|
||||
/// The passed key does not exist in storage.
|
||||
KeyNotFound = 3,
|
||||
/// Deprecated and no longer returned: There is only the minimum balance.
|
||||
_BelowSubsistenceThreshold = 4,
|
||||
/// See [`Error::TransferFailed`].
|
||||
TransferFailed = 5,
|
||||
/// Deprecated and no longer returned: Endowment is no longer required.
|
||||
_EndowmentTooLow = 6,
|
||||
/// No code could be found at the supplied code hash.
|
||||
CodeNotFound = 7,
|
||||
/// The contract that was called is no contract (a plain account).
|
||||
@@ -1280,7 +1293,7 @@ pub mod env {
|
||||
|
||||
/// Make a call to another contract.
|
||||
///
|
||||
/// # Deprecation
|
||||
/// # New version available
|
||||
///
|
||||
/// This is equivalent to calling the newer version of this function with
|
||||
/// `flags` set to `ALLOW_REENTRY`. See the newer version for documentation.
|
||||
@@ -1418,7 +1431,7 @@ pub mod env {
|
||||
|
||||
/// Instantiate a contract with the specified code hash.
|
||||
///
|
||||
/// # Deprecation
|
||||
/// # New version available
|
||||
///
|
||||
/// This is equivalent to calling the newer version of this function. The newer version
|
||||
/// drops the now unnecessary length fields.
|
||||
@@ -1538,7 +1551,7 @@ pub mod env {
|
||||
|
||||
/// Remove the calling account and transfer remaining balance.
|
||||
///
|
||||
/// # Deprecation
|
||||
/// # New version available
|
||||
///
|
||||
/// This is equivalent to calling the newer version of this function. The newer version
|
||||
/// drops the now unnecessary length fields.
|
||||
@@ -1879,12 +1892,8 @@ pub mod env {
|
||||
/// space at `out_ptr` is less than the size of the value a trap is triggered.
|
||||
///
|
||||
/// The data is encoded as `T::Hash`.
|
||||
///
|
||||
/// # Deprecation
|
||||
///
|
||||
/// This function is deprecated. Users should migrate to the [`super::seal1::Api::random()`]
|
||||
/// version.
|
||||
#[prefixed_alias]
|
||||
#[deprecated]
|
||||
fn random(
|
||||
ctx: _,
|
||||
memory: _,
|
||||
@@ -1931,6 +1940,7 @@ pub mod env {
|
||||
/// commitment.
|
||||
#[version(1)]
|
||||
#[prefixed_alias]
|
||||
#[deprecated]
|
||||
fn random(
|
||||
ctx: _,
|
||||
memory: _,
|
||||
@@ -2001,10 +2011,11 @@ pub mod env {
|
||||
/// `out_ptr`. This call overwrites it with the size of the value. If the available
|
||||
/// space at `out_ptr` is less than the size of the value a trap is triggered.
|
||||
///
|
||||
/// # Deprecation
|
||||
/// # Note
|
||||
///
|
||||
/// There is no longer a tombstone deposit. This function always returns `0`.
|
||||
#[prefixed_alias]
|
||||
#[deprecated]
|
||||
fn tombstone_deposit(
|
||||
ctx: _,
|
||||
memory: _,
|
||||
@@ -2030,6 +2041,7 @@ pub mod env {
|
||||
/// The state rent functionality was removed. This is stub only exists for
|
||||
/// backwards compatiblity
|
||||
#[prefixed_alias]
|
||||
#[deprecated]
|
||||
fn restore_to(
|
||||
ctx: _,
|
||||
memory: _,
|
||||
@@ -2054,6 +2066,7 @@ pub mod env {
|
||||
/// backwards compatiblity
|
||||
#[version(1)]
|
||||
#[prefixed_alias]
|
||||
#[deprecated]
|
||||
fn restore_to(
|
||||
ctx: _,
|
||||
memory: _,
|
||||
@@ -2067,6 +2080,59 @@ pub mod env {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Was used to set rent allowance of the contract.
|
||||
///
|
||||
/// # Note
|
||||
///
|
||||
/// The state rent functionality was removed. This is stub only exists for
|
||||
/// backwards compatiblity.
|
||||
#[prefixed_alias]
|
||||
#[deprecated]
|
||||
fn set_rent_allowance(
|
||||
ctx: _,
|
||||
memory: _,
|
||||
_value_ptr: u32,
|
||||
_value_len: u32,
|
||||
) -> Result<(), TrapReason> {
|
||||
ctx.charge_gas(RuntimeCosts::DebugMessage)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Was used to set rent allowance of the contract.
|
||||
///
|
||||
/// # Note
|
||||
///
|
||||
/// The state rent functionality was removed. This is stub only exists for
|
||||
/// backwards compatiblity.
|
||||
#[version(1)]
|
||||
#[prefixed_alias]
|
||||
#[deprecated]
|
||||
fn set_rent_allowance(ctx: _, _memory: _, _value_ptr: u32) -> Result<(), TrapReason> {
|
||||
ctx.charge_gas(RuntimeCosts::DebugMessage)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Was used to store the rent allowance into the supplied buffer.
|
||||
///
|
||||
/// # Note
|
||||
///
|
||||
/// The state rent functionality was removed. This is stub only exists for
|
||||
/// backwards compatiblity.
|
||||
#[prefixed_alias]
|
||||
#[deprecated]
|
||||
fn rent_allowance(ctx: _, memory: _, out_ptr: u32, out_len_ptr: u32) -> Result<(), TrapReason> {
|
||||
ctx.charge_gas(RuntimeCosts::Balance)?;
|
||||
let rent_allowance = <BalanceOf<E::T>>::max_value().encode();
|
||||
Ok(ctx.write_sandbox_output(
|
||||
memory,
|
||||
out_ptr,
|
||||
out_len_ptr,
|
||||
&rent_allowance,
|
||||
false,
|
||||
already_charged,
|
||||
)?)
|
||||
}
|
||||
|
||||
/// Deposit a contract event with the data buffer and optional list of topics. There is a limit
|
||||
/// on the maximum number of topics specified by `event_topics`.
|
||||
///
|
||||
@@ -2110,56 +2176,6 @@ pub mod env {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Was used to set rent allowance of the contract.
|
||||
///
|
||||
/// # Note
|
||||
///
|
||||
/// The state rent functionality was removed. This is stub only exists for
|
||||
/// backwards compatiblity.
|
||||
#[prefixed_alias]
|
||||
fn set_rent_allowance(
|
||||
ctx: _,
|
||||
memory: _,
|
||||
_value_ptr: u32,
|
||||
_value_len: u32,
|
||||
) -> Result<(), TrapReason> {
|
||||
ctx.charge_gas(RuntimeCosts::DebugMessage)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Was used to set rent allowance of the contract.
|
||||
///
|
||||
/// # Note
|
||||
///
|
||||
/// The state rent functionality was removed. This is stub only exists for
|
||||
/// backwards compatiblity.
|
||||
#[version(1)]
|
||||
#[prefixed_alias]
|
||||
fn set_rent_allowance(ctx: _, _memory: _, _value_ptr: u32) -> Result<(), TrapReason> {
|
||||
ctx.charge_gas(RuntimeCosts::DebugMessage)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Was used to store the rent allowance into the supplied buffer.
|
||||
///
|
||||
/// # Note
|
||||
///
|
||||
/// The state rent functionality was removed. This is stub only exists for
|
||||
/// backwards compatiblity.
|
||||
#[prefixed_alias]
|
||||
fn rent_allowance(ctx: _, memory: _, out_ptr: u32, out_len_ptr: u32) -> Result<(), TrapReason> {
|
||||
ctx.charge_gas(RuntimeCosts::Balance)?;
|
||||
let rent_allowance = <BalanceOf<E::T>>::max_value().encode();
|
||||
Ok(ctx.write_sandbox_output(
|
||||
memory,
|
||||
out_ptr,
|
||||
out_len_ptr,
|
||||
&rent_allowance,
|
||||
false,
|
||||
already_charged,
|
||||
)?)
|
||||
}
|
||||
|
||||
/// Stores the current block number of the current contract into the supplied buffer.
|
||||
///
|
||||
/// The value is stored to linear memory at the address pointed to by `out_ptr`.
|
||||
|
||||
Reference in New Issue
Block a user