Skip to content

Commit

Permalink
Add more detailed error messages to some VM failures
Browse files Browse the repository at this point in the history
  • Loading branch information
muXxer committed May 3, 2024
1 parent 540c748 commit 5faed23
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions vm/nova/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ func accountStakingGenesisValidation(vmParams *vm.Params, stakingFeat *iotago.St
pastBoundedEpoch := timeProvider.EpochFromSlot(pastBoundedSlot)

if stakingFeat.StartEpoch != pastBoundedEpoch {
return iotago.ErrStakingStartEpochInvalid
return ierrors.WithMessagef(iotago.ErrStakingStartEpochInvalid, "is %d, expected %d", stakingFeat.StartEpoch, pastBoundedEpoch)
}

unbondingEpoch := pastBoundedEpoch + vmParams.API.ProtocolParameters().StakingUnbondingPeriod()
Expand Down Expand Up @@ -996,7 +996,7 @@ func delegationGenesisValid(vmParams *vm.Params, current *iotago.DelegationOutpu
}

if current.DelegatedAmount != current.Amount {
return iotago.ErrDelegationAmountMismatch
return ierrors.WithMessagef(iotago.ErrDelegationAmountMismatch, "delegated amount %d, amount %d", current.DelegatedAmount, current.Amount)
}

if current.EndEpoch != 0 {
Expand Down
2 changes: 1 addition & 1 deletion vm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ func ExecFuncBalancedMana() ExecFunc {
} else if manaIn > manaOut {
// less mana on output side than on input side => check if mana burning is allowed
if vmParams.WorkingSet.Tx.Capabilities.CannotBurnMana() {
return ierrors.Chain(iotago.ErrInputOutputManaMismatch, iotago.ErrTxCapabilitiesManaBurningNotAllowed)
return ierrors.Chain(iotago.ErrInputOutputManaMismatch, ierrors.WithMessagef(iotago.ErrTxCapabilitiesManaBurningNotAllowed, "Mana in %d, Mana out %d", manaIn, manaOut))
}
}

Expand Down

0 comments on commit 5faed23

Please sign in to comment.