@@ -33,16 +33,17 @@ import (
33
33
"github.com/ethereum/go-ethereum/params"
34
34
"github.com/ethereum/go-ethereum/rlp"
35
35
"github.com/ethereum/go-ethereum/trie"
36
+ "github.com/holiman/uint256"
36
37
"golang.org/x/crypto/sha3"
37
38
)
38
39
39
40
// Ethash proof-of-work protocol constants.
40
41
var (
41
- FrontierBlockReward = big .NewInt (5e+18 ) // Block reward in wei for successfully mining a block
42
- ByzantiumBlockReward = big .NewInt (3e+18 ) // Block reward in wei for successfully mining a block upward from Byzantium
43
- ConstantinopleBlockReward = big .NewInt (2e+18 ) // Block reward in wei for successfully mining a block upward from Constantinople
44
- maxUncles = 2 // Maximum number of uncles allowed in a single block
45
- allowedFutureBlockTimeSeconds = int64 (15 ) // Max seconds from current time allowed for blocks, before they're considered future blocks
42
+ FrontierBlockReward = uint256 .NewInt (5e+18 ) // Block reward in wei for successfully mining a block
43
+ ByzantiumBlockReward = uint256 .NewInt (3e+18 ) // Block reward in wei for successfully mining a block upward from Byzantium
44
+ ConstantinopleBlockReward = uint256 .NewInt (2e+18 ) // Block reward in wei for successfully mining a block upward from Constantinople
45
+ maxUncles = 2 // Maximum number of uncles allowed in a single block
46
+ allowedFutureBlockTimeSeconds = int64 (15 ) // Max seconds from current time allowed for blocks, before they're considered future blocks
46
47
47
48
// calcDifficultyEip5133 is the difficulty adjustment algorithm as specified by EIP 5133.
48
49
// It offsets the bomb a total of 11.4M blocks.
@@ -562,8 +563,8 @@ func (ethash *Ethash) SealHash(header *types.Header) (hash common.Hash) {
562
563
563
564
// Some weird constants to avoid constant memory allocs for them.
564
565
var (
565
- big8 = big .NewInt (8 )
566
- big32 = big .NewInt (32 )
566
+ u256_8 = uint256 .NewInt (8 )
567
+ u256_32 = uint256 .NewInt (32 )
567
568
)
568
569
569
570
// AccumulateRewards credits the coinbase of the given block with the mining
@@ -579,16 +580,18 @@ func accumulateRewards(config *params.ChainConfig, state *state.StateDB, header
579
580
blockReward = ConstantinopleBlockReward
580
581
}
581
582
// Accumulate the rewards for the miner and any included uncles
582
- reward := new (big.Int ).Set (blockReward )
583
- r := new (big.Int )
583
+ reward := new (uint256.Int ).Set (blockReward )
584
+ r := new (uint256.Int )
585
+ hNum , _ := uint256 .FromBig (header .Number )
584
586
for _ , uncle := range uncles {
585
- r .Add (uncle .Number , big8 )
586
- r .Sub (r , header .Number )
587
+ uNum , _ := uint256 .FromBig (uncle .Number )
588
+ r .AddUint64 (uNum , 8 )
589
+ r .Sub (r , hNum )
587
590
r .Mul (r , blockReward )
588
- r .Div (r , big8 )
591
+ r .Div (r , u256_8 )
589
592
state .AddBalance (uncle .Coinbase , r )
590
593
591
- r .Div (blockReward , big32 )
594
+ r .Div (blockReward , u256_32 )
592
595
reward .Add (reward , r )
593
596
}
594
597
state .AddBalance (header .Coinbase , reward )
0 commit comments