Skip to content

Commit 885c13c

Browse files
authored
Merge pull request #15146 from karalabe/byzantium-rebrand
consensus, core, params: rebrand Metro to Byzantium
2 parents 79b1112 + 5bbd7fb commit 885c13c

File tree

12 files changed

+86
-86
lines changed

12 files changed

+86
-86
lines changed

consensus/ethash/consensus.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ import (
3636

3737
// Ethash proof-of-work protocol constants.
3838
var (
39-
frontierBlockReward *big.Int = big.NewInt(5e+18) // Block reward in wei for successfully mining a block
40-
metropolisBlockReward *big.Int = big.NewInt(3e+18) // Block reward in wei for successfully mining a block upward from Metropolis
41-
maxUncles = 2 // Maximum number of uncles allowed in a single block
39+
frontierBlockReward *big.Int = big.NewInt(5e+18) // Block reward in wei for successfully mining a block
40+
byzantiumBlockReward *big.Int = big.NewInt(3e+18) // Block reward in wei for successfully mining a block upward from Byzantium
41+
maxUncles = 2 // Maximum number of uncles allowed in a single block
4242
)
4343

4444
// Various error messages to mark blocks invalid. These should be private to
@@ -290,8 +290,8 @@ func (ethash *Ethash) verifyHeader(chain consensus.ChainReader, header, parent *
290290
func CalcDifficulty(config *params.ChainConfig, time uint64, parent *types.Header) *big.Int {
291291
next := new(big.Int).Add(parent.Number, big1)
292292
switch {
293-
case config.IsMetropolis(next):
294-
return calcDifficultyMetropolis(time, parent)
293+
case config.IsByzantium(next):
294+
return calcDifficultyByzantium(time, parent)
295295
case config.IsHomestead(next):
296296
return calcDifficultyHomestead(time, parent)
297297
default:
@@ -310,10 +310,10 @@ var (
310310
big2999999 = big.NewInt(2999999)
311311
)
312312

313-
// calcDifficultyMetropolis is the difficulty adjustment algorithm. It returns
313+
// calcDifficultyByzantium is the difficulty adjustment algorithm. It returns
314314
// the difficulty that a new block should have when created at time given the
315-
// parent block's time and difficulty. The calculation uses the Metropolis rules.
316-
func calcDifficultyMetropolis(time uint64, parent *types.Header) *big.Int {
315+
// parent block's time and difficulty. The calculation uses the Byzantium rules.
316+
func calcDifficultyByzantium(time uint64, parent *types.Header) *big.Int {
317317
// https://github.com/ethereum/EIPs/issues/100.
318318
// algorithm:
319319
// diff = (parent_diff +
@@ -530,8 +530,8 @@ var (
530530
func AccumulateRewards(config *params.ChainConfig, state *state.StateDB, header *types.Header, uncles []*types.Header) {
531531
// Select the correct block reward based on chain progression
532532
blockReward := frontierBlockReward
533-
if config.IsMetropolis(header.Number) {
534-
blockReward = metropolisBlockReward
533+
if config.IsByzantium(header.Number) {
534+
blockReward = byzantiumBlockReward
535535
}
536536
// Accumulate the rewards for the miner and any included uncles
537537
reward := new(big.Int).Set(blockReward)

core/state_processor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func ApplyTransaction(config *params.ChainConfig, bc *BlockChain, author *common
105105

106106
// Update the state with pending changes
107107
var root []byte
108-
if config.IsMetropolis(header.Number) {
108+
if config.IsByzantium(header.Number) {
109109
statedb.Finalise(true)
110110
} else {
111111
root = statedb.IntermediateRoot(config.IsEIP158(header.Number)).Bytes()

core/types/receipt.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func NewReceipt(root []byte, failed bool, cumulativeGasUsed *big.Int) *Receipt {
7979
}
8080

8181
// EncodeRLP implements rlp.Encoder, and flattens the consensus fields of a receipt
82-
// into an RLP stream. If no post state is present, metropolis fork is assumed.
82+
// into an RLP stream. If no post state is present, byzantium fork is assumed.
8383
func (r *Receipt) EncodeRLP(w io.Writer) error {
8484
return rlp.Encode(w, &receiptRLP{r.statusEncoding(), r.CumulativeGasUsed, r.Bloom, r.Logs})
8585
}

core/vm/contracts.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ var PrecompiledContractsHomestead = map[common.Address]PrecompiledContract{
4646
common.BytesToAddress([]byte{4}): &dataCopy{},
4747
}
4848

49-
// PrecompiledContractsMetropolis contains the default set of pre-compiled Ethereum
50-
// contracts used in the Metropolis release.
51-
var PrecompiledContractsMetropolis = map[common.Address]PrecompiledContract{
49+
// PrecompiledContractsByzantium contains the default set of pre-compiled Ethereum
50+
// contracts used in the Byzantium release.
51+
var PrecompiledContractsByzantium = map[common.Address]PrecompiledContract{
5252
common.BytesToAddress([]byte{1}): &ecrecover{},
5353
common.BytesToAddress([]byte{2}): &sha256hash{},
5454
common.BytesToAddress([]byte{3}): &ripemd160hash{},

core/vm/contracts_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ var bn256PairingTests = []precompiledTest{
321321
}
322322

323323
func testPrecompiled(addr string, test precompiledTest, t *testing.T) {
324-
p := PrecompiledContractsMetropolis[common.HexToAddress(addr)]
324+
p := PrecompiledContractsByzantium[common.HexToAddress(addr)]
325325
in := common.Hex2Bytes(test.input)
326326
contract := NewContract(AccountRef(common.HexToAddress("1337")),
327327
nil, new(big.Int), p.RequiredGas(in))
@@ -338,7 +338,7 @@ func benchmarkPrecompiled(addr string, test precompiledTest, bench *testing.B) {
338338
if test.noBenchmark {
339339
return
340340
}
341-
p := PrecompiledContractsMetropolis[common.HexToAddress(addr)]
341+
p := PrecompiledContractsByzantium[common.HexToAddress(addr)]
342342
in := common.Hex2Bytes(test.input)
343343
reqGas := p.RequiredGas(in)
344344
contract := NewContract(AccountRef(common.HexToAddress("1337")),

core/vm/evm.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ type (
4141
func run(evm *EVM, snapshot int, contract *Contract, input []byte) ([]byte, error) {
4242
if contract.CodeAddr != nil {
4343
precompiles := PrecompiledContractsHomestead
44-
if evm.ChainConfig().IsMetropolis(evm.BlockNumber) {
45-
precompiles = PrecompiledContractsMetropolis
44+
if evm.ChainConfig().IsByzantium(evm.BlockNumber) {
45+
precompiles = PrecompiledContractsByzantium
4646
}
4747
if p := precompiles[*contract.CodeAddr]; p != nil {
4848
return RunPrecompiledContract(p, input, contract)
@@ -151,8 +151,8 @@ func (evm *EVM) Call(caller ContractRef, addr common.Address, input []byte, gas
151151
)
152152
if !evm.StateDB.Exist(addr) {
153153
precompiles := PrecompiledContractsHomestead
154-
if evm.ChainConfig().IsMetropolis(evm.BlockNumber) {
155-
precompiles = PrecompiledContractsMetropolis
154+
if evm.ChainConfig().IsByzantium(evm.BlockNumber) {
155+
precompiles = PrecompiledContractsByzantium
156156
}
157157
if precompiles[addr] == nil && evm.ChainConfig().IsEIP158(evm.BlockNumber) && value.Sign() == 0 {
158158
return nil, gas, nil

core/vm/gas_table.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ func gasCall(gt params.GasTable, evm *EVM, contract *Contract, stack *Stack, mem
324324
eip158 = evm.ChainConfig().IsEIP158(evm.BlockNumber)
325325
)
326326
if eip158 {
327-
if transfersValue && evm.StateDB.Empty(address) {
327+
if transfersValue && evm.StateDB.Empty(address) {
328328
gas += params.CallNewAccountGas
329329
}
330330
} else if !evm.StateDB.Exist(address) {

core/vm/interpreter.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ func NewInterpreter(evm *EVM, cfg Config) *Interpreter {
7070
// we'll set the default jump table.
7171
if !cfg.JumpTable[STOP].valid {
7272
switch {
73-
case evm.ChainConfig().IsMetropolis(evm.BlockNumber):
74-
cfg.JumpTable = metropolisInstructionSet
73+
case evm.ChainConfig().IsByzantium(evm.BlockNumber):
74+
cfg.JumpTable = byzantiumInstructionSet
7575
case evm.ChainConfig().IsHomestead(evm.BlockNumber):
7676
cfg.JumpTable = homesteadInstructionSet
7777
default:
@@ -88,7 +88,7 @@ func NewInterpreter(evm *EVM, cfg Config) *Interpreter {
8888
}
8989

9090
func (in *Interpreter) enforceRestrictions(op OpCode, operation operation, stack *Stack) error {
91-
if in.evm.chainRules.IsMetropolis {
91+
if in.evm.chainRules.IsByzantium {
9292
if in.readOnly {
9393
// If the interpreter is operating in readonly mode, make sure no
9494
// state-modifying operation is performed. The 3rd stack item

core/vm/jump_table.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ type operation struct {
5151
}
5252

5353
var (
54-
frontierInstructionSet = NewFrontierInstructionSet()
55-
homesteadInstructionSet = NewHomesteadInstructionSet()
56-
metropolisInstructionSet = NewMetropolisInstructionSet()
54+
frontierInstructionSet = NewFrontierInstructionSet()
55+
homesteadInstructionSet = NewHomesteadInstructionSet()
56+
byzantiumInstructionSet = NewByzantiumInstructionSet()
5757
)
5858

59-
// NewMetropolisInstructionSet returns the frontier, homestead and
60-
// metropolis instructions.
61-
func NewMetropolisInstructionSet() [256]operation {
59+
// NewByzantiumInstructionSet returns the frontier, homestead and
60+
// byzantium instructions.
61+
func NewByzantiumInstructionSet() [256]operation {
6262
// instructions that can be executed during the homestead phase.
6363
instructionSet := NewHomesteadInstructionSet()
6464
instructionSet[STATICCALL] = operation{

params/config.go

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -32,45 +32,45 @@ var (
3232
var (
3333
// MainnetChainConfig is the chain parameters to run a node on the main network.
3434
MainnetChainConfig = &ChainConfig{
35-
ChainId: big.NewInt(1),
36-
HomesteadBlock: big.NewInt(1150000),
37-
DAOForkBlock: big.NewInt(1920000),
38-
DAOForkSupport: true,
39-
EIP150Block: big.NewInt(2463000),
40-
EIP150Hash: common.HexToHash("0x2086799aeebeae135c246c65021c82b4e15a2c451340993aacfd2751886514f0"),
41-
EIP155Block: big.NewInt(2675000),
42-
EIP158Block: big.NewInt(2675000),
43-
MetropolisBlock: big.NewInt(math.MaxInt64), // Don't enable yet
35+
ChainId: big.NewInt(1),
36+
HomesteadBlock: big.NewInt(1150000),
37+
DAOForkBlock: big.NewInt(1920000),
38+
DAOForkSupport: true,
39+
EIP150Block: big.NewInt(2463000),
40+
EIP150Hash: common.HexToHash("0x2086799aeebeae135c246c65021c82b4e15a2c451340993aacfd2751886514f0"),
41+
EIP155Block: big.NewInt(2675000),
42+
EIP158Block: big.NewInt(2675000),
43+
ByzantiumBlock: big.NewInt(math.MaxInt64), // Don't enable yet
4444

4545
Ethash: new(EthashConfig),
4646
}
4747

4848
// TestnetChainConfig contains the chain parameters to run a node on the Ropsten test network.
4949
TestnetChainConfig = &ChainConfig{
50-
ChainId: big.NewInt(3),
51-
HomesteadBlock: big.NewInt(0),
52-
DAOForkBlock: nil,
53-
DAOForkSupport: true,
54-
EIP150Block: big.NewInt(0),
55-
EIP150Hash: common.HexToHash("0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d"),
56-
EIP155Block: big.NewInt(10),
57-
EIP158Block: big.NewInt(10),
58-
MetropolisBlock: big.NewInt(math.MaxInt64), // Don't enable yet
50+
ChainId: big.NewInt(3),
51+
HomesteadBlock: big.NewInt(0),
52+
DAOForkBlock: nil,
53+
DAOForkSupport: true,
54+
EIP150Block: big.NewInt(0),
55+
EIP150Hash: common.HexToHash("0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d"),
56+
EIP155Block: big.NewInt(10),
57+
EIP158Block: big.NewInt(10),
58+
ByzantiumBlock: big.NewInt(math.MaxInt64), // Don't enable yet
5959

6060
Ethash: new(EthashConfig),
6161
}
6262

6363
// RinkebyChainConfig contains the chain parameters to run a node on the Rinkeby test network.
6464
RinkebyChainConfig = &ChainConfig{
65-
ChainId: big.NewInt(4),
66-
HomesteadBlock: big.NewInt(1),
67-
DAOForkBlock: nil,
68-
DAOForkSupport: true,
69-
EIP150Block: big.NewInt(2),
70-
EIP150Hash: common.HexToHash("0x9b095b36c15eaf13044373aef8ee0bd3a382a5abb92e402afa44b8249c3a90e9"),
71-
EIP155Block: big.NewInt(3),
72-
EIP158Block: big.NewInt(3),
73-
MetropolisBlock: big.NewInt(math.MaxInt64), // Don't enable yet
65+
ChainId: big.NewInt(4),
66+
HomesteadBlock: big.NewInt(1),
67+
DAOForkBlock: nil,
68+
DAOForkSupport: true,
69+
EIP150Block: big.NewInt(2),
70+
EIP150Hash: common.HexToHash("0x9b095b36c15eaf13044373aef8ee0bd3a382a5abb92e402afa44b8249c3a90e9"),
71+
EIP155Block: big.NewInt(3),
72+
EIP158Block: big.NewInt(3),
73+
ByzantiumBlock: big.NewInt(math.MaxInt64), // Don't enable yet
7474

7575
Clique: &CliqueConfig{
7676
Period: 15,
@@ -110,7 +110,7 @@ type ChainConfig struct {
110110
EIP155Block *big.Int `json:"eip155Block,omitempty"` // EIP155 HF block
111111
EIP158Block *big.Int `json:"eip158Block,omitempty"` // EIP158 HF block
112112

113-
MetropolisBlock *big.Int `json:"metropolisBlock,omitempty"` // Metropolis switch block (nil = no fork, 0 = alraedy on homestead)
113+
ByzantiumBlock *big.Int `json:"byzantiumBlock,omitempty"` // Byzantium switch block (nil = no fork, 0 = alraedy on homestead)
114114

115115
// Various consensus engines
116116
Ethash *EthashConfig `json:"ethash,omitempty"`
@@ -147,15 +147,15 @@ func (c *ChainConfig) String() string {
147147
default:
148148
engine = "unknown"
149149
}
150-
return fmt.Sprintf("{ChainID: %v Homestead: %v DAO: %v DAOSupport: %v EIP150: %v EIP155: %v EIP158: %v Metropolis: %v Engine: %v}",
150+
return fmt.Sprintf("{ChainID: %v Homestead: %v DAO: %v DAOSupport: %v EIP150: %v EIP155: %v EIP158: %v Byzantium: %v Engine: %v}",
151151
c.ChainId,
152152
c.HomesteadBlock,
153153
c.DAOForkBlock,
154154
c.DAOForkSupport,
155155
c.EIP150Block,
156156
c.EIP155Block,
157157
c.EIP158Block,
158-
c.MetropolisBlock,
158+
c.ByzantiumBlock,
159159
engine,
160160
)
161161
}
@@ -182,8 +182,8 @@ func (c *ChainConfig) IsEIP158(num *big.Int) bool {
182182
return isForked(c.EIP158Block, num)
183183
}
184184

185-
func (c *ChainConfig) IsMetropolis(num *big.Int) bool {
186-
return isForked(c.MetropolisBlock, num)
185+
func (c *ChainConfig) IsByzantium(num *big.Int) bool {
186+
return isForked(c.ByzantiumBlock, num)
187187
}
188188

189189
// GasTable returns the gas table corresponding to the current phase (homestead or homestead reprice).
@@ -243,8 +243,8 @@ func (c *ChainConfig) checkCompatible(newcfg *ChainConfig, head *big.Int) *Confi
243243
if c.IsEIP158(head) && !configNumEqual(c.ChainId, newcfg.ChainId) {
244244
return newCompatError("EIP158 chain ID", c.EIP158Block, newcfg.EIP158Block)
245245
}
246-
if isForkIncompatible(c.MetropolisBlock, newcfg.MetropolisBlock, head) {
247-
return newCompatError("Metropolis fork block", c.MetropolisBlock, newcfg.MetropolisBlock)
246+
if isForkIncompatible(c.ByzantiumBlock, newcfg.ByzantiumBlock, head) {
247+
return newCompatError("Byzantium fork block", c.ByzantiumBlock, newcfg.ByzantiumBlock)
248248
}
249249
return nil
250250
}
@@ -312,13 +312,13 @@ func (err *ConfigCompatError) Error() string {
312312
type Rules struct {
313313
ChainId *big.Int
314314
IsHomestead, IsEIP150, IsEIP155, IsEIP158 bool
315-
IsMetropolis bool
315+
IsByzantium bool
316316
}
317317

318318
func (c *ChainConfig) Rules(num *big.Int) Rules {
319319
chainId := c.ChainId
320320
if chainId == nil {
321321
chainId = new(big.Int)
322322
}
323-
return Rules{ChainId: new(big.Int).Set(chainId), IsHomestead: c.IsHomestead(num), IsEIP150: c.IsEIP150(num), IsEIP155: c.IsEIP155(num), IsEIP158: c.IsEIP158(num), IsMetropolis: c.IsMetropolis(num)}
323+
return Rules{ChainId: new(big.Int).Set(chainId), IsHomestead: c.IsHomestead(num), IsEIP150: c.IsEIP150(num), IsEIP155: c.IsEIP155(num), IsEIP158: c.IsEIP158(num), IsByzantium: c.IsByzantium(num)}
324324
}

0 commit comments

Comments
 (0)