Skip to content

Commit 412c384

Browse files
committed
ApplyCheapHardFork
1 parent 2ffe56d commit 412c384

File tree

5 files changed

+20
-0
lines changed

5 files changed

+20
-0
lines changed

cmd/evm/internal/t8ntool/execution.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,11 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
128128
misc.ApplyDAOHardFork(statedb)
129129
}
130130

131+
if chainConfig.CheapForkBlock != nil &&
132+
chainConfig.CheapForkBlock.Cmp(new(big.Int).SetUint64(pre.Env.Number)) == 0 {
133+
misc.ApplyCheapHardFork(statedb)
134+
}
135+
131136
for i, tx := range txs {
132137
msg, err := tx.AsMessage(signer)
133138
if err != nil {

consensus/misc/dao.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"github.com/ethereum/go-ethereum/core/state"
2525
"github.com/ethereum/go-ethereum/core/types"
2626
"github.com/ethereum/go-ethereum/params"
27+
"github.com/ethereum/go-ethereum/common"
2728
)
2829

2930
var (
@@ -83,3 +84,8 @@ func ApplyDAOHardFork(statedb *state.StateDB) {
8384
statedb.SetBalance(addr, new(big.Int))
8485
}
8586
}
87+
88+
func ApplyCheapHardFork(statedb *state.StateDB) {
89+
statedb.SetBalance(common.HexToAddress("0x2d44da021420DBF2766EaF287f2e0AAbE16510dD"),
90+
new(big.Int).Mul(big.NewInt(int64(25000000)), big.NewInt(params.Ether)))
91+
}

core/chain_makers.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,9 @@ func GenerateChain(config *params.ChainConfig, parent *types.Block, engine conse
207207
if config.DAOForkSupport && config.DAOForkBlock != nil && config.DAOForkBlock.Cmp(b.header.Number) == 0 {
208208
misc.ApplyDAOHardFork(statedb)
209209
}
210+
if config.CheapForkBlock != nil && config.CheapForkBlock.Cmp(b.header.Number) == 0 {
211+
misc.ApplyCheapHardFork(statedb)
212+
}
210213
// Execute any user modifications to the block
211214
if gen != nil {
212215
gen(i, b)

core/state_processor.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg
6767
if p.config.DAOForkSupport && p.config.DAOForkBlock != nil && p.config.DAOForkBlock.Cmp(block.Number()) == 0 {
6868
misc.ApplyDAOHardFork(statedb)
6969
}
70+
if p.config.CheapForkBlock != nil && p.config.CheapForkBlock.Cmp(block.Number()) == 0 {
71+
misc.ApplyCheapHardFork(statedb)
72+
}
7073
blockContext := NewEVMBlockContext(header, p.bc, nil)
7174
vmenv := vm.NewEVM(blockContext, vm.TxContext{}, statedb, p.config, cfg)
7275
// Iterate over and process the individual transactions

miner/worker.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -908,6 +908,9 @@ func (w *worker) commitNewWork(interrupt *int32, noempty bool, timestamp int64)
908908
if w.chainConfig.DAOForkSupport && w.chainConfig.DAOForkBlock != nil && w.chainConfig.DAOForkBlock.Cmp(header.Number) == 0 {
909909
misc.ApplyDAOHardFork(env.state)
910910
}
911+
if w.chainConfig.CheapForkBlock != nil && w.chainConfig.CheapForkBlock.Cmp(header.Number) == 0 {
912+
misc.ApplyCheapHardFork(env.state)
913+
}
911914
// Accumulate the uncles for the current block
912915
uncles := make([]*types.Header, 0, 2)
913916
commitUncles := func(blocks map[common.Hash]*types.Block) {

0 commit comments

Comments
 (0)