difftreelog
feat estimate multiple extrinsics PoV
in: master
3 files changed
client/rpc/src/pov_estimate.rsdiffbeforeafterboth122#[async_trait]122#[async_trait]123pub trait PovEstimateApi<BlockHash> {123pub trait PovEstimateApi<BlockHash> {124 #[method(name = "unique_estimateExtrinsicPoV")]124 #[method(name = "unique_estimateExtrinsicPoV")]125 fn estimate_extrinsic_pov(&self, encoded_xt: Bytes, at: Option<BlockHash>) -> Result<PovInfo>;125 fn estimate_extrinsic_pov(126 &self,127 encoded_xts: Vec<Bytes>,128 at: Option<BlockHash>,129 ) -> Result<PovInfo>;126}130}127131135{139{136 fn estimate_extrinsic_pov(140 fn estimate_extrinsic_pov(137 &self,141 &self,138 encoded_xt: Bytes,142 encoded_xts: Vec<Bytes>,139 at: Option<<Block as BlockT>::Hash>,143 at: Option<<Block as BlockT>::Hash>,140 ) -> Result<PovInfo> {144 ) -> Result<PovInfo> {141 self.deny_unsafe.check_if_safe()?;145 self.deny_unsafe.check_if_safe()?;151 RuntimeId::Unique => execute_extrinsic_in_sandbox::<Block, UniqueRuntimeExecutor>(155 RuntimeId::Unique => execute_extrinsic_in_sandbox::<Block, UniqueRuntimeExecutor>(152 state,156 state,153 &self.exec_params,157 &self.exec_params,154 encoded_xt,158 encoded_xts,155 ),159 ),156160157 #[cfg(feature = "quartz-runtime")]161 #[cfg(feature = "quartz-runtime")]158 RuntimeId::Quartz => execute_extrinsic_in_sandbox::<Block, QuartzRuntimeExecutor>(162 RuntimeId::Quartz => execute_extrinsic_in_sandbox::<Block, QuartzRuntimeExecutor>(159 state,163 state,160 &self.exec_params,164 &self.exec_params,161 encoded_xt,165 encoded_xts,162 ),166 ),163167164 RuntimeId::Opal => execute_extrinsic_in_sandbox::<Block, OpalRuntimeExecutor>(168 RuntimeId::Opal => execute_extrinsic_in_sandbox::<Block, OpalRuntimeExecutor>(165 state,169 state,166 &self.exec_params,170 &self.exec_params,167 encoded_xt,171 encoded_xts,168 ),172 ),169173170 runtime_id => Err(anyhow!("unknown runtime id {:?}", runtime_id).into()),174 runtime_id => Err(anyhow!("unknown runtime id {:?}", runtime_id).into()),188fn execute_extrinsic_in_sandbox<Block, D>(192fn execute_extrinsic_in_sandbox<Block, D>(189 state: StateOf<Block>,193 state: StateOf<Block>,190 exec_params: &ExecutorParams,194 exec_params: &ExecutorParams,191 encoded_xt: Bytes,195 encoded_xts: Vec<Bytes>,192) -> Result<PovInfo>196) -> Result<PovInfo>193where197where194 Block: BlockT,198 Block: BlockT,216 );220 );217 let execution = ExecutionStrategy::NativeElseWasm;221 let execution = ExecutionStrategy::NativeElseWasm;218222223 let mut results = Vec::new();224225 for encoded_xt in encoded_xts {219 let encoded_bytes = encoded_xt.encode();226 let encoded_bytes = encoded_xt.encode();220227221 let xt_result = StateMachine::new(228 let xt_result = StateMachine::new(234 let xt_result = Decode::decode(&mut &*xt_result)241 let xt_result = Decode::decode(&mut &*xt_result)235 .map_err(|e| anyhow!("failed to decode the extrinsic result {:?}", e))?;242 .map_err(|e| anyhow!("failed to decode the extrinsic result {:?}", e))?;243244 results.push(xt_result);245 }236246237 let proof = proving_backend247 let proof = proving_backend238 .extract_proof()248 .extract_proof()252 proof_size: proof_size as u64,262 proof_size: proof_size as u64,253 compact_proof_size: compact_proof_size as u64,263 compact_proof_size: compact_proof_size as u64,254 compressed_proof_size: compressed_proof_size as u64,264 compressed_proof_size: compressed_proof_size as u64,255 result: xt_result,265 results,256 })266 })257}267}258268primitives/pov-estimate-rpc/src/lib.rsdiffbeforeafterboth--- a/primitives/pov-estimate-rpc/src/lib.rs
+++ b/primitives/pov-estimate-rpc/src/lib.rs
@@ -17,6 +17,7 @@
#![cfg_attr(not(feature = "std"), no_std)]
use scale_info::TypeInfo;
+use sp_std::vec::Vec;
#[cfg(feature = "std")]
use serde::Serialize;
@@ -30,7 +31,7 @@
pub proof_size: u64,
pub compact_proof_size: u64,
pub compressed_proof_size: u64,
- pub result: ApplyExtrinsicResult,
+ pub results: Vec<ApplyExtrinsicResult>,
}
sp_api::decl_runtime_apis! {
tests/src/interfaces/unique/definitions.tsdiffbeforeafterboth--- a/tests/src/interfaces/unique/definitions.ts
+++ b/tests/src/interfaces/unique/definitions.ts
@@ -175,28 +175,10 @@
[collectionParam, tokenParam],
'Option<u128>',
),
-<<<<<<< HEAD
-<<<<<<< HEAD
allowanceForAll: fun(
'Tells whether the given `owner` approves the `operator`.',
[collectionParam, crossAccountParam('owner'), crossAccountParam('operator')],
'Option<bool>',
-=======
- povEstimate: fun(
- 'Estimate PoV size',
- [{name: 'encodedXt', type: 'Vec<u8>'}],
-=======
- estimateExtrinsicPoV: fun(
- 'Estimate PoV size of an encoded extrinsic',
- [{name: 'encodedXt', type: 'Bytes'}],
- 'UpPovEstimateRpcPovInfo',
- ),
- estimateCallPoV: fun(
- 'Estimate PoV size of an encoded call',
- [{name: 'encodedCall', type: 'Bytes'}],
->>>>>>> chore: regenerate types
- 'UpPovEstimateRpcPovInfo',
->>>>>>> fix: update polkadot types and definitions
),
},
};