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) return fmt.Errorf("block %d not found", i)
} }
stateAt, _ := chain.StateAt(block.Root()) 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 { if errProcess != nil {
return fmt.Errorf("error executing block #%d: %s", i, errProcess) return fmt.Errorf("error executing block #%d: %s", i, errProcess)
} }

@ -143,7 +143,7 @@ func (p *StateProcessor) Process(
processTxsAndStxs = false processTxsAndStxs = false
} }
if !errors.Is(err, ErrNoMigrationRequired) && !errors.Is(err, ErrNoMigrationPossible) { 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 { } else {
if cxReceipt != nil { if cxReceipt != nil {
@ -162,7 +162,7 @@ func (p *StateProcessor) Process(
p.bc, &beneficiary, gp, statedb, header, tx, usedGas, cfg, p.bc, &beneficiary, gp, statedb, header, tx, usedGas, cfg,
) )
if err != nil { 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) receipts = append(receipts, receipt)
if cxReceipt != nil { if cxReceipt != nil {
@ -185,7 +185,7 @@ func (p *StateProcessor) Process(
p.bc, &beneficiary, gp, statedb, header, tx, usedGas, cfg, p.bc, &beneficiary, gp, statedb, header, tx, usedGas, cfg,
) )
if err != nil { 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) receipts = append(receipts, receipt)
allLogs = append(allLogs, receipt.Logs...) 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 { if err := MayShardReduction(p.bc, statedb, header); err != nil {
return nil, nil, nil, nil, nil, 0, nil, statedb, err 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 return numeric.ZeroDec(), reader, err
} }
@ -304,13 +304,17 @@ func waitForCommitSigs(sigsReady chan bool) error {
return nil return nil
} }
func distributeRewardAfterAggregateEpoch( func distributeRewardAfterAggregateEpoch(bc engine.ChainReader, state *state.DB, header *block.Header, beaconChain engine.ChainReader,
bc engine.ChainReader, rewardToDistribute numeric.Dec) (numeric.Dec, reward.Reader, error) {
state *state.DB, epoch := header.Epoch()
header *block.Header, defaultReward := rewardToDistribute
beaconChain engine.ChainReader, remainingReward := numeric.ZeroDec()
defaultReward numeric.Dec, if bc.Config().IsHIP30(epoch) {
) (reward.Reader, error) { fractionToRecovery := shard.Schedule.InstanceForEpoch(epoch).HIP30EmissionFraction()
fractionToValidators := numeric.OneDec().Sub(fractionToRecovery)
defaultReward = rewardToDistribute.Mul(fractionToValidators)
remainingReward = rewardToDistribute.Mul(fractionToRecovery)
}
newRewards, payouts := newRewards, payouts :=
big.NewInt(0), []reward.Payout{} big.NewInt(0), []reward.Payout{}
@ -341,7 +345,7 @@ func distributeRewardAfterAggregateEpoch(
if cxLinks := curHeader.CrossLinks(); len(cxLinks) > 0 { if cxLinks := curHeader.CrossLinks(); len(cxLinks) > 0 {
crossLinks := types.CrossLinks{} crossLinks := types.CrossLinks{}
if err := rlp.DecodeBytes(cxLinks, &crossLinks); err != nil { if err := rlp.DecodeBytes(cxLinks, &crossLinks); err != nil {
return network.EmptyPayout, err return numeric.ZeroDec(), network.EmptyPayout, err
} }
allCrossLinks = append(allCrossLinks, crossLinks...) allCrossLinks = append(allCrossLinks, crossLinks...)
} }
@ -356,7 +360,7 @@ func distributeRewardAfterAggregateEpoch(
payables, _, err := processOneCrossLink(bc, state, cxLink, defaultReward, i) payables, _, err := processOneCrossLink(bc, state, cxLink, defaultReward, i)
if err != nil { if err != nil {
return network.EmptyPayout, err return numeric.ZeroDec(), network.EmptyPayout, err
} }
allPayables = append(allPayables, payables...) allPayables = append(allPayables, payables...)
@ -395,14 +399,14 @@ func distributeRewardAfterAggregateEpoch(
for _, addr := range allAddresses { for _, addr := range allAddresses {
snapshot, err := bc.ReadValidatorSnapshot(addr) snapshot, err := bc.ReadValidatorSnapshot(addr)
if err != nil { if err != nil {
return network.EmptyPayout, err return numeric.ZeroDec(), network.EmptyPayout, err
} }
due := allValidatorPayable[addr] due := allValidatorPayable[addr]
newRewards.Add(newRewards, due) newRewards.Add(newRewards, due)
shares, err := lookupDelegatorShares(snapshot) shares, err := lookupDelegatorShares(snapshot)
if err != nil { if err != nil {
return network.EmptyPayout, err return numeric.ZeroDec(), network.EmptyPayout, err
} }
if err := state.AddReward( if err := state.AddReward(
snapshot.Validator, snapshot.Validator,
@ -415,7 +419,7 @@ func distributeRewardAfterAggregateEpoch(
// and delegations pruned afterwards // and delegations pruned afterwards
bc.Config().IsNoNilDelegations(header.Epoch()), bc.Config().IsNoNilDelegations(header.Epoch()),
); err != nil { ); err != nil {
return network.EmptyPayout, err return numeric.ZeroDec(), network.EmptyPayout, err
} }
} }

Loading…
Cancel
Save