Skip to content

Commit

Permalink
mux review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberphysic4l committed Aug 2, 2023
1 parent 6e79329 commit da1cd54
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion rent.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (r *RentStructure) CoversMinDeposit(object NonEphemeralObject, amount BaseT
return minDeposit, nil
}

// MinDeposit returns the minimum rent to cover a given object.
// MinDeposit returns the minimum deposit to cover a given object.
func (r *RentStructure) MinDeposit(object NonEphemeralObject) BaseToken {
return BaseToken(r.VByteCost) * BaseToken(object.VBytes(r, nil))
}
Expand Down
5 changes: 3 additions & 2 deletions vm/stardust/vm_stardust.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,11 @@ func accountBlockIssuerSTVF(input *vm.ChainOutputWithCreationTime, next *iotago.
// AccountInPotential
// the storage deposit does not generate potential mana, so we only use the excess base tokens to calculate the potential mana
var excessBaseTokensAccount iotago.BaseToken
if current.Amount <= rentStructure.MinDeposit(current) {
minDeposit := rentStructure.MinDeposit(current)
if current.Amount <= minDeposit {
excessBaseTokensAccount = 0
} else {
excessBaseTokensAccount = current.Amount - rentStructure.MinDeposit(current)
excessBaseTokensAccount = current.Amount - minDeposit
}
manaPotentialAccount, err := manaDecayProvider.PotentialManaWithDecay(excessBaseTokensAccount, input.CreationTime, vmParams.WorkingSet.Tx.Essence.CreationTime)
if err != nil {
Expand Down
5 changes: 3 additions & 2 deletions vm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,11 @@ func TotalManaIn(manaDecayProvider *iotago.ManaDecayProvider, rentStructure *iot

// potential Mana
// the storage deposit does not generate potential mana, so we only use the excess base tokens to calculate the potential mana
if input.Output.BaseTokenAmount() <= rentStructure.MinDeposit(input.Output) {
minDeposit := rentStructure.MinDeposit(input.Output)
if input.Output.BaseTokenAmount() <= minDeposit {
continue
}
excessBaseTokens := input.Output.BaseTokenAmount() - rentStructure.MinDeposit(input.Output)
excessBaseTokens := input.Output.BaseTokenAmount() - minDeposit
manaPotential, err := manaDecayProvider.PotentialManaWithDecay(excessBaseTokens, input.CreationTime, txCreationTime)
if err != nil {
return 0, ierrors.Wrapf(err, "input %s potential mana calculation failed", outputID)
Expand Down

0 comments on commit da1cd54

Please sign in to comment.