revm_interpreter/instructions/
tx_info.rs

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