PUSH0 Opcode Compatibility
Description
The contract should specify appropriate EVM version settings to ensure compatibility across different blockchain networks and Layer 2 solutions where this faucet may be deployed.
Solidity 0.8.20+ defaults to Shanghai EVM features including the PUSH0 opcode, which may not be supported on all Layer 2 chains, testnets, or alternative EVM implementations where testnet faucets are commonly deployed.
@> pragma solidity ^0.8.30;
Risk
Likelihood: Medium
-
Many Layer 2 networks and testnets have not implemented Shanghai EVM features yet
-
Deployment attempts on incompatible networks will fail immediately with opcode errors
-
Testnet faucets are commonly deployed across multiple networks for broad ecosystem support
Impact: Low
-
Contract deployment fails completely on non-Shanghai compatible networks
-
Severely limits deployment options for testnet usage across different blockchain ecosystems
-
Requires recompilation with different settings for different target networks
-
Significant delays in deployment and testing processes across multiple chains
Proof of Concept
contract PUSH0CompatibilityTest {
function getIncompatibleNetworks() external pure returns (string[] memory networks) {
networks = new string[](8);
networks[0] = "Arbitrum One (depending on upgrade status)";
networks[1] = "Polygon PoS (pre-Shanghai upgrade)";
networks[2] = "Avalanche C-Chain (depending on version)";
networks[3] = "BSC (Binance Smart Chain)";
networks[4] = "Fantom Opera";
networks[5] = "Various L2 testnets";
networks[6] = "Private/enterprise blockchain networks";
networks[7] = "Older Ethereum testnets";
return networks;
}
function simulateDeploymentFailure() external pure returns (
string memory errorMessage,
string memory technicalDetails,
string memory impact
) {
errorMessage = "Error: Invalid opcode PUSH0 at position 0x1a3";
technicalDetails = "Contract bytecode contains PUSH0 (0x5f) which is unsupported on this network";
impact = "Complete deployment failure - contract cannot be deployed";
return (errorMessage, technicalDetails, impact);
}
function showCrossChainChallenges() external pure returns (
string memory challenge1,
string memory challenge2,
string memory challenge3
) {
challenge1 = "Same source requires different compiler settings per network";
challenge2 = "Testing becomes fragmented across supported vs unsupported chains";
challenge3 = "Maintenance overhead increases with multiple compilation targets";
return (challenge1, challenge2, challenge3);
}
}
Real deployment scenario:
Team develops faucet for multi-chain testnet deployment
Successfully deploys on Ethereum Sepolia (Shanghai compatible)
Attempts deployment on Polygon Mumbai testnet
Deployment transaction fails with "Invalid opcode" error
Team investigates and discovers PUSH0 incompatibility
Must recompile with London EVM target
Retesting required with new bytecode
Deployment pipeline becomes network-specific
Increased complexity for multi-chain operations
Recommended Mitigation
The mitigation specifies the London EVM version to ensure broad compatibility across different networks while maintaining access to modern Solidity features without problematic opcodes.
// Option 1: Use London EVM target in compiler settings
// In foundry.toml:
+ [profile.default]
+ solc_version = "0.8.30"
+ evm_version = "london"
+ optimizer = { enabled = true, runs = 200 }
// Option 2: Use older Solidity version (alternative approach)
- pragma solidity ^0.8.30;
+ pragma solidity 0.8.19; // Last version before Shanghai default
// Option 3: Document EVM requirements clearly
+ /**
+ * @title RaiseBoxFaucet
+ * @dev EVM Compatibility Requirements:
+ * - Compile with London EVM target for maximum compatibility
+ * - Shanghai EVM features (PUSH0) not required for functionality
+ * - Compatible with Ethereum mainnet, most L2s, and testnets
+ *
+ * Deployment Instructions:
+ * - Ethereum/Polygon: Use London EVM target
+ * - Arbitrum/Optimism: Use London EVM target
+ * - BSC/Fantom: Use London EVM target
+ * - Custom networks: Verify EVM version support first
+ */
pragma solidity 0.8.30;
// Add network compatibility verification in deployment scripts
+ // deploy.js example
+ const supportedNetworks = {
+ ethereum: { evmVersion: "london", gasLimit: 8000000 },
+ polygon: { evmVersion: "london", gasLimit: 20000000 },
+ arbitrum: { evmVersion: "london", gasLimit: 32000000 },
+ // Add other networks as tested
+ };
+
+ function verifyNetworkCompatibility(networkName) {
+ if (!supportedNetworks[networkName]) {
+ throw new Error(`Network ${networkName} not tested for compatibility`);
+ }
+ return supportedNetworks[networkName];
+ }