diff --git a/core/preimages.go b/core/preimages.go index 5034cc0e9..0bb22853a 100644 --- a/core/preimages.go +++ b/core/preimages.go @@ -226,7 +226,7 @@ func GeneratePreimages(chain BlockChain, start, end uint64) error { return fmt.Errorf("block %d not found", i) } stateAt, _ := chain.StateAt(block.Root()) - _, _, _, _, _, _, endingState, errProcess = chain.Processor().Process(block, startingState, *chain.GetVMConfig(), false) + _, _, _, _, _, _, _, endingState, errProcess = chain.Processor().Process(block, startingState, *chain.GetVMConfig(), false) if errProcess != nil { return fmt.Errorf("error executing block #%d: %s", i, errProcess) } diff --git a/core/state_processor.go b/core/state_processor.go index 6bc808c45..1037941d1 100644 --- a/core/state_processor.go +++ b/core/state_processor.go @@ -143,7 +143,7 @@ func (p *StateProcessor) Process( processTxsAndStxs = false } if !errors.Is(err, ErrNoMigrationRequired) && !errors.Is(err, ErrNoMigrationPossible) { - return nil, nil, nil, nil, 0, nil, statedb, err + return nil, nil, nil, nil, nil, 0, nil, statedb, err } } else { if cxReceipt != nil { @@ -162,7 +162,7 @@ func (p *StateProcessor) Process( p.bc, &beneficiary, gp, statedb, header, tx, usedGas, cfg, ) if err != nil { - return nil, nil, nil, nil, 0, nil, statedb, err + return nil, nil, nil, nil, nil, 0, nil, statedb, err } receipts = append(receipts, receipt) if cxReceipt != nil { @@ -185,7 +185,7 @@ func (p *StateProcessor) Process( p.bc, &beneficiary, gp, statedb, header, tx, usedGas, cfg, ) if err != nil { - return nil, nil, nil, nil, 0, nil, statedb, err + return nil, nil, nil, nil, nil, 0, nil, statedb, err } receipts = append(receipts, receipt) allLogs = append(allLogs, receipt.Logs...) @@ -211,10 +211,6 @@ func (p *StateProcessor) Process( } } - if err := MayTestnetShardReduction(p.bc, statedb, header); err != nil { - return nil, nil, nil, nil, nil, 0, nil, statedb, err - } - if err := MayShardReduction(p.bc, statedb, header); err != nil { return nil, nil, nil, nil, nil, 0, nil, statedb, err } diff --git a/internal/chain/reward.go b/internal/chain/reward.go index 407090540..09d883885 100644 --- a/internal/chain/reward.go +++ b/internal/chain/reward.go @@ -287,7 +287,7 @@ func AccumulateRewardsAndCountSigs( } - reader, err := distributeRewardAfterAggregateEpoch(bc, state, header, beaconChain, defaultReward) + _, reader, err := distributeRewardAfterAggregateEpoch(bc, state, header, beaconChain, defaultReward) return numeric.ZeroDec(), reader, err } @@ -304,13 +304,17 @@ func waitForCommitSigs(sigsReady chan bool) error { return nil } -func distributeRewardAfterAggregateEpoch( - bc engine.ChainReader, - state *state.DB, - header *block.Header, - beaconChain engine.ChainReader, - defaultReward numeric.Dec, -) (reward.Reader, error) { +func distributeRewardAfterAggregateEpoch(bc engine.ChainReader, state *state.DB, header *block.Header, beaconChain engine.ChainReader, + rewardToDistribute numeric.Dec) (numeric.Dec, reward.Reader, error) { + epoch := header.Epoch() + defaultReward := rewardToDistribute + remainingReward := numeric.ZeroDec() + if bc.Config().IsHIP30(epoch) { + fractionToRecovery := shard.Schedule.InstanceForEpoch(epoch).HIP30EmissionFraction() + fractionToValidators := numeric.OneDec().Sub(fractionToRecovery) + defaultReward = rewardToDistribute.Mul(fractionToValidators) + remainingReward = rewardToDistribute.Mul(fractionToRecovery) + } newRewards, payouts := big.NewInt(0), []reward.Payout{} @@ -341,7 +345,7 @@ func distributeRewardAfterAggregateEpoch( if cxLinks := curHeader.CrossLinks(); len(cxLinks) > 0 { crossLinks := types.CrossLinks{} if err := rlp.DecodeBytes(cxLinks, &crossLinks); err != nil { - return network.EmptyPayout, err + return numeric.ZeroDec(), network.EmptyPayout, err } allCrossLinks = append(allCrossLinks, crossLinks...) } @@ -356,7 +360,7 @@ func distributeRewardAfterAggregateEpoch( payables, _, err := processOneCrossLink(bc, state, cxLink, defaultReward, i) if err != nil { - return network.EmptyPayout, err + return numeric.ZeroDec(), network.EmptyPayout, err } allPayables = append(allPayables, payables...) @@ -395,14 +399,14 @@ func distributeRewardAfterAggregateEpoch( for _, addr := range allAddresses { snapshot, err := bc.ReadValidatorSnapshot(addr) if err != nil { - return network.EmptyPayout, err + return numeric.ZeroDec(), network.EmptyPayout, err } due := allValidatorPayable[addr] newRewards.Add(newRewards, due) shares, err := lookupDelegatorShares(snapshot) if err != nil { - return network.EmptyPayout, err + return numeric.ZeroDec(), network.EmptyPayout, err } if err := state.AddReward( snapshot.Validator, @@ -415,7 +419,7 @@ func distributeRewardAfterAggregateEpoch( // and delegations pruned afterwards bc.Config().IsNoNilDelegations(header.Epoch()), ); err != nil { - return network.EmptyPayout, err + return numeric.ZeroDec(), network.EmptyPayout, err } }