Questions tagged [opcode]

operation codes specify the instructions to be performed in machine languages

39 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
4 votes
0 answers
560 views

Solidity sourceMap and opcodes. No map entries for every code?

After compiling a simple contract, the output are these values: "opcodes": "PUSH1 0x80 PUSH1 0x40 MSTORE CALLVALUE DUP1 ISZERO PUSH1 0xF JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP ...
Juan Ignacio Pérez Sacristán's user avatar
4 votes
1 answer
314 views

Why Yul doesn't have the else block?

The yul documentation states: No “else” block can be defined. It seems really weird. Yul has much more complex control flow schemes like loops and switches. Also other EVM languages like Solidity ...
CodeSandwich's user avatar
4 votes
3 answers
1k views

How to deploy contract with bytecode from etherscan?

For example, I want to deploy a contract to my local testnet. But I only have its opcode from etherscan. How to deploy the contract with just those runtime bytecode?
user avatar
4 votes
3 answers
671 views

convert bytes to uint8[8] using mstore()

I know how to convert bytes to uint8[8] using mload but mstore seemed like it could be more gas efficient. Is something like this possible? function bytesToUintArray(bytes input) returns (uint8[8])) ...
antevirus's user avatar
3 votes
2 answers
146 views

Remix Assembly vs. Solidity Compiler Assembly

I am just diving into EVM assembly and am a little confused about the following. I have the following simple contract: pragma solidity >=0.8.1; contract MyTest {} When I compile it using Remix, I ...
Sebastian Dine's user avatar
3 votes
0 answers
48 views

Why does a STORAGEADD op (SSTORE) add 80 bytes to state rather than 32?

According to this spreadsheet that Vitalik has referenced before, stating that it's what they used to determine gas fees for each opcode, a STORAGEADD opcode (presumably renamed to SSTORE) is ...
Paul DeLucia's user avatar
2 votes
0 answers
255 views

Is there a way to call a function via a selector from within a contract?

In the case of calling a function with signature foo(uint256) from contract A, I could use this construction in solidity: address(A).call(abi.encodeWithSignature("foo(uint256)", 100)); // or ...
Marlo's user avatar
  • 329
2 votes
0 answers
182 views

Understanding the relationship between opcodes and the number of semicolons in source maps

Contract Take the following contract: // SPDX-License-Identifier: Unlicense pragma solidity >=0.8.4; contract Adder { function add(uint256 x, uint256 y) external pure returns (uint256 z) { ...
Paul Razvan Berg's user avatar
2 votes
0 answers
51 views

How does addition look like at the opcode level in Solidity v0.8 and above?

In Solidity v0.7 and below, addition was a simple opcode: ADD Which cost 3 gas units and didn't handle overflows, silently returning the overflown value. But Solidity v0.8 made addition overflow-safe....
Paul Razvan Berg's user avatar
2 votes
2 answers
171 views

Why return to String need so many operations when develop a smart contract?

I found a smart contract. The address is '0x2fabe69843e9a74a35b89145cb52e5568986c7a1'. I am really confused about is that why it need over 3000 lines Opcode to when Created this smart contract? Like ...
Gabriel Mike's user avatar
2 votes
0 answers
337 views

Is it possible to get compiler version from the bytecode and smart contract code?

The problem is that I have deployed some contract on the etherscan.io some time ago. Now I want to verify it, so I need to specify: Smart contract code Compiler version ABI encoded constructor ...
Sergey Potekhin's user avatar
2 votes
0 answers
226 views

analysis of the opcodes used in smart contract execution on ropsten, geth

I've deployed the following verified smart-contract to ropsten: contract Incrementer { uint iteration; function Incrementer() { iteration = 0; } function increment(uint ...
smatthewenglish's user avatar
2 votes
0 answers
153 views

Possible to create new contract via a proposal in the ethereum.org/dao framework?

Is it possible to deploy contracts from within contracts, using something like p.recipient.call.value(p.amount * 1 ether)(bytecode); This article says so, https://blog.ethereum.org/2015/12/04/...
dor's user avatar
  • 91
1 vote
0 answers
32 views

Hardhat: setPrevRandao does not work

I'm trying to simulate prevrandao but it does not work out. To check it, I've written a contract and a test. contracts/AnotherContract.sol // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.9;...
unegare's user avatar
  • 21
1 vote
0 answers
81 views

Which contract's storage does SLOAD/SSTORE use?

A given SSTORE and SLOAD instruction uses storage from a certain smart contract. How can we know which contract that is, and do we need any additional data than the raw struct/opcode traces to find ...
Vegard Stikbakke's user avatar
1 vote
1 answer
213 views

EOA transfer and OPCODEs

I'm doing some research on how the transactions are made in Ethereum. I got reading the code of Geth and the Yellow Paper that a Smart Contract method call with a value on the payload will transfer ...
dbp's user avatar
  • 11
1 vote
1 answer
92 views

Vyper - Why is my first memory variable placed with an offset of 0x40 (64 bytes) instead of 0x20 (32 bytes) or even 0x00 (no offset)?

I have a vyper contract, as such: @external def add_two(my_number: uint256) -> uint256: two: uint256 = 123456 return my_number + two When you compile this (with 0.3.6), a piece of the ...
Patrick Collins's user avatar
1 vote
0 answers
41 views

Why does SudoSwap using opcode create not create2 to create a pair contract?

SudoSwap contract lib LSSVMPairCloner.sol source code: https://github.com/sudoswap/lssvm/blob/main/src/lib/LSSVMPairCloner.sol I don't understand why using opcode create not create2 to create a ...
Ted Zhu's user avatar
  • 11
1 vote
1 answer
338 views

What do the retOffset and retSize parameters of the CALL opcode do?

When reading the data returned by CALLing another contract, RETURNDATASIZE and RETURNDATACOPY opcodes are used. They allow moving the data from an otherwise unreachable context to the memory, so it ...
CodeSandwich's user avatar
1 vote
0 answers
62 views

Jump within verbatim block with label

I want to inject verbatim block to my yul contract. My verbatim block is a function, I need to implement if block, to be able to implement it, I need to have ability to use labels, I need to point to ...
GDocal's user avatar
  • 111
1 vote
1 answer
111 views

What settings should a private PoA blockchain have to be free to use? ( No ether in use )

I am a total noob in creating blockchains, and I am trying to make one using geth with PoA. I want to make a PoA private blockchain where transactions and smart contracts ( usage and deployments ) are ...
MrFrenzoid's user avatar
1 vote
0 answers
62 views

How are blocks processed while syncing Ethereum blockchain full sync mode?

I am syncing a Geth client in full sync mode and also have made some changes in the client to log the execution time , time stamp and block number of all the opcodes executed in the Ethereum virtual ...
Proton's user avatar
  • 155
1 vote
1 answer
144 views

How do I send funds from a contract to an account using bytecode?

The instruction CREATE will send funds to a new account. Is there another instruction for sending funds to an account that already exists? Or I just have to use CREATE as if the account doesn't exist?
alandefreitas's user avatar
1 vote
0 answers
66 views

Why JUMP opcode costs more than the rest

Looking here, most of the basic opcodes are 3 while JUMP is 8. Wondering why this is, why the 3x multiplier on this instruction.
user10869858's user avatar
1 vote
0 answers
39 views

Code scope in evm

Short question, how is code scope defined/determined by the compiler when looking at EVM opcodes (or rather bitcode)? Is it simply by looking out for jump calls or return statements? Or does it define ...
Theko Lekena's user avatar
0 votes
0 answers
8 views

Why remaining gas increase after some opcodes

I use debug api of go ethereum to get traces of transactions. The api document shows that field gas represents the amount of gas remaining in the transaction at the current step of execution and field ...
Zoey's user avatar
  • 1
0 votes
1 answer
21 views

Reliably disassamble bytecode to opcodes across various evm versions

Is there a reliable way of disassembling bytecode into opcodes across different EVM versions, to make it agnostic to the EVM version used during compilation? As the second best option - is there a ...
Stas Buzuluk's user avatar
0 votes
1 answer
155 views

Invalid OpCode while deploying "HelloWorld"

I'm receiving the following error message trying to deploy a very simple contract to Ganache. How can I resolve this? Contract: pragma solidity ^0.8.21; // ^0.4.24; contract HelloWorld { string ...
Mark P's user avatar
  • 1
0 votes
1 answer
24 views

EVM opcodes for Boolean AND operations

What opcodes does the EVM use in performing boolean AND (&&) operations
Emmanuel Anah's user avatar
0 votes
1 answer
155 views

Inline Assembly: RETURN opcode can't not work. Failed to decode output

I know that: return(p, s): end execution, return data mem[p…(p+s)). I want to return something in memory but not a multiple of bytes32. For example, I want to return 1 byte: pragma solidity 0.8.20; ...
LEVI_104's user avatar
0 votes
0 answers
34 views

Is there a way to calculate all the gas used in a transaction from within a smart contract?

If I use gasleft() and the beginning and end of the function then I only capture the amount of gas used between those two points. Is there a way to capture all of the gas used then to multiply that ...
Nat's user avatar
  • 279
0 votes
1 answer
382 views

OPCODES How is work "CODECOPY"?

Somebody could explain how CODECOPY works in practice ? There is only one sample in evm.playground but I dont understand above-mentioned sample. Could you give me another concrete sample (with ...
Engin YILMAZ's user avatar
0 votes
0 answers
96 views

Difference in Control Flow Graph (CFG) of bytecode having vulnerability and after fixing the vulnerability in Ethereum smart contract?

I was analyzing the Control Flow Graph (CFG) extraction from ByteCode by EtherSolve and then thought about an interesting question, how CFG of vulnerable smart contract gets changed after fixing this ...
Rue Lawliet's user avatar
0 votes
0 answers
42 views

Under which condition "CALL" opcode does not increase the depth?

I'm currently researching EVM opcode trace data(data fetched from "debug_traceTransaction"), and I meet several cases where the opcode "CALL" does not increase the depth. I already ...
Jeff Chen's user avatar
0 votes
0 answers
2k views

I am getting "invalid opcode: INVALID" as error when i try to return an array of structures

I am getting error as ValueError: invalid opcode: INVALID. Is it because of use of memory and storage keyword in the function or is it because i can't return an array. My Solidity Code:- struct ...
Deepak Lohmod's user avatar
0 votes
0 answers
195 views

invalid opcode error

I would like to set array contents using data present in another one. I'm tring to use the function below but got opcode error. Can anyone explain me why? function getfreecars() public returns(uint) { ...
Gabriele's user avatar
0 votes
0 answers
40 views

What is the OP_CODE for getting another account (storage and/or code)?

I'm debugging solidity opcode by opcode. How do I tell when the compiler is referencing another smart contract through OpCode? I know that you can do this in Browser Solidity. However I would just ...
nick carraway's user avatar
0 votes
2 answers
58 views

Are current ethereum opcodes prices in pyethereum updated?

I am not an expert in opcodes for Ethereum, but I am wondering if their prices here [https://github.com/ethereum/pyethereum/blob/develop/ethereum/opcodes.py] are updated as the latest version used by ...
MWH's user avatar
  • 363
0 votes
0 answers
344 views

log output of modified function to geth console

To analyze the execution time of different opcodes I've created the following modifications to the go-ethereum file instructions.go: func opAdd(pc *uint64, evm *EVM, contract *Contract, memory *...
smatthewenglish's user avatar