diff --git a/cmd/evm/internal/t8ntool/execution.go b/cmd/evm/internal/t8ntool/execution.go index 3c09229e1c..a3eba92d22 100644 --- a/cmd/evm/internal/t8ntool/execution.go +++ b/cmd/evm/internal/t8ntool/execution.go @@ -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 { diff --git a/consensus/misc/dao.go b/consensus/misc/dao.go index 45669d0bce..f6d6ed1a0b 100644 --- a/consensus/misc/dao.go +++ b/consensus/misc/dao.go @@ -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) diff --git a/core/chain_makers.go b/core/chain_makers.go index 13d7cb86c0..47f5000811 100644 --- a/core/chain_makers.go +++ b/core/chain_makers.go @@ -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) } diff --git a/core/state_processor.go b/core/state_processor.go index b1a8938f67..be67b4b982 100644 --- a/core/state_processor.go +++ b/core/state_processor.go @@ -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) } diff --git a/core/tracing/hooks.go b/core/tracing/hooks.go index 48cb4d2027..dd8cad046e 100644 --- a/core/tracing/hooks.go +++ b/core/tracing/hooks.go @@ -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. diff --git a/params/config.go b/params/config.go index 7683b147e2..14f86321eb 100644 --- a/params/config.go +++ b/params/config.go @@ -39,8 +39,9 @@ var ( // MainnetChainConfig is the chain parameters to run a node on the main network. MainnetChainConfig = &ChainConfig{ - ChainID: big.NewInt(1), - HomesteadBlock: big.NewInt(1_150_000), + 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), @@ -63,8 +64,9 @@ var ( } // HoleskyChainConfig contains the chain parameters to run a node on the Holesky test network. HoleskyChainConfig = &ChainConfig{ - ChainID: big.NewInt(17000), - HomesteadBlock: big.NewInt(0), + ChainID: big.NewInt(17000), + HomesteadBlock: big.NewInt(0), + // EIP-779, Holesky test network 상에서는 TheDAO hard-fork 가 적용되지 않습니다. DAOForkBlock: nil, DAOForkSupport: true, EIP150Block: big.NewInt(0), @@ -88,8 +90,9 @@ var ( } // SepoliaChainConfig contains the chain parameters to run a node on the Sepolia test network. SepoliaChainConfig = &ChainConfig{ - ChainID: big.NewInt(11155111), - HomesteadBlock: big.NewInt(0), + ChainID: big.NewInt(11155111), + HomesteadBlock: big.NewInt(0), + // EIP-779, Sepolia test network 상에서는 TheDAO hard-fork 가 적용되지 않습니다. DAOForkBlock: nil, DAOForkSupport: true, EIP150Block: big.NewInt(0), @@ -113,8 +116,9 @@ var ( } // GoerliChainConfig contains the chain parameters to run a node on the Görli test network. GoerliChainConfig = &ChainConfig{ - ChainID: big.NewInt(5), - HomesteadBlock: big.NewInt(0), + ChainID: big.NewInt(5), + HomesteadBlock: big.NewInt(0), + // EIP-779, Goerli test network 상에서는 TheDAO hard-fork 가 적용되지 않습니다. DAOForkBlock: nil, DAOForkSupport: true, EIP150Block: big.NewInt(0), @@ -140,8 +144,9 @@ var ( // AllEthashProtocolChanges contains every protocol change (EIPs) introduced // and accepted by the Ethereum core developers into the Ethash consensus. AllEthashProtocolChanges = &ChainConfig{ - ChainID: big.NewInt(1337), - HomesteadBlock: big.NewInt(0), + ChainID: big.NewInt(1337), + HomesteadBlock: big.NewInt(0), + // EIP-779, TheDAO hard-fork 가 적용되지 않습니다. DAOForkBlock: nil, DAOForkSupport: false, EIP150Block: big.NewInt(0), @@ -191,8 +196,9 @@ var ( // AllCliqueProtocolChanges contains every protocol change (EIPs) introduced // and accepted by the Ethereum core developers into the Clique consensus. AllCliqueProtocolChanges = &ChainConfig{ - ChainID: big.NewInt(1337), - HomesteadBlock: big.NewInt(0), + ChainID: big.NewInt(1337), + HomesteadBlock: big.NewInt(0), + // EIP-779, AllCliqueProtocolChanges 에서는 TheDAO hard-fork 가 적용되지 않습니다. DAOForkBlock: nil, DAOForkSupport: false, EIP150Block: big.NewInt(0), @@ -221,8 +227,9 @@ var ( // TestChainConfig contains every protocol change (EIPs) introduced // and accepted by the Ethereum core developers for testing purposes. TestChainConfig = &ChainConfig{ - ChainID: big.NewInt(1), - HomesteadBlock: big.NewInt(0), + ChainID: big.NewInt(1), + HomesteadBlock: big.NewInt(0), + // EIP-779, TestChainConfig 에서는 TheDAO hard-fork 가 적용되지 않습니다. DAOForkBlock: nil, DAOForkSupport: false, EIP150Block: big.NewInt(0), @@ -251,8 +258,9 @@ var ( // MergedTestChainConfig contains every protocol change (EIPs) introduced // and accepted by the Ethereum core developers for testing purposes. MergedTestChainConfig = &ChainConfig{ - ChainID: big.NewInt(1), - HomesteadBlock: big.NewInt(0), + ChainID: big.NewInt(1), + HomesteadBlock: big.NewInt(0), + // EIP-779, MergedTestChainConfig 에서는 TheDAO hard-fork 가 적용되지 않습니다. DAOForkBlock: nil, DAOForkSupport: false, EIP150Block: big.NewInt(0), @@ -281,8 +289,9 @@ var ( // NonActivatedConfig defines the chain configuration without activating // any protocol change (EIPs). NonActivatedConfig = &ChainConfig{ - ChainID: big.NewInt(1), - HomesteadBlock: nil, + ChainID: big.NewInt(1), + HomesteadBlock: nil, + // EIP-779, NonActivatedConfig 에서는 TheDAO hard-fork가 적용되지 않습니다. DAOForkBlock: nil, DAOForkSupport: false, EIP150Block: nil, @@ -332,8 +341,10 @@ 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) - DAOForkSupport bool `json:"daoForkSupport,omitempty"` // Whether the nodes supports or opposes the DAO hard-fork + // 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) EIP150Block *big.Int `json:"eip150Block,omitempty"` // EIP150 HF block (nil = no fork) @@ -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) } diff --git a/params/dao.go b/params/dao.go index da3c8dfc99..709b4cf455 100644 --- a/params/dao.go +++ b/params/dao.go @@ -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"), diff --git a/tests/difficulty_test.go b/tests/difficulty_test.go index 03e14df7c4..74883b8543 100644 --- a/tests/difficulty_test.go +++ b/tests/difficulty_test.go @@ -27,7 +27,9 @@ var ( mainnetChainConfig = params.ChainConfig{ ChainID: big.NewInt(1), HomesteadBlock: big.NewInt(1150000), - DAOForkBlock: big.NewInt(1920000), + // 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),