Questions tagged [opcode]
operation codes specify the instructions to be performed in machine languages
97
questions
0
votes
2answers
106 views
How to code ADDRESS using opcodes in a solidity function?
Reference - http://solidity.readthedocs.io/en/develop/assembly.html
Objective - example of a function returning the contract address.
Code -
pragma solidity ^0.4.18;
contract d4{
function ...
4
votes
3answers
386 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])) ...
0
votes
1answer
684 views
Transaction Error. Exception thrown in contract code. REVERT opcode when sending ETH to crowdsale
I wanted to follow the tutorial - https://blog.zeppelin.solutions/how-to-create-token-and-initial-coin-offering-contracts-using-truffle-openzeppelin-1b7a5dae99b6 - but there was a new release - https:/...
1
vote
1answer
181 views
Why is a state-modifying function working from Truffle console, but not when calling from web3?
I have a contract which offers two functions:
1) A state modifying function which takes two parameters
2) A constant function
I have a web frontend in React calling these functions. When I call the ...
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 {
...
5
votes
1answer
476 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.
0
votes
2answers
348 views
Why is using `<address>.callcode()` discouraged in Solidity?
The Solidity document says
Note
The use of callcode is discouraged and will be removed in the future.
But in what reason is using <address>.callcode() discouraged?
Is using CALLCODE ...
2
votes
0answers
137 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 ...
0
votes
2answers
282 views
Why does an Oraclize contract deployed with Remix JavaScript VM gives an “invalid opcode error” and not on main/testnet?
Why does an Oraclize contract deployed with Remix JavaScript VM gives an "invalid opcode error" and not on main/testnet?
I have thought why the Remix JavaScript VM reports the error:
Exception ...
4
votes
1answer
445 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 ?????...
2
votes
1answer
137 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 {
...
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?
...
3
votes
1answer
633 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 ...
2
votes
1answer
224 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 ...
1
vote
2answers
160 views
filter to restrict output of opcode data only to contracts/functions called by local node
Having modified the instructions.go file in geth I'm able to see the execution time of individual opcodes, it looks like this:
My interpretation of that output is that it represents the execution of ...
0
votes
0answers
320 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 *...
5
votes
1answer
185 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 ...
3
votes
1answer
289 views
evaluation of execution speeds for various opcodes in EVM
Using traceTransaction we can get the following data:
debug.traceTransaction("0x0cec118d22fbd572bf25c7e4143919e608989bec7da08512f2a6f3171df3b3b8")
{
gas: 104030,
returnValue: "...
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
0answers
213 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 ...
3
votes
1answer
609 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
...
4
votes
1answer
425 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:
...
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 ...
4
votes
3answers
569 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 ...
2
votes
1answer
744 views
Internal message call CALL opcode
I am trying to make sense of a contacts internal messaging. The contract is sending 6.6 ether to the address that invoked the contract. From what I understand, the CALL opcode carries out a ...
3
votes
2answers
503 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"...
34
votes
2answers
13k 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?
5
votes
1answer
408 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 ...
13
votes
3answers
4k 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 ...
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 ...
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
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?
3
votes
1answer
474 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 ...
6
votes
1answer
587 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 ...
3
votes
1answer
758 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 ...
1
vote
2answers
343 views
Create a contract at a defined address?
Is it possible to define a smart contract at a predictable address?
0xf0 CREATE in the Yellow Paper suggests that the address is deterministically determined by
x = A(Ia, σ[Ia]n)
page 29 of http://...
2
votes
0answers
142 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/...
4
votes
1answer
522 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 ...
8
votes
1answer
231 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 ...
8
votes
1answer
775 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 ...
2
votes
0answers
80 views
Is there a decompiler for the binary data in the blockchain [duplicate]
I want to know if there is a decompiler for the binary data in the blockchain, I want to know about the details of my contract after it was uploaded to the blockchain?
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 ...
8
votes
1answer
990 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
703 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 ...
37
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 ...
57
votes
5answers
16k 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?
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?