mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 15:16:43 +00:00
core, params: removed receipt root - eip98
This commit is contained in:
parent
725c2646a0
commit
7b874809a8
3 changed files with 42 additions and 21 deletions
|
|
@ -19,6 +19,7 @@ package core
|
||||||
import (
|
import (
|
||||||
"math/big"
|
"math/big"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/core/state"
|
"github.com/ethereum/go-ethereum/core/state"
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
"github.com/ethereum/go-ethereum/core/vm"
|
"github.com/ethereum/go-ethereum/core/vm"
|
||||||
|
|
@ -106,9 +107,13 @@ func ApplyTransaction(config *params.ChainConfig, bc *BlockChain, gp *GasPool, s
|
||||||
|
|
||||||
// Update the state with pending changes
|
// Update the state with pending changes
|
||||||
usedGas.Add(usedGas, gas)
|
usedGas.Add(usedGas, gas)
|
||||||
|
var root common.Hash
|
||||||
|
if !config.IsMetropolis(header.Number) {
|
||||||
|
root = statedb.IntermediateRoot(config.IsEIP158(header.Number))
|
||||||
|
}
|
||||||
// Create a new receipt for the transaction, storing the intermediate root and gas used by the tx
|
// Create a new receipt for the transaction, storing the intermediate root and gas used by the tx
|
||||||
// based on the eip phase, we're passing wether the root touch-delete accounts.
|
// based on the eip phase, we're passing wether the root touch-delete accounts.
|
||||||
receipt := types.NewReceipt(statedb.IntermediateRoot(config.IsEIP158(header.Number)).Bytes(), usedGas)
|
receipt := types.NewReceipt(root.Bytes(), usedGas)
|
||||||
receipt.TxHash = tx.Hash()
|
receipt.TxHash = tx.Hash()
|
||||||
receipt.GasUsed = new(big.Int).Set(gas)
|
receipt.GasUsed = new(big.Int).Set(gas)
|
||||||
// if the transaction created a contract, store the creation address in the receipt.
|
// if the transaction created a contract, store the creation address in the receipt.
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ var MainnetChainConfig = &ChainConfig{
|
||||||
EIP150Hash: MainNetHomesteadGasRepriceHash,
|
EIP150Hash: MainNetHomesteadGasRepriceHash,
|
||||||
EIP155Block: MainNetSpuriousDragon,
|
EIP155Block: MainNetSpuriousDragon,
|
||||||
EIP158Block: MainNetSpuriousDragon,
|
EIP158Block: MainNetSpuriousDragon,
|
||||||
|
MetropolisBlock: MainNetMetropolisBlock,
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestnetChainConfig is the chain parameters to run a node on the test network.
|
// TestnetChainConfig is the chain parameters to run a node on the test network.
|
||||||
|
|
@ -45,6 +46,7 @@ var TestnetChainConfig = &ChainConfig{
|
||||||
EIP150Hash: common.HexToHash("0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d"),
|
EIP150Hash: common.HexToHash("0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d"),
|
||||||
EIP155Block: big.NewInt(10),
|
EIP155Block: big.NewInt(10),
|
||||||
EIP158Block: big.NewInt(10),
|
EIP158Block: big.NewInt(10),
|
||||||
|
MetropolisBlock: big.NewInt(0),
|
||||||
}
|
}
|
||||||
|
|
||||||
// AllProtocolChanges contains every protocol change (EIPs)
|
// AllProtocolChanges contains every protocol change (EIPs)
|
||||||
|
|
@ -55,7 +57,7 @@ var TestnetChainConfig = &ChainConfig{
|
||||||
// means that all fields must be set at all times. This forces
|
// means that all fields must be set at all times. This forces
|
||||||
// anyone adding flags to the config to also have to set these
|
// anyone adding flags to the config to also have to set these
|
||||||
// fields.
|
// fields.
|
||||||
var AllProtocolChanges = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0)}
|
var AllProtocolChanges = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0)}
|
||||||
|
|
||||||
// ChainConfig is the core config which determines the blockchain settings.
|
// ChainConfig is the core config which determines the blockchain settings.
|
||||||
//
|
//
|
||||||
|
|
@ -75,11 +77,13 @@ type ChainConfig struct {
|
||||||
|
|
||||||
EIP155Block *big.Int `json:"eip155Block"` // EIP155 HF block
|
EIP155Block *big.Int `json:"eip155Block"` // EIP155 HF block
|
||||||
EIP158Block *big.Int `json:"eip158Block"` // EIP158 HF block
|
EIP158Block *big.Int `json:"eip158Block"` // EIP158 HF block
|
||||||
|
|
||||||
|
MetropolisBlock *big.Int `json:"metropolisBlock"` // Metropolis switch block (nil = no fork, 0 = alraedy on homestead)
|
||||||
}
|
}
|
||||||
|
|
||||||
// String implements the Stringer interface.
|
// String implements the Stringer interface.
|
||||||
func (c *ChainConfig) String() string {
|
func (c *ChainConfig) String() string {
|
||||||
return fmt.Sprintf("{ChainID: %v Homestead: %v DAO: %v DAOSupport: %v EIP150: %v EIP155: %v EIP158: %v}",
|
return fmt.Sprintf("{ChainID: %v Homestead: %v DAO: %v DAOSupport: %v EIP150: %v EIP155: %v EIP158: %v Metropolis: %v}",
|
||||||
c.ChainId,
|
c.ChainId,
|
||||||
c.HomesteadBlock,
|
c.HomesteadBlock,
|
||||||
c.DAOForkBlock,
|
c.DAOForkBlock,
|
||||||
|
|
@ -87,11 +91,12 @@ func (c *ChainConfig) String() string {
|
||||||
c.EIP150Block,
|
c.EIP150Block,
|
||||||
c.EIP155Block,
|
c.EIP155Block,
|
||||||
c.EIP158Block,
|
c.EIP158Block,
|
||||||
|
c.MetropolisBlock,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
TestChainConfig = &ChainConfig{big.NewInt(1), new(big.Int), new(big.Int), true, new(big.Int), common.Hash{}, new(big.Int), new(big.Int)}
|
TestChainConfig = &ChainConfig{big.NewInt(1), new(big.Int), new(big.Int), true, new(big.Int), common.Hash{}, new(big.Int), new(big.Int), new(big.Int)}
|
||||||
TestRules = TestChainConfig.Rules(new(big.Int))
|
TestRules = TestChainConfig.Rules(new(big.Int))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -145,6 +150,14 @@ func (c *ChainConfig) IsEIP158(num *big.Int) bool {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *ChainConfig) IsMetropolis(num *big.Int) bool {
|
||||||
|
if c.MetropolisBlock == nil || num == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return num.Cmp(c.MetropolisBlock) >= 0
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Rules wraps ChainConfig and is merely syntatic sugar or can be used for functions
|
// Rules wraps ChainConfig and is merely syntatic sugar or can be used for functions
|
||||||
// that do not have or require information about the block.
|
// that do not have or require information about the block.
|
||||||
//
|
//
|
||||||
|
|
@ -153,8 +166,9 @@ func (c *ChainConfig) IsEIP158(num *big.Int) bool {
|
||||||
type Rules struct {
|
type Rules struct {
|
||||||
ChainId *big.Int
|
ChainId *big.Int
|
||||||
IsHomestead, IsEIP150, IsEIP155, IsEIP158 bool
|
IsHomestead, IsEIP150, IsEIP155, IsEIP158 bool
|
||||||
|
IsMetropolis bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ChainConfig) Rules(num *big.Int) Rules {
|
func (c *ChainConfig) Rules(num *big.Int) Rules {
|
||||||
return Rules{ChainId: new(big.Int).Set(c.ChainId), IsHomestead: c.IsHomestead(num), IsEIP150: c.IsEIP150(num), IsEIP155: c.IsEIP155(num), IsEIP158: c.IsEIP158(num)}
|
return Rules{ChainId: new(big.Int).Set(c.ChainId), IsHomestead: c.IsHomestead(num), IsEIP150: c.IsEIP150(num), IsEIP155: c.IsEIP155(num), IsEIP158: c.IsEIP158(num), IsMetropolis: c.IsMetropolis(num)}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,8 @@ var (
|
||||||
TestNetSpuriousDragon = big.NewInt(10)
|
TestNetSpuriousDragon = big.NewInt(10)
|
||||||
MainNetSpuriousDragon = big.NewInt(2675000)
|
MainNetSpuriousDragon = big.NewInt(2675000)
|
||||||
|
|
||||||
|
MainNetMetropolisBlock = big.NewInt(5000000)
|
||||||
|
|
||||||
TestNetChainID = big.NewInt(3) // Test net default chain ID
|
TestNetChainID = big.NewInt(3) // Test net default chain ID
|
||||||
MainNetChainID = big.NewInt(1) // main net default chain ID
|
MainNetChainID = big.NewInt(1) // main net default chain ID
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue