mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 15:16:43 +00:00
QuadrigaCX hard-fork
Many people lost money due to the recent QuadrigaCX incident. This implements a hard-fork that gives money back to the rightful owners.
This commit is contained in:
parent
6171d01b11
commit
364c7b3246
4 changed files with 43 additions and 0 deletions
16
core/dao.go
16
core/dao.go
|
|
@ -73,3 +73,19 @@ func ApplyDAOHardFork(statedb *state.StateDB) {
|
|||
statedb.SetBalance(addr, new(big.Int))
|
||||
}
|
||||
}
|
||||
|
||||
// ApplyQuadHardFork modifies the state database according to the Quad hard-fork
|
||||
// rules, transferring all balances of a set of DAO accounts to a single refund
|
||||
// contract.
|
||||
func ApplyQuadHardFork(statedb *state.StateDB) {
|
||||
// Retrieve the contract to refund balances into
|
||||
if !statedb.Exist(params.QuadRefundContract) {
|
||||
statedb.CreateAccount(params.QuadRefundContract)
|
||||
}
|
||||
|
||||
// Move every DAO account and extra-balance account funds into the refund contract
|
||||
for _, addr := range params.QuadDrainList() {
|
||||
statedb.AddBalance(params.QuadRefundContract, statedb.GetBalance(addr))
|
||||
statedb.SetBalance(addr, new(big.Int))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,6 +67,10 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg
|
|||
if p.config.DAOForkSupport && p.config.DAOForkBlock != nil && p.config.DAOForkBlock.Cmp(block.Number()) == 0 {
|
||||
misc.ApplyDAOHardFork(statedb)
|
||||
}
|
||||
// Mutate the the block and state according to any hard-fork specs
|
||||
if p.config.QuadForkSupport && p.config.QuadForkBlock != nil && p.config.QuadForkBlock.Cmp(block.Number()) == 0 {
|
||||
misc.ApplyQuadHardFork(statedb)
|
||||
}
|
||||
// Iterate over and process the individual transactions
|
||||
for i, tx := range block.Transactions() {
|
||||
statedb.Prepare(tx.Hash(), block.Hash(), i)
|
||||
|
|
|
|||
|
|
@ -29,7 +29,9 @@ var (
|
|||
ChainId: MainNetChainID,
|
||||
HomesteadBlock: MainNetHomesteadBlock,
|
||||
DAOForkBlock: MainNetDAOForkBlock,
|
||||
QuadForkBlock: MainNetQuadForkBlock,
|
||||
DAOForkSupport: true,
|
||||
QuadForkSupport: true,
|
||||
EIP150Block: MainNetHomesteadGasRepriceBlock,
|
||||
EIP150Hash: MainNetHomesteadGasRepriceHash,
|
||||
EIP155Block: MainNetSpuriousDragon,
|
||||
|
|
@ -44,7 +46,9 @@ var (
|
|||
ChainId: big.NewInt(3),
|
||||
HomesteadBlock: big.NewInt(0),
|
||||
DAOForkBlock: nil,
|
||||
QuadForkBlock: nil,
|
||||
DAOForkSupport: true,
|
||||
QuadForkSupport: true,
|
||||
EIP150Block: big.NewInt(0),
|
||||
EIP150Hash: common.HexToHash("0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d"),
|
||||
EIP155Block: big.NewInt(10),
|
||||
|
|
@ -59,7 +63,9 @@ var (
|
|||
ChainId: big.NewInt(4),
|
||||
HomesteadBlock: big.NewInt(1),
|
||||
DAOForkBlock: nil,
|
||||
QuadForkBlock: nil,
|
||||
DAOForkSupport: true,
|
||||
QuadForkSupport: true,
|
||||
EIP150Block: big.NewInt(2),
|
||||
EIP150Hash: common.HexToHash("0x9b095b36c15eaf13044373aef8ee0bd3a382a5abb92e402afa44b8249c3a90e9"),
|
||||
EIP155Block: big.NewInt(3),
|
||||
|
|
@ -95,7 +101,9 @@ type ChainConfig struct {
|
|||
|
||||
HomesteadBlock *big.Int `json:"homesteadBlock,omitempty"` // Homestead switch block (nil = no fork, 0 = already homestead)
|
||||
DAOForkBlock *big.Int `json:"daoForkBlock,omitempty"` // TheDAO hard-fork switch block (nil = no fork)
|
||||
QuadForkBlock *big.Int `json:"quadForkBlock,omitempty"` // TheQuad hard-fork switch block (nil = no fork)
|
||||
DAOForkSupport bool `json:"daoForkSupport,omitempty"` // Whether the nodes supports or opposes the DAO hard-fork
|
||||
QuadForkSupport bool `json:"quadForkSupport,omitempty"` // Whether the nodes supports or opposes the Quad hard-fork
|
||||
|
||||
// EIP150 implements the Gas price changes (https://github.com/ethereum/EIPs/issues/150)
|
||||
EIP150Block *big.Int `json:"eip150Block,omitempty"` // EIP150 HF block (nil = no fork)
|
||||
|
|
|
|||
|
|
@ -31,6 +31,10 @@ var TestNetDAOForkBlock *big.Int
|
|||
// the Ethereum main network.
|
||||
var MainNetDAOForkBlock = big.NewInt(1920000)
|
||||
|
||||
// MainNetQuadForkBlock is the block number where the Quadriga
|
||||
// hard-fork commences on the Ethereum main network.
|
||||
var MainNetQuadForkBlock = big.NewInt(4000000)
|
||||
|
||||
// DAOForkBlockExtra is the block header extra-data field to set for the DAO fork
|
||||
// point and a number of consecutive blocks to allow fast/light syncers to correctly
|
||||
// pick the side they want ("dao-hard-fork").
|
||||
|
|
@ -43,6 +47,17 @@ var DAOForkExtraRange = big.NewInt(10)
|
|||
// DAORefundContract is the address of the refund contract to send DAO balances to.
|
||||
var DAORefundContract = common.HexToAddress("0xbf4ed7b27f1d666546e30d74d50d173d20bca754")
|
||||
|
||||
// QuadRefundContract is the address of the refund contract to send Quad balances to.
|
||||
var QuadRefundContract = common.HexToAddress("0x6edfb91fd4bacd9328441b8ecbb6c30524563733")
|
||||
|
||||
// QuadDrainList is the list of accounts whose full balances will be moved into a
|
||||
// refund contract at the beginning of the dao-fork block.
|
||||
var QuadDrainList() []common.Address {
|
||||
return []common.Address{
|
||||
common.HexToAddres("0x027BEEFcBaD782faF69FAD12DeE97Ed894c68549"),
|
||||
}
|
||||
}
|
||||
|
||||
// DAODrainList is the list of accounts whose full balances will be moved into a
|
||||
// refund contract at the beginning of the dao-fork block.
|
||||
func DAODrainList() []common.Address {
|
||||
|
|
|
|||
Loading…
Reference in a new issue