Skip to content

Commit

Permalink
[rewarding] fix error check position (#3704)
Browse files Browse the repository at this point in the history
  • Loading branch information
dustinxie authored Dec 2, 2022
1 parent 81f7f80 commit cb2c5fa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions action/protocol/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ type (
FixGasAndNonceUpdate bool
FixUnproductiveDelegates bool
CorrectGasRefund bool
FixRewardErroCheckPosition bool
}

// FeatureWithHeightCtx provides feature check functions.
Expand Down Expand Up @@ -243,6 +244,7 @@ func WithFeatureCtx(ctx context.Context) context.Context {
FixGasAndNonceUpdate: g.IsOkhotsk(height),
FixUnproductiveDelegates: g.IsOkhotsk(height),
CorrectGasRefund: g.IsOkhotsk(height),
FixRewardErroCheckPosition: g.IsOkhotsk(height),
},
)
}
Expand Down
12 changes: 10 additions & 2 deletions action/protocol/rewarding/reward.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ func (p *Protocol) GrantBlockReward(
return nil, nil
}
rewardAddr, err := address.FromString(rewardAddrStr)
fCtx := protocol.MustGetFeatureCtx(ctx)
if fCtx.FixRewardErroCheckPosition {
if err != nil {
return nil, err
}
}

a := admin{}
if _, err := p.state(ctx, sm, _adminKey, &a); err != nil {
Expand All @@ -106,8 +112,10 @@ func (p *Protocol) GrantBlockReward(
if err := p.updateAvailableBalance(ctx, sm, a.blockReward); err != nil {
return nil, err
}
if err != nil {
return nil, err
if !fCtx.FixRewardErroCheckPosition {
if err != nil {
return nil, err
}
}
if err := p.grantToAccount(ctx, sm, rewardAddr, a.blockReward); err != nil {
return nil, err
Expand Down

0 comments on commit cb2c5fa

Please sign in to comment.