Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
885c13c2
Commit
885c13c2
authored
Sep 14, 2017
by
Péter Szilágyi
Committed by
GitHub
Sep 14, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #15146 from karalabe/byzantium-rebrand
consensus, core, params: rebrand Metro to Byzantium
parents
79b11121
5bbd7fb3
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
86 additions
and
86 deletions
+86
-86
consensus.go
consensus/ethash/consensus.go
+10
-10
state_processor.go
core/state_processor.go
+1
-1
receipt.go
core/types/receipt.go
+1
-1
contracts.go
core/vm/contracts.go
+3
-3
contracts_test.go
core/vm/contracts_test.go
+2
-2
evm.go
core/vm/evm.go
+4
-4
gas_table.go
core/vm/gas_table.go
+1
-1
interpreter.go
core/vm/interpreter.go
+3
-3
jump_table.go
core/vm/jump_table.go
+6
-6
config.go
params/config.go
+36
-36
init.go
tests/init.go
+13
-13
transaction_test.go
tests/transaction_test.go
+6
-6
No files found.
consensus/ethash/consensus.go
View file @
885c13c2
...
@@ -36,9 +36,9 @@ import (
...
@@ -36,9 +36,9 @@ import (
// Ethash proof-of-work protocol constants.
// Ethash proof-of-work protocol constants.
var
(
var
(
frontierBlockReward
*
big
.
Int
=
big
.
NewInt
(
5e+18
)
// Block reward in wei for successfully mining a block
frontierBlockReward
*
big
.
Int
=
big
.
NewInt
(
5e+18
)
// Block reward in wei for successfully mining a block
metropolisBlockReward
*
big
.
Int
=
big
.
NewInt
(
3e+18
)
// Block reward in wei for successfully mining a block upward from Metropolis
byzantiumBlockReward
*
big
.
Int
=
big
.
NewInt
(
3e+18
)
// Block reward in wei for successfully mining a block upward from Byzantium
maxUncles
=
2
// Maximum number of uncles allowed in a single block
maxUncles
=
2
// Maximum number of uncles allowed in a single block
)
)
// Various error messages to mark blocks invalid. These should be private to
// 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 *
...
@@ -290,8 +290,8 @@ func (ethash *Ethash) verifyHeader(chain consensus.ChainReader, header, parent *
func
CalcDifficulty
(
config
*
params
.
ChainConfig
,
time
uint64
,
parent
*
types
.
Header
)
*
big
.
Int
{
func
CalcDifficulty
(
config
*
params
.
ChainConfig
,
time
uint64
,
parent
*
types
.
Header
)
*
big
.
Int
{
next
:=
new
(
big
.
Int
)
.
Add
(
parent
.
Number
,
big1
)
next
:=
new
(
big
.
Int
)
.
Add
(
parent
.
Number
,
big1
)
switch
{
switch
{
case
config
.
Is
Metropolis
(
next
)
:
case
config
.
Is
Byzantium
(
next
)
:
return
calcDifficulty
Metropolis
(
time
,
parent
)
return
calcDifficulty
Byzantium
(
time
,
parent
)
case
config
.
IsHomestead
(
next
)
:
case
config
.
IsHomestead
(
next
)
:
return
calcDifficultyHomestead
(
time
,
parent
)
return
calcDifficultyHomestead
(
time
,
parent
)
default
:
default
:
...
@@ -310,10 +310,10 @@ var (
...
@@ -310,10 +310,10 @@ var (
big2999999
=
big
.
NewInt
(
2999999
)
big2999999
=
big
.
NewInt
(
2999999
)
)
)
// calcDifficulty
Metropolis
is the difficulty adjustment algorithm. It returns
// calcDifficulty
Byzantium
is the difficulty adjustment algorithm. It returns
// the difficulty that a new block should have when created at time given the
// the difficulty that a new block should have when created at time given the
// parent block's time and difficulty. The calculation uses the
Metropolis
rules.
// parent block's time and difficulty. The calculation uses the
Byzantium
rules.
func
calcDifficulty
Metropolis
(
time
uint64
,
parent
*
types
.
Header
)
*
big
.
Int
{
func
calcDifficulty
Byzantium
(
time
uint64
,
parent
*
types
.
Header
)
*
big
.
Int
{
// https://github.com/ethereum/EIPs/issues/100.
// https://github.com/ethereum/EIPs/issues/100.
// algorithm:
// algorithm:
// diff = (parent_diff +
// diff = (parent_diff +
...
@@ -530,8 +530,8 @@ var (
...
@@ -530,8 +530,8 @@ var (
func
AccumulateRewards
(
config
*
params
.
ChainConfig
,
state
*
state
.
StateDB
,
header
*
types
.
Header
,
uncles
[]
*
types
.
Header
)
{
func
AccumulateRewards
(
config
*
params
.
ChainConfig
,
state
*
state
.
StateDB
,
header
*
types
.
Header
,
uncles
[]
*
types
.
Header
)
{
// Select the correct block reward based on chain progression
// Select the correct block reward based on chain progression
blockReward
:=
frontierBlockReward
blockReward
:=
frontierBlockReward
if
config
.
Is
Metropolis
(
header
.
Number
)
{
if
config
.
Is
Byzantium
(
header
.
Number
)
{
blockReward
=
metropolis
BlockReward
blockReward
=
byzantium
BlockReward
}
}
// Accumulate the rewards for the miner and any included uncles
// Accumulate the rewards for the miner and any included uncles
reward
:=
new
(
big
.
Int
)
.
Set
(
blockReward
)
reward
:=
new
(
big
.
Int
)
.
Set
(
blockReward
)
...
...
core/state_processor.go
View file @
885c13c2
...
@@ -105,7 +105,7 @@ func ApplyTransaction(config *params.ChainConfig, bc *BlockChain, author *common
...
@@ -105,7 +105,7 @@ func ApplyTransaction(config *params.ChainConfig, bc *BlockChain, author *common
// Update the state with pending changes
// Update the state with pending changes
var
root
[]
byte
var
root
[]
byte
if
config
.
Is
Metropolis
(
header
.
Number
)
{
if
config
.
Is
Byzantium
(
header
.
Number
)
{
statedb
.
Finalise
(
true
)
statedb
.
Finalise
(
true
)
}
else
{
}
else
{
root
=
statedb
.
IntermediateRoot
(
config
.
IsEIP158
(
header
.
Number
))
.
Bytes
()
root
=
statedb
.
IntermediateRoot
(
config
.
IsEIP158
(
header
.
Number
))
.
Bytes
()
...
...
core/types/receipt.go
View file @
885c13c2
...
@@ -79,7 +79,7 @@ func NewReceipt(root []byte, failed bool, cumulativeGasUsed *big.Int) *Receipt {
...
@@ -79,7 +79,7 @@ func NewReceipt(root []byte, failed bool, cumulativeGasUsed *big.Int) *Receipt {
}
}
// EncodeRLP implements rlp.Encoder, and flattens the consensus fields of a receipt
// EncodeRLP implements rlp.Encoder, and flattens the consensus fields of a receipt
// into an RLP stream. If no post state is present,
metropolis
fork is assumed.
// into an RLP stream. If no post state is present,
byzantium
fork is assumed.
func
(
r
*
Receipt
)
EncodeRLP
(
w
io
.
Writer
)
error
{
func
(
r
*
Receipt
)
EncodeRLP
(
w
io
.
Writer
)
error
{
return
rlp
.
Encode
(
w
,
&
receiptRLP
{
r
.
statusEncoding
(),
r
.
CumulativeGasUsed
,
r
.
Bloom
,
r
.
Logs
})
return
rlp
.
Encode
(
w
,
&
receiptRLP
{
r
.
statusEncoding
(),
r
.
CumulativeGasUsed
,
r
.
Bloom
,
r
.
Logs
})
}
}
...
...
core/vm/contracts.go
View file @
885c13c2
...
@@ -46,9 +46,9 @@ var PrecompiledContractsHomestead = map[common.Address]PrecompiledContract{
...
@@ -46,9 +46,9 @@ var PrecompiledContractsHomestead = map[common.Address]PrecompiledContract{
common
.
BytesToAddress
([]
byte
{
4
})
:
&
dataCopy
{},
common
.
BytesToAddress
([]
byte
{
4
})
:
&
dataCopy
{},
}
}
// PrecompiledContracts
Metropolis
contains the default set of pre-compiled Ethereum
// PrecompiledContracts
Byzantium
contains the default set of pre-compiled Ethereum
// contracts used in the
Metropolis
release.
// contracts used in the
Byzantium
release.
var
PrecompiledContracts
Metropolis
=
map
[
common
.
Address
]
PrecompiledContract
{
var
PrecompiledContracts
Byzantium
=
map
[
common
.
Address
]
PrecompiledContract
{
common
.
BytesToAddress
([]
byte
{
1
})
:
&
ecrecover
{},
common
.
BytesToAddress
([]
byte
{
1
})
:
&
ecrecover
{},
common
.
BytesToAddress
([]
byte
{
2
})
:
&
sha256hash
{},
common
.
BytesToAddress
([]
byte
{
2
})
:
&
sha256hash
{},
common
.
BytesToAddress
([]
byte
{
3
})
:
&
ripemd160hash
{},
common
.
BytesToAddress
([]
byte
{
3
})
:
&
ripemd160hash
{},
...
...
core/vm/contracts_test.go
View file @
885c13c2
...
@@ -321,7 +321,7 @@ var bn256PairingTests = []precompiledTest{
...
@@ -321,7 +321,7 @@ var bn256PairingTests = []precompiledTest{
}
}
func
testPrecompiled
(
addr
string
,
test
precompiledTest
,
t
*
testing
.
T
)
{
func
testPrecompiled
(
addr
string
,
test
precompiledTest
,
t
*
testing
.
T
)
{
p
:=
PrecompiledContracts
Metropolis
[
common
.
HexToAddress
(
addr
)]
p
:=
PrecompiledContracts
Byzantium
[
common
.
HexToAddress
(
addr
)]
in
:=
common
.
Hex2Bytes
(
test
.
input
)
in
:=
common
.
Hex2Bytes
(
test
.
input
)
contract
:=
NewContract
(
AccountRef
(
common
.
HexToAddress
(
"1337"
)),
contract
:=
NewContract
(
AccountRef
(
common
.
HexToAddress
(
"1337"
)),
nil
,
new
(
big
.
Int
),
p
.
RequiredGas
(
in
))
nil
,
new
(
big
.
Int
),
p
.
RequiredGas
(
in
))
...
@@ -338,7 +338,7 @@ func benchmarkPrecompiled(addr string, test precompiledTest, bench *testing.B) {
...
@@ -338,7 +338,7 @@ func benchmarkPrecompiled(addr string, test precompiledTest, bench *testing.B) {
if
test
.
noBenchmark
{
if
test
.
noBenchmark
{
return
return
}
}
p
:=
PrecompiledContracts
Metropolis
[
common
.
HexToAddress
(
addr
)]
p
:=
PrecompiledContracts
Byzantium
[
common
.
HexToAddress
(
addr
)]
in
:=
common
.
Hex2Bytes
(
test
.
input
)
in
:=
common
.
Hex2Bytes
(
test
.
input
)
reqGas
:=
p
.
RequiredGas
(
in
)
reqGas
:=
p
.
RequiredGas
(
in
)
contract
:=
NewContract
(
AccountRef
(
common
.
HexToAddress
(
"1337"
)),
contract
:=
NewContract
(
AccountRef
(
common
.
HexToAddress
(
"1337"
)),
...
...
core/vm/evm.go
View file @
885c13c2
...
@@ -41,8 +41,8 @@ type (
...
@@ -41,8 +41,8 @@ type (
func
run
(
evm
*
EVM
,
snapshot
int
,
contract
*
Contract
,
input
[]
byte
)
([]
byte
,
error
)
{
func
run
(
evm
*
EVM
,
snapshot
int
,
contract
*
Contract
,
input
[]
byte
)
([]
byte
,
error
)
{
if
contract
.
CodeAddr
!=
nil
{
if
contract
.
CodeAddr
!=
nil
{
precompiles
:=
PrecompiledContractsHomestead
precompiles
:=
PrecompiledContractsHomestead
if
evm
.
ChainConfig
()
.
Is
Metropolis
(
evm
.
BlockNumber
)
{
if
evm
.
ChainConfig
()
.
Is
Byzantium
(
evm
.
BlockNumber
)
{
precompiles
=
PrecompiledContracts
Metropolis
precompiles
=
PrecompiledContracts
Byzantium
}
}
if
p
:=
precompiles
[
*
contract
.
CodeAddr
];
p
!=
nil
{
if
p
:=
precompiles
[
*
contract
.
CodeAddr
];
p
!=
nil
{
return
RunPrecompiledContract
(
p
,
input
,
contract
)
return
RunPrecompiledContract
(
p
,
input
,
contract
)
...
@@ -151,8 +151,8 @@ func (evm *EVM) Call(caller ContractRef, addr common.Address, input []byte, gas
...
@@ -151,8 +151,8 @@ func (evm *EVM) Call(caller ContractRef, addr common.Address, input []byte, gas
)
)
if
!
evm
.
StateDB
.
Exist
(
addr
)
{
if
!
evm
.
StateDB
.
Exist
(
addr
)
{
precompiles
:=
PrecompiledContractsHomestead
precompiles
:=
PrecompiledContractsHomestead
if
evm
.
ChainConfig
()
.
Is
Metropolis
(
evm
.
BlockNumber
)
{
if
evm
.
ChainConfig
()
.
Is
Byzantium
(
evm
.
BlockNumber
)
{
precompiles
=
PrecompiledContracts
Metropolis
precompiles
=
PrecompiledContracts
Byzantium
}
}
if
precompiles
[
addr
]
==
nil
&&
evm
.
ChainConfig
()
.
IsEIP158
(
evm
.
BlockNumber
)
&&
value
.
Sign
()
==
0
{
if
precompiles
[
addr
]
==
nil
&&
evm
.
ChainConfig
()
.
IsEIP158
(
evm
.
BlockNumber
)
&&
value
.
Sign
()
==
0
{
return
nil
,
gas
,
nil
return
nil
,
gas
,
nil
...
...
core/vm/gas_table.go
View file @
885c13c2
...
@@ -324,7 +324,7 @@ func gasCall(gt params.GasTable, evm *EVM, contract *Contract, stack *Stack, mem
...
@@ -324,7 +324,7 @@ func gasCall(gt params.GasTable, evm *EVM, contract *Contract, stack *Stack, mem
eip158
=
evm
.
ChainConfig
()
.
IsEIP158
(
evm
.
BlockNumber
)
eip158
=
evm
.
ChainConfig
()
.
IsEIP158
(
evm
.
BlockNumber
)
)
)
if
eip158
{
if
eip158
{
if
transfersValue
&&
evm
.
StateDB
.
Empty
(
address
)
{
if
transfersValue
&&
evm
.
StateDB
.
Empty
(
address
)
{
gas
+=
params
.
CallNewAccountGas
gas
+=
params
.
CallNewAccountGas
}
}
}
else
if
!
evm
.
StateDB
.
Exist
(
address
)
{
}
else
if
!
evm
.
StateDB
.
Exist
(
address
)
{
...
...
core/vm/interpreter.go
View file @
885c13c2
...
@@ -70,8 +70,8 @@ func NewInterpreter(evm *EVM, cfg Config) *Interpreter {
...
@@ -70,8 +70,8 @@ func NewInterpreter(evm *EVM, cfg Config) *Interpreter {
// we'll set the default jump table.
// we'll set the default jump table.
if
!
cfg
.
JumpTable
[
STOP
]
.
valid
{
if
!
cfg
.
JumpTable
[
STOP
]
.
valid
{
switch
{
switch
{
case
evm
.
ChainConfig
()
.
Is
Metropolis
(
evm
.
BlockNumber
)
:
case
evm
.
ChainConfig
()
.
Is
Byzantium
(
evm
.
BlockNumber
)
:
cfg
.
JumpTable
=
metropolis
InstructionSet
cfg
.
JumpTable
=
byzantium
InstructionSet
case
evm
.
ChainConfig
()
.
IsHomestead
(
evm
.
BlockNumber
)
:
case
evm
.
ChainConfig
()
.
IsHomestead
(
evm
.
BlockNumber
)
:
cfg
.
JumpTable
=
homesteadInstructionSet
cfg
.
JumpTable
=
homesteadInstructionSet
default
:
default
:
...
@@ -88,7 +88,7 @@ func NewInterpreter(evm *EVM, cfg Config) *Interpreter {
...
@@ -88,7 +88,7 @@ func NewInterpreter(evm *EVM, cfg Config) *Interpreter {
}
}
func
(
in
*
Interpreter
)
enforceRestrictions
(
op
OpCode
,
operation
operation
,
stack
*
Stack
)
error
{
func
(
in
*
Interpreter
)
enforceRestrictions
(
op
OpCode
,
operation
operation
,
stack
*
Stack
)
error
{
if
in
.
evm
.
chainRules
.
Is
Metropolis
{
if
in
.
evm
.
chainRules
.
Is
Byzantium
{
if
in
.
readOnly
{
if
in
.
readOnly
{
// If the interpreter is operating in readonly mode, make sure no
// If the interpreter is operating in readonly mode, make sure no
// state-modifying operation is performed. The 3rd stack item
// state-modifying operation is performed. The 3rd stack item
...
...
core/vm/jump_table.go
View file @
885c13c2
...
@@ -51,14 +51,14 @@ type operation struct {
...
@@ -51,14 +51,14 @@ type operation struct {
}
}
var
(
var
(
frontierInstructionSet
=
NewFrontierInstructionSet
()
frontierInstructionSet
=
NewFrontierInstructionSet
()
homesteadInstructionSet
=
NewHomesteadInstructionSet
()
homesteadInstructionSet
=
NewHomesteadInstructionSet
()
metropolisInstructionSet
=
NewMetropolis
InstructionSet
()
byzantiumInstructionSet
=
NewByzantium
InstructionSet
()
)
)
// New
Metropolis
InstructionSet returns the frontier, homestead and
// New
Byzantium
InstructionSet returns the frontier, homestead and
//
metropolis
instructions.
//
byzantium
instructions.
func
New
Metropolis
InstructionSet
()
[
256
]
operation
{
func
New
Byzantium
InstructionSet
()
[
256
]
operation
{
// instructions that can be executed during the homestead phase.
// instructions that can be executed during the homestead phase.
instructionSet
:=
NewHomesteadInstructionSet
()
instructionSet
:=
NewHomesteadInstructionSet
()
instructionSet
[
STATICCALL
]
=
operation
{
instructionSet
[
STATICCALL
]
=
operation
{
...
...
params/config.go
View file @
885c13c2
...
@@ -32,45 +32,45 @@ var (
...
@@ -32,45 +32,45 @@ var (
var
(
var
(
// MainnetChainConfig is the chain parameters to run a node on the main network.
// MainnetChainConfig is the chain parameters to run a node on the main network.
MainnetChainConfig
=
&
ChainConfig
{
MainnetChainConfig
=
&
ChainConfig
{
ChainId
:
big
.
NewInt
(
1
),
ChainId
:
big
.
NewInt
(
1
),
HomesteadBlock
:
big
.
NewInt
(
1150000
),
HomesteadBlock
:
big
.
NewInt
(
1150000
),
DAOForkBlock
:
big
.
NewInt
(
1920000
),
DAOForkBlock
:
big
.
NewInt
(
1920000
),
DAOForkSupport
:
true
,
DAOForkSupport
:
true
,
EIP150Block
:
big
.
NewInt
(
2463000
),
EIP150Block
:
big
.
NewInt
(
2463000
),
EIP150Hash
:
common
.
HexToHash
(
"0x2086799aeebeae135c246c65021c82b4e15a2c451340993aacfd2751886514f0"
),
EIP150Hash
:
common
.
HexToHash
(
"0x2086799aeebeae135c246c65021c82b4e15a2c451340993aacfd2751886514f0"
),
EIP155Block
:
big
.
NewInt
(
2675000
),
EIP155Block
:
big
.
NewInt
(
2675000
),
EIP158Block
:
big
.
NewInt
(
2675000
),
EIP158Block
:
big
.
NewInt
(
2675000
),
Metropolis
Block
:
big
.
NewInt
(
math
.
MaxInt64
),
// Don't enable yet
Byzantium
Block
:
big
.
NewInt
(
math
.
MaxInt64
),
// Don't enable yet
Ethash
:
new
(
EthashConfig
),
Ethash
:
new
(
EthashConfig
),
}
}
// TestnetChainConfig contains the chain parameters to run a node on the Ropsten test network.
// TestnetChainConfig contains the chain parameters to run a node on the Ropsten test network.
TestnetChainConfig
=
&
ChainConfig
{
TestnetChainConfig
=
&
ChainConfig
{
ChainId
:
big
.
NewInt
(
3
),
ChainId
:
big
.
NewInt
(
3
),
HomesteadBlock
:
big
.
NewInt
(
0
),
HomesteadBlock
:
big
.
NewInt
(
0
),
DAOForkBlock
:
nil
,
DAOForkBlock
:
nil
,
DAOForkSupport
:
true
,
DAOForkSupport
:
true
,
EIP150Block
:
big
.
NewInt
(
0
),
EIP150Block
:
big
.
NewInt
(
0
),
EIP150Hash
:
common
.
HexToHash
(
"0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d"
),
EIP150Hash
:
common
.
HexToHash
(
"0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d"
),
EIP155Block
:
big
.
NewInt
(
10
),
EIP155Block
:
big
.
NewInt
(
10
),
EIP158Block
:
big
.
NewInt
(
10
),
EIP158Block
:
big
.
NewInt
(
10
),
Metropolis
Block
:
big
.
NewInt
(
math
.
MaxInt64
),
// Don't enable yet
Byzantium
Block
:
big
.
NewInt
(
math
.
MaxInt64
),
// Don't enable yet
Ethash
:
new
(
EthashConfig
),
Ethash
:
new
(
EthashConfig
),
}
}
// RinkebyChainConfig contains the chain parameters to run a node on the Rinkeby test network.
// RinkebyChainConfig contains the chain parameters to run a node on the Rinkeby test network.
RinkebyChainConfig
=
&
ChainConfig
{
RinkebyChainConfig
=
&
ChainConfig
{
ChainId
:
big
.
NewInt
(
4
),
ChainId
:
big
.
NewInt
(
4
),
HomesteadBlock
:
big
.
NewInt
(
1
),
HomesteadBlock
:
big
.
NewInt
(
1
),
DAOForkBlock
:
nil
,
DAOForkBlock
:
nil
,
DAOForkSupport
:
true
,
DAOForkSupport
:
true
,
EIP150Block
:
big
.
NewInt
(
2
),
EIP150Block
:
big
.
NewInt
(
2
),
EIP150Hash
:
common
.
HexToHash
(
"0x9b095b36c15eaf13044373aef8ee0bd3a382a5abb92e402afa44b8249c3a90e9"
),
EIP150Hash
:
common
.
HexToHash
(
"0x9b095b36c15eaf13044373aef8ee0bd3a382a5abb92e402afa44b8249c3a90e9"
),
EIP155Block
:
big
.
NewInt
(
3
),
EIP155Block
:
big
.
NewInt
(
3
),
EIP158Block
:
big
.
NewInt
(
3
),
EIP158Block
:
big
.
NewInt
(
3
),
Metropolis
Block
:
big
.
NewInt
(
math
.
MaxInt64
),
// Don't enable yet
Byzantium
Block
:
big
.
NewInt
(
math
.
MaxInt64
),
// Don't enable yet
Clique
:
&
CliqueConfig
{
Clique
:
&
CliqueConfig
{
Period
:
15
,
Period
:
15
,
...
@@ -110,7 +110,7 @@ type ChainConfig struct {
...
@@ -110,7 +110,7 @@ type ChainConfig struct {
EIP155Block
*
big
.
Int
`json:"eip155Block,omitempty"`
// EIP155 HF block
EIP155Block
*
big
.
Int
`json:"eip155Block,omitempty"`
// EIP155 HF block
EIP158Block
*
big
.
Int
`json:"eip158Block,omitempty"`
// EIP158 HF block
EIP158Block
*
big
.
Int
`json:"eip158Block,omitempty"`
// EIP158 HF block
MetropolisBlock
*
big
.
Int
`json:"metropolisBlock,omitempty"`
// Metropolis
switch block (nil = no fork, 0 = alraedy on homestead)
ByzantiumBlock
*
big
.
Int
`json:"byzantiumBlock,omitempty"`
// Byzantium
switch block (nil = no fork, 0 = alraedy on homestead)
// Various consensus engines
// Various consensus engines
Ethash
*
EthashConfig
`json:"ethash,omitempty"`
Ethash
*
EthashConfig
`json:"ethash,omitempty"`
...
@@ -147,7 +147,7 @@ func (c *ChainConfig) String() string {
...
@@ -147,7 +147,7 @@ func (c *ChainConfig) String() string {
default
:
default
:
engine
=
"unknown"
engine
=
"unknown"
}
}
return
fmt
.
Sprintf
(
"{ChainID: %v Homestead: %v DAO: %v DAOSupport: %v EIP150: %v EIP155: %v EIP158: %v
Metropolis
: %v Engine: %v}"
,
return
fmt
.
Sprintf
(
"{ChainID: %v Homestead: %v DAO: %v DAOSupport: %v EIP150: %v EIP155: %v EIP158: %v
Byzantium
: %v Engine: %v}"
,
c
.
ChainId
,
c
.
ChainId
,
c
.
HomesteadBlock
,
c
.
HomesteadBlock
,
c
.
DAOForkBlock
,
c
.
DAOForkBlock
,
...
@@ -155,7 +155,7 @@ func (c *ChainConfig) String() string {
...
@@ -155,7 +155,7 @@ func (c *ChainConfig) String() string {
c
.
EIP150Block
,
c
.
EIP150Block
,
c
.
EIP155Block
,
c
.
EIP155Block
,
c
.
EIP158Block
,
c
.
EIP158Block
,
c
.
Metropolis
Block
,
c
.
Byzantium
Block
,
engine
,
engine
,
)
)
}
}
...
@@ -182,8 +182,8 @@ func (c *ChainConfig) IsEIP158(num *big.Int) bool {
...
@@ -182,8 +182,8 @@ func (c *ChainConfig) IsEIP158(num *big.Int) bool {
return
isForked
(
c
.
EIP158Block
,
num
)
return
isForked
(
c
.
EIP158Block
,
num
)
}
}
func
(
c
*
ChainConfig
)
Is
Metropolis
(
num
*
big
.
Int
)
bool
{
func
(
c
*
ChainConfig
)
Is
Byzantium
(
num
*
big
.
Int
)
bool
{
return
isForked
(
c
.
Metropolis
Block
,
num
)
return
isForked
(
c
.
Byzantium
Block
,
num
)
}
}
// GasTable returns the gas table corresponding to the current phase (homestead or homestead reprice).
// 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
...
@@ -243,8 +243,8 @@ func (c *ChainConfig) checkCompatible(newcfg *ChainConfig, head *big.Int) *Confi
if
c
.
IsEIP158
(
head
)
&&
!
configNumEqual
(
c
.
ChainId
,
newcfg
.
ChainId
)
{
if
c
.
IsEIP158
(
head
)
&&
!
configNumEqual
(
c
.
ChainId
,
newcfg
.
ChainId
)
{
return
newCompatError
(
"EIP158 chain ID"
,
c
.
EIP158Block
,
newcfg
.
EIP158Block
)
return
newCompatError
(
"EIP158 chain ID"
,
c
.
EIP158Block
,
newcfg
.
EIP158Block
)
}
}
if
isForkIncompatible
(
c
.
MetropolisBlock
,
newcfg
.
Metropolis
Block
,
head
)
{
if
isForkIncompatible
(
c
.
ByzantiumBlock
,
newcfg
.
Byzantium
Block
,
head
)
{
return
newCompatError
(
"
Metropolis fork block"
,
c
.
MetropolisBlock
,
newcfg
.
Metropolis
Block
)
return
newCompatError
(
"
Byzantium fork block"
,
c
.
ByzantiumBlock
,
newcfg
.
Byzantium
Block
)
}
}
return
nil
return
nil
}
}
...
@@ -312,7 +312,7 @@ func (err *ConfigCompatError) Error() string {
...
@@ -312,7 +312,7 @@ func (err *ConfigCompatError) Error() string {
type
Rules
struct
{
type
Rules
struct
{
ChainId
*
big
.
Int
ChainId
*
big
.
Int
IsHomestead
,
IsEIP150
,
IsEIP155
,
IsEIP158
bool
IsHomestead
,
IsEIP150
,
IsEIP155
,
IsEIP158
bool
Is
Metropolis
bool
Is
Byzantium
bool
}
}
func
(
c
*
ChainConfig
)
Rules
(
num
*
big
.
Int
)
Rules
{
func
(
c
*
ChainConfig
)
Rules
(
num
*
big
.
Int
)
Rules
{
...
@@ -320,5 +320,5 @@ func (c *ChainConfig) Rules(num *big.Int) Rules {
...
@@ -320,5 +320,5 @@ func (c *ChainConfig) Rules(num *big.Int) Rules {
if
chainId
==
nil
{
if
chainId
==
nil
{
chainId
=
new
(
big
.
Int
)
chainId
=
new
(
big
.
Int
)
}
}
return
Rules
{
ChainId
:
new
(
big
.
Int
)
.
Set
(
chainId
),
IsHomestead
:
c
.
IsHomestead
(
num
),
IsEIP150
:
c
.
IsEIP150
(
num
),
IsEIP155
:
c
.
IsEIP155
(
num
),
IsEIP158
:
c
.
IsEIP158
(
num
),
Is
Metropolis
:
c
.
IsMetropolis
(
num
)}
return
Rules
{
ChainId
:
new
(
big
.
Int
)
.
Set
(
chainId
),
IsHomestead
:
c
.
IsHomestead
(
num
),
IsEIP150
:
c
.
IsEIP150
(
num
),
IsEIP155
:
c
.
IsEIP155
(
num
),
IsEIP158
:
c
.
IsEIP158
(
num
),
Is
Byzantium
:
c
.
IsByzantium
(
num
)}
}
}
tests/init.go
View file @
885c13c2
...
@@ -45,13 +45,13 @@ var Forks = map[string]*params.ChainConfig{
...
@@ -45,13 +45,13 @@ var Forks = map[string]*params.ChainConfig{
EIP158Block
:
big
.
NewInt
(
0
),
EIP158Block
:
big
.
NewInt
(
0
),
},
},
"Byzantium"
:
&
params
.
ChainConfig
{
"Byzantium"
:
&
params
.
ChainConfig
{
ChainId
:
big
.
NewInt
(
1
),
ChainId
:
big
.
NewInt
(
1
),
HomesteadBlock
:
big
.
NewInt
(
0
),
HomesteadBlock
:
big
.
NewInt
(
0
),
EIP150Block
:
big
.
NewInt
(
0
),
EIP150Block
:
big
.
NewInt
(
0
),
EIP155Block
:
big
.
NewInt
(
0
),
EIP155Block
:
big
.
NewInt
(
0
),
EIP158Block
:
big
.
NewInt
(
0
),
EIP158Block
:
big
.
NewInt
(
0
),
DAOForkBlock
:
big
.
NewInt
(
0
),
DAOForkBlock
:
big
.
NewInt
(
0
),
Metropolis
Block
:
big
.
NewInt
(
0
),
Byzantium
Block
:
big
.
NewInt
(
0
),
},
},
"FrontierToHomesteadAt5"
:
&
params
.
ChainConfig
{
"FrontierToHomesteadAt5"
:
&
params
.
ChainConfig
{
ChainId
:
big
.
NewInt
(
1
),
ChainId
:
big
.
NewInt
(
1
),
...
@@ -69,12 +69,12 @@ var Forks = map[string]*params.ChainConfig{
...
@@ -69,12 +69,12 @@ var Forks = map[string]*params.ChainConfig{
DAOForkSupport
:
true
,
DAOForkSupport
:
true
,
},
},
"EIP158ToByzantiumAt5"
:
&
params
.
ChainConfig
{
"EIP158ToByzantiumAt5"
:
&
params
.
ChainConfig
{
ChainId
:
big
.
NewInt
(
1
),
ChainId
:
big
.
NewInt
(
1
),
HomesteadBlock
:
big
.
NewInt
(
0
),
HomesteadBlock
:
big
.
NewInt
(
0
),
EIP150Block
:
big
.
NewInt
(
0
),
EIP150Block
:
big
.
NewInt
(
0
),
EIP155Block
:
big
.
NewInt
(
0
),
EIP155Block
:
big
.
NewInt
(
0
),
EIP158Block
:
big
.
NewInt
(
0
),
EIP158Block
:
big
.
NewInt
(
0
),
Metropolis
Block
:
big
.
NewInt
(
5
),
Byzantium
Block
:
big
.
NewInt
(
5
),
},
},
}
}
...
...
tests/transaction_test.go
View file @
885c13c2
...
@@ -37,12 +37,12 @@ func TestTransaction(t *testing.T) {
...
@@ -37,12 +37,12 @@ func TestTransaction(t *testing.T) {
EIP158Block
:
big
.
NewInt
(
0
),
EIP158Block
:
big
.
NewInt
(
0
),
ChainId
:
big
.
NewInt
(
1
),
ChainId
:
big
.
NewInt
(
1
),
})
})
txt
.
config
(
`^
Metropolis
/`
,
params
.
ChainConfig
{
txt
.
config
(
`^
Byzantium
/`
,
params
.
ChainConfig
{
HomesteadBlock
:
big
.
NewInt
(
0
),
HomesteadBlock
:
big
.
NewInt
(
0
),
EIP150Block
:
big
.
NewInt
(
0
),
EIP150Block
:
big
.
NewInt
(
0
),
EIP155Block
:
big
.
NewInt
(
0
),
EIP155Block
:
big
.
NewInt
(
0
),
EIP158Block
:
big
.
NewInt
(
0
),
EIP158Block
:
big
.
NewInt
(
0
),
Metropolis
Block
:
big
.
NewInt
(
0
),
Byzantium
Block
:
big
.
NewInt
(
0
),
})
})
txt
.
walk
(
t
,
transactionTestDir
,
func
(
t
*
testing
.
T
,
name
string
,
test
*
TransactionTest
)
{
txt
.
walk
(
t
,
transactionTestDir
,
func
(
t
*
testing
.
T
,
name
string
,
test
*
TransactionTest
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment