paritytech / polkadot-sdk

The Parity Polkadot Blockchain SDK
https://polkadot.network/
1.8k stars 652 forks source link

[pallet-revive] update generic runtime types #5608

Closed pgherveou closed 2 weeks ago

pgherveou commented 3 weeks ago

fix #5574

The Ext trait still depends on the associated type T: Config, we can look into refactoring it even more later but even in the current state it should not influence how the data is encoded / decoded between the contract and the host

fn caller(&self) -> Origin<Self::T>;
-> only use to extract the address of the caller 

fn account_id(&self) -> &AccountIdOf<Self::T>;
 -> only used to expose the address or access the account_id internally   

fn gas_meter(&self) -> &GasMeter<Self::T>;
fn gas_meter_mut(&mut self) -> &mut GasMeter<Self::T>;
 -> encoding does not depend on T

fn call_runtime(&self, call: <Self::T as Config>::RuntimeCall) -> DispatchResultWithPostInfo;
-> Substrate specific, just an opaque blob of bytes from the contract's perspective

fn contract_info(&mut self) -> &mut ContractInfo<Self::T>;
fn transient_storage(&mut self) -> &mut TransientStorage<Self::T>;
-> gated by #[cfg(any(test, feature = "runtime-benchmarks"))]
athei commented 3 weeks ago

Let's stay silent before 1.0 to not clutter the changelog with information of a not ready to use pallet. Still need a prdoc for the bumps though.

pgherveou commented 2 weeks ago

Can you remove the usage of SCALE where it became possible due to having a concrete type? I put some example comments where this was the case.

And yeah let's not sweat removing the T for now.

Made the change in the last commit. SCALE is mostly used now for substrate specific host fns (call_runtime and xcm) https://github.com/paritytech/polkadot-sdk/pull/5608/commits/1b2ed74ac4ad085219bd4e7373e9e392b32b8e09