revm_interpreter/instructions/
tx_info.rs

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