Skip to content

Commit

Permalink
[staking] reject endorse action before HF activated (#4187)
Browse files Browse the repository at this point in the history
  • Loading branch information
envestcc authored Mar 14, 2024
1 parent a5b7ef8 commit 855d8ba
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions action/protocol/staking/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,10 @@ func (p *Protocol) Validate(ctx context.Context, act action.Action, sr protocol.
return p.validateCandidateRegister(ctx, act)
case *action.CandidateUpdate:
return p.validateCandidateUpdate(ctx, act)
case *action.CandidateActivate:
return p.validateCandidateActivate(ctx, act)
case *action.CandidateEndorsement:
return p.validateCandidateEndorsement(ctx, act)
}
return nil
}
Expand Down
14 changes: 14 additions & 0 deletions action/protocol/staking/validations.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,17 @@ func (p *Protocol) validateCandidateUpdate(ctx context.Context, act *action.Cand
}
return nil
}

func (p *Protocol) validateCandidateEndorsement(ctx context.Context, act *action.CandidateEndorsement) error {
if protocol.MustGetFeatureCtx(ctx).DisableDelegateEndorsement {
return errors.Wrap(action.ErrInvalidAct, "candidate endorsement is disabled")
}
return nil
}

func (p *Protocol) validateCandidateActivate(ctx context.Context, act *action.CandidateActivate) error {
if protocol.MustGetFeatureCtx(ctx).DisableDelegateEndorsement {
return errors.Wrap(action.ErrInvalidAct, "candidate activate is disabled")
}
return nil
}

0 comments on commit 855d8ba

Please sign in to comment.