mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-06-14 00:41:04 +00:00
extend mock runtime to allow executing constructors and cross contract calls
Signed-off-by: xermicus <cyrill@parity.io>
This commit is contained in:
@@ -31,14 +31,14 @@ where
|
||||
#[cfg(feature = "bench-pvm-interpreter")]
|
||||
{
|
||||
let contract = contract(p.clone());
|
||||
let (state, mut instance, export) = revive_benchmarks::prepare_pvm(
|
||||
let (transaction, mut instance, export) = revive_benchmarks::prepare_pvm(
|
||||
&contract.pvm_runtime,
|
||||
&contract.calldata,
|
||||
contract.calldata,
|
||||
polkavm::BackendKind::Interpreter,
|
||||
);
|
||||
group.bench_with_input(BenchmarkId::new("PVMInterpreter", l), p, |b, _| {
|
||||
b.iter(|| {
|
||||
revive_integration::mock_runtime::call(state.clone(), &mut instance, export);
|
||||
transaction.clone().call_on(&mut instance, export);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -46,14 +46,14 @@ where
|
||||
#[cfg(feature = "bench-pvm")]
|
||||
{
|
||||
let contract = contract(p.clone());
|
||||
let (state, mut instance, export) = revive_benchmarks::prepare_pvm(
|
||||
let (transaction, mut instance, export) = revive_benchmarks::prepare_pvm(
|
||||
&contract.pvm_runtime,
|
||||
&contract.calldata,
|
||||
contract.calldata,
|
||||
polkavm::BackendKind::Compiler,
|
||||
);
|
||||
group.bench_with_input(BenchmarkId::new("PVM", l), p, |b, _| {
|
||||
b.iter(|| {
|
||||
revive_integration::mock_runtime::call(state.clone(), &mut instance, export);
|
||||
transaction.clone().call_on(&mut instance, export);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
use polkavm::{BackendKind, Config, Engine, ExportIndex, Instance, SandboxKind};
|
||||
use revive_integration::mock_runtime;
|
||||
use revive_integration::mock_runtime::State;
|
||||
use revive_integration::mock_runtime::{self, TransactionBuilder};
|
||||
use revive_integration::mock_runtime::{State, Transaction};
|
||||
|
||||
pub fn prepare_pvm(
|
||||
code: &[u8],
|
||||
input: &[u8],
|
||||
input: Vec<u8>,
|
||||
backend: BackendKind,
|
||||
) -> (State, Instance<State>, ExportIndex) {
|
||||
) -> (TransactionBuilder, Instance<Transaction>, ExportIndex) {
|
||||
let mut config = Config::new();
|
||||
config.set_backend(Some(backend));
|
||||
config.set_sandbox(Some(SandboxKind::Linux));
|
||||
|
||||
let (instance, export_index) = mock_runtime::prepare(code, Some(config));
|
||||
let transaction = State::default().transaction().calldata(input);
|
||||
|
||||
(State::new(input.to_vec()), instance, export_index)
|
||||
(transaction, instance, export_index)
|
||||
}
|
||||
|
||||
pub fn instantiate_engine(backend: BackendKind) -> Engine {
|
||||
|
||||
Reference in New Issue
Block a user