diff --git a/consensus/tests/engine_v2_tests/helper.go b/consensus/tests/engine_v2_tests/helper.go index c702704174..90e68dc7a9 100644 --- a/consensus/tests/engine_v2_tests/helper.go +++ b/consensus/tests/engine_v2_tests/helper.go @@ -682,9 +682,6 @@ func PrepareXDCTestBlockChainWithProtectorObserver(t *testing.T, numOfBlocks int } block := CreateBlock(blockchain, chainConfig, currentBlock, i, roundNumber, blockCoinBase, signer, signFn, penalty, nil, "f11ec19df702aa6bd9b3b2186edbc66d6b50b06334455a4a2ae8d166f28a14ff") - if i == 900 { - fmt.Println(block.Penalties()) - } err = blockchain.InsertBlock(block) if err != nil { t.Fatal(err) diff --git a/consensus/tests/engine_v2_tests/reward_test.go b/consensus/tests/engine_v2_tests/reward_test.go index 60eba07ada..9d095b3c3f 100644 --- a/consensus/tests/engine_v2_tests/reward_test.go +++ b/consensus/tests/engine_v2_tests/reward_test.go @@ -291,9 +291,9 @@ func TestHookRewardAfterUpgrade(t *testing.T) { assert.Equal(t, addr, observer1Addr) r := x.(map[common.Address]*big.Int) owner := state.GetCandidateOwner(parentState, addr) - a, _ := big.NewInt(0).SetString("270000000000000000000", 10) + a, _ := big.NewInt(0).SetString("270112500000000000000", 10) // this value tests the float64 reward assert.Zero(t, a.Cmp(r[owner]), "real reward is", r[owner]) - b, _ := big.NewInt(0).SetString("30000000000000000000", 10) + b, _ := big.NewInt(0).SetString("30012500000000000000", 10) // this value tests the float64 reward assert.Zero(t, b.Cmp(r[config.XDPoS.FoudationWalletAddr]), "real reward is", r[config.XDPoS.FoudationWalletAddr]) } common.TIPUpgradeReward = backup diff --git a/eth/hooks/engine_v2_hooks.go b/eth/hooks/engine_v2_hooks.go index 3a8f578b74..4cfb228456 100644 --- a/eth/hooks/engine_v2_hooks.go +++ b/eth/hooks/engine_v2_hooks.go @@ -234,7 +234,7 @@ func AttachConsensusV2Hooks(adaptor *XDPoS.XDPoS, bc *core.BlockChain, chainConf rewardsMap["signersProtector"] = signers[ProtectorNodeBeneficiary] rewardsMap["signersObserver"] = signers[ObserverNodeBeneficiary] type rewardWithType struct { - r uint64 + r float64 t Beneficiary key string } @@ -243,7 +243,8 @@ func AttachConsensusV2Hooks(adaptor *XDPoS.XDPoS, bc *core.BlockChain, chainConf {currentConfig.ProtectorReward, ProtectorNodeBeneficiary, "rewardsProtector"}, {currentConfig.ObserverReward, ObserverNodeBeneficiary, "rewardsObserver"}, } { - originalReward := new(big.Int).Mul(new(big.Int).SetUint64(rwt.r), new(big.Int).SetUint64(params.Ether)) + originalRewardFloat := new(big.Float).Mul(new(big.Float).SetFloat64(rwt.r), new(big.Float).SetUint64(params.Ether)) + originalReward, _ := originalRewardFloat.Int(nil) chainReward := util.RewardInflation(chain, originalReward, number, common.BlocksPerYear) rewardSigners, err := CalculateRewardForSignerFixed(chainReward, signers[rwt.t]) if err != nil { diff --git a/params/config.go b/params/config.go index 94aaeff9f9..0142090df4 100644 --- a/params/config.go +++ b/params/config.go @@ -180,7 +180,7 @@ var ( ExpTimeoutConfig: ExpTimeoutConfig{Base: 1.0, MaxExponent: 0}, MasternodeReward: 500, // double as Reward ProtectorReward: 400, - ObserverReward: 300, + ObserverReward: 300.125, }, } @@ -462,9 +462,9 @@ type V2Config struct { TimeoutPeriod int `json:"timeoutPeriod"` // Duration in ms CertThreshold float64 `json:"certificateThreshold"` // Necessary number of messages from master nodes to form a certificate - MasternodeReward uint64 `json:"masternodeReward"` // Block reward per master node (core validator) - unit Ether - ProtectorReward uint64 `json:"protectorReward"` // Block reward per protector - unit Ether - ObserverReward uint64 `json:"observerReward"` // Block reward per observer - unit Ether + MasternodeReward float64 `json:"masternodeReward"` // Block reward per master node (core validator) - unit Ether + ProtectorReward float64 `json:"protectorReward"` // Block reward per protector - unit Ether + ObserverReward float64 `json:"observerReward"` // Block reward per observer - unit Ether ExpTimeoutConfig ExpTimeoutConfig `json:"expTimeoutConfig"` }