Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
seal: Remove ext_dispatch_call and ext_get_runtime_storage
Those are way too hard to audit and make only sense with specific
chains. They shouldn't be in the core API.
  • Loading branch information
athei committed Jun 22, 2020
commit 384c37926884bdfacbdf0b6fbd570c89e77c58a1
1 change: 0 additions & 1 deletion bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,6 @@ parameter_types! {
impl pallet_contracts::Trait for Runtime {
type Time = Timestamp;
type Randomness = RandomnessCollectiveFlip;
type Call = Call;
type Event = Event;
type DetermineContractAddress = pallet_contracts::SimpleAddressDeterminer<Runtime>;
type TrieIdGenerator = pallet_contracts::TrieIdFromParentCounter<Runtime>;
Expand Down
14 changes: 0 additions & 14 deletions frame/contracts/fixtures/dispatch_call.wat

This file was deleted.

15 changes: 0 additions & 15 deletions frame/contracts/fixtures/dispatch_call_then_trap.wat

This file was deleted.

74 changes: 0 additions & 74 deletions frame/contracts/fixtures/get_runtime_storage.wat

This file was deleted.

4 changes: 2 additions & 2 deletions frame/contracts/fixtures/restoration.wat
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@

;; Code hash of SET_RENT
(data (i32.const 264)
"\c2\1c\41\10\a5\22\d8\59\1c\4c\77\35\dd\2d\bf\a1"
"\13\0b\50\93\76\9b\92\31\97\b7\c5\74\26\aa\38\2a"
"\ab\d6\58\65\1e\83\6e\4a\18\0d\f2\6d\bc\42\ba\e9"
"\3d\64\76\e5\30\5b\33\46\bb\4d\43\99\38\21\ee\32"
)

;; Rent allowance
Expand Down
19 changes: 12 additions & 7 deletions frame/contracts/fixtures/set_rent.wat
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(module
(import "env" "ext_dispatch_call" (func $ext_dispatch_call (param i32 i32)))
(import "env" "ext_transfer" (func $ext_transfer (param i32 i32 i32 i32) (result i32)))
(import "env" "ext_set_storage" (func $ext_set_storage (param i32 i32 i32)))
(import "env" "ext_clear_storage" (func $ext_clear_storage (param i32)))
(import "env" "ext_set_rent_allowance" (func $ext_set_rent_allowance (param i32 i32)))
Expand All @@ -23,11 +23,13 @@
)
)

;; transfer 50 to ALICE
;; transfer 50 to CHARLIE
(func $call_2
(call $ext_dispatch_call
(i32.const 68)
(i32.const 11)
(call $assert
(i32.eq
(call $ext_transfer (i32.const 68) (i32.const 8) (i32.const 76) (i32.const 8))
(i32.const 0)
)
)
)

Expand Down Expand Up @@ -96,6 +98,9 @@
;; Encoding of 10 in balance
(data (i32.const 0) "\28")

;; Encoding of call transfer 50 to CHARLIE
(data (i32.const 68) "\00\00\03\00\00\00\00\00\00\00\C8")
;; encoding of Charlies's account id
(data (i32.const 68) "\03")

;; encoding of 50 balance
(data (i32.const 76) "\32")
)
17 changes: 0 additions & 17 deletions frame/contracts/src/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ use frame_support::{
};

pub type AccountIdOf<T> = <T as frame_system::Trait>::AccountId;
pub type CallOf<T> = <T as Trait>::Call;
pub type MomentOf<T> = <<T as Trait>::Time as Time>::Moment;
pub type SeedOf<T> = <T as frame_system::Trait>::Hash;
pub type BlockNumberOf<T> = <T as frame_system::Trait>::BlockNumber;
Expand Down Expand Up @@ -144,9 +143,6 @@ pub trait Ext {
input_data: Vec<u8>,
) -> ExecResult;

/// Notes a call dispatch.
fn note_dispatch_call(&mut self, call: CallOf<Self::T>);

/// Notes a restoration request.
fn note_restore_to(
&mut self,
Expand Down Expand Up @@ -270,12 +266,6 @@ pub enum DeferredAction<T: Trait> {
/// The event to deposit.
event: Event<T>,
},
DispatchRuntimeCall {
/// The account id of the contract who dispatched this call.
origin: T::AccountId,
/// The call to dispatch.
call: <T as Trait>::Call,
},
RestoreTo {
/// The account id of the contract which is removed during the restoration and transfers
/// its storage to the restored contract.
Expand Down Expand Up @@ -788,13 +778,6 @@ where
self.ctx.call(to.clone(), value, gas_meter, input_data)
}

fn note_dispatch_call(&mut self, call: CallOf<Self::T>) {
self.ctx.deferred.push(DeferredAction::DispatchRuntimeCall {
origin: self.ctx.self_account.clone(),
call,
});
}

fn note_restore_to(
&mut self,
dest: AccountIdOf<Self::T>,
Expand Down
37 changes: 5 additions & 32 deletions frame/contracts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,13 @@ use sp_runtime::{
},
RuntimeDebug,
};
use frame_support::dispatch::{
PostDispatchInfo, DispatchResult, Dispatchable, DispatchResultWithPostInfo
};
use frame_support::{
Parameter, decl_module, decl_event, decl_storage, decl_error,
parameter_types, IsSubType, storage::child::{self, ChildInfo},
decl_module, decl_event, decl_storage, decl_error,
parameter_types, storage::child::{self, ChildInfo},
dispatch::{DispatchResult, DispatchResultWithPostInfo},
traits::{OnUnbalanced, Currency, Get, Time, Randomness},
};
use frame_support::traits::{OnUnbalanced, Currency, Get, Time, Randomness};
use frame_support::weights::GetDispatchInfo;
use frame_system::{self as system, ensure_signed, RawOrigin, ensure_root};
use frame_system::{self as system, ensure_signed, ensure_root};
use pallet_contracts_primitives::{RentProjection, ContractAccessError};

pub type CodeHash<T> = <T as frame_system::Trait>::Hash;
Expand All @@ -129,11 +126,6 @@ pub trait ContractAddressFor<CodeHash, AccountId> {
fn contract_address_for(code_hash: &CodeHash, data: &[u8], origin: &AccountId) -> AccountId;
}

/// A function that returns the fee for dispatching a `Call`.
pub trait ComputeDispatchFee<Call, Balance> {
fn compute_dispatch_fee(call: &Call) -> Balance;
}

/// Information for managing an account and its sub trie abstraction.
/// This is the required info to cache for an account
#[derive(Encode, Decode, RuntimeDebug)]
Expand Down Expand Up @@ -318,12 +310,6 @@ pub trait Trait: frame_system::Trait + pallet_transaction_payment::Trait {
type Time: Time;
type Randomness: Randomness<Self::Hash>;

/// The outer call dispatch type.
type Call:
Parameter +
Dispatchable<PostInfo=PostDispatchInfo, Origin=<Self as frame_system::Trait>::Origin> +
IsSubType<Module<Self>, Self> + GetDispatchInfo;

/// The overarching event type.
type Event: From<Event<Self>> + Into<<Self as frame_system::Trait>::Event>;

Expand Down Expand Up @@ -661,19 +647,6 @@ impl<T: Trait> Module<T> {
&*topics,
<T as Trait>::Event::from(event).into(),
),
DispatchRuntimeCall {
origin: who,
call,
} => {
let info = call.get_dispatch_info();
let result = call.dispatch(RawOrigin::Signed(who.clone()).into());
let post_info = match result {
Ok(post_info) => post_info,
Err(err) => err.post_info,
};
gas_meter.refund(post_info.calc_unspent(&info));
Self::deposit_event(RawEvent::Dispatched(who, result.is_ok()));
}
RestoreTo {
donor,
dest,
Expand Down
Loading