import { Account } from '@nomicfoundation/ethereumjs-util'; import { EvmError } from './exceptions.js'; import { Memory } from './memory.js'; import { Message } from './message.js'; import { Stack } from './stack.js'; import type { EVM } from './evm.js'; import type { Journal } from './journal.js'; import type { EVMPerformanceLogger } from './logger.js'; import type { Opcode, OpcodeMapEntry } from './opcodes/index.js'; import type { Block, Blockchain, EVMProfilerOpts, Log } from './types.js'; import type { Common, EVMStateManagerInterface } from '@nomicfoundation/ethereumjs-common'; import type { Address } from '@nomicfoundation/ethereumjs-util'; export interface InterpreterOpts { pc?: number; } /** * Immediate (unprocessed) result of running an EVM bytecode. */ export interface RunResult { logs: Log[]; returnValue?: Uint8Array; /** * A set of accounts to selfdestruct */ selfdestruct: Set; /** * A map which tracks which addresses were created (used in EIP 6780) */ createdAddresses?: Set; } export interface Env { address: Address; caller: Address; callData: Uint8Array; callValue: bigint; code: Uint8Array; isStatic: boolean; depth: number; gasPrice: bigint; origin: Address; block: Block; contract: Account; codeAddress: Address; gasRefund: bigint; containerCode?: Uint8Array; /** Full container code for EOF1 contracts */ blobVersionedHashes: Uint8Array[]; /** Versioned hashes for blob transactions */ createdAddresses?: Set; } export interface RunState { programCounter: number; opCode: number; memory: Memory; memoryWordCount: bigint; highestMemCost: bigint; stack: Stack; returnStack: Stack; code: Uint8Array; shouldDoJumpAnalysis: boolean; validJumps: Uint8Array; cachedPushes: { [pc: number]: bigint; }; stateManager: EVMStateManagerInterface; blockchain: Blockchain; env: Env; messageGasLimit?: bigint; interpreter: Interpreter; gasRefund: bigint; gasLeft: bigint; auth?: Address; /** EIP-3074 AUTH parameter */ returnBytes: Uint8Array; } export interface InterpreterResult { runState: RunState; exceptionError?: EvmError; } export interface InterpreterStep { gasLeft: bigint; gasRefund: bigint; stateManager: EVMStateManagerInterface; stack: bigint[]; returnStack: bigint[]; pc: number; depth: number; opcode: { name: string; fee: number; dynamicFee?: bigint; isAsync: boolean; }; account: Account; address: Address; memory: Uint8Array; memoryWordCount: bigint; codeAddress: Address; } /** * Parses and executes EVM bytecode. */ export declare class Interpreter { protected _vm: any; protected _runState: RunState; protected _stateManager: EVMStateManagerInterface; protected common: Common; _evm: EVM; journal: Journal; _env: Env; _result: RunResult; private opDebuggers; private profilerOpts?; private performanceLogger; constructor(evm: EVM, stateManager: EVMStateManagerInterface, blockchain: Blockchain, env: Env, gasLeft: bigint, journal: Journal, performanceLogs: EVMPerformanceLogger, profilerOpts?: EVMProfilerOpts); run(code: Uint8Array, opts?: InterpreterOpts): Promise; /** * Executes the opcode to which the program counter is pointing, * reducing its base gas cost, and increments the program counter. */ runStep(opcodeObj?: OpcodeMapEntry): Promise; /** * Get info for an opcode from EVM's list of opcodes. */ lookupOpInfo(op: number): OpcodeMapEntry; _runStepHook(dynamicFee: bigint, gasLeft: bigint): Promise; _getValidJumpDests(code: Uint8Array): { jumps: Uint8Array; pushes: { [pc: number]: bigint; }; opcodesCached: any[]; }; /** * Subtracts an amount from the gas counter. * @param amount - Amount of gas to consume * @param context - Usage context for debugging * @throws if out of gas */ useGas(amount: bigint, context?: string | Opcode): void; /** * Adds a positive amount to the gas counter. * @param amount - Amount of gas refunded * @param context - Usage context for debugging */ refundGas(amount: bigint, context?: string): void; /** * Reduces amount of gas to be refunded by a positive value. * @param amount - Amount to subtract from gas refunds * @param context - Usage context for debugging */ subRefund(amount: bigint, context?: string): void; /** * Increments the internal gasLeft counter. Used for adding callStipend. * @param amount - Amount to add */ addStipend(amount: bigint): void; /** * Returns balance of the given account. * @param address - Address of account */ getExternalBalance(address: Address): Promise; /** * Store 256-bit a value in memory to persistent storage. */ storageStore(key: Uint8Array, value: Uint8Array): Promise; /** * Loads a 256-bit value to memory from persistent storage. * @param key - Storage key * @param original - If true, return the original storage value (default: false) */ storageLoad(key: Uint8Array, original?: boolean): Promise; /** * Store 256-bit a value in memory to transient storage. * @param address Address to use * @param key Storage key * @param value Storage value */ transientStorageStore(key: Uint8Array, value: Uint8Array): void; /** * Loads a 256-bit value to memory from transient storage. * @param address Address to use * @param key Storage key */ transientStorageLoad(key: Uint8Array): Uint8Array; /** * Set the returning output data for the execution. * @param returnData - Output data to return */ finish(returnData: Uint8Array): void; /** * Set the returning output data for the execution. This will halt the * execution immediately and set the execution result to "reverted". * @param returnData - Output data to return */ revert(returnData: Uint8Array): void; /** * Returns address of currently executing account. */ getAddress(): Address; /** * Returns balance of self. */ getSelfBalance(): bigint; /** * Returns the deposited value by the instruction/transaction * responsible for this execution. */ getCallValue(): bigint; /** * Returns input data in current environment. This pertains to the input * data passed with the message call instruction or transaction. */ getCallData(): Uint8Array; /** * Returns size of input data in current environment. This pertains to the * input data passed with the message call instruction or transaction. */ getCallDataSize(): bigint; /** * Returns caller address. This is the address of the account * that is directly responsible for this execution. */ getCaller(): bigint; /** * Returns the size of code running in current environment. */ getCodeSize(): bigint; /** * Returns the code running in current environment. */ getCode(): Uint8Array; /** * Returns the current gasCounter. */ getGasLeft(): bigint; /** * Returns size of current return data buffer. This contains the return data * from the last executed call, callCode, callDelegate, callStatic or create. * Note: create only fills the return data buffer in case of a failure. */ getReturnDataSize(): bigint; /** * Returns the current return data buffer. This contains the return data * from last executed call, callCode, callDelegate, callStatic or create. * Note: create only fills the return data buffer in case of a failure. */ getReturnData(): Uint8Array; /** * Returns true if the current call must be executed statically. */ isStatic(): boolean; /** * Returns price of gas in current environment. */ getTxGasPrice(): bigint; /** * Returns the execution's origination address. This is the * sender of original transaction; it is never an account with * non-empty associated code. */ getTxOrigin(): bigint; /** * Returns the block’s number. */ getBlockNumber(): bigint; /** * Returns the block's beneficiary address. */ getBlockCoinbase(): bigint; /** * Returns the block's timestamp. */ getBlockTimestamp(): bigint; /** * Returns the block's difficulty. */ getBlockDifficulty(): bigint; /** * Returns the block's prevRandao field. */ getBlockPrevRandao(): bigint; /** * Returns the block's gas limit. */ getBlockGasLimit(): bigint; /** * Returns the Base Fee of the block as proposed in [EIP-3198](https://eips.ethereum.org/EIPS/eip-3198) */ getBlockBaseFee(): bigint; /** * Returns the Blob Base Fee of the block as proposed in [EIP-7516](https://eips.ethereum.org/EIPS/eip-7516) */ getBlobBaseFee(): bigint; /** * Returns the chain ID for current chain. Introduced for the * CHAINID opcode proposed in [EIP-1344](https://eips.ethereum.org/EIPS/eip-1344). */ getChainId(): bigint; /** * Sends a message with arbitrary data to a given address path. */ call(gasLimit: bigint, address: Address, value: bigint, data: Uint8Array): Promise; /** * Sends a message with arbitrary data to a given address path. */ authcall(gasLimit: bigint, address: Address, value: bigint, data: Uint8Array): Promise; /** * Message-call into this account with an alternative account's code. */ callCode(gasLimit: bigint, address: Address, value: bigint, data: Uint8Array): Promise; /** * Sends a message with arbitrary data to a given address path, but disallow * state modifications. This includes log, create, selfdestruct and call with * a non-zero value. */ callStatic(gasLimit: bigint, address: Address, value: bigint, data: Uint8Array): Promise; /** * Message-call into this account with an alternative account’s code, but * persisting the current values for sender and value. */ callDelegate(gasLimit: bigint, address: Address, value: bigint, data: Uint8Array): Promise; _baseCall(msg: Message): Promise; /** * Creates a new contract with a given value. */ create(gasLimit: bigint, value: bigint, data: Uint8Array, salt?: Uint8Array): Promise; /** * Creates a new contract with a given value. Generates * a deterministic address via CREATE2 rules. */ create2(gasLimit: bigint, value: bigint, data: Uint8Array, salt: Uint8Array): Promise; /** * Mark account for later deletion and give the remaining balance to the * specified beneficiary address. This will cause a trap and the * execution will be aborted immediately. * @param toAddress - Beneficiary address */ selfDestruct(toAddress: Address): Promise; _selfDestruct(toAddress: Address): Promise; /** * Creates a new log in the current environment. */ log(data: Uint8Array, numberOfTopics: number, topics: Uint8Array[]): void; private _getReturnCode; } //# sourceMappingURL=interpreter.d.ts.map