Skip to content

Commit

Permalink
Comparison with getTimestamp instead of now
Browse files Browse the repository at this point in the history
  • Loading branch information
Marko Boben committed Aug 22, 2023
1 parent d4341e1 commit 8da4310
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
4 changes: 2 additions & 2 deletions avalanchego/vms/platformvm/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -2145,8 +2145,8 @@ type GetMinStakeReply struct {

// GetMinStake returns the minimum staking amount in nAVAX.
func (service *Service) GetMinStake(_ *http.Request, _ *struct{}, reply *GetMinStakeReply) error {
now := service.vm.clock.Time()
minValidatorStake, _, minDelegatorStake, _, _, _, _, _, _, _ := executor.GetCurrentInflationSettings(now, service.vm.ctx.NetworkID, &service.vm.Config)
timestamp := service.vm.state.GetTimestamp()
minValidatorStake, _, minDelegatorStake, _, _, _, _, _, _, _ := executor.GetCurrentInflationSettings(timestamp, service.vm.ctx.NetworkID, &service.vm.Config)
reply.MinValidatorStake = json.Uint64(minValidatorStake)
reply.MinDelegatorStake = json.Uint64(minDelegatorStake)
return nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,8 @@ func (e *ProposalTxExecutor) AddValidatorTx(tx *txs.AddValidatorTx) error {
return state.ErrMissingParentState
}
currentTimestamp := parentState.GetTimestamp()
now := e.Clk.Time()

minValidatorStake, maxValidatorStake, _, minDelegationFee, minStakeDuration, _, maxStakeDuration, minFutureStartTimeOffset, _, minStakeStartTime := GetCurrentInflationSettings(now, e.Backend.Ctx.NetworkID, e.Config)
minValidatorStake, maxValidatorStake, _, minDelegationFee, minStakeDuration, _, maxStakeDuration, minFutureStartTimeOffset, _, minStakeStartTime := GetCurrentInflationSettings(currentTimestamp, e.Backend.Ctx.NetworkID, e.Config)
switch {
case tx.Validator.Wght < minValidatorStake:
// Ensure validator is staking at least the minimum amount
Expand Down Expand Up @@ -381,9 +380,8 @@ func (e *ProposalTxExecutor) AddDelegatorTx(tx *txs.AddDelegatorTx) error {
return state.ErrMissingParentState
}
currentTimestamp := parentState.GetTimestamp()
now := e.Clk.Time()

_, maxValidatorStake, minDelegatorStake, _, _, minDelegateDuration, maxStakeDuration, minFutureStartTimeOffset, maxValidatorWeightFactor, _ := GetCurrentInflationSettings(now, e.Backend.Ctx.NetworkID, e.Config)
_, maxValidatorStake, minDelegatorStake, _, _, minDelegateDuration, maxStakeDuration, minFutureStartTimeOffset, maxValidatorWeightFactor, _ := GetCurrentInflationSettings(currentTimestamp, e.Backend.Ctx.NetworkID, e.Config)

duration := tx.Validator.Duration()
switch {
Expand Down

0 comments on commit 8da4310

Please sign in to comment.