You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 2, 2024. It is now read-only.
Accessing the wallet's utxos from the WalletState of the EmulatorTrace results in TxOutRefs with indexes in the range 0-9 for all wallets, this cannot be correct because each wallet must have unique utxos. The Contract sees unique TxOutRefs for each wallet, e.g. w1 uses index range 50-59 and w2 uses 20-29.
Steps to reproduce the behavior
There are currently workarounds for this bug in existing tests mustSpendPubKeyOutput plutus-context tests, such as this. Please remove workarounds once fixed.
There is a commented out test to recreate this bug, see here. Edit: this also now affects MustReferenceOutput tests
Actual Result
Getting TxOutRef from WalletState, w1TxoRefs will have indexes in range 0-9.
let trace ::Trace.EmulatorTrace()=do
w1State <-Trace.agentState w1
let w1TxoRefs =S.elems $head$M.elems $ w1State ^. chainIndexEmulatorState . diskState . addressMap . unCredentialMap
Logging in Contract will print indexes in range 50-59
There is no bug, at least no reused TxOutIdx but we need to clarify the API: addressMap in diskState, contains a map the TxOutRef for all the Credentials, not only those of the given wallet. So we need to access the right entry of the map, and not take the head of its entries:
let trace :: Trace.EmulatorTrace () = do
w1State <- Trace.agentState w1
let cred = addressCredential $ Wallet.ownAddress w1State
w1TxoRefs = w1State ^. chainIndexEmulatorState . diskState . addressMap . at cred . non mempty
Summary
Accessing the wallet's utxos from the WalletState of the EmulatorTrace results in TxOutRefs with indexes in the range 0-9 for all wallets, this cannot be correct because each wallet must have unique utxos. The Contract sees unique TxOutRefs for each wallet, e.g. w1 uses index range 50-59 and w2 uses 20-29.
Steps to reproduce the behavior
There are currently workarounds for this bug in existing tests
mustSpendPubKeyOutput
plutus-context tests, such as this. Please remove workarounds once fixed.There is a commented out test to recreate this bug, see here. Edit: this also now affects MustReferenceOutput tests
Actual Result
Getting
TxOutRef
fromWalletState
,w1TxoRefs
will have indexes in range 0-9.Logging in Contract will print indexes in range 50-59
Expected Result
Wallets' utxos should be consistent.
Describe the approach you would take to fix this
No response
System info
a8540db
The text was updated successfully, but these errors were encountered: