diff --git a/evm/differences-with-ethereum.mdx b/evm/differences-with-ethereum.mdx index cb1e3c8..4d7b7cc 100644 --- a/evm/differences-with-ethereum.mdx +++ b/evm/differences-with-ethereum.mdx @@ -4,6 +4,9 @@ sidebarTitle: 'Divergence from Ethereum' description: "A comparison of Sei EVM and Ethereum, highlighting Sei's advantages in blocktime, throughput, finality, and execution environment, as well as technical differences in opcodes, state storage, and other features." keywords: ['Sei EVM', 'Ethereum comparison', 'blockchain differences', 'EVM compatibility', 'blockchain performance'] --- + +import { SstoreGasLive } from '/snippets/sstore-gas-live.jsx'; + While Sei features full EVM compatibility, there are some distinctions between Sei's EVM and Ethereum itself: @@ -177,11 +180,13 @@ Transaction Fee = Gas Used × Gas Price ## SSTORE Gas Cost -On Sei, the `SSTORE` opcode gas cost is configurable as an on-chain parameter, meaning it can be adjusted via governance proposal without requiring a chain upgrade. +On Sei, the `SSTORE` opcode gas cost is configurable as an on-chain parameter, meaning it can be adjusted via governance proposal without requiring a chain upgrade. This provides flexibility to tune storage costs based on EVM state size and network conditions. + +Currently, the `SSTORE` gas cost is set to the non-standard value of **72,000 gas**. This value is the same on both mainnet (`pacific-1`) and testnet (`atlantic-2`). It was set by governance [Proposal #109](https://www.mintscan.io/sei/proposals/109) ("Update EVM SSTORE set gas to 72000"), which changed the `evm` module parameter `KeySeiSstoreSetGasEIP2200` to `72000`. -This provides flexibility to tune storage costs based on EVM state size and network conditions. +The values below are read **live** from the Sei EVM: -Currently, the `SSTORE` gas cost is set to the non-standard value of **72,000 gas**, and this is the same on both mainnet (`pacific-1`) and testnet (`atlantic-2`) — it does not vary by network. It was set by governance [Proposal #109](https://www.mintscan.io/sei/proposals/109) ("Update EVM SSTORE set gas to 72000"), which changed the `evm` module parameter `KeySeiSstoreSetGasEIP2200` to `72000`. + To confirm the real cost yourself, use a live `eth_estimateGas` call against a Sei RPC. Note that a Foundry `forge test --gas-report --fork-url ` report forks chain *state* but applies revm's standard EVM gas schedule, so it reports the Ethereum cost (~22,100) rather than Sei's — it is useful for relative profiling of your own logic, not for the absolute storage-write cost. diff --git a/snippets/sstore-gas-live.jsx b/snippets/sstore-gas-live.jsx new file mode 100644 index 0000000..b5a578c --- /dev/null +++ b/snippets/sstore-gas-live.jsx @@ -0,0 +1,139 @@ +export const SstoreGasLive = ({ network = 'mainnet' }) => { + // Reads the live SSTORE gas cost from SstoreGasProbe — a tiny, Sourcify-verified + // contract whose functions measure a throwaway SSTORE with the GAS opcode. Called via + // eth_call (read-only, state discarded, no gas spent), so the number always reflects the + // current governance parameter (KeySeiSstoreSetGasEIP2200) and can never go stale. + const COLD = '0x50025cb2'; // coldWriteCost() -> SSTORE_SET + EIP-2929 cold access + const PARAM = '0x095f88b9'; // setParamGas() -> SSTORE_SET parameter alone (pre-warmed) + + const RPC = { + mainnet: { + url: 'https://evm-rpc.sei-apis.com', + chain: 'pacific-1', + id: 1329, + probe: '0xeeB428bcf499D0A1c401f123F64BFf754a5de57A', + explorer: 'https://seiscan.io/address/0xeeB428bcf499D0A1c401f123F64BFf754a5de57A' + }, + testnet: { + url: 'https://evm-rpc-testnet.sei-apis.com', + chain: 'atlantic-2', + id: 1328, + probe: '0xE5A35b2457E1C3cfF2F6527fAA32DE0B2a8e28E0', + explorer: 'https://testnet.seiscan.io/address/0xE5A35b2457E1C3cfF2F6527fAA32DE0B2a8e28E0' + } + }; + + const [net, setNet] = useState(network === 'testnet' ? 'testnet' : 'mainnet'); + const [data, setData] = useState(null); + const [err, setErr] = useState(null); + const [loading, setLoading] = useState(true); + + const ethCall = async (url, to, data) => { + const res = await fetch(url, { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ jsonrpc: '2.0', id: 1, method: 'eth_call', params: [{ to, data }, 'latest'] }) + }); + const json = await res.json(); + if (json.error) throw new Error(json.error.message || 'eth_call failed'); + return parseInt(json.result, 16); + }; + + const load = async (which) => { + setLoading(true); + setErr(null); + try { + const { url, probe } = RPC[which]; + const [param, cold] = await Promise.all([ethCall(url, probe, PARAM), ethCall(url, probe, COLD)]); + setData({ param, cold }); + } catch (e) { + setErr(e && e.message ? e.message : 'Failed to query RPC'); + setData(null); + } finally { + setLoading(false); + } + }; + + useEffect(() => { + load(net); + }, [net]); + + const fmt = (n) => (n == null ? '—' : n.toLocaleString('en-US')); + + const TabButton = ({ value, children }) => { + const active = net === value; + return ( + + ); + }; + + const Stat = ({ label, value, sub }) => ( +
+ + {label} + + + {loading ? '…' : value} + gas + + {sub && {sub}} +
+ ); + + return ( +
+
+ + Live SSTORE gas — measured on-chain + +
+ Mainnet + Testnet +
+
+ + {err ? ( +
+ Could not reach {RPC[net].chain} RPC: {err}{' '} + +
+ ) : ( +
+ + +
+ )} + +
+ {RPC[net].chain} ({RPC[net].id}) · read via eth_call from the verified{' '} + + SstoreGasProbe + {' '} + contract. Governance-adjustable — set by{' '} + + Proposal #109 + + . +
+
+ ); +};