Questions tagged [opcode]

operation codes specify the instructions to be performed in machine languages

Filter by
Sorted by
Tagged with
60
votes
2answers
22k views

What OPCODES are available for the Ethereum EVM?

The Ethereum virtual machine has a large number of operation codes and base level instruction sets. Is a complete listing available?
58
votes
5answers
18k views

How can you decompile a smart contract?

On the blockchain I can inspect the code of a contract, and see the EVM opcodes. Is there a way to decompile this and convert it back to (Solidity) source code?
38
votes
2answers
4k views

What's a precompiled contract and how are they different from native opcodes?

The Yellow Paper states: These are four so-called ‘precompiled’ contracts, meant as a preliminary piece of architecture that may later become native extensions. The four contracts in addresses ...
37
votes
2answers
15k views

Is there a table of EVM instructions and their gas costs?

The EVM instructions are in the yellow paper, or they are summed up in this answer. But their gas costs are not there. Where can I find a list of all instructions with their associated gas costs?
18
votes
2answers
1k views

What does bytecode of blank contract do?

When I compile a blank contract: contract A {} with solc --optimize --optimize-runs 300000 --opcodes test.sol I get: PUSH1 0x60 PUSH1 0x40 MSTORE PUSH1 0x6 DUP1 PUSH1 0x10 PUSH1 0x0 CODECOPY ...
14
votes
3answers
5k views

what is block.timestamp

In a function, does block.timestamp record the time the transaction was processed, or the time the block.timestamp computational step was processed? Is block.timestamp the time the transaction is ...
8
votes
1answer
840 views

Is the cost of updating storage different than the cost of adding to storage?

Do these have a separate cost? sstore(1, 10) # first time adding a value to storage with this key sstore(1, 20) # changing the value in storage. I looked for a list of gas costs / opcodes, and the ...
8
votes
1answer
1k views

Can a contract access the code of another contract?

Using web3.js, the EVM (bytecode) of a contract can be obtained by web3.eth.getCode(addressOfContract). Can this be performed by a contract using the address of another contract? If so, how? ...
8
votes
1answer
720 views

Are linkable ring signatures available in Ethereum?

Are transactions with ring signatures available in Ethereum? There should be as anonymity/fungibility is important. Also, I think Vitalk Buterin mentioned it may be possible to implement an EVM ...
8
votes
1answer
618 views

What are the two arguments to a RETURN opcode?

The RETURN opcode in the EVM takes 2 arguments(ie, consumes two elements from the stack), but what do they represent? I tried to understand the yellow paper describing them, but I don't understand the ...
8
votes
1answer
237 views

When does a SUICIDE opcode becomes effective?

The documentation (https://github.com/ethereum/wiki/wiki/Subtleties) states that SUICIDE becomes effective at the end of the transaction, but in block 116525, the same contract was able to SUICIDE ...
7
votes
1answer
253 views

Why a contract with only one variable produces lots of EVM code?

Why does a 'void' contract we have a long bytecode with many duplicated opcodes? For instance, the following contract: pragma solidity ^0.4.0; contract A { string s="s"; } will be translated ...
6
votes
1answer
1k views

why is the EVM stack limited to 1024?

Here you can see that if the EVM stack gets larger than 1024, it results in an error: Why is there this hard limit on the stack size? What is the justification for this not being parametrizable? ...
5
votes
1answer
188 views

Are new Opcodes approved in EIP's implemented in Solidity before they are introduced in a hardfork?

REVERT, STATICCALL, RETURNDATASIZE and RETURNDATACOPY are all approved and pending the next Ethereum hardfork as specified here However, the Solidity changelogs shows all 4 of these opcodes entering ...
5
votes
1answer
509 views

What are the reasons behind jumpdest?

I know, the practical reasons behind it is just to add additional security layer. But why does EVM even need it? Asm doesn't have it and works great.
5
votes
1answer
418 views

Can a contract fetch the global block gas limit?

The OPCODE GASLIMIT gets the block's gas limit. Could in-line assembly, uint gasLimit; assembly { gasLimit := gaslimit } fetch the gas limit ? contract B { function ...
4
votes
3answers
1k views

Understanding solidity inline assembly code

Here is a code from solidity documentation: function sumAsm(uint[] _data) public returns (uint o_sum) { for (uint i = 0; i < _data.length; ++i) { assembly { ...
4
votes
2answers
798 views

How to separate functions in evm bytecode?

I want to build the control-flow-graph (CFG) from the bytecode of a smart-contract (assuming it is obtained by compiling a Solidity source file). This CFG should also distinguish the different methods ...
4
votes
1answer
458 views

Why does PUSH1 0x60 PUSH1 x40 MSTORE store 0x60 at memory location 0x50 (and not 0x40)?

According to browser solidity, after executing 000 PUSH1 60 002 PUSH1 40 004 MSTORE Memory is: 0x00: 00000000000000000000000000000000 ???????????????? 0x10: 00000000000000000000000000000000 ?????...
4
votes
1answer
198 views

How are storage pointers implemented in the EVM layer?

I'm trying to understand how storage pointers work. From looking at the ethereumjs-vm implementation it seems that the actual value is returned from SLOAD. Does the compiler handle the 'pointer' ...
4
votes
1answer
528 views

Why are there missing opcodes when using the disassembler on bytecode from the blockchain?

I'm using the disassembler from go-ethereum repo which fails on about 20% of the bytecode from the blockchain with missing/unknown opcodes. The disassembler on Etherscan fails as well. Is there an ...
4
votes
2answers
416 views

Ethereum opcode: meaning of first few instructions?

Looking at the opcode level, the first few instructions of any smart contracts start with this: push1 80 push1 40 mstore I understand that this saves 0x80 to address 0x40, but what is this all for? ...
4
votes
3answers
629 views

Can a transaction have a negative fee?

I know there are some opcodes that have negative gas costs (see this). So if I send a transaction that calls one (or multiple) instance(s) of these opcodes, will the gas used be negative? i.e. will my ...
4
votes
1answer
475 views

Why does the init code of a contract change for Solidity > 0.4.5?

I have a simple empty contract: contract test { } That I compile on Remix using different versions. I notice that the compiled output is getting more and more complex with later compiler versions: ...
4
votes
1answer
53 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 ...
4
votes
3answers
400 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])) ...
3
votes
2answers
972 views

Solidity 0.6.0 address(this).balance throws error invalid opcode

Whenever I try to execute a function that uses address(this).balance I get an invalid opcode error. It compiles fine using 0.6.0. Using truffle debug I get the following error: Transaction halted ...
3
votes
1answer
839 views

CREATE opcode: what does it really do?

I am looking at the docs, but cannot really understand what CREATE opcode does. I can tell that CREATE does create a new smart contract from a memory chunk, pass the gas value to this new contract, ...
3
votes
2answers
395 views

How can we implement a new opcode in the Ethereum Virtual Machine.

How can we implement a new opcode in the Ethereum Virtual Machine. For eg : I want to implement an opcode logic such that the opcode number of this operation is 0x21. The EVM-implementation I am using ...
3
votes
2answers
390 views

EVM SIGNEXTEND Opcode explanation

I am trying to develop my own small EVM. That is a good way for me to learn more about the bytelevel. I hadn't had any problems with most of the instructions, but there are a few, which I just don't ...
3
votes
1answer
642 views

does the command `evm --debug --code OPCODES` still work?

I've been trying to run this command evm --debug --code 600580600b6000396000f36005600401, and some associated permutations of it, such as: evm --debug --code ...
3
votes
1answer
300 views

evaluation of execution speeds for various opcodes in EVM

Using traceTransaction we can get the following data: debug.traceTransaction("0x0cec118d22fbd572bf25c7e4143919e608989bec7da08512f2a6f3171df3b3b8") { gas: 104030, returnValue: "...
3
votes
1answer
621 views

Why doesn't bytecode match the opcodes on Etherscan?

I'm just going through the first few opcodes on this contract: https://etherscan.io/address/0xab7c74abc0c4d48d1bdad5dcb26153fc8780f83e#code. Which are (according to the opcodes view): PUSH1 0x60 ...
3
votes
2answers
513 views

Can the CALL opcode be used to create a contract?

The Yellow Paper Appendix H defines the CREATE and CALL opcodes. For CALL: the operand order is: gas, to, value, in offset, in size, out offset, out size. By setting the second operand (the "to"...
3
votes
1answer
476 views

Ethereum Ddos attack

I have a background in security, so i try to understand what is hapeneing to Ethereum project. Recently, i heard that Ethereum will make a fork to stop the Ddos attack. here i want to know how the ...
3
votes
1answer
777 views

Ethereum's Storage: is SSTORE updates only at the post-transaction state?

I'm trying to figure out from Ethereum's yellow paper (Homestead edition) how does its storage model works (NOT memory model). It seems that the storage is updated only once, after a transaction is ...
3
votes
1answer
69 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 ...
2
votes
1answer
106 views

Parameters on evm opcode create

Why the usual way to create a contract with evm opcodes use add and mload, for example: bytes memory bytecode = hex"600580600c6000396000b800602a600052b8"; ... assembly { _address := ...
2
votes
1answer
2k views

Where are the opcode 0xfe and 0xfd documented?

The Solidity documentation has the following: Internally, Solidity performs a revert operation (instruction 0xfd) for a require-style exception and executes an invalid operation (instruction ...
2
votes
2answers
1k views

Recursive call ends with `VM Exception: invalid opcode`

I am running f: contract Test { function f() { f(); } } which produces VM Exception: invalid opcode in browser-solidity. Is that a bug or expected behavior?
2
votes
1answer
116 views

Efficient, safe pow using EXP opcode

I recently stumbled across ds-math's rpow() being a O(lg n) safe implementation of exponentiation. Such a function is ultimately created because the EVM EXP opcode is unsafe wrt. overflows. The ...
2
votes
3answers
908 views

Updated list of EVM Opcodes

Is there an updated Opcode Specifications available for the EVM to date? Specifically, is there a continuously updated list of Opcode Specifications similar to that found in the ethereum yellow paper?...
2
votes
1answer
741 views

EVM opcodes-prices

1) Why are opcodes in Ethereum priced the way they are priced and why is the EVM so expensive? 2) Right upfront, I do not say that it is too expensive to perform a tx on Ethereum, I just say that ...
2
votes
1answer
138 views

Are makeLog instruction functions opcodes or not?

The following code snippet is a constituent piece of the instructions.go file, where our lieblings opCodes all live. // make log instruction function func makeLog(size int) executionFunc { ...
2
votes
1answer
765 views

how are conditional JUMPI opcodes valid?

I've been reading this example from https://github.com/comaeio/porosity/wiki/Ethereum-Internals And I am wondering how some of these JUMPI operations are valid: loc_00000000: 0x00000000 60 60 ...
2
votes
2answers
271 views

CALL instruction push GAS to stack?

According to https://ethervm.io, when CALL instruction is executed, the stack layout like this: [address, value, argOffset, argLen, retOffset, retLen] So CALL would pop 6 words from stack bottom to ...
2
votes
1answer
234 views

Why does the EVM program counter not increase by one but by two in PUSH1 opcode?

In the tutorial here, the program counter increases by 2 for a PUSH1 opcode. Then it increases by 1 for other opcodes. Why is this? Does it have to do with the opcodes size in memory? Aren't they all ...
2
votes
1answer
218 views

geth console flag/option to output all opcodes executed in call to contract or function invocation

What I'd like to do is analyze all the opcodes that are executed when I call a contract, or call a function from a contract. According to my understanding, this computation would happen on my own ...
2
votes
1answer
408 views

Is there any available sandbox for Ethereum's OPCODES?

In case of Bitcoin, there are few tools, which allow you to play with Script OPCODES - one, two. So, is there any handy way to simulate / debug Ethereum's OPCODES execution?
2
votes
1answer
87 views

Missing create2 opcode in ethereum yellow paper

In eip 1014 Vitalik added Create2 at opcode 0xf5 Adds a new opcode at 0xf5 But in ethereum yellow paper opcode i don't see opcode 0xf5 or any create2 opcode, it doesn't appear in https://www....