Questions tagged [opcode]

operation codes specify the instructions to be performed in machine languages

Filter by
Sorted by
Tagged with
4 votes
1 answer
53 views

What are the first 128 bytes in solidity memory reserved for?

In most solidity contracts, the first few opcodes generate the free memory pointer PUSH1 0x80 PUSH1 0x40 MSTORE This places the 0x80 value (128) at location 0x40 in memory. So, why don't we start ...
1 vote
1 answer
29 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 ...
0 votes
1 answer
16 views

Why is memory used by RETURN misaligned compared to how it was allocated?

I am experimenting with evmone and evmc to execute some simple assembly code snippets on EVM. I wrote a test that is supposed to return 0x42 as output data. The code goes as follows: PUSH 0x42 PUSH ...
  • 103
0 votes
0 answers
24 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 ...
0 votes
0 answers
21 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 ...
0 votes
1 answer
18 views

Ethernaut Challenge Magicnumber

This my OPCODE: INIT: PUSH 0x0a(10 OPCODES=10 bytes) = 600a PUSH 0x0c = 600c PUSH 0x00 = 6000 CODECOPY - Where, current location of runtime code, size of runtime code = ...
2 votes
1 answer
39 views

Why and When To Use uint8 instead of uint?

As far as I know uint8 costs more gas than uint256 (or uint they are same). Let's say my variable can't be bigger than 100, and I already check for it with an if statement. I saw many examples of ...
  • 304
1 vote
1 answer
32 views

is OPCODE applicable for sending ethers from wallet to another account?

I know smart contracts are converted to bytecodes and they are executing OPCODES in the EVM. But I want to know, what OPCODES does Wallet to wallet transactions have?
  • 82
1 vote
0 answers
21 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 ...
  • 11
6 votes
1 answer
344 views

Why is there a `LOG` opcode being created from my solidity code when I don't have any events?

I have the following solidity code: // SPDX-License-Identifier: MIT pragma solidity 0.8.15; contract SSimpleStorage { uint256 storedNumber; function storeNumber(uint256 newNumber) external { ...
1 vote
1 answer
35 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 ...
3 votes
1 answer
156 views

Is the `indexed` keyword for a Solidity event no longer necessary because of subgraphs?

Context: The indexed keyword is used for Event fields when we want them to be easily searchable using the JSON-RPC method eth_newFilter. This was the best way to offchain index the interactions with ...
  • 566
1 vote
1 answer
65 views

Is it possible to get the revert reason during CREATE?

I'm trying to return the revert reason of a revert that is triggered during a CREATE opcode. I'm currently using function deployCode(bytes memory bytecode) internal returns (address payable addr) {...
  • 1,359
0 votes
0 answers
53 views

Contract initialization opcodes

Every contract I compile starts with the following opcodes: Is this just a design choice by Solidity, or a "rule" in Ethereum? Otherwise it seems like every time the EVM starts up, it would ...
0 votes
1 answer
73 views

Why dedicated ADDMOD opcode?

Is the ADDMOD that commonly used that we needed to create a specific opcode for it? Why couldn't we simply use the ADD opcode + the MOD opcode together? The same question is also valid for the MULMOD ...
0 votes
0 answers
10 views

Completely disregarding all storage costs, is compute time a sufficient metric to determine the computational cost of an opcode operation?

Completely disregarding all storage costs, is compute time a sufficient metric to determine the computational cost of an opcode operation? Or are/is there some other factor(s) that need to be ...
3 votes
0 answers
27 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 ...
1 vote
1 answer
55 views

Opcode LOG3 Data Value Problem

I am trying to get the Event data from LOG3 but the data sometimes on stack5 and sometimes on stack6, can anyone help? for example, transfer amount = 1 of both two transfer functions, take a look at ...
  • 13
1 vote
0 answers
22 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 ...
  • 11
0 votes
0 answers
644 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 ...
1 vote
0 answers
49 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 ...
1 vote
0 answers
120 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 ...
  • 229
1 vote
1 answer
290 views

How to get opcode trace of failed transaction without solidity source?

tldr: want to run simulated transactions against deployed bytecode on rinkeby that has no verified solidity source, and step through opcodes and view stack/memory leading up to revert. To clairfy: in ...
0 votes
0 answers
18 views

Create and Create2 opcode in EVM [duplicate]

What is the difference between CREATE and CREATE2 opcode present in Ethereum Virtual Machine(EVM)? and How do they work?
  • 11
1 vote
0 answers
42 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 ...
  • 155
0 votes
1 answer
138 views

Using assembly to store more values per word

I need to store 1250 numbers 16 bits elements in an array. Storing unit256 cost 20.000 gas units each (SSTORE opcode), which at 200gwei gas price, will cost around 4.5 ETH. My understanding is that I ...
  • 103
0 votes
1 answer
199 views

Why does changing a storage slot's value from zero to non-zero cost more than non-zero to non-zero in the sstore opcode?

Why does changing a storage slot's value from zero to non-zero cost more than changing from non-zero to non-zero, zero to zero, or non-zero to zero?
1 vote
1 answer
216 views

Why do Etherscan's opcode view and opcode disassembler show different opcodes for the USDT contract?

We have USDT smart contract, which is located at 0xdac17f958d2ee523a2206206994597c13d831ec7. I am trying to decompile the smart contract (at least view it as at opcodes). What I see is that it begins ...
  • 123
1 vote
1 answer
473 views

Is the source code of any Ethereum smart necessarily contract open?

I thought that any smart contract had open code. However, from time to time I'll encounter smart contracts that have no publicly available Solidiy code, on etherscan. How can this be? Doesn't that ...
1 vote
1 answer
304 views

Is there a size limitation on create2 bytecode field?

I have the following method in my Solidity contract. function deploy(bytes memory bytecode, uint _salt) public payable returns (address){ address addr; assembly { addr := create2( ...
  • 13
2 votes
1 answer
892 views

Solidity shr opcode

What does this code mean? sender := shr(96, calldataload(sub(calldatasize(), 20))) Btw sender is an address variable.
0 votes
1 answer
194 views

SLOAD opcode working in ethereum virtual machine

How SLOAD opcode works in ethereum virtual machine and why it is one of the most computationally expensive and time consuming process. vm stats for different opcodes of evm
  • 155
1 vote
0 answers
96 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) { ...
0 votes
1 answer
253 views

How to read the current program counter (PC) in Solidity or Yul?

I was reading about the EVM dialect in the docs, and saw this: Instruction Explanation pc() Current position in code I went to Remix to try it out: function read_pc() external view returns (uint256 ...
3 votes
2 answers
2k views

does using external over public in a library reduce any gas costs?

I have a library utils.sol library Utils { struct UtilType { unit var1; bool var2; } function addExtra(UtilType storage state, uint extra) public { state.var1 += extra; } } ...
0 votes
2 answers
321 views

Where do I find the solidity provisions of Ethereum OPCODEs?

There is Solidity Cheat Sheet: https://github.com/manojpramesh/solidity-cheatsheet There is OPCODEs list: https://github.com/crytic/evm-opcodes But is there any list that show opcode's solidity code ...
3 votes
0 answers
326 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 ...
1 vote
1 answer
49 views

Is optimization in Remix worth the risk of bugs?

Is the future gas savings for users worth the risk of bugs? In other words, is optimization worth it when launching a token using Remix? Tether has had 112 million transfers...https://etherscan.io/...
0 votes
1 answer
240 views

How to clone(fork) a smart contract with only bytecodes deployed on etherscan.io (without abi and source code)? [duplicate]

How to clone(fork) a smart contract with only bytecodes deployed on etherscan.io (without abi and source code)? First, I try to submit the same bytecodes from etherscan.io using web3, but it failed. ...
2 votes
1 answer
161 views

BSC Op Code Costs

Where can I find the current cost of gas for each OP Code on the Binance Smart Chain? Is the gas per opcode always going to be the same as Ethereum? I'm specfically trying to figure out how much gas ...
  • 131
2 votes
0 answers
40 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....
3 votes
1 answer
440 views

Adding new custom opcode to solidity

I have a problem with adding new opcode to solidity. I'm using solc (on C++) and geth(ethereum on Go). I want to add new opcode, that takes address payable, uint256, uint256, bytes memory and returns ...
1 vote
1 answer
273 views

another "invalid opcode" error

I am stuck on this little problem in my chat app smart contract(this is only the faulty piece of code) contract ChatApp { struct user{ bool acceptReq; uint nreq; ...
  • 51
0 votes
0 answers
133 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) { ...
1 vote
1 answer
342 views

Remix (or any other tool): Solidity program to EVM opcode

I am interested in obtaining sequence of opcodes for a Solidity program: One example is given in the following program obtained from Link of paper I have attached the image also I need a link to a ...
  • 1,328
14 votes
2 answers
4k views

What is the difference between the STATICCALL and CALL EVM opcodes?

Besides the regular and very common CALL, the Ethereum Virtual Machine has the STATICCALL opcode. In which ways does it differ from the regular CALL? Edit: This is not a duplicate because this ...
  • 9,557
4 votes
1 answer
114 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 ...
4 votes
1 answer
564 views

How to implement the CREATE2 in Python

I'd like to know either how to implement the skinny CREATE2 in Python or a package that provides it. This is the function I'm trying to port from TypeScript to Python. It calls generateAddress2 with ...
0 votes
1 answer
36 views

Do different clients use different amounts of gas?

I'm trying to understand clients/nodes a bit can someone help clarify the below for me. My understanding is that each client implements the EVM in their own way. Smart contracts are written in ...
  • 145
5 votes
1 answer
512 views

Copy and deploy a smart contract from opcodes without source code

I extracted opcodes from an already existing and deployed smart contract and I would like to know if it is possible to deploy an exact copy of this contract from its opcodes? My extracted opcodes ...
  • 51