Let's see which opcode we need to test it
About EIP-3855(PUSH0)
Let’s try to verify all of the above-mentioned details about PUSH0
opcode with an example and see if it actually does the magic. 🪄
We will take this small contract for example,
contract PushZero_Test{
uint256 public num;
function set(uint256 _n) public{
num = _n;
}
}
Then, let’s Compile and Deploy this contract:
First, use older versions like 0.8.19 or 0.8.16, etc.
Then using the latest version, 0.8.20.
Contract Code Size
608060405234801561001057600080fd5b5060b18061001f6000396000f3fe6080604052348015600f57600080fd5b506004361060325760003560e01c80634e70b1dc14603757806360fe47b1146051575b600080fd5b603f60005481565b60405190815260200160405180910390f35b6061605c3660046063565b600055565b005b600060208284031215607457600080fd5b503591905056fea264697066735822122012c9c28a3afc19fc4abcdf6f9ad630831905962e9230729b065886c3b506f53564736f6c63430008130033
➡️ Contract bytecode size using older version = ~678 characters
6080604052348015600e575f80fd5b5060aa8061001b5f395ff3fe6080604052348015600e575f80fd5b50600436106030575f3560e01c80634e70b1dc14603457806360fe47b114604d575b5f80fd5b603b5f5481565b60405190815260200160405180910390f35b605c6058366004605e565b5f55565b005b5f60208284031215606d575f80fd5b503591905056fea26469706673582212205ee59545aaece46407d5982db44b8260dfa4e7227c4837321575367f34ef827864736f6c63430008140033
➡️ Contract bytecode size using 0.8.20 versions = ~646 characters
Deployment Gas Cost ⛽️
https://devnet.blocksscan.io/txs/0xc6a1f83325c8749115f45cf42f35e16a58452d57881eaad00fdf2e8d805651a2
➡️ Contract Deployment cost using older versions = ~61511 gas
https://devnet.blocksscan.io/txs/0xf87590988d34a24db47a045a70d567fb1168697b35d0739895496784c07f6fdd
➡️ Contract Deployment cost using 0.8.20 versions = ~58909 gas
As a result of this short experiment, we can clearly verify that with the inclusion of PUSH0
opcode, we now have:
Reduced contract code size, and
Reduced contract deployment gas cost
Hmmm, the opcode does its magic well. 🧐
Important Warning for Solidity Devs
If don't support PUSH0 opcode
And you might get an error that looks something like this 👇
About EIP-3198(BASEFEE)
I deployed the smart contract about this code
pragma solidity =0.8.20;
contract TestPush0 {
function getBaseFee()
external
view
returns (uint256 number, uint256 basefee)
{
return (block.number, block.basefee);
}
function getRandom()
external
view
returns (uint256 number, uint256 basefee)
{
return (block.number, block.prevrandao);
}
}
https://devnet.blocksscan.io/txs/0xe204c319c5f8805fb98aa6fabceb3eecd39171967b53272da8a0c213a908a272
The contract address is 0x25aAf52906f3b36DBA16FF22FBCb6d238Eb9a1d9
I can get the value from getBaseFee function, so it have supported the block.baseFee
Hmmm, the opcode does its magic well. 🧐
*About EIP-4399(RANDOM, PREVRANDAO) *
I can get the value from getRandom function, so it have supported the block.prevrandao
Discussion (6)
very cool sir
Great... Good work team...!!!
NICE!
Nice!!!
Great work.!!
Amazing, Good Job Galaxy!