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    //gas!(context.interpreter, gas::BASE);
15    push!(context.interpreter, context.host.effective_gas_price());
16}
17
18/// Implements the ORIGIN instruction.
19///
20/// Gets the execution origination address.
21pub fn origin<WIRE: InterpreterTypes, H: Host + ?Sized>(context: InstructionContext<'_, H, WIRE>) {
22    //gas!(context.interpreter, gas::BASE);
23    push!(
24        context.interpreter,
25        context.host.caller().into_word().into()
26    );
27}
28
29/// Implements the BLOBHASH instruction.
30///
31/// EIP-4844: Shard Blob Transactions - gets the hash of a transaction blob.
32pub fn blob_hash<WIRE: InterpreterTypes, H: Host + ?Sized>(
33    context: InstructionContext<'_, H, WIRE>,
34) {
35    check!(context.interpreter, CANCUN);
36    //gas!(context.interpreter, gas::VERYLOW);
37    popn_top!([], index, context.interpreter);
38    let i = as_usize_saturated!(index);
39    *index = context.host.blob_hash(i).unwrap_or_default();
40}