Skip to content

Commit

Permalink
Don't send community rewards to reserve (#2030)
Browse files Browse the repository at this point in the history
  • Loading branch information
palango authored Jun 6, 2023
1 parent 5aef595 commit 7521f9d
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions consensus/istanbul/backend/pos.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,14 @@ func (sb *Backend) distributeEpochRewards(header *types.Header, state *state.Sta
return err
}

if err := sb.distributeCommunityRewards(vmRunner, communityReward); err != nil {
return err
if sb.ChainConfig().IsGFork(header.Number) {
if err := sb.distributeCommunityRewards(vmRunner, communityReward); err != nil {
return err
}
} else {
if err := sb.distributeCommunityRewardsWithReserveFallback(vmRunner, communityReward); err != nil {
return err
}
}

if err := sb.distributeVoterRewards(vmRunner, valSet, totalVoterRewards, uptimes); err != nil {
Expand Down Expand Up @@ -174,6 +180,18 @@ func (sb *Backend) distributeValidatorRewards(vmRunner vm.EVMRunner, valSet []is
}

func (sb *Backend) distributeCommunityRewards(vmRunner vm.EVMRunner, communityReward *big.Int) error {
governanceAddress, err := contracts.GetRegisteredAddress(vmRunner, config.GovernanceRegistryId)
if err != nil {
return err
}
if governanceAddress != common.ZeroAddress {
// TODO: How to split eco fund here
return gold_token.Mint(vmRunner, governanceAddress, communityReward)
}
return nil
}

func (sb *Backend) distributeCommunityRewardsWithReserveFallback(vmRunner vm.EVMRunner, communityReward *big.Int) error {
governanceAddress, err := contracts.GetRegisteredAddress(vmRunner, config.GovernanceRegistryId)
if err != nil {
return err
Expand Down

0 comments on commit 7521f9d

Please sign in to comment.