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