Skip to main content

revm_interpreter/instructions/
tx_info.rs

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