Skip to content

Commit

Permalink
Resolve SSW-101
Browse files Browse the repository at this point in the history
The settings UTXO required the output to have the exact same value as
the input

But, this means we can't change the size in bytes of the datum, and the
output might be locked if the minUTXO ever increases.

To resolve this, we compare `without_lovelace` of the own_output.value
and own_input.value. This allows the ADA to vary arbitrarily, so the
minUTXO can be adjusted.

Two things to note about the safety of this:
- We never expect an appreciable amount of ADA at this UTXO, essentially
  just the minUTXO, so the fact that someone can take any surplus if the
  minUTXO changes is not an issue
- Only the settings admin and the treasury admin can spend the UTXO
  anyway
  • Loading branch information
Quantumplation committed Feb 11, 2024
1 parent 2487900 commit 1bcf561
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions validators/settings.ak
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ validator(protocol_boot_utxo: OutputReference) {
expect output_datum: SettingsDatum = output_datum

// We check that the value on the input and output are equal, to ensure the settings NFT gets paid back into the output
// TODO: should we allow the ADA to change, just in case the minUTXO changes? that would allow us to add or reclaim
// ADA if minUTXO changed
// We compare `without_lovelace` to leave full freedom for ADA to be added/removed as the minUTXO requirement changes
// Note that this can only be spent by the SettingsAdmin or TreasuryAdmin, so we won't leak a small amount of ADA to arbitrary users
// Also, it is not expected that the ADA ever be more than the minUTXO cost, so this doesn't expose hundreds of ADA (for example) to the treasury admin
let value_not_changed =
own_output.value == own_input.value
value.without_lovelace(own_output.value) == value.without_lovelace(own_input.value)

// Make sure we don't mint anything, otherwise someone might mint another settings token
let no_mint =
Expand Down

0 comments on commit 1bcf561

Please sign in to comment.