Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 8 additions & 0 deletions prdoc/pr_10380.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
title: pallet-revive benchmark opcode fix
doc:
- audience: Runtime Dev
description: "Benchmark opcode was using the invalid opcode instead of defining\
\ a new one. \n"
crates:
- name: pallet-revive
bump: patch
8 changes: 5 additions & 3 deletions substrate/frame/revive/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2100,7 +2100,7 @@ mod benchmarks {
i: Linear<{ 10 * 1024 }, { 48 * 1024 }>,
) -> Result<(), BenchmarkError> {
use crate::vm::evm::instructions::BENCH_INIT_CODE;
let mut setup = CallSetup::<T>::new(VmBinaryModule::dummy());
let mut setup = CallSetup::<T>::new(VmBinaryModule::evm_sized(0));
setup.set_origin(ExecOrigin::from_account_id(setup.contract().account_id.clone()));
setup.set_balance(caller_funding::<T>());

Expand All @@ -2115,17 +2115,19 @@ mod benchmarks {

let init_code = vec![BENCH_INIT_CODE; i as usize];
let _ = interpreter.memory.resize(0, init_code.len());
let salt = U256::from(42u64);
interpreter.memory.set_data(0, 0, init_code.len(), &init_code);

// Setup stack for create instruction [value, offset, size]
// Setup stack for create instruction [value, offset, size, salt]
let _ = interpreter.stack.push(salt);
let _ = interpreter.stack.push(U256::from(init_code.len()));
let _ = interpreter.stack.push(U256::zero());
let _ = interpreter.stack.push(value);

let result;
#[block]
{
result = instructions::contract::create::<false, _>(&mut interpreter);
result = instructions::contract::create::<true, _>(&mut interpreter);
}

assert!(result.is_continue());
Expand Down
3 changes: 2 additions & 1 deletion substrate/frame/revive/src/vm/evm/instructions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ mod tx_info;
pub mod utility;

#[cfg(feature = "runtime-benchmarks")]
pub const BENCH_INIT_CODE: u8 = 0xfe; // Arbitrary unused opcode for benchmarking
pub const BENCH_INIT_CODE: u8 = 0x1F; // Arbitrary unused opcode for benchmarking

pub fn exec_instruction<E: Ext>(
interpreter: &mut Interpreter<E>,
Expand Down Expand Up @@ -215,6 +215,7 @@ pub fn exec_instruction<E: Ext>(
#[cfg(feature = "runtime-benchmarks")]
BENCH_INIT_CODE => control::bench_init_code(),

INVALID => control::invalid(interpreter),
_ => control::invalid(interpreter),
}
}
Loading