mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 02:42:27 +00:00
consensus/misc/dao.go: eip-779 comment
This commit is contained in:
parent
93418502a4
commit
1b139eb53a
8 changed files with 73 additions and 21 deletions
|
|
@ -187,6 +187,8 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
|
|||
}
|
||||
// If DAO is supported/enabled, we need to handle it here. In geth 'proper', it's
|
||||
// done in StateProcessor.Process(block, ...), right before transactions are applied.
|
||||
// EIP-779, DAO fork 가 지원되고 ChainConfig에 명시된 블록 넘버가 현재 블록 넘버와 동일하다면
|
||||
// DAO fork 를 DB 에 적용합니다.
|
||||
if chainConfig.DAOForkSupport &&
|
||||
chainConfig.DAOForkBlock != nil &&
|
||||
chainConfig.DAOForkBlock.Cmp(new(big.Int).SetUint64(pre.Env.Number)) == 0 {
|
||||
|
|
|
|||
|
|
@ -47,6 +47,10 @@ var (
|
|||
// with the fork specific extra-data set.
|
||||
// - if the node is pro-fork, require blocks in the specific range to have the
|
||||
// unique extra-data set.
|
||||
//
|
||||
// 블록헤더의 extra-data field 를 검증하여 DAO fork 규칙을 만족하는지 검사하는 함수입니다.
|
||||
// 만약 현재 node 가 `no-fork` 라면, [fork, fork+10) 범위의 블록을 accept 하지 않습니다.
|
||||
// 만약 현재 node 가 `pro-fork` 라면, 특정 범위의 블록들이 고유한 `extra-data set`을 갖는 것이 필요합니다.
|
||||
func VerifyDAOHeaderExtraData(config *params.ChainConfig, header *types.Header) error {
|
||||
// Short circuit validation if the node doesn't care about the DAO fork
|
||||
if config.DAOForkBlock == nil {
|
||||
|
|
@ -74,13 +78,20 @@ func VerifyDAOHeaderExtraData(config *params.ChainConfig, header *types.Header)
|
|||
// ApplyDAOHardFork modifies the state database according to the DAO hard-fork
|
||||
// rules, transferring all balances of a set of DAO accounts to a single refund
|
||||
// contract.
|
||||
//
|
||||
// EIP-779, TheDAO hard-fork 에 따라 DB의 상태를 변경하는 함수입니다.
|
||||
// EIP-779에서도 설명하듯이 DAODrainList 의 계정들로부터 하나의 DAORefundContract 에
|
||||
// 돈을 전송하게 됩니다.
|
||||
func ApplyDAOHardFork(statedb *state.StateDB) {
|
||||
// Retrieve the contract to refund balances into
|
||||
// EIP-779, 돈을 받을 계정이 존재하지 않는다면 새로 하나 생성합니다.
|
||||
// 참고로, 계정주소는 "common.HexToAddress("0xbf4ed7b27f1d666546e30d74d50d173d20bca754")" 입니다.
|
||||
if !statedb.Exist(params.DAORefundContract) {
|
||||
statedb.CreateAccount(params.DAORefundContract)
|
||||
}
|
||||
|
||||
// Move every DAO account and extra-balance account funds into the refund contract
|
||||
// 모든 `DAODrainList` 의 계정으로부터 `refund contract`에 돈을 보냅니다.
|
||||
for _, addr := range params.DAODrainList() {
|
||||
statedb.AddBalance(params.DAORefundContract, statedb.GetBalance(addr), tracing.BalanceIncreaseDaoContract)
|
||||
statedb.SetBalance(addr, new(uint256.Int), tracing.BalanceDecreaseDaoAccount)
|
||||
|
|
|
|||
|
|
@ -338,6 +338,8 @@ func GenerateChain(config *params.ChainConfig, parent *types.Block, engine conse
|
|||
}
|
||||
}
|
||||
}
|
||||
// EIP-779, DAO fork 를 지원하고 Chain Config에 DAO fork 블록 넘버가 현재 블록 넘버와 동일하다면
|
||||
// TheDAO hard-fork 를 적용합니다.
|
||||
if config.DAOForkSupport && config.DAOForkBlock != nil && config.DAOForkBlock.Cmp(b.header.Number) == 0 {
|
||||
misc.ApplyDAOHardFork(statedb)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,6 +69,8 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg
|
|||
)
|
||||
|
||||
// Mutate the block and state according to any hard-fork specs
|
||||
// EIP-779, DAO fork 를 지원하고 Chain Config에 DAO fork 블록 넘버가 현재 블록 넘버와 동일하다면
|
||||
// TheDAO hard-fork 를 적용합니다.
|
||||
if p.config.DAOForkSupport && p.config.DAOForkBlock != nil && p.config.DAOForkBlock.Cmp(block.Number()) == 0 {
|
||||
misc.ApplyDAOHardFork(statedb)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -193,8 +193,10 @@ const (
|
|||
|
||||
// DAO fork
|
||||
// BalanceIncreaseDaoContract is ether sent to the DAO refund contract.
|
||||
// EIP-779, DAO fork 를 위해 DAO refund contract에 전송되는 `ether` 를 의미합니다.
|
||||
BalanceIncreaseDaoContract BalanceChangeReason = 8
|
||||
// BalanceDecreaseDaoAccount is ether taken from a DAO account to be moved to the refund contract.
|
||||
// EIP-779, DAO fork 를 위해 DAO Drain List의 account 들로부터 가져온 `ether`를 의미합니다.
|
||||
BalanceDecreaseDaoAccount BalanceChangeReason = 9
|
||||
|
||||
// BalanceChangeTransfer is ether transferred via a call.
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ var (
|
|||
MainnetChainConfig = &ChainConfig{
|
||||
ChainID: big.NewInt(1),
|
||||
HomesteadBlock: big.NewInt(1_150_000),
|
||||
// EIP-779, TheDAO hard-fork 가 적용되는 블록이 1,920,000 임을 명시합니다.
|
||||
DAOForkBlock: big.NewInt(1_920_000),
|
||||
DAOForkSupport: true,
|
||||
EIP150Block: big.NewInt(2_463_000),
|
||||
|
|
@ -65,6 +66,7 @@ var (
|
|||
HoleskyChainConfig = &ChainConfig{
|
||||
ChainID: big.NewInt(17000),
|
||||
HomesteadBlock: big.NewInt(0),
|
||||
// EIP-779, Holesky test network 상에서는 TheDAO hard-fork 가 적용되지 않습니다.
|
||||
DAOForkBlock: nil,
|
||||
DAOForkSupport: true,
|
||||
EIP150Block: big.NewInt(0),
|
||||
|
|
@ -90,6 +92,7 @@ var (
|
|||
SepoliaChainConfig = &ChainConfig{
|
||||
ChainID: big.NewInt(11155111),
|
||||
HomesteadBlock: big.NewInt(0),
|
||||
// EIP-779, Sepolia test network 상에서는 TheDAO hard-fork 가 적용되지 않습니다.
|
||||
DAOForkBlock: nil,
|
||||
DAOForkSupport: true,
|
||||
EIP150Block: big.NewInt(0),
|
||||
|
|
@ -115,6 +118,7 @@ var (
|
|||
GoerliChainConfig = &ChainConfig{
|
||||
ChainID: big.NewInt(5),
|
||||
HomesteadBlock: big.NewInt(0),
|
||||
// EIP-779, Goerli test network 상에서는 TheDAO hard-fork 가 적용되지 않습니다.
|
||||
DAOForkBlock: nil,
|
||||
DAOForkSupport: true,
|
||||
EIP150Block: big.NewInt(0),
|
||||
|
|
@ -142,6 +146,7 @@ var (
|
|||
AllEthashProtocolChanges = &ChainConfig{
|
||||
ChainID: big.NewInt(1337),
|
||||
HomesteadBlock: big.NewInt(0),
|
||||
// EIP-779, TheDAO hard-fork 가 적용되지 않습니다.
|
||||
DAOForkBlock: nil,
|
||||
DAOForkSupport: false,
|
||||
EIP150Block: big.NewInt(0),
|
||||
|
|
@ -193,6 +198,7 @@ var (
|
|||
AllCliqueProtocolChanges = &ChainConfig{
|
||||
ChainID: big.NewInt(1337),
|
||||
HomesteadBlock: big.NewInt(0),
|
||||
// EIP-779, AllCliqueProtocolChanges 에서는 TheDAO hard-fork 가 적용되지 않습니다.
|
||||
DAOForkBlock: nil,
|
||||
DAOForkSupport: false,
|
||||
EIP150Block: big.NewInt(0),
|
||||
|
|
@ -223,6 +229,7 @@ var (
|
|||
TestChainConfig = &ChainConfig{
|
||||
ChainID: big.NewInt(1),
|
||||
HomesteadBlock: big.NewInt(0),
|
||||
// EIP-779, TestChainConfig 에서는 TheDAO hard-fork 가 적용되지 않습니다.
|
||||
DAOForkBlock: nil,
|
||||
DAOForkSupport: false,
|
||||
EIP150Block: big.NewInt(0),
|
||||
|
|
@ -253,6 +260,7 @@ var (
|
|||
MergedTestChainConfig = &ChainConfig{
|
||||
ChainID: big.NewInt(1),
|
||||
HomesteadBlock: big.NewInt(0),
|
||||
// EIP-779, MergedTestChainConfig 에서는 TheDAO hard-fork 가 적용되지 않습니다.
|
||||
DAOForkBlock: nil,
|
||||
DAOForkSupport: false,
|
||||
EIP150Block: big.NewInt(0),
|
||||
|
|
@ -283,6 +291,7 @@ var (
|
|||
NonActivatedConfig = &ChainConfig{
|
||||
ChainID: big.NewInt(1),
|
||||
HomesteadBlock: nil,
|
||||
// EIP-779, NonActivatedConfig 에서는 TheDAO hard-fork가 적용되지 않습니다.
|
||||
DAOForkBlock: nil,
|
||||
DAOForkSupport: false,
|
||||
EIP150Block: nil,
|
||||
|
|
@ -332,7 +341,9 @@ type ChainConfig struct {
|
|||
|
||||
HomesteadBlock *big.Int `json:"homesteadBlock,omitempty"` // Homestead switch block (nil = no fork, 0 = already homestead)
|
||||
|
||||
// EIP-779 에 따라, TheDAO hard-fork 가 적용되는 블록 넘버를 명시합니다.
|
||||
DAOForkBlock *big.Int `json:"daoForkBlock,omitempty"` // TheDAO hard-fork switch block (nil = no fork)
|
||||
// EIP-779 에 따라, 현재 노드가 TheDAO hard-fork 를 지원하는지 여부를 명시합니다.
|
||||
DAOForkSupport bool `json:"daoForkSupport,omitempty"` // Whether the nodes supports or opposes the DAO hard-fork
|
||||
|
||||
// EIP150 implements the Gas price changes (https://github.com/ethereum/EIPs/issues/150)
|
||||
|
|
@ -393,6 +404,7 @@ func (c *CliqueConfig) String() string {
|
|||
return "clique"
|
||||
}
|
||||
|
||||
// Chain 설정에 대해 사람이 읽을 수 있는 형태의 Description 을 반환하는 함수
|
||||
// Description returns a human-readable description of ChainConfig.
|
||||
func (c *ChainConfig) Description() string {
|
||||
var banner string
|
||||
|
|
@ -428,8 +440,11 @@ func (c *ChainConfig) Description() string {
|
|||
// Create a list of forks with a short description of them. Forks that only
|
||||
// makes sense for mainnet should be optional at printing to avoid bloating
|
||||
// the output for testnets and private networks.
|
||||
// FORK 들에 대한 짧은 기술을 담은 리스트를 생성합니다.
|
||||
// mainnet 에만 해당하는 FORK 들은 '선택'으로 두어서 testnet 과 private networks 에 대한 결과물이 부풀어 오르지 않도록 해야합니다.
|
||||
banner += "Pre-Merge hard forks (block based):\n"
|
||||
banner += fmt.Sprintf(" - Homestead: #%-8v (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/homestead.md)\n", c.HomesteadBlock)
|
||||
// DAOForkBlock 이 설정되어 있으면, TheDAO hard-fork 에 대한 FORK 정보를 추가합니다.
|
||||
if c.DAOForkBlock != nil {
|
||||
banner += fmt.Sprintf(" - DAO Fork: #%-8v (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/dao-fork.md)\n", c.DAOForkBlock)
|
||||
}
|
||||
|
|
@ -491,6 +506,8 @@ func (c *ChainConfig) IsHomestead(num *big.Int) bool {
|
|||
}
|
||||
|
||||
// IsDAOFork returns whether num is either equal to the DAO fork block or greater.
|
||||
//
|
||||
// 인자로 받은 수 `num` 이 TheDAO fork 를 위한 블록 넘버보다 크거나 같은지 함수입니다.
|
||||
func (c *ChainConfig) IsDAOFork(num *big.Int) bool {
|
||||
return isBlockForked(c.DAOForkBlock, num)
|
||||
}
|
||||
|
|
@ -613,6 +630,8 @@ func (c *ChainConfig) CheckCompatible(newcfg *ChainConfig, height uint64, time u
|
|||
|
||||
// CheckConfigForkOrder checks that we don't "skip" any forks, geth isn't pluggable enough
|
||||
// to guarantee that forks can be implemented in a different order than on official networks
|
||||
// CheckConfigForkOrder는 포크를 "건너뛰지" 않았는지 확인합니다.
|
||||
// geth는 공식 네트워크와 다른 순서로 포크를 구현할 수 있도록 보장할 수 있을 만큼 충분히 플러그 가능하지 않습니다.
|
||||
func (c *ChainConfig) CheckConfigForkOrder() error {
|
||||
type fork struct {
|
||||
name string
|
||||
|
|
@ -623,6 +642,8 @@ func (c *ChainConfig) CheckConfigForkOrder() error {
|
|||
var lastFork fork
|
||||
for _, cur := range []fork{
|
||||
{name: "homesteadBlock", block: c.HomesteadBlock},
|
||||
// 현재 ChainConfig 에 명시된 TheDAO hard-fork 블록 넘버를 활용합니다.
|
||||
// optional 값이 설정되어있기 때문에, 해당 fork 를 적용하지 않을 수도 있습니다.
|
||||
{name: "daoForkBlock", block: c.DAOForkBlock, optional: true},
|
||||
{name: "eip150Block", block: c.EIP150Block},
|
||||
{name: "eip155Block", block: c.EIP155Block},
|
||||
|
|
@ -683,9 +704,12 @@ func (c *ChainConfig) checkCompatible(newcfg *ChainConfig, headNumber *big.Int,
|
|||
if isForkBlockIncompatible(c.HomesteadBlock, newcfg.HomesteadBlock, headNumber) {
|
||||
return newBlockCompatError("Homestead fork block", c.HomesteadBlock, newcfg.HomesteadBlock)
|
||||
}
|
||||
// 현재의 Chain 설정 `c` 와 새로운 설정 `newcfg` 가 호환되는지 검사합니다.
|
||||
// `headNumber`는 현재 블록 넘버를 의미합니다.
|
||||
if isForkBlockIncompatible(c.DAOForkBlock, newcfg.DAOForkBlock, headNumber) {
|
||||
return newBlockCompatError("DAO fork block", c.DAOForkBlock, newcfg.DAOForkBlock)
|
||||
}
|
||||
// EIP-779 를 지원하는지 검사합니다.
|
||||
if c.IsDAOFork(headNumber) && c.DAOForkSupport != newcfg.DAOForkSupport {
|
||||
return newBlockCompatError("DAO fork support flag", c.DAOForkBlock, newcfg.DAOForkBlock)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,17 +25,24 @@ import (
|
|||
// 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").
|
||||
// EIP-779, DAO hard-fork 지점 이후 및 추가로 연속되는 블록들의 `extra-data` 필드에
|
||||
// "dao-hard-fork" 를 16진수 형태로 변환하여 기록합니다.
|
||||
// 이를 통해, 빠른 동기화나 경량 클라이언트 같은 동기화 메커니즘들이 올바른 체인을 선택하도록 돕습니다.
|
||||
var DAOForkBlockExtra = common.FromHex("0x64616f2d686172642d666f726b")
|
||||
|
||||
// DAOForkExtraRange is the number of consecutive blocks from the DAO fork point
|
||||
// to override the extra-data in to prevent no-fork attacks.
|
||||
// EIP-779, `no-fork attack` 으로부터 체인을 보호하기 위해 얼마나 많은
|
||||
// DAO fork 지점 이후 연속되는 블록의 `extra-data`에 덮어쓰기를 할 것인지 명시합니다.
|
||||
var DAOForkExtraRange = big.NewInt(10)
|
||||
|
||||
// DAORefundContract is the address of the refund contract to send DAO balances to.
|
||||
// EIP-779, 환불(refund)을 위해 사용할 refund contract 의 주소를 명시합니다.
|
||||
var DAORefundContract = common.HexToAddress("0xbf4ed7b27f1d666546e30d74d50d173d20bca754")
|
||||
|
||||
// DAODrainList is the list of accounts whose full balances will be moved into a
|
||||
// refund contract at the beginning of the dao-fork block.
|
||||
// EIP-779, 돈을 회수할 계정을 명시합니다.
|
||||
func DAODrainList() []common.Address {
|
||||
return []common.Address{
|
||||
common.HexToAddress("0xd4fe7bc31cedb7bfb8a345f31e668033056b2728"),
|
||||
|
|
|
|||
|
|
@ -27,7 +27,9 @@ var (
|
|||
mainnetChainConfig = params.ChainConfig{
|
||||
ChainID: big.NewInt(1),
|
||||
HomesteadBlock: big.NewInt(1150000),
|
||||
// EIP-779, mainnet에서 TheDAO hard fork가 블록 1,920,000에서 발생했음을 보여줌
|
||||
DAOForkBlock: big.NewInt(1920000),
|
||||
// EIP-779, TheDAO hard fork 적용 여부를 나타냄
|
||||
DAOForkSupport: true,
|
||||
EIP150Block: big.NewInt(2463000),
|
||||
EIP155Block: big.NewInt(2675000),
|
||||
|
|
|
|||
Loading…
Reference in a new issue