revm_interpreter/instructions/
tx_info.rs

1use crate::{
2    gas,
3    interpreter_types::{InterpreterTypes, RuntimeFlag, StackTr},
4    Host,
5};
6use primitives::U256;
7
8use crate::InstructionContext;
9
10pub fn gasprice<WIRE: InterpreterTypes, H: Host + ?Sized>(
11    context: InstructionContext<'_, H, WIRE>,
12) {
13    gas!(context.interpreter, gas::BASE);
14    push!(
15        context.interpreter,
16        U256::from(context.host.effective_gas_price())
17    );
18}
19
20pub fn origin<WIRE: InterpreterTypes, H: Host + ?Sized>(context: InstructionContext<'_, H, WIRE>) {
21    gas!(context.interpreter, gas::BASE);
22    push!(
23        context.interpreter,
24        context.host.caller().into_word().into()
25    );
26}
27
28// EIP-4844: Shard Blob Transactions
29pub fn blob_hash<WIRE: InterpreterTypes, H: Host + ?Sized>(
30    context: InstructionContext<'_, H, WIRE>,
31) {
32    check!(context.interpreter, CANCUN);
33    gas!(context.interpreter, gas::VERYLOW);
34    popn_top!([], index, context.interpreter);
35    let i = as_usize_saturated!(index);
36    *index = context.host.blob_hash(i).unwrap_or_default();
37}