Skip to main content
5 votes

Why does mload(0x40) result in 0x20?

Your reasoning is correct, but only for values of type bytes32 or uint256. The next code will return 0x80 function mloadTest1() public pure returns(bytes32) { bytes32 a; assembly { a :=...
Alexey Smirnov's user avatar
4 votes
Accepted

Why does mload(0x40) result in 0x20?

Unlike value types like bytesN or uintN reference types (denoted by their memory, calldata or storage annotation) are merely pointers to their underlying data. When you use inline-assembly to set a ...
Philogy's user avatar
  • 627
4 votes

invalid opcode: opcode 0x5f not defined

Instead of going back to an older version of Solidity compiler, in hardhat to prevent use of PUSH0 you can try setting evmVersion to a previous version (e.g. paris, which is the one before shanghai) ...
SKYBITDEV3's user avatar
4 votes
Accepted

Beacon contract contructor seems to call address 0x02?

address(2) hosts a precompiled contract ( a "smart contract" that is actually blent in the VM) that computes the sha256 hash of a number sent to it as argument. Actually, address 1 to 9 are ...
Foxxxey's user avatar
  • 4,337
2 votes
Accepted

Determining if a smart contract is using delegatecall

The basic idea is that you're scanning for the DELEGATECALL (F4) opcode, to do that you have to find an f4 in your code that isnt data being pushed (You can push up to 32 bytes through the PUSH1-...
Foxxxey's user avatar
  • 4,337
2 votes
Accepted

What does FE stand for in "InvalidFEOpcode"?

FE stands for the INVALID opcode, which has the value 0xFE. From evm.codes: Equivalent to any other opcode not present in this reference, but guaranteed to remain an invalid instruction. Equivalent ...
Paul Razvan Berg's user avatar
2 votes
Accepted

How does opcode JUMP work in the EVM?

Yes, The JUMP instruction uses a value from the stack and alters the program counter, thus breaking the linear path of the execution to another point in the deployed code. The value of the counter in ...
Alexey Smirnov's user avatar
2 votes

OPCODES WHY DOES free memory pointer(0X40) use 0x80 as starting value?

First of all what exactly is a free memory pointer ? Free memory pointer points to a place where we can store whatever we want in memory right now meaning; we can store something right there in that ...
pv0's user avatar
  • 21
2 votes
Accepted

How do old smart contracts that contain certain opcodes behave when those opcodes get deprecated/removed in hard fork upgrades?

A contract that uses an opcode that is subsequently removed would no longer be working (its behavior would be unspecifiable). However, to my knowledge, no opcode has ever been removed from Ethereum. ...
Paul Razvan Berg's user avatar
1 vote
Accepted

What happens to opcodes during fork tests in foundry?

No, the opcodes and the associated gas are determined by the evm_version set in the foundry profile, regardless of the forked state.
smol-ninja's user avatar
1 vote

What's the difference between zkSync `system contracts` and EVM precompiles?

According to the zkSync AI Bot: The difference between zkSync system contracts and EVM precompiles lies in their roles and how they are integrated within the zkSync architecture: System Contracts: ...
Patrick Collins's user avatar
1 vote

what's the point of CODECOPY opcode

CODECOPY returns bytecode of a smart contract it could be a good functionality when you want to dynamically load and execute code from another contract. for example for creating upgradeable contracts, ...
Aref Riant's user avatar
1 vote

what's the point of CODECOPY opcode

A case, I can think of is during the contract deployment. It stores the runtime bytecode into memory and that bytecode is returned later. More details here - https://www.zaryabs.com/journey-of-smart-...
Zartaj Afser's user avatar
  • 4,474
1 vote

Is there a way to stop wallet homomorph attacks without ditching the create2 opcode?

Even without create2, people could still do address poisoning attacks...it would just be a little harder to generate the addresses but still not hard enough to make a difference.
user127148's user avatar
1 vote

How does the stack multiply a 32 byte number with a 1 byte number?

That is precisely because you have only 32 bytes, and the EVM manages overflows, removing the most significant bits in the result. The multiply operation is just an add operation you do multiple times....
Giuseppe Bertone's user avatar
1 vote
Accepted

Solidity - Function Selector Loading onto the stack: why DIV instead of SHR?

That is probably due to using non-updated documentation or tutorials, which refers to an old Solidity compiler. The procedure you mention using SHR has been in place as default for the compiler, with ...
Giuseppe Bertone's user avatar
1 vote

Run optimizer on opcodes

It is an interesting topic, but please consider the optimizations solc can apply on existing opcodes without the original Solidity or YUL code are probably limited. It's easier to find something about ...
Giuseppe Bertone's user avatar
1 vote
Accepted

Can I edit in the msg.sender value for the called contract?

In Solidity, it is not possible to directly set msg.sender in the called contract (DelegateContract) to a specific address like address one from EntryPointContract. The msg.sender is determined by the ...
Mehran Ra's user avatar
  • 590
1 vote
Accepted

Question about a function implementation in Ethereum Account Abstraction

From the eip-4337: https://eips.ethereum.org/EIPS/eip-4337#simulation The client(or bundler) simulated call performs the full validation before submitting on-chain, by calling: If initCode is present,...
Kritsada Dechawattana's user avatar
1 vote

Where is the return data from an external call stored?

It is not memory, stack nor storage. It is its own place inside the EVM implementation. It can only be accessed through RETURNDATASIZE and RETURNDATACOPY.
Ismael's user avatar
  • 30.5k
1 vote
Accepted

Where is the return data from an external call stored?

When a smart contract makes an external call to another smart contract or external function, the return data from that call is not directly stored within the calling smart contract's storage. Instead, ...
Joey Yi Zhao's user avatar
1 vote

Should all method hashes be found in a smart contract's opcodes?

Ok maybe this is glaringly obvious to most, but I have very little experience with machine/assembly/evm... I guess bc the method hash starts with '00' (2 zeros) that only 3 bytes are stored for the ...
jjordan's user avatar
  • 31
1 vote
Accepted

what does it mean "JUMPDEST occupies position 43"

I don't know what you mean by "Does that mean that JUMPDEST is located at the 43rd position in many opcodes", but what they are saying is that all the EVM instructions that make up the ...
Julissa DC's user avatar
  • 1,916

Only top scored, non community-wiki answers of a minimum length are eligible