Revert "core: update DAO soft-fork number, clean up the code"
This reverts commit ba784bdf36
.
This commit is contained in:
@ -371,10 +371,5 @@ func CalcGasLimit(parent *types.Block) *big.Int {
|
||||
gl.Add(parent.GasLimit(), decay)
|
||||
gl.Set(common.BigMin(gl, params.TargetGasLimit))
|
||||
}
|
||||
// Temporary special case: if DAO rupture is requested, cap the gas limit
|
||||
if DAOSoftFork && parent.NumberU64() <= ruptureBlock && gl.Cmp(ruptureTarget) > 0 {
|
||||
gl.Sub(parent.GasLimit(), decay)
|
||||
gl.Set(common.BigMax(gl, ruptureTarget))
|
||||
}
|
||||
return gl
|
||||
}
|
||||
|
@ -84,10 +84,12 @@ func exec(env vm.Environment, caller vm.ContractRef, address, codeAddr *common.A
|
||||
address = &addr
|
||||
createAccount = true
|
||||
}
|
||||
// Mark all contracts doing outbound value transfers to allow DAO filtering.
|
||||
|
||||
// mark the code hash if the execution is a call, callcode or delegate.
|
||||
if value.Cmp(common.Big0) > 0 {
|
||||
env.MarkCodeHash(env.Db().GetCodeHash(caller.Address()))
|
||||
}
|
||||
|
||||
snapshotPreTransfer := env.MakeSnapshot()
|
||||
var (
|
||||
from = env.Db().GetAccount(caller.Address())
|
||||
@ -146,7 +148,7 @@ func execDelegateCall(env vm.Environment, caller vm.ContractRef, originAddr, toA
|
||||
caller.ReturnGas(gas, gasPrice)
|
||||
return nil, common.Address{}, vm.DepthError
|
||||
}
|
||||
// Mark all contracts doing outbound value transfers to allow DAO filtering.
|
||||
|
||||
if value.Cmp(common.Big0) > 0 {
|
||||
env.MarkCodeHash(env.Db().GetCodeHash(caller.Address()))
|
||||
}
|
||||
|
@ -51,6 +51,8 @@ type StateDB struct {
|
||||
txIndex int
|
||||
logs map[common.Hash]vm.Logs
|
||||
logSize uint
|
||||
|
||||
reducedDao bool
|
||||
}
|
||||
|
||||
// Create a new state from a given trie
|
||||
|
@ -35,10 +35,7 @@ var (
|
||||
blockedCodeHashErr = errors.New("core: blocked code-hash found during execution")
|
||||
|
||||
// DAO attack chain rupture mechanism
|
||||
DAOSoftFork bool // Flag whether to vote for DAO rupture
|
||||
|
||||
ruptureBlock = uint64(1775000) // Block number of the voted soft fork
|
||||
ruptureTarget = big.NewInt(3141592) // Gas target (hard) for miners voting to fork
|
||||
ruptureBlock = uint64(1760000) // Block number of the voted soft fork
|
||||
ruptureThreshold = big.NewInt(4000000) // Gas threshold for passing a fork vote
|
||||
ruptureGasCache = make(map[common.Hash]*big.Int) // Amount of gas in the point of rupture
|
||||
ruptureCodeHashes = map[common.Hash]struct{}{
|
||||
@ -144,13 +141,21 @@ func ApplyTransaction(config *ChainConfig, bc *BlockChain, gp *GasPool, statedb
|
||||
}
|
||||
}
|
||||
}
|
||||
// Verify if the DAO soft fork kicks in
|
||||
if blockRuptureCodes {
|
||||
if recipient := tx.To(); recipient == nil || !ruptureWhitelist[*recipient] {
|
||||
for hash, _ := range env.GetMarkedCodeHashes() {
|
||||
if _, blocked := ruptureCodeHashes[hash]; blocked {
|
||||
return nil, nil, nil, blockedCodeHashErr
|
||||
}
|
||||
// Iterate over the bullshit blacklist to keep waste some time while keeping random Joe's happy
|
||||
if len(BlockedCodeHashes) > 0 {
|
||||
for hash, _ := range env.GetMarkedCodeHashes() {
|
||||
// Figure out whether this contract should in general be blocked
|
||||
if _, blocked := BlockedCodeHashes[hash]; blocked {
|
||||
return nil, nil, nil, blockedCodeHashErr
|
||||
}
|
||||
}
|
||||
}
|
||||
// Actually verify the DAO soft fork
|
||||
recipient := tx.To()
|
||||
if blockRuptureCodes && (recipient == nil || !ruptureWhitelist[*recipient]) {
|
||||
for hash, _ := range env.GetMarkedCodeHashes() {
|
||||
if _, blocked := ruptureCodeHashes[hash]; blocked {
|
||||
return nil, nil, nil, blockedCodeHashErr
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -27,9 +27,10 @@ import (
|
||||
|
||||
// Env is a basic runtime environment required for running the EVM.
|
||||
type Env struct {
|
||||
ruleSet vm.RuleSet
|
||||
depth int
|
||||
state *state.StateDB
|
||||
ruleSet vm.RuleSet
|
||||
depth int
|
||||
state *state.StateDB
|
||||
illegalHashes []common.Hash
|
||||
|
||||
origin common.Address
|
||||
coinbase common.Address
|
||||
@ -49,14 +50,15 @@ type Env struct {
|
||||
// NewEnv returns a new vm.Environment
|
||||
func NewEnv(cfg *Config, state *state.StateDB) vm.Environment {
|
||||
env := &Env{
|
||||
ruleSet: cfg.RuleSet,
|
||||
state: state,
|
||||
origin: cfg.Origin,
|
||||
coinbase: cfg.Coinbase,
|
||||
number: cfg.BlockNumber,
|
||||
time: cfg.Time,
|
||||
difficulty: cfg.Difficulty,
|
||||
gasLimit: cfg.GasLimit,
|
||||
ruleSet: cfg.RuleSet,
|
||||
illegalHashes: cfg.illegalHashes,
|
||||
state: state,
|
||||
origin: cfg.Origin,
|
||||
coinbase: cfg.Coinbase,
|
||||
number: cfg.BlockNumber,
|
||||
time: cfg.Time,
|
||||
difficulty: cfg.Difficulty,
|
||||
gasLimit: cfg.GasLimit,
|
||||
}
|
||||
env.evm = vm.New(env, vm.Config{
|
||||
Debug: cfg.Debug,
|
||||
|
@ -35,17 +35,18 @@ func (ruleSet) IsHomestead(*big.Int) bool { return true }
|
||||
// Config is a basic type specifying certain configuration flags for running
|
||||
// the EVM.
|
||||
type Config struct {
|
||||
RuleSet vm.RuleSet
|
||||
Difficulty *big.Int
|
||||
Origin common.Address
|
||||
Coinbase common.Address
|
||||
BlockNumber *big.Int
|
||||
Time *big.Int
|
||||
GasLimit *big.Int
|
||||
GasPrice *big.Int
|
||||
Value *big.Int
|
||||
DisableJit bool // "disable" so it's enabled by default
|
||||
Debug bool
|
||||
RuleSet vm.RuleSet
|
||||
Difficulty *big.Int
|
||||
Origin common.Address
|
||||
Coinbase common.Address
|
||||
BlockNumber *big.Int
|
||||
Time *big.Int
|
||||
GasLimit *big.Int
|
||||
GasPrice *big.Int
|
||||
Value *big.Int
|
||||
DisableJit bool // "disable" so it's enabled by default
|
||||
Debug bool
|
||||
illegalHashes []common.Hash
|
||||
|
||||
State *state.StateDB
|
||||
GetHashFn func(n uint64) common.Hash
|
||||
|
@ -25,6 +25,10 @@ import (
|
||||
"github.com/ethereum/go-ethereum/core/vm"
|
||||
)
|
||||
|
||||
// BlockedCodeHashes is a set of EVM code hashes that this node should block
|
||||
// sending funds from.
|
||||
var BlockedCodeHashes map[common.Hash]struct{}
|
||||
|
||||
// GetHashFn returns a function for which the VM env can query block hashes through
|
||||
// up to the limit defined by the Yellow Paper and uses the given block chain
|
||||
// to query for information.
|
||||
|
Reference in New Issue
Block a user