Skip to content

pallas-validate: Conway phase-1 validation fails on value check when comparing Coin(x) vs Multiasset(x, {}) #731

@a-osiecki

Description

@a-osiecki

Summary

A transaction that burns all of its native assets should leave both sides of the preservation of value check as pure ADA. However the arithmetic can produce Multiasset(ada, {}) on the lhs while the rhs resolves to Coin(ada).

The equality check fails here:

if !conway_values_are_equal(&input, &output) {
return Err(PostAlonzo(PreservationOfValue));
}

pub fn conway_values_are_equal(first: &ConwayValue, second: &ConwayValue) -> bool {
match (first, second) {
(ConwayValue::Coin(f), ConwayValue::Coin(s)) => f == s,
(ConwayValue::Multiasset(..), ConwayValue::Coin(..)) => false,
(ConwayValue::Coin(..), ConwayValue::Multiasset(..)) => false,
(ConwayValue::Multiasset(f, fma), ConwayValue::Multiasset(s, sma)) => {
if f != s {
false
} else {
conway_multi_assets_are_equal(fma, sma)
}
}
}
}

Observed behaviour

Validation fails with transaction values are not preserved correctly, despite the values being equal. This was captured after adding tracing to the Conway phase-1 validation:

conway preservation of value mismatch
  consumed         = Ok(Multiasset(821828716, {policy: {Bounty_23: 1}}))
  produced         = Coin(820149135)
  fee              = 1679581
  mint             = Some({policy: {Bounty_23: -1}})
  lhs_input_plus_mint = Multiasset(821828716, {})
  rhs_output_plus_fee = Coin(821828716)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions