Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem: push0 opcode is not tested #1273

Merged
merged 14 commits into from
Dec 22, 2023
Prev Previous commit
Next Next commit
Problem: push0 opcode is not tested
- shanghai hardfork introduces push0 opcode, can be enabled in solc

Update CHANGELOG.md

Signed-off-by: yihuang <huang@crypto.com>

enlarge gas gap

assert some exact gas number

fix python lint

test upgrade

test push0 opcode in upgrade
  • Loading branch information
yihuang committed Dec 22, 2023
commit 6a475183ef8b50d95d9d3fb28a26a06bd9e63fb7
2 changes: 1 addition & 1 deletion integration_tests/contracts/contracts/Greeter.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity >0.5.0;
pragma solidity 0.8.21;

contract Greeter {
string public greeting;
Expand Down
8 changes: 8 additions & 0 deletions integration_tests/contracts/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ module.exports = {
evmVersion: "shanghai"
}
},
{
version: "0.8.10",
settings: {
optimizer: {
enabled: true
}
}
},
{
version: "0.6.6",
settings: {
Expand Down
18 changes: 18 additions & 0 deletions integration_tests/test_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,21 @@ def exec(c, tmp_path_factory, testnet=True):
print("upgrade height", target_height)

w3 = c.w3

if not testnet:
# before upgrade, PUSH0 opcode is not supported
with pytest.raises(ValueError) as e_info:
deploy_contract(w3, CONTRACTS["Greeter"])
assert 'invalid opcode: PUSH0' in str(e_info.value)

contract = deploy_contract(w3, CONTRACTS["TestERC20A"])

tx = contract.functions.transfer(ADDRS["community"], 10).transact(
{"from": ADDRS["validator"]}
)
tx_receipt = w3.eth.wait_for_transaction_receipt(tx)
print(tx_receipt)
mmsqe marked this conversation as resolved.
Show resolved Hide resolved

yihuang marked this conversation as resolved.
Show resolved Hide resolved
old_height = w3.eth.block_number
old_balance = w3.eth.get_balance(ADDRS["validator"], block_identifier=old_height)
old_base_fee = w3.eth.get_block(old_height).baseFeePerGas
Expand Down Expand Up @@ -174,6 +188,10 @@ def exec(c, tmp_path_factory, testnet=True):
)
assert receipt.status == 1

if not testnet:
# after upgrade, PUSH0 opcode is supported
deploy_contract(w3, CONTRACTS["Greeter"])

# query json-rpc on older blocks should success
assert old_balance == w3.eth.get_balance(
ADDRS["validator"], block_identifier=old_height
Expand Down
Loading