difftreelog
feat estimate multiple extrinsics PoV
in: master
3 files changed
client/rpc/src/pov_estimate.rsdiffbeforeafterboth--- a/client/rpc/src/pov_estimate.rs
+++ b/client/rpc/src/pov_estimate.rs
@@ -122,7 +122,11 @@
#[async_trait]
pub trait PovEstimateApi<BlockHash> {
#[method(name = "unique_estimateExtrinsicPoV")]
- fn estimate_extrinsic_pov(&self, encoded_xt: Bytes, at: Option<BlockHash>) -> Result<PovInfo>;
+ fn estimate_extrinsic_pov(
+ &self,
+ encoded_xts: Vec<Bytes>,
+ at: Option<BlockHash>,
+ ) -> Result<PovInfo>;
}
#[allow(deprecated)]
@@ -135,7 +139,7 @@
{
fn estimate_extrinsic_pov(
&self,
- encoded_xt: Bytes,
+ encoded_xts: Vec<Bytes>,
at: Option<<Block as BlockT>::Hash>,
) -> Result<PovInfo> {
self.deny_unsafe.check_if_safe()?;
@@ -151,20 +155,20 @@
RuntimeId::Unique => execute_extrinsic_in_sandbox::<Block, UniqueRuntimeExecutor>(
state,
&self.exec_params,
- encoded_xt,
+ encoded_xts,
),
#[cfg(feature = "quartz-runtime")]
RuntimeId::Quartz => execute_extrinsic_in_sandbox::<Block, QuartzRuntimeExecutor>(
state,
&self.exec_params,
- encoded_xt,
+ encoded_xts,
),
RuntimeId::Opal => execute_extrinsic_in_sandbox::<Block, OpalRuntimeExecutor>(
state,
&self.exec_params,
- encoded_xt,
+ encoded_xts,
),
runtime_id => Err(anyhow!("unknown runtime id {:?}", runtime_id).into()),
@@ -188,7 +192,7 @@
fn execute_extrinsic_in_sandbox<Block, D>(
state: StateOf<Block>,
exec_params: &ExecutorParams,
- encoded_xt: Bytes,
+ encoded_xts: Vec<Bytes>,
) -> Result<PovInfo>
where
Block: BlockT,
@@ -216,23 +220,29 @@
);
let execution = ExecutionStrategy::NativeElseWasm;
- let encoded_bytes = encoded_xt.encode();
+ let mut results = Vec::new();
+
+ for encoded_xt in encoded_xts {
+ let encoded_bytes = encoded_xt.encode();
+
+ let xt_result = StateMachine::new(
+ &proving_backend,
+ &mut changes,
+ &executor,
+ "PovEstimateApi_pov_estimate",
+ encoded_bytes.as_slice(),
+ full_extensions(),
+ &runtime_code,
+ sp_core::testing::TaskExecutor::new(),
+ )
+ .execute(execution.into())
+ .map_err(|e| anyhow!("failed to execute the extrinsic {:?}", e))?;
- let xt_result = StateMachine::new(
- &proving_backend,
- &mut changes,
- &executor,
- "PovEstimateApi_pov_estimate",
- encoded_bytes.as_slice(),
- full_extensions(),
- &runtime_code,
- sp_core::testing::TaskExecutor::new(),
- )
- .execute(execution.into())
- .map_err(|e| anyhow!("failed to execute the extrinsic {:?}", e))?;
+ let xt_result = Decode::decode(&mut &*xt_result)
+ .map_err(|e| anyhow!("failed to decode the extrinsic result {:?}", e))?;
- let xt_result = Decode::decode(&mut &*xt_result)
- .map_err(|e| anyhow!("failed to decode the extrinsic result {:?}", e))?;
+ results.push(xt_result);
+ }
let proof = proving_backend
.extract_proof()
@@ -252,6 +262,6 @@
proof_size: proof_size as u64,
compact_proof_size: compact_proof_size as u64,
compressed_proof_size: compressed_proof_size as u64,
- result: xt_result,
+ results,
})
}
primitives/pov-estimate-rpc/src/lib.rsdiffbeforeafterboth1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617#![cfg_attr(not(feature = "std"), no_std)]1819use scale_info::TypeInfo;2021#[cfg(feature = "std")]22use serde::Serialize;2324use sp_runtime::ApplyExtrinsicResult;25use sp_core::Bytes;2627#[cfg_attr(feature = "std", derive(Serialize))]28#[derive(Debug, TypeInfo)]29pub struct PovInfo {30 pub proof_size: u64,31 pub compact_proof_size: u64,32 pub compressed_proof_size: u64,33 pub result: ApplyExtrinsicResult,34}3536sp_api::decl_runtime_apis! {37 pub trait PovEstimateApi {38 fn pov_estimate(uxt: Bytes) -> ApplyExtrinsicResult;39 }40}1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617#![cfg_attr(not(feature = "std"), no_std)]1819use scale_info::TypeInfo;20use sp_std::vec::Vec;2122#[cfg(feature = "std")]23use serde::Serialize;2425use sp_runtime::ApplyExtrinsicResult;26use sp_core::Bytes;2728#[cfg_attr(feature = "std", derive(Serialize))]29#[derive(Debug, TypeInfo)]30pub struct PovInfo {31 pub proof_size: u64,32 pub compact_proof_size: u64,33 pub compressed_proof_size: u64,34 pub results: Vec<ApplyExtrinsicResult>,35}3637sp_api::decl_runtime_apis! {38 pub trait PovEstimateApi {39 fn pov_estimate(uxt: Bytes) -> ApplyExtrinsicResult;40 }41}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
),
},
};