fix merge conflict and syncing with dev

feature/dev-engine_test
static 1 year ago
parent 801716261d
commit 3687575bcd
  1. 2
      core/preimages.go
  2. 10
      core/state_processor.go
  3. 30
      internal/chain/reward.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)
}

@ -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
}

@ -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
}
}

Loading…
Cancel
Save