[contracts] API host functions: remove seal_ name prefix + enable aliasing (#12126)

* works but ugly

* refactored + renamed host fns

* fixed tests

* fix benchmarks

* updated marco docs

* Update frame/contracts/proc-macro/src/lib.rs

Co-authored-by: Alexander Theißen <alex.theissen@me.com>

* fix for the duplicated prefixed alias bug + test

* refactored a bit

* fix warnings + try to make macro rustdoc compile

* fmt after clearing

* examples update + nocompile

* add seal_ prefixes to unstable host functions

* updated after a review

Co-authored-by: Alexander Theißen <alex.theissen@me.com>
This commit is contained in:
Sasha Gryaznov
2022-09-07 11:54:17 +03:00
committed by GitHub
parent 56e536f6e8
commit d8e9fff3e4
5 changed files with 262 additions and 162 deletions
+136 -124
View File
@@ -957,7 +957,7 @@ pub mod env {
/// This call is supposed to be called only by instrumentation injected code.
///
/// - amount: How much gas is used.
fn gas(ctx: Runtime<E: Ext>, amount: u32) -> Result<(), TrapReason> {
fn gas(ctx: Runtime<E>, amount: u32) -> Result<(), TrapReason> {
ctx.charge_gas(RuntimeCosts::MeteringBlock(amount))?;
Ok(())
}
@@ -966,8 +966,9 @@ pub mod env {
///
/// Equivalent to the newer version of `seal_set_storage` with the exception of the return
/// type. Still a valid thing to call when not interested in the return value.
fn seal_set_storage(
ctx: Runtime<E: Ext>,
#[prefixed_alias]
fn set_storage(
ctx: Runtime<E>,
key_ptr: u32,
value_ptr: u32,
value_len: u32,
@@ -994,8 +995,9 @@ pub mod env {
/// Returns the size of the pre-existing value at the specified key if any. Otherwise
/// `SENTINEL` is returned as a sentinel value.
#[version(1)]
fn seal_set_storage(
ctx: Runtime<E: Ext>,
#[prefixed_alias]
fn set_storage(
ctx: Runtime<E>,
key_ptr: u32,
value_ptr: u32,
value_len: u32,
@@ -1020,8 +1022,9 @@ pub mod env {
/// Returns the size of the pre-existing value at the specified key if any. Otherwise
/// `SENTINEL` is returned as a sentinel value.
#[unstable]
fn seal_set_storage(
ctx: Runtime<E: Ext>,
#[prefixed_alias]
fn set_storage(
ctx: Runtime<E>,
key_ptr: u32,
key_len: u32,
value_ptr: u32,
@@ -1034,7 +1037,8 @@ pub mod env {
///
/// Equivalent to the newer version of `seal_clear_storage` with the exception of the return
/// type. Still a valid thing to call when not interested in the return value.
fn seal_clear_storage(ctx: Runtime<E: Ext>, key_ptr: u32) -> Result<(), TrapReason> {
#[prefixed_alias]
fn clear_storage(ctx: Runtime<E>, key_ptr: u32) -> Result<(), TrapReason> {
ctx.clear_storage(KeyType::Fix, key_ptr).map(|_| ())
}
@@ -1050,11 +1054,8 @@ pub mod env {
/// Returns the size of the pre-existing value at the specified key if any. Otherwise
/// `SENTINEL` is returned as a sentinel value.
#[unstable]
fn seal_clear_storage(
ctx: Runtime<E: Ext>,
key_ptr: u32,
key_len: u32,
) -> Result<u32, TrapReason> {
#[prefixed_alias]
fn clear_storage(ctx: Runtime<E>, key_ptr: u32, key_len: u32) -> Result<u32, TrapReason> {
ctx.clear_storage(KeyType::Variable(key_len), key_ptr)
}
@@ -1073,8 +1074,9 @@ pub mod env {
/// # Errors
///
/// `ReturnCode::KeyNotFound`
fn seal_get_storage(
ctx: Runtime<E: Ext>,
#[prefixed_alias]
fn get_storage(
ctx: Runtime<E>,
key_ptr: u32,
out_ptr: u32,
out_len_ptr: u32,
@@ -1101,8 +1103,9 @@ pub mod env {
///
/// `ReturnCode::KeyNotFound`
#[unstable]
fn seal_get_storage(
ctx: Runtime<E: Ext>,
#[prefixed_alias]
fn get_storage(
ctx: Runtime<E>,
key_ptr: u32,
key_len: u32,
out_ptr: u32,
@@ -1124,7 +1127,8 @@ pub mod env {
///
/// Returns the size of the pre-existing value at the specified key if any. Otherwise
/// `SENTINEL` is returned as a sentinel value.
fn seal_contains_storage(ctx: Runtime<E: Ext>, key_ptr: u32) -> Result<u32, TrapReason> {
#[prefixed_alias]
fn contains_storage(ctx: Runtime<E>, key_ptr: u32) -> Result<u32, TrapReason> {
ctx.contains_storage(KeyType::Fix, key_ptr)
}
@@ -1142,11 +1146,8 @@ pub mod env {
/// Returns the size of the pre-existing value at the specified key if any. Otherwise
/// `SENTINEL` is returned as a sentinel value.
#[unstable]
fn seal_contains_storage(
ctx: Runtime<E: Ext>,
key_ptr: u32,
key_len: u32,
) -> Result<u32, TrapReason> {
#[prefixed_alias]
fn contains_storage(ctx: Runtime<E>, key_ptr: u32, key_len: u32) -> Result<u32, TrapReason> {
ctx.contains_storage(KeyType::Variable(key_len), key_ptr)
}
@@ -1164,8 +1165,9 @@ pub mod env {
///
/// `ReturnCode::KeyNotFound`
#[unstable]
fn seal_take_storage(
ctx: Runtime<E: Ext>,
#[prefixed_alias]
fn take_storage(
ctx: Runtime<E>,
key_ptr: u32,
key_len: u32,
out_ptr: u32,
@@ -1200,8 +1202,9 @@ pub mod env {
/// # Errors
///
/// `ReturnCode::TransferFailed`
fn seal_transfer(
ctx: Runtime<E: Ext>,
#[prefixed_alias]
fn transfer(
ctx: Runtime<E>,
account_ptr: u32,
_account_len: u32,
value_ptr: u32,
@@ -1233,8 +1236,9 @@ pub mod env {
/// The values `_callee_len` and `_value_len` are ignored because the encoded sizes
/// of those types are fixed through `[`MaxEncodedLen`]. The fields exist for backwards
/// compatibility. Consider switching to the newest version of this function.
fn seal_call(
ctx: Runtime<E: Ext>,
#[prefixed_alias]
fn call(
ctx: Runtime<E>,
callee_ptr: u32,
_callee_len: u32,
gas: u64,
@@ -1285,8 +1289,9 @@ pub mod env {
/// `ReturnCode::TransferFailed`
/// `ReturnCode::NotCallable`
#[version(1)]
fn seal_call(
ctx: Runtime<E: Ext>,
#[prefixed_alias]
fn call(
ctx: Runtime<E>,
flags: u32,
callee_ptr: u32,
gas: u64,
@@ -1330,8 +1335,9 @@ pub mod env {
/// `ReturnCode::CalleeReverted`: Output buffer is returned.
/// `ReturnCode::CalleeTrapped`
/// `ReturnCode::CodeNotFound`
fn seal_delegate_call(
ctx: Runtime<E: Ext>,
#[prefixed_alias]
fn delegate_call(
ctx: Runtime<E>,
flags: u32,
code_hash_ptr: u32,
input_data_ptr: u32,
@@ -1360,8 +1366,9 @@ pub mod env {
/// The values `_code_hash_len` and `_value_len` are ignored because the encoded sizes
/// of those types are fixed through `[`MaxEncodedLen`]. The fields exist for backwards
/// compatibility. Consider switching to the newest version of this function.
fn seal_instantiate(
ctx: Runtime<E: Ext>,
#[prefixed_alias]
fn instantiate(
ctx: Runtime<E>,
code_hash_ptr: u32,
_code_hash_len: u32,
gas: u64,
@@ -1432,8 +1439,9 @@ pub mod env {
/// `ReturnCode::TransferFailed`
/// `ReturnCode::CodeNotFound`
#[version(1)]
fn seal_instantiate(
ctx: Runtime<E: Ext>,
#[prefixed_alias]
fn instantiate(
ctx: Runtime<E>,
code_hash_ptr: u32,
gas: u64,
value_ptr: u32,
@@ -1473,8 +1481,9 @@ pub mod env {
/// The value `_beneficiary_len` is ignored because the encoded sizes
/// this type is fixed through `[`MaxEncodedLen`]. The field exist for backwards
/// compatibility. Consider switching to the newest version of this function.
fn seal_terminate(
ctx: Runtime<E: Ext>,
#[prefixed_alias]
fn terminate(
ctx: Runtime<E>,
beneficiary_ptr: u32,
_beneficiary_len: u32,
) -> Result<(), TrapReason> {
@@ -1497,7 +1506,8 @@ pub mod env {
/// - Failed to send the balance to the beneficiary.
/// - The deletion queue is full.
#[version(1)]
fn seal_terminate(ctx: Runtime<E: Ext>, beneficiary_ptr: u32) -> Result<(), TrapReason> {
#[prefixed_alias]
fn terminate(ctx: Runtime<E>, beneficiary_ptr: u32) -> Result<(), TrapReason> {
ctx.terminate(beneficiary_ptr)
}
@@ -1511,7 +1521,8 @@ pub mod env {
/// # Note
///
/// This function traps if the input was previously forwarded by a `seal_call`.
fn seal_input(ctx: Runtime<E: Ext>, out_ptr: u32, out_len_ptr: u32) -> Result<(), TrapReason> {
#[prefixed_alias]
fn input(ctx: Runtime<E>, out_ptr: u32, out_len_ptr: u32) -> Result<(), TrapReason> {
ctx.charge_gas(RuntimeCosts::InputBase)?;
if let Some(input) = ctx.input_data.take() {
ctx.write_sandbox_output(out_ptr, out_len_ptr, &input, false, |len| {
@@ -1542,7 +1553,7 @@ pub mod env {
///
/// Using a reserved bit triggers a trap.
fn seal_return(
ctx: Runtime<E: Ext>,
ctx: Runtime<E>,
flags: u32,
data_ptr: u32,
data_len: u32,
@@ -1564,7 +1575,8 @@ pub mod env {
/// If this is a top-level call (i.e. initiated by an extrinsic) the origin address of the
/// extrinsic will be returned. Otherwise, if this call is initiated by another contract then
/// the address of the contract will be returned. The value is encoded as T::AccountId.
fn seal_caller(ctx: Runtime<E: Ext>, out_ptr: u32, out_len_ptr: u32) -> Result<(), TrapReason> {
#[prefixed_alias]
fn caller(ctx: Runtime<E>, out_ptr: u32, out_len_ptr: u32) -> Result<(), TrapReason> {
ctx.charge_gas(RuntimeCosts::Caller)?;
Ok(ctx.write_sandbox_output(
out_ptr,
@@ -1583,7 +1595,8 @@ pub mod env {
/// `T::AccountId`. Traps otherwise.
///
/// Returned value is a u32-encoded boolean: (0 = false, 1 = true).
fn seal_is_contract(ctx: Runtime<E: Ext>, account_ptr: u32) -> Result<u32, TrapReason> {
#[prefixed_alias]
fn is_contract(ctx: Runtime<E>, account_ptr: u32) -> Result<u32, TrapReason> {
ctx.charge_gas(RuntimeCosts::IsContract)?;
let address: <<E as Ext>::T as frame_system::Config>::AccountId =
ctx.read_sandbox_memory_as(account_ptr)?;
@@ -1604,8 +1617,9 @@ pub mod env {
/// # Errors
///
/// `ReturnCode::KeyNotFound`
fn seal_code_hash(
ctx: Runtime<E: Ext>,
#[prefixed_alias]
fn code_hash(
ctx: Runtime<E>,
account_ptr: u32,
out_ptr: u32,
out_len_ptr: u32,
@@ -1634,11 +1648,8 @@ pub mod env {
/// - `out_ptr`: pointer to the linear memory where the returning value is written to.
/// - `out_len_ptr`: in-out pointer into linear memory where the buffer length is read from and
/// the value length is written to.
fn seal_own_code_hash(
ctx: Runtime<E: Ext>,
out_ptr: u32,
out_len_ptr: u32,
) -> Result<(), TrapReason> {
#[prefixed_alias]
fn own_code_hash(ctx: Runtime<E>, out_ptr: u32, out_len_ptr: u32) -> Result<(), TrapReason> {
ctx.charge_gas(RuntimeCosts::OwnCodeHash)?;
let code_hash_encoded = &ctx.ext.own_code_hash().encode();
Ok(ctx.write_sandbox_output(
@@ -1660,7 +1671,8 @@ pub mod env {
/// and `false` indicates that the caller is another contract.
///
/// Returned value is a u32-encoded boolean: (0 = false, 1 = true).
fn seal_caller_is_origin(ctx: Runtime<E: Ext>) -> Result<u32, TrapReason> {
#[prefixed_alias]
fn caller_is_origin(ctx: Runtime<E>) -> Result<u32, TrapReason> {
ctx.charge_gas(RuntimeCosts::CallerIsOrigin)?;
Ok(ctx.ext.caller_is_origin() as u32)
}
@@ -1671,11 +1683,8 @@ pub mod env {
/// `out_len_ptr` must point to a u32 value that describes the available space at
/// `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.
fn seal_address(
ctx: Runtime<E: Ext>,
out_ptr: u32,
out_len_ptr: u32,
) -> Result<(), TrapReason> {
#[prefixed_alias]
fn address(ctx: Runtime<E>, out_ptr: u32, out_len_ptr: u32) -> Result<(), TrapReason> {
ctx.charge_gas(RuntimeCosts::Address)?;
Ok(ctx.write_sandbox_output(
out_ptr,
@@ -1699,8 +1708,9 @@ pub mod env {
///
/// It is recommended to avoid specifying very small values for `gas` as the prices for a single
/// gas can be smaller than one.
fn seal_weight_to_fee(
ctx: Runtime<E: Ext>,
#[prefixed_alias]
fn weight_to_fee(
ctx: Runtime<E>,
gas: u64,
out_ptr: u32,
out_len_ptr: u32,
@@ -1724,11 +1734,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 Gas.
fn seal_gas_left(
ctx: Runtime<E: Ext>,
out_ptr: u32,
out_len_ptr: u32,
) -> Result<(), TrapReason> {
#[prefixed_alias]
fn gas_left(ctx: Runtime<E>, out_ptr: u32, out_len_ptr: u32) -> Result<(), TrapReason> {
ctx.charge_gas(RuntimeCosts::GasLeft)?;
let gas_left = &ctx.ext.gas_meter().gas_left().encode();
Ok(ctx.write_sandbox_output(out_ptr, out_len_ptr, gas_left, false, already_charged)?)
@@ -1742,11 +1749,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::Balance.
fn seal_balance(
ctx: Runtime<E: Ext>,
out_ptr: u32,
out_len_ptr: u32,
) -> Result<(), TrapReason> {
#[prefixed_alias]
fn balance(ctx: Runtime<E>, out_ptr: u32, out_len_ptr: u32) -> Result<(), TrapReason> {
ctx.charge_gas(RuntimeCosts::Balance)?;
Ok(ctx.write_sandbox_output(
out_ptr,
@@ -1765,8 +1769,9 @@ 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::Balance.
fn seal_value_transferred(
ctx: Runtime<E: Ext>,
#[prefixed_alias]
fn value_transferred(
ctx: Runtime<E>,
out_ptr: u32,
out_len_ptr: u32,
) -> Result<(), TrapReason> {
@@ -1792,8 +1797,9 @@ pub mod env {
/// # Deprecation
///
/// This function is deprecated. Users should migrate to the version in the "seal1" module.
fn seal_random(
ctx: Runtime<E: Ext>,
#[prefixed_alias]
fn random(
ctx: Runtime<E>,
subject_ptr: u32,
subject_len: u32,
out_ptr: u32,
@@ -1835,8 +1841,9 @@ pub mod env {
/// call this on later blocks until the block number returned is later than the latest
/// commitment.
#[version(1)]
fn seal_random(
ctx: Runtime<E: Ext>,
#[prefixed_alias]
fn random(
ctx: Runtime<E>,
subject_ptr: u32,
subject_len: u32,
out_ptr: u32,
@@ -1862,7 +1869,8 @@ pub mod env {
/// `out_len_ptr` must point to a u32 value that describes the available space at
/// `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.
fn seal_now(ctx: Runtime<E: Ext>, out_ptr: u32, out_len_ptr: u32) -> Result<(), TrapReason> {
#[prefixed_alias]
fn now(ctx: Runtime<E>, out_ptr: u32, out_len_ptr: u32) -> Result<(), TrapReason> {
ctx.charge_gas(RuntimeCosts::Now)?;
Ok(ctx.write_sandbox_output(
out_ptr,
@@ -1876,11 +1884,8 @@ pub mod env {
/// Stores the minimum balance (a.k.a. existential deposit) into the supplied buffer.
///
/// The data is encoded as T::Balance.
fn seal_minimum_balance(
ctx: Runtime<E: Ext>,
out_ptr: u32,
out_len_ptr: u32,
) -> Result<(), TrapReason> {
#[prefixed_alias]
fn minimum_balance(ctx: Runtime<E>, out_ptr: u32, out_len_ptr: u32) -> Result<(), TrapReason> {
ctx.charge_gas(RuntimeCosts::MinimumBalance)?;
Ok(ctx.write_sandbox_output(
out_ptr,
@@ -1901,8 +1906,9 @@ pub mod env {
/// # Deprecation
///
/// There is no longer a tombstone deposit. This function always returns 0.
fn seal_tombstone_deposit(
ctx: Runtime<E: Ext>,
#[prefixed_alias]
fn tombstone_deposit(
ctx: Runtime<E>,
out_ptr: u32,
out_len_ptr: u32,
) -> Result<(), TrapReason> {
@@ -1917,8 +1923,9 @@ pub mod env {
///
/// The state rent functionality was removed. This is stub only exists for
/// backwards compatiblity
fn seal_restore_to(
ctx: Runtime<E: Ext>,
#[prefixed_alias]
fn restore_to(
ctx: Runtime<E>,
_dest_ptr: u32,
_dest_len: u32,
_code_hash_ptr: u32,
@@ -1939,8 +1946,9 @@ pub mod env {
/// The state rent functionality was removed. This is stub only exists for
/// backwards compatiblity
#[version(1)]
fn seal_restore_to(
ctx: Runtime<E: Ext>,
#[prefixed_alias]
fn restore_to(
ctx: Runtime<E>,
_dest_ptr: u32,
_code_hash_ptr: u32,
_rent_allowance_ptr: u32,
@@ -1959,8 +1967,9 @@ pub mod env {
/// - topics_len - the length of the topics buffer. Pass 0 if you want to pass an empty vector.
/// - data_ptr - a pointer to a raw data buffer which will saved along the event.
/// - data_len - the length of the data buffer.
fn seal_deposit_event(
ctx: Runtime<E: Ext>,
#[prefixed_alias]
fn deposit_event(
ctx: Runtime<E>,
topics_ptr: u32,
topics_len: u32,
data_ptr: u32,
@@ -2017,8 +2026,9 @@ pub mod env {
///
/// The state rent functionality was removed. This is stub only exists for
/// backwards compatiblity.
fn seal_set_rent_allowance(
ctx: Runtime<E: Ext>,
#[prefixed_alias]
fn set_rent_allowance(
ctx: Runtime<E>,
_value_ptr: u32,
_value_len: u32,
) -> Result<(), TrapReason> {
@@ -2033,7 +2043,8 @@ pub mod env {
/// The state rent functionality was removed. This is stub only exists for
/// backwards compatiblity.
#[version(1)]
fn seal_set_rent_allowance(ctx: Runtime<E: Ext>, _value_ptr: u32) -> Result<(), TrapReason> {
#[prefixed_alias]
fn set_rent_allowance(ctx: Runtime<E>, _value_ptr: u32) -> Result<(), TrapReason> {
ctx.charge_gas(RuntimeCosts::DebugMessage)?;
Ok(())
}
@@ -2044,11 +2055,8 @@ pub mod env {
///
/// The state rent functionality was removed. This is stub only exists for
/// backwards compatiblity.
fn seal_rent_allowance(
ctx: Runtime<E: Ext>,
out_ptr: u32,
out_len_ptr: u32,
) -> Result<(), TrapReason> {
#[prefixed_alias]
fn rent_allowance(ctx: Runtime<E>, 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(
@@ -2066,11 +2074,8 @@ pub mod env {
/// `out_len_ptr` must point to a u32 value that describes the available space at
/// `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.
fn seal_block_number(
ctx: Runtime<E: Ext>,
out_ptr: u32,
out_len_ptr: u32,
) -> Result<(), TrapReason> {
#[prefixed_alias]
fn block_number(ctx: Runtime<E>, out_ptr: u32, out_len_ptr: u32) -> Result<(), TrapReason> {
ctx.charge_gas(RuntimeCosts::BlockNumber)?;
Ok(ctx.write_sandbox_output(
out_ptr,
@@ -2098,8 +2103,9 @@ pub mod env {
/// - `input_len`: the length of the input data in bytes.
/// - `output_ptr`: the pointer into the linear memory where the output data is placed. The
/// function will write the result directly into this buffer.
fn seal_hash_sha2_256(
ctx: Runtime<E: Ext>,
#[prefixed_alias]
fn hash_sha2_256(
ctx: Runtime<E>,
input_ptr: u32,
input_len: u32,
output_ptr: u32,
@@ -2125,8 +2131,9 @@ pub mod env {
/// - `input_len`: the length of the input data in bytes.
/// - `output_ptr`: the pointer into the linear memory where the output data is placed. The
/// function will write the result directly into this buffer.
fn seal_hash_keccak_256(
ctx: Runtime<E: Ext>,
#[prefixed_alias]
fn hash_keccak_256(
ctx: Runtime<E>,
input_ptr: u32,
input_len: u32,
output_ptr: u32,
@@ -2152,8 +2159,9 @@ pub mod env {
/// - `input_len`: the length of the input data in bytes.
/// - `output_ptr`: the pointer into the linear memory where the output data is placed. The
/// function will write the result directly into this buffer.
fn seal_hash_blake2_256(
ctx: Runtime<E: Ext>,
#[prefixed_alias]
fn hash_blake2_256(
ctx: Runtime<E>,
input_ptr: u32,
input_len: u32,
output_ptr: u32,
@@ -2179,8 +2187,9 @@ pub mod env {
/// - `input_len`: the length of the input data in bytes.
/// - `output_ptr`: the pointer into the linear memory where the output data is placed. The
/// function will write the result directly into this buffer.
fn seal_hash_blake2_128(
ctx: Runtime<E: Ext>,
#[prefixed_alias]
fn hash_blake2_128(
ctx: Runtime<E>,
input_ptr: u32,
input_len: u32,
output_ptr: u32,
@@ -2200,8 +2209,9 @@ pub mod env {
///
/// If no chain extension exists the contract will trap with the `NoChainExtension`
/// module error.
fn seal_call_chain_extension(
ctx: Runtime<E: Ext>,
#[prefixed_alias]
fn call_chain_extension(
ctx: Runtime<E>,
id: u32,
input_ptr: u32,
input_len: u32,
@@ -2243,8 +2253,9 @@ pub mod env {
/// not being executed as an RPC. For example, they could allow users to disable logging
/// through compile time flags (cargo features) for on-chain deployment. Additionally, the
/// return value of this function can be cached in order to prevent further calls at runtime.
fn seal_debug_message(
ctx: Runtime<E: Ext>,
#[prefixed_alias]
fn debug_message(
ctx: Runtime<E>,
str_ptr: u32,
str_len: u32,
) -> Result<ReturnCode, TrapReason> {
@@ -2297,8 +2308,9 @@ pub mod env {
/// This function is unstable and subject to change (or removal) in the future. Do not
/// deploy a contract using it to a production chain.
#[unstable]
fn seal_call_runtime(
ctx: Runtime<E: Ext>,
#[prefixed_alias]
fn call_runtime(
ctx: Runtime<E>,
call_ptr: u32,
call_len: u32,
) -> Result<ReturnCode, TrapReason> {
@@ -2334,8 +2346,9 @@ pub mod env {
/// # Errors
///
/// `ReturnCode::EcdsaRecoverFailed`
fn seal_ecdsa_recover(
ctx: Runtime<E: Ext>,
#[prefixed_alias]
fn ecdsa_recover(
ctx: Runtime<E>,
signature_ptr: u32,
message_hash_ptr: u32,
output_ptr: u32,
@@ -2387,10 +2400,8 @@ pub mod env {
/// # Errors
///
/// `ReturnCode::CodeNotFound`
fn seal_set_code_hash(
ctx: Runtime<E: Ext>,
code_hash_ptr: u32,
) -> Result<ReturnCode, TrapReason> {
#[prefixed_alias]
fn set_code_hash(ctx: Runtime<E>, code_hash_ptr: u32) -> Result<ReturnCode, TrapReason> {
ctx.charge_gas(RuntimeCosts::SetCodeHash)?;
let code_hash: CodeHash<<E as Ext>::T> = ctx.read_sandbox_memory_as(code_hash_ptr)?;
match ctx.ext.set_code_hash(code_hash) {
@@ -2418,8 +2429,9 @@ pub mod env {
/// # Errors
///
/// `ReturnCode::EcdsaRecoverFailed`
fn seal_ecdsa_to_eth_address(
ctx: Runtime<E: Ext>,
#[prefixed_alias]
fn ecdsa_to_eth_address(
ctx: Runtime<E>,
key_ptr: u32,
out_ptr: u32,
) -> Result<ReturnCode, TrapReason> {