Introduction
Hi, I'm cardene, a software engineer and technical writer focused on blockchain and AI.
I've also authored Japanese technical books on specification-driven development with LLMs and decentralized application (DApp) development.
I also build and publish a variety of tools, libraries, and open-source projects.
Background
EIP-2 specifies four changes introduced in Ethereum's Homestead hard fork. This article explains what each change did and why it mattered.
The explanation below translates, summarizes, and expands on the proposal.
I also cover other EIPs here.
Parameters
| FORK_BLKNUM | CHAIN_NAME |
|---|---|
1,150,000 |
Mainnet |
494,000 |
Morden |
0 |
Future testnets |
Specification
The Homestead upgrade introduced the following changes.
Higher gas cost for creating contracts via transactions
Homestead increased the initial gas charge for contract creation transactions from 21,000 to 53,000 gas. The charge applies when the destination field is empty, indicating that the transaction creates a new contract. Transaction data still incurs a separate gas cost. Creating a contract from another contract with the CREATE opcode is unaffected.
For more on the CREATE opcode, see the following article.
Restricting the s-value of transaction signatures
Transaction signatures with an s value strictly greater than half of secp256k1n became invalid. The ECDSA recovery precompile still accepts high s values, which lets contracts recover signatures such as older Bitcoin signatures.
secp256k1n
What is secp256k1n?
secp256k1n is a parameter of secp256k1, the elliptic curve Ethereum and Bitcoin use for digital signatures.
Elliptic curve basics
Elliptic curve cryptography works with points that follow a mathematical group operation. These points play a role in deriving public keys from private keys.
What n represents
secp256k1n is the order of the standard generator of the secp256k1 group. It gives the number of points in the subgroup generated by that point. The order is on the scale of 10^77, allowing a very large number of keys.
Example
A private key is an integer from 1 through secp256k1n minus one. Scalar multiplication maps that number to a particular point on the curve, which is the public key. Given the public key, recovering the original private key is computationally infeasible with known classical methods and securely generated keys.
Suppose Alice signs a message with her private key and sends it to Bob. Bob uses her public key to check the signature. The verification relies on the curve's properties and the order secp256k1n.
Why secp256k1n matters
The large group order makes guessing a uniformly generated private key impractical. This property underpins the signature schemes Ethereum and Bitcoin use to authenticate transactions and establish that a message came from the holder of a signing key.
The s-value
What is ECDSA?
ECDSA is a public-key digital signature algorithm widely used in systems such as Bitcoin and Ethereum. It uses elliptic curve operations to generate and verify signatures. A valid signature demonstrates that the corresponding private key authorized a message.
How ECDSA signs a message
-
Generate the keys
- Generate a private key and derive the public key as a point on the curve.
-
Generate the signature
- Use the private key to sign a message, such as a transaction.
- The resulting signature has two numbers, r and s.
-
Verify the signature
- The recipient or another verifier checks the signature against the message and public key.
What r and s represent
- r-value
- This part of the signature is derived from the ephemeral nonce used for signing. Multiplying the curve generator by that nonce gives a point, and its x-coordinate reduced modulo the group order provides r.
- s-value
- This part is calculated from the message hash, private key, ephemeral nonce, and r.
Why these values matter
- r and s together encode a signature. A given message and key can yield different valid signatures, and EIP-2 addresses one specific way in which an existing signature can be altered without invalidating it.
- A signature helps the verifier detect changes to a message or transaction and verify authorization by the corresponding private key.
- Blockchain nodes use ECDSA signature verification to confirm that transactions were authorized by the relevant signer.
Together, r and s let a verifier check a message's integrity and the signer's authorization.
Rejecting s-values greater than secp256k1n/2
Ethereum rejects transaction signatures whose s value is greater than half of secp256k1n. This prevents a form of transaction malleability in which someone can alter the signature while retaining a valid transaction.
The ECDSA recovery precompile
The ECDSA recovery precompile is a built-in contract for recovering the Ethereum address that corresponds to the signer. As part of that process, the recovery operation derives the signing public key from the signature and message hash. The precompile continues to accept high s values, allowing contracts to handle historical signatures such as those from Bitcoin.
Failure when contract creation runs out of gas
If contract creation lacks the gas to pay for adding the resulting code to state, the creation runs out of gas and fails completely. It no longer leaves behind an empty contract.
Changes to difficulty adjustment
Homestead changed the difficulty formula to block_diff = parent_diff + parent_diff // 2048 * max(1 - (block_timestamp - parent_timestamp) // 10, -99) + int(2**((block.number // 100000) - 2)). Here // means integer division. The minDifficulty parameter still sets the minimum allowed difficulty.
These changes addressed several issues in Ethereum's early operation. Increasing the cost of creation transactions removed an incentive to misuse them. Restricting s reduced signature malleability, and changing out-of-gas behavior prevented incomplete contract creation. The revised difficulty formula aimed to stabilize block production by adjusting mining difficulty according to the time between blocks.
Difficulty adjustment algorithm
This formula shows how Ethereum's proof-of-work difficulty adjustment worked at Homestead. The network adjusted the difficulty of new blocks to keep the production rate near its target.
Terms in the formula
block_diff- Difficulty of the new block.
parent_diff- Difficulty of its parent block.
block_timestamp- New block's timestamp.
parent_timestamp- Parent block's timestamp.
block.number- Number of the new block.
Breaking down the formula
This part adjusts difficulty based on the time between the parent and new blocks.
Dividing the parent block's difficulty by 2048 gives the base unit for adjustment.
This divides the elapsed time between the blocks by 10, rounding down.
The resulting adjustment multiplier ranges from -99 to 1 for valid block timestamps.
This component adjusts difficulty periodically based on the block number.
This divides the block number by 100,000, rounding down.
This is the difficulty bomb component, which rises exponentially for every additional 100,000 blocks.
Difficulty bomb
The difficulty bomb intentionally increases mining difficulty rapidly over time, lengthening the intervals between proof-of-work blocks.
What the difficulty bomb was for
-
Encouraging the transition from Proof of Work to Proof of Stake
- Ethereum used the difficulty bomb as an incentive to move from PoW to PoS. It raised the long-term cost of continuing on the old consensus mechanism.
-
Encouraging network upgrades
- The bomb also encouraged participants to adopt protocol upgrades on time.
Effects of the difficulty bomb
-
Longer block times
- As the difficulty bomb takes effect, blocks can take significantly longer to produce. Confirmations slow down and network delays increase.
-
The Ice Age
- If difficulty rises far enough, the chain can enter a state known as the Ice Age, where mining blocks becomes so difficult that the chain effectively grinds to a halt.
Responses
- Delaying or removing it through a hard fork
- Ethereum used hard forks to postpone or remove the bomb's effects and keep the network operating. Managing the bomb was a consequential protocol decision for Ethereum's future.
Worked example
Suppose the parent difficulty (parent_diff) is 2,000,000, the parent timestamp is 100,000, the new timestamp is 100,010, and the new block number is 200,000.
- Base unit for difficulty adjustment
2,000,000 // 2048 = 976
- Elapsed time in ten-second units
(100,010 - 100,000) // 10 = 1
- Adjustment multiplier
max(1 - 1, -99) = 0
- Difficulty adjustment from elapsed time
976 * 0 = 0
- Difficulty bomb adjustment
int(2**((200,000 // 100000) - 2)) = int(2**(2 - 2)) = int(2**0) = 1
The new difficulty is therefore:
block_diff = 2,000,000 + 0 + 1 = 2,000,001
With a ten-second interval, the elapsed-time adjustment is zero. The difficulty bomb still increases the new difficulty slightly.
This historical algorithm adjusted mining difficulty dynamically to keep block production near its intended rate, roughly one block every 14 seconds in the example given by the Japanese article. That helped keep confirmation times and network operation more predictable.
Taken together, the Homestead changes altered how transactions and blocks were validated. Users and developers had to account for the new rules in their clients and applications.
Rationale
Before Homestead, creating a contract through a transaction cost 21,000 gas initially. This was lower than the 32,000 gas charged for creating a contract from another contract, creating an unintended incentive to use a creation transaction. The historical self-destruct gas refund also made it possible to transfer ether using only 11,664 gas. The proposal illustrates this with the following example.
from ethereum import tester as t
from ethereum import utils
s = t.state()
c = s.abi_contract('def init():\n suicide(0x47e25df8822538a8596b28c637896b4d143c351e)', endowment=10**15)
s.block.get_receipts()[-1].gas_used
# 出力: 11664
s.block.get_balance(utils.normalize_address(0x47e25df8822538a8596b28c637896b4d143c351e))
# 出力: 1000000000000000The proposal treats this as a minor bug.
Under the old transaction rules, any s value satisfying 0 < s < secp256k1n was valid. This permitted a form of malleability: replacing s with secp256k1n - s and flipping v (27 -> 28, 28 -> 27) yielded a signature that still validated.
The underlying value transfer remained authorized. Ethereum uses addresses as the inputs to ether transfers and other transactions, rather than using a previous transaction hash as a spend reference. However, an altered signature changed the hash of the transaction that appeared in the block. This could interfere with a wallet or other interface that tracked the original hash. Rejecting high s values removed that alternate form.
The old rules provided behavior that some users could take advantage of, but they complicated transaction tracking and affected how efficiently the network used its resources. Homestead addressed these issues at the protocol level.
The changes also made contract creation failures easier to detect and block timing more predictable.
Handling out-of-gas failures during contract creation
- (i) Previously, a creation attempt could succeed, fail, or leave an empty contract.
- Homestead reduced the outcomes to success or failure, making the result easier to interpret.
- (ii) A creation attempt does not create a contract account unless it succeeds completely.
- This makes failed creations easier to detect.
- (iii) Contract creation with an endowment became safer.
- Initialization either succeeds in full or the creation fails and the endowment is returned.
Changes to difficulty adjustment
Previously, many miners produced blocks with a timestamp of parent_timestamp + 1, which skewed the distribution of recorded block intervals. EIP-2 explains that this could allow the average real block time to rise. The new formula targets the average block time. Under the model described by the proposal, it prevents average block times from exceeding 24 seconds in the long run.
Key inputs to the difficulty algorithm
The expression (block_timestamp - parent_timestamp) // 10 groups timestamp differences into ten-second intervals. This limits how much the algorithm reacts to small differences and removes the incentive to claim a timestamp difference of exactly 1. Blocks with a more accurate timestamp can therefore be slightly harder to mine and carry more weight than blocks on a competing branch that uses an artificially low timestamp difference.
The lower bound of -99 prevents difficulty from falling too sharply if the timestamps of two consecutive blocks are unusually far apart, for example after a security bug or a network incident.
Clear creation outcomes help users interpret failures, while the revised difficulty rule makes proof-of-work block production more predictable.
Implementation
The following historical implementation references show the changes.
Citation
Vitalik Buterin (@vbuterin), "EIP-2: Homestead Hard-fork Changes," Ethereum Improvement Proposals, no. 2, November 2015. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-2.
Conclusion
EIP-2 changed the price and failure behavior of contract creation, restricted transaction signature s values, and adjusted proof-of-work mining difficulty as part of the Homestead hard fork.
Questions are welcome via direct message.
You can find more of my work at these links.



