-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pay back funds to faucet after smoke-test run #770
Conversation
260090f
to
3ba4d4a
Compare
- We want to also be able to return funds to the faucet on mainnet
- Now they are not only refering to the Faucet but can also be an exception for Actor when we are returning funds to the faucet.
… better - When returning funds use queryUTxOFor instead of queryMarkedUTxo
- When we _seed from faucet_ we expect one faucet utxo to contain more lovelace than expected. BUT when we want to return the funds to the faucet we actually don't care about filtering. - Added a todo on how to handle fees when returning funds?
3ba4d4a
to
44dc719
Compare
Transactions CostsSizes and execution budgets for Hydra protocol transactions. Note that unlisted parameters are currently using
Script summary
Cost of Init Transaction
Cost of Commit TransactionCurrently only one UTxO per commit allowed (this is about to change soon)
Cost of CollectCom Transaction
Cost of Close Transaction
Cost of Contest Transaction
Cost of Abort TransactionSome variation because of random mixture of still initial and already committed outputs.
Cost of FanOut TransactionInvolves spending head output and burning head tokens. Uses ada-only UTxO for better comparability.
|
Test Results296 tests - 1 290 ✔️ - 1 24m 55s ⏱️ + 5m 14s Results for commit 5011714. ± Comparison against base commit 497ccb1. This pull request removes 1 test.
♻️ This comment has been updated with latest results. |
(senderVk, senderSk) <- keysFor sender | ||
utxo <- queryUTxOFor networkId nodeSocket QueryTip senderVk | ||
-- TODO: 'balance' here is just `foldMap txOutValue` so it doesn't actually ballance anything. | ||
-- How to exclude the fees from the amount? This hardcoded subtraction needs to go away |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Precise error is hydra-cluster: FailedToBuildTx {reason = TxBodyErrorAdaBalanceNegative (Lovelace (-173949))}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We introduced a hardcoded fix for the fees since we are missing the fee calculation in smoke-tests.
2cc3d65
to
5011714
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some comments on how to do this differently. Happy to pair with you on this if you want, just mention it.
@@ -37,8 +37,8 @@ import Hydra.Ledger.Cardano () | |||
data Marked = Fuel | Normal | |||
|
|||
data FaucetException | |||
= FaucetHasNotEnoughFunds {faucetUTxO :: UTxO} | |||
| FaucetFailedToBuildTx {reason :: TxBodyErrorAutoBalance} | |||
= NotEnoughFunds {utxos :: UTxO, requestedAmount :: Lovelace} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could: use utxo
for a name as it's more often used in the code base.
-- | Sender signing key | ||
SigningKey PaymentKey -> | ||
-- | Should we filter utxo to find the one containing more lovelace than we want to send? | ||
Bool -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should: not compose functions this way.
This Bool
is a smell to me. It indicates that you are using only a part of the code below in some cases. Why not structure it differently to assemble what you need and don't need better?
I'll point out more comments at the usage sites.
let fuelBalance = selectLovelace $ balance @Tx fuelUTxO | ||
when (fuelBalance < amount) $ do | ||
utxo <- seedFromFaucet node actorVk amount Fuel (contramap FromFaucet tracer) | ||
traceWith tracer $ RefueledFunds{actor = actorName actor, refuelingAmount = amount, fuelUTxO = utxo} | ||
utxo <- sendFundsTo node (senderVk, senderSk) receivingVk amount Fuel (contramap FromFaucet tracer) True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should: use the better named and higher-level API (using the actor type) seedFromFaucet
here.
It's not clear to me why the lower-level sendFundsTo
was used here. The whole refuelIfNeeded
should stay as it was.
-- Bit ugly bit we need to subtract the fees manually here. | ||
-- TODO: Implement the fee calculation for our smoke-tests | ||
let returnBalance = (selectLovelace $ balance @Tx utxo) - 1_200_000 | ||
void $ sendFundsTo node (senderVk, senderSk) receivingVk returnBalance Normal (contramap FromFaucet tracer) False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should: do what sendFundsTo ... Normal ... False
means directly here.
This is the only usage of sendFundsTo
with this parameterization, so there is no point in creating a function, which even contains optional semantics (smelly).
else utxos | ||
when (null foundUTxO) $ | ||
throwIO $ NotEnoughFunds{utxos, requestedAmount = lovelace} | ||
pure foundUTxO |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should: not compose functions this way.
This is seedFromFaucet
specific functionality and the Bool
flag is smelly. Keep this functionality in seedFromFaucet
, and not change it .. or change it with the enhancement of selecting multiple UTxo to meet the requested lovelace. (This is what this PR should be about).
If you want to reduce boiler plate of the queryUTxO networkId nodeSocket QueryTip [buildAddress faucetVk networkId]
, that would be a good function to have a separate queryFaucetUTxO
or so if you want (but not do refactor too early).
-- | Determine the amount we want to grab from the faucet based on network | ||
seedFromFaucetAmount :: NetworkId -> Lovelace | ||
seedFromFaucetAmount Mainnet = 100_000_000 | ||
seedFromFaucetAmount _ = 100_000_000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could: not do this, but just find a common denominator between networks.
I see why you want to do this, but I think it's not important how much we seed things with. It just needs to meet the minimum UTxO requirements. We don't expect these tests don't behave different with big or small amounts (if we would, we also should test NFTs). These are only E2E or even smoke tests - their scope is limited.
This parameter can stay uniform for all networks as we do not change valuation or minima in the parameters.
closing in favor of #773 |
Why
As part of the Mainnet compatibility issue #713 we would like to be able to return the funds back to our faucet.
NOTE: This PR introduces a hardcoded amount for the fees
1_200_000
and we should look into calculating fees for smoke-tests in the future.